~ubuntu-branches/ubuntu/quantal/glom/quantal

« back to all changes in this revision

Viewing changes to glom/mode_design/print_layouts/print_layout_toolbar_button.cc

  • Committer: Bazaar Package Importer
  • Author(s): Iain Lane
  • Date: 2009-01-11 17:12:01 UTC
  • mfrom: (1.1.39 upstream)
  • Revision ID: james.westby@ubuntu.com-20090111171201-0ov9zh1fxfueshxc
Tags: 1.8.5-0ubuntu1
* New upstream release (LP: #256701), fixes LP bugs: 
  + Clear the text in property dialogs for text items (LP: #309147)
  + Don't crash when showing and then hiding the grid (LP: #303453)
  + Temporarily remember the sort order so it is the same when navigating 
    away and back (LP: #303422)
  + Use the list's sort order for the top-level records in the report 
    (LP: #303425)
  + Users/Groups: Disable drag-and-drop for the treeview, because it is
    useless and confusing (LP: #299573)
  + Import: Sort the fields list alphabetically (LP: #306593)
  + delete primary key make unusuable the database (LP: #299549)
  + Spanish translate incomplete (LP: #299556)
  + import date format error (LP: #299591)
  + can't delete data from table list view (LP: #299853)
  + Field definition: default value not saved (LP: #299896)
  + reports crashing (LP: #300054)
  + Year error with date fields (LP: #300057)
  + list view: 2 records added instead of 1 (LP: #300819)
* debian/control: Refreshed dependencies for libglom-dev.
* debian/control: Updated build-deps to match configure checks. goocavnasmm
  build-dep bumped to version without .la files.
* debian/rules: Don't delete the directory containing the templates.
* debian/control, debian/rules, debian/glom-doc.*: Split out
  arch-independent manual and examples into separate package glom-doc, which
  is now recommended by glom (glom will still work if they're not available)
* debian/copyright: Rewritten to new machine-readable format. 

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Glom
 
2
 *
 
3
 * Copyright (C) 2007, 2008 Openismus GmbH
 
4
 *
 
5
 * This program is free software; you can redistribute it and/or
 
6
 * modify it under the terms of the GNU General Public License as
 
7
 * published by the Free Software Foundation; either version 2 of the
 
8
 * License, or (at your option) any later version.
 
9
 *
 
10
 * This program is distributed in the hope that it will be useful, but
 
11
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
13
 * General Public License for more details.
 
14
 *
 
15
 * You should have received a copy of the GNU General Public
 
16
 * License along with this program; if not, write to the
 
17
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 
18
 * Boston, MA 02111-1307, USA.
 
19
 */
 
20
 
 
21
#include "print_layout_toolbar_button.h"
 
22
#include <glom/utility_widgets/egg/toolpalette/eggtoolpalette.h>
 
23
#include <iostream>
 
24
 
 
25
namespace
 
26
{
 
27
 
 
28
std::string get_icon_path(const std::string& filename)
 
29
{
 
30
#ifdef G_OS_WIN32
 
31
  gchar* basepath = g_win32_get_package_installation_subdirectory(NULL, NULL, "share/glom/pixmaps");
 
32
  const std::string result = Glib::build_filename(basepath, filename);
 
33
  g_free(basepath);
 
34
  return result;
 
35
#else
 
36
  return Glib::build_filename(GLOM_ICON_DIR, filename);
 
37
#endif
 
38
}
 
39
 
 
40
} //anonymous namespace
 
41
 
 
42
 
 
43
namespace Glom
 
44
{
 
45
 
 
46
PrintLayoutToolbarButton::PrintLayoutToolbarButton(const std::string& icon_name, enumItems type,
 
47
                                         const Glib::ustring& title, const Glib::ustring& tooltip)
 
48
: Gtk::ToolButton( *(Gtk::manage (new Gtk::Image(get_icon_path(icon_name)))) )
 
49
{
 
50
  m_type = type;
 
51
  g_object_set_data(G_OBJECT(gobj()), "glom-type", GINT_TO_POINTER(type));
 
52
 
 
53
  std::list<Gtk::TargetEntry> targetentries;
 
54
  targetentries.push_back(Gtk::TargetEntry(get_target()));
 
55
 
 
56
  drag_source_set(targetentries, Gdk::MODIFIER_MASK, 
 
57
                  Gdk::ACTION_COPY | Gdk::ACTION_MOVE);
 
58
  set_tooltip_text(tooltip);
 
59
  set_label(title);
 
60
}
 
61
 
 
62
PrintLayoutToolbarButton::~PrintLayoutToolbarButton()
 
63
{
 
64
}
 
65
 
 
66
PrintLayoutToolbarButton::enumItems PrintLayoutToolbarButton::get_item_type_from_selection_data(const Glib::RefPtr<Gdk::DragContext>& drag_context, const Gtk::SelectionData& selection_data)
 
67
{
 
68
  PrintLayoutToolbarButton::enumItems result = ITEM_INVALID;
 
69
 
 
70
  //Put this code in the toolbar class:
 
71
  Gtk::Widget* palette = drag_get_source_widget(drag_context);
 
72
  while(palette && !EGG_IS_TOOL_PALETTE (palette->gobj()))
 
73
    palette = palette->get_parent();
 
74
  
 
75
  if(!palette)
 
76
    return result;
 
77
 
 
78
  GtkWidget* tool_item = egg_tool_palette_get_drag_item(EGG_TOOL_PALETTE (palette->gobj()), selection_data.gobj());
 
79
  if(!tool_item)
 
80
    return result;
 
81
 
 
82
  result = static_cast<PrintLayoutToolbarButton::enumItems>(GPOINTER_TO_INT(g_object_get_data(G_OBJECT(tool_item), "glom-type")));
 
83
  return result;
 
84
}
 
85
 
 
86
void PrintLayoutToolbarButton::on_drag_data_get(const Glib::RefPtr<Gdk::DragContext>&, 
 
87
                                  Gtk::SelectionData& selection_data, guint, guint)
 
88
{
 
89
  selection_data.set(8, (guint8*)(&m_type), 4);
 
90
}
 
91
 
 
92
void PrintLayoutToolbarButton::on_drag_begin(const Glib::RefPtr<Gdk::DragContext>& drag_context)
 
93
{
 
94
  drag_context->set_icon(dynamic_cast<Gtk::Image*>(get_icon_widget())->get_pixbuf(), 0, 0);
 
95
}
 
96
 
 
97
} // namespace Glom
 
98