glom r1670 - in trunk: . glom/mode_data glom/mode_design/print_layouts glom/utility_widgets



Author: murrayc
Date: Wed Aug 27 09:41:58 2008
New Revision: 1670
URL: http://svn.gnome.org/viewvc/glom?rev=1670&view=rev

Log:
2008-08-27  Murray Cumming  <murrayc murrayc com>

* glom/utility_widgets/layouttoolbarbutton.cc:
* glom/utility_widgets/layouttoolbarbutton.h: Change the constructor to 
take an icon name, to reduce some code elsewhere.
* glom/utility_widgets/layouttoolbar.cc: Adapted.
* glom/mode_data/box_data_details.cc:
* glom/utility_widgets/flowtable_dnd.cc:
* glom/utility_widgets/flowtable_dnd.h: Correct whitespace.

Added:
   trunk/glom/mode_design/print_layouts/print_layout_toolbar_button.cc
   trunk/glom/mode_design/print_layouts/print_layout_toolbar_button.h
Modified:
   trunk/ChangeLog
   trunk/glom/mode_data/box_data_details.cc
   trunk/glom/utility_widgets/flowtable_dnd.cc
   trunk/glom/utility_widgets/flowtable_dnd.h
   trunk/glom/utility_widgets/layouttoolbar.cc
   trunk/glom/utility_widgets/layouttoolbarbutton.cc
   trunk/glom/utility_widgets/layouttoolbarbutton.h

Modified: trunk/glom/mode_data/box_data_details.cc
==============================================================================
--- trunk/glom/mode_data/box_data_details.cc	(original)
+++ trunk/glom/mode_data/box_data_details.cc	Wed Aug 27 09:41:58 2008
@@ -78,7 +78,7 @@
   m_ScrolledWindow.set_shadow_type(Gtk::SHADOW_NONE); //SHADOW_IN is Recommended by the GNOME HIG, but looks odd.
 
 #ifndef GLOM_ENABLE_CLIENT_ONLY
-  m_HBox_Sidebar.pack_start (m_Dragbar, Gtk::PACK_SHRINK);
+  m_HBox_Sidebar.pack_start(m_Dragbar, Gtk::PACK_SHRINK);
   m_Dragbar.hide();
 #endif
 
@@ -996,7 +996,7 @@
 
 void Box_Data_Details::show_layout_toolbar (bool show)
 {
-  if (show)
+  if(show)
     m_Dragbar.show();
   else
     m_Dragbar.hide();

Added: trunk/glom/mode_design/print_layouts/print_layout_toolbar_button.cc
==============================================================================

Added: trunk/glom/mode_design/print_layouts/print_layout_toolbar_button.h
==============================================================================

Modified: trunk/glom/utility_widgets/flowtable_dnd.cc
==============================================================================
--- trunk/glom/utility_widgets/flowtable_dnd.cc	(original)
+++ trunk/glom/utility_widgets/flowtable_dnd.cc	Wed Aug 27 09:41:58 2008
@@ -35,14 +35,17 @@
   
 FlowTableDnd::FlowTableDnd() :
   m_current_dnd_item(0),
-  m_internal_drag (false)
+  m_internal_drag(false)
 {
   std::list<Gtk::TargetEntry> drag_targets;
+
   const GtkTargetEntry* target_entry = egg_tool_palette_get_drag_target_item();
-  Gtk::TargetEntry toolbar_target (*target_entry);
-  Gtk::TargetEntry move_target(MOVE_TARGET);
+  Gtk::TargetEntry toolbar_target(*target_entry);
   drag_targets.push_back(toolbar_target);
+
+  Gtk::TargetEntry move_target(MOVE_TARGET);
   drag_targets.push_back(move_target);
+
   drag_dest_set(drag_targets);
 }
 
@@ -51,25 +54,28 @@
   
 }
 
-void FlowTableDnd::start_dnd (Gtk::Widget& child)
+void FlowTableDnd::start_dnd(Gtk::Widget& child)
 {
-  if (dynamic_cast<PlaceholderGlom*>(&child) ||
-      dynamic_cast<FlowTableDnd*>(&child))
+  if(dynamic_cast<PlaceholderGlom*>(&child) ||
+     dynamic_cast<FlowTableDnd*>(&child))
+  {
     return;
-  
-	// Call this method recursive for all (real) children
+  }
+
+  // Call this method recursive for all (real) children
   Gtk::Container* container = dynamic_cast<Gtk::Container*>(&child);
-  if (container)
+  if(container)
   {
     typedef Glib::ListHandle<Gtk::Widget*>::const_iterator CI;
     Glib::ListHandle<Gtk::Widget*> children = container->get_children();
-    for (CI cur_child = children.begin(); cur_child != children.end();
+    for(CI cur_child = children.begin(); cur_child != children.end();
          ++cur_child)
     {
-      start_dnd (*(*cur_child));
+      start_dnd(*(*cur_child));
     }
   }
-  // Needed to move items around
+
+  // Needed to move items around:
   std::list<Gtk::TargetEntry> source_targets;
   source_targets.push_back (Gtk::TargetEntry (MOVE_TARGET));
   child.drag_source_set(source_targets, Gdk::ModifierType(GDK_BUTTON1_MASK | GDK_BUTTON3_MASK),
@@ -78,7 +84,8 @@
   child.signal_drag_end().connect (sigc::bind<Gtk::Widget*>(sigc::mem_fun (*this, &FlowTableDnd::on_child_drag_end), &child), false);
   child.signal_drag_data_get().connect (sigc::bind<Gtk::Widget*>(sigc::mem_fun (*this, &FlowTableDnd::on_child_drag_data_get), &child), false);
   child.signal_drag_data_delete().connect (sigc::bind<Gtk::Widget*>(sigc::mem_fun (*this, &FlowTableDnd::on_child_drag_data_delete), &child), false);
-  if (!(child.get_flags() & Gtk::NO_WINDOW))
+
+  if(!(child.get_flags() & Gtk::NO_WINDOW))
   { 
     std::list<Gtk::TargetEntry> drag_targets;
     const GtkTargetEntry* target_entry = egg_tool_palette_get_drag_target_item();
@@ -90,7 +97,7 @@
     Glib::RefPtr<Gtk::TargetList> targets =
 			child.drag_dest_get_target_list ();
     // The widget has already a default drag destination - add more targets
-    if (targets)
+    if(targets)
     {
       targets->add (drag_targets);
       child.drag_dest_set_target_list (targets);
@@ -100,22 +107,22 @@
                           Gdk::ACTION_COPY | Gdk::ACTION_MOVE);
 		    
     // It's important to connect this one BEFORE
-    child.signal_drag_motion().connect (sigc::bind<Gtk::Widget*>(sigc::mem_fun (*this, &FlowTableDnd::on_child_drag_motion), &child),
+    child.signal_drag_motion().connect(sigc::bind<Gtk::Widget*>(sigc::mem_fun (*this, &FlowTableDnd::on_child_drag_motion), &child),
                                         false);
-    child.signal_drag_data_received().connect (sigc::bind<Gtk::Widget*>(sigc::mem_fun (*this, &FlowTableDnd::on_child_drag_data_received), &child));
-    child.signal_drag_leave().connect (sigc::mem_fun (*this, &FlowTableDnd::on_child_drag_leave));
+    child.signal_drag_data_received().connect(sigc::bind<Gtk::Widget*>(sigc::mem_fun (*this, &FlowTableDnd::on_child_drag_data_received), &child));
+    child.signal_drag_leave().connect(sigc::mem_fun (*this, &FlowTableDnd::on_child_drag_leave));
   }
 }
 
-void FlowTableDnd::stop_dnd (Gtk::Widget& child)
+void FlowTableDnd::stop_dnd(Gtk::Widget& child)
 {
-  if (dynamic_cast<PlaceholderGlom*>(&child) ||
+  if(dynamic_cast<PlaceholderGlom*>(&child) ||
       dynamic_cast<FlowTableDnd*>(&child))
     return;
   
 	// Call this method recursive for all (real) children
   Gtk::Container* container = dynamic_cast<Gtk::Container*>(&child);
-  if (container)
+  if(container)
   {
     typedef Glib::ListHandle<Gtk::Widget*>::const_iterator CI;
     Glib::ListHandle<Gtk::Widget*> children = container->get_children();
@@ -146,17 +153,18 @@
 void FlowTableDnd::on_drag_data_received(const Glib::RefPtr<Gdk::DragContext>& drag_context, int drag_x, int drag_y, const Gtk::SelectionData& selection_data, guint, guint time)
 {
   Gtk::Widget* palette = drag_get_source_widget (drag_context);
-  while (palette && !EGG_IS_TOOL_PALETTE (palette->gobj()))
+  while(palette && !EGG_IS_TOOL_PALETTE (palette->gobj()))
     palette = palette->get_parent();
   
   on_dnd_remove_placeholder();
   LayoutWidgetBase* above = dnd_datawidget_from_item(0);
-  if (palette)
+  if(palette)
   {
-    GtkWidget* tool_item = egg_tool_palette_get_drag_item (EGG_TOOL_PALETTE (palette->gobj()), selection_data.gobj());
+    GtkWidget* tool_item = egg_tool_palette_get_drag_item(EGG_TOOL_PALETTE (palette->gobj()), selection_data.gobj());
     LayoutWidgetBase::enumType type = 
       static_cast<LayoutWidgetBase::enumType>(GPOINTER_TO_INT(g_object_get_data(G_OBJECT(tool_item), "glom-type")));
-    switch (type)
+
+    switch(type)
     {
       case LayoutWidgetBase::TYPE_FIELD:
         on_dnd_add_layout_item_field(above);
@@ -187,18 +195,19 @@
     if (base)
     {
       sharedptr<LayoutItem> item = base->get_layout_item();
-      if (item)
+      if(item)
       {
         sharedptr<LayoutGroup> group = sharedptr<LayoutGroup>::cast_dynamic(get_layout_item());
         LayoutGroup::type_list_items items = group->m_list_items;
-        if (std::find (items.begin(), items.end(), item) != items.end())
+        if(std::find (items.begin(), items.end(), item) != items.end())
         {
           m_internal_drag = true;
           group->remove_item(item);
         }
         else
           m_internal_drag = false;
-        on_dnd_add_layout_item (above, item);
+
+        on_dnd_add_layout_item(above, item);
         base->set_dnd_in_progress(false);
       }
     }
@@ -214,18 +223,18 @@
 FlowTable::FlowTableItem*
 FlowTableDnd::dnd_item_at_position(int drag_x, int drag_y)
 { 
-  int column_width;
-  get_column_height (0, m_children.size(), column_width);
+  int column_width = 0;
+  get_column_height(0, m_children.size(), column_width);
   int column = 0;
 	
-  if (column_width != 0)
+  if(column_width != 0)
     column = drag_x / column_width;
   
-  for (std::vector<FlowTableItem>::iterator cur_item = m_children.begin(); cur_item != m_children.end(); 
+  for(std::vector<FlowTableItem>::iterator cur_item = m_children.begin(); cur_item != m_children.end(); 
        cur_item++)
   {
     Gdk::Rectangle rect = cur_item->m_first->get_allocation();
-    if (cur_item->m_second)
+    if(cur_item->m_second)
     {
       Gdk::Rectangle second_rect = cur_item->m_second->get_allocation();
       rect.set_height (MAX (rect.get_height(), second_rect.get_height()));
@@ -233,16 +242,14 @@
     }
     
     int cur_column = 0;
-    if (column_width != 0)
+    if(column_width != 0)
       cur_column = rect.get_x() / column_width;
     
-    if (cur_column != column)
-    {
+    if(cur_column != column)
       continue;  
-    }
     
     // Allow dragging at the end
-    if (cur_item == --m_children.end())
+    if(cur_item == --m_children.end())
     {
       if (drag_y > (rect.get_y() + rect.get_height() / 2) &&
           drag_y < (rect.get_y() + rect.get_height()))
@@ -251,10 +258,8 @@
       }
     }
     
-    if (drag_y < (rect.get_y() + rect.get_height()))
-    {
-			return &(*cur_item);
-    }
+    if(drag_y < (rect.get_y() + rect.get_height()))
+      return &(*cur_item);
   }
   
   return 0;
@@ -272,79 +277,83 @@
   
   if(used_item)
   {
-		if(used_item->m_first)
+    if(used_item->m_first)
     {
       Gtk::Alignment* alignment = dynamic_cast <Gtk::Alignment*>(used_item->m_first);
-      if (alignment)
-      {
+      if(alignment)
         above = dynamic_cast<LayoutWidgetBase*>(alignment->get_child());
-      }
     }
+
     if(!above && used_item->m_first)
       above = dynamic_cast<LayoutWidgetBase*>(used_item->m_first);
+
     if(!above && used_item->m_second)
     {
       above = dynamic_cast<LayoutWidgetBase*>(used_item->m_second);
+
       // Special case for labels
-      if (!above)
+      if(!above)
       {       
         Gtk::Alignment* alignment = dynamic_cast <Gtk::Alignment*>(used_item->m_second);
         if (alignment)
-        {
           above = dynamic_cast<LayoutWidgetBase*>(alignment->get_child());
-        }
       } 
     }
   }
   return above;
 }
 
-FlowTable::FlowTableItem* FlowTableDnd::find_current_dnd_item (Gtk::Widget* child, int x, int y)
+FlowTable::FlowTableItem* FlowTableDnd::find_current_dnd_item(Gtk::Widget* child, int x, int y)
 {
   FlowTableItem* item;
   type_vecChildren::iterator cur_child;
-  for (cur_child = m_children.begin();
-       cur_child != m_children.end(); cur_child++)
+  for(cur_child = m_children.begin();
+      cur_child != m_children.end(); cur_child++)
   {
     // The widget was added directly to the FlowTableDnd
-    if (cur_child->m_first == child || 
-        cur_child->m_second == child)
+    if(cur_child->m_first == child || 
+       cur_child->m_second == child)
     {
       break;
     }
+
     // The parent of the widget was added to the FlowTableDnd
-    else if (cur_child->m_first == child->get_parent() ||
-             cur_child->m_second == child->get_parent())
+    else if(cur_child->m_first == child->get_parent() ||
+            cur_child->m_second == child->get_parent())
     {
       break;
     }
+
     Gtk::EventBox* bin = dynamic_cast<Gtk::EventBox*>(cur_child->m_second);
+
     // The widget was added inside a Gtk::EventBox
-    if (bin)
+    if(bin)
     {
       if (bin->get_child() == child ||
           bin->get_child() == child->get_parent())
         break;
     }
+
     bin = dynamic_cast<Gtk::EventBox*>(cur_child->m_first);
-    if (bin)
+    if(bin)
     {
-      if (bin->get_child() == child ||
+      if(bin->get_child() == child ||
           bin->get_child() == child->get_parent())
         break;
     }
   }
-  if (cur_child != m_children.end())
+
+  if(cur_child != m_children.end())
     item = &(*cur_child);
   else
     item = 0;
   
   // Allow dragging at-the-end
-  if (cur_child == --m_children.end() && y > 0)
+  if(cur_child == --m_children.end() && y > 0)
   {
     Gdk::Rectangle rect = child->get_allocation();
-    if (y > (rect.get_y() + rect.get_height() / 2) &&
-        y < (rect.get_y() + rect.get_height()))
+    if(y > (rect.get_y() + rect.get_height() / 2) &&
+       y < (rect.get_y() + rect.get_height()))
     {
       item = 0; // means end
     }
@@ -374,63 +383,68 @@
                                             const Gtk::SelectionData& selection_data, guint info, guint time,
                                             Gtk::Widget* child)
 {
-  on_drag_data_received (drag_context, x, y, selection_data, info, time);
+  on_drag_data_received(drag_context, x, y, selection_data, info, time);
 }
 
 void FlowTableDnd::on_child_drag_data_get(const Glib::RefPtr<Gdk::DragContext>& drag_context, 
                                           Gtk::SelectionData& selection_data, guint, guint time, 
                                           Gtk::Widget* child)
 {
-  FlowTableItem* item = find_current_dnd_item (child);
-  LayoutWidgetBase* base = dnd_datawidget_from_item (item);
+  FlowTableItem* item = find_current_dnd_item(child);
+  LayoutWidgetBase* base = dnd_datawidget_from_item(item);
+
   gpointer data = 0;
-  if (base)
-  {
+  if(base)
     data = base;
-  }
+
   selection_data.set ("LayoutWidgetBase*", 8, (guint8*)&data, 
                       sizeof(gpointer*));
 }
 
-void FlowTableDnd::on_child_drag_begin (const Glib::RefPtr<Gdk::DragContext>& drag_context,
+void FlowTableDnd::on_child_drag_begin(const Glib::RefPtr<Gdk::DragContext>& drag_context,
                           Gtk::Widget* child)
 {
   FlowTableItem* item = find_current_dnd_item (child);
-  if (!item)
+  if(!item)
   {
     gdk_drag_abort (drag_context->gobj(), 0);
     return;
   }
-  if (item->m_first)
+
+  if(item->m_first)
     item->m_first->hide();
-  if (item->m_second)
+
+  if(item->m_second)
     item->m_second->hide();
+
   LayoutWidgetBase* base = dnd_datawidget_from_item (item);
   base->set_dnd_in_progress(); 
 }
 
-void FlowTableDnd::on_child_drag_end (const Glib::RefPtr<Gdk::DragContext>& drag_context,
+void FlowTableDnd::on_child_drag_end(const Glib::RefPtr<Gdk::DragContext>& drag_context,
                         Gtk::Widget* child)
 {
   FlowTableItem* item = find_current_dnd_item (child);
   if (!item)
     return;
+
   LayoutWidgetBase* base = dnd_datawidget_from_item (item);
   if (base->get_dnd_in_progress())
   {
-    if (!item)
+    if(!item)
       return;
-    if (item->m_first)
+    if(item->m_first)
       item->m_first->show();
-    if (item->m_second)
+    if(item->m_second)
       item->m_second->show();  
   }
-  else if (!m_internal_drag)
+  else if(!m_internal_drag)
   {
     sharedptr<LayoutItem> item = base->get_layout_item();
     sharedptr<LayoutGroup> group = sharedptr<LayoutGroup>::cast_dynamic(get_layout_item());
     group->remove_item(item);
-  }  
+  }
+
   signal_layout_changed().emit();
 }
 
@@ -443,15 +457,12 @@
 void FlowTableDnd::set_design_mode(bool value)
 {
   FlowTable::set_design_mode(value);
+
   // We only want to enable drag and drop when in design mode
-  if (value)
-  {
-    forall (sigc::mem_fun(*this, &FlowTableDnd::start_dnd));
-  }
+  if(value)
+    forall(sigc::mem_fun(*this, &FlowTableDnd::start_dnd));
   else
-  {
-    forall (sigc::mem_fun(*this, &FlowTableDnd::stop_dnd));
-  } 
+    forall(sigc::mem_fun(*this, &FlowTableDnd::stop_dnd));
 }
 
 /* This is a hack. The problem is that when you move the mouse down to the last

Modified: trunk/glom/utility_widgets/flowtable_dnd.h
==============================================================================
--- trunk/glom/utility_widgets/flowtable_dnd.h	(original)
+++ trunk/glom/utility_widgets/flowtable_dnd.h	Wed Aug 27 09:41:58 2008
@@ -44,22 +44,24 @@
   virtual bool on_drag_motion(const Glib::RefPtr<Gdk::DragContext>& drag_context, int x, int y, guint time);
   virtual void on_drag_leave(const Glib::RefPtr<Gdk::DragContext>& drag_context, guint time);
   virtual void on_drag_data_received(const Glib::RefPtr<Gdk::DragContext>& drag_context, int, int, const Gtk::SelectionData& selection_data, guint, guint time);
-  virtual bool on_child_drag_motion(const Glib::RefPtr<Gdk::DragContext>& drag_context, int x, int y, guint time, Gtk::Widget* child);
-  virtual void on_child_drag_leave(const Glib::RefPtr<Gdk::DragContext>& drag_context, guint time);
-  virtual void on_child_drag_data_received(const Glib::RefPtr<Gdk::DragContext>& drag_context, int, int, 
+
+  bool on_child_drag_motion(const Glib::RefPtr<Gdk::DragContext>& drag_context, int x, int y, guint time, Gtk::Widget* child);
+  void on_child_drag_leave(const Glib::RefPtr<Gdk::DragContext>& drag_context, guint time);
+  void on_child_drag_data_received(const Glib::RefPtr<Gdk::DragContext>& drag_context, int, int, 
                                            const Gtk::SelectionData& selection_data, guint, guint time, Gtk::Widget* child);  
-  virtual void on_child_drag_data_get(const Glib::RefPtr<Gdk::DragContext>& drag_context, 
+  void on_child_drag_data_get(const Glib::RefPtr<Gdk::DragContext>& drag_context, 
                                            Gtk::SelectionData& selection_data, guint, guint time, Gtk::Widget* child);
-  virtual void on_child_drag_data_delete(const Glib::RefPtr<Gdk::DragContext>& drag_context, Gtk::Widget* child); 
-  virtual void on_child_drag_begin (const Glib::RefPtr<Gdk::DragContext>& drag_context, Gtk::Widget* child);
-  virtual void on_child_drag_end (const Glib::RefPtr<Gdk::DragContext>& drag_context, Gtk::Widget* child);    
+  void on_child_drag_data_delete(const Glib::RefPtr<Gdk::DragContext>& drag_context, Gtk::Widget* child); 
+  void on_child_drag_begin (const Glib::RefPtr<Gdk::DragContext>& drag_context, Gtk::Widget* child);
+  void on_child_drag_end (const Glib::RefPtr<Gdk::DragContext>& drag_context, Gtk::Widget* child);    
     
-  virtual void start_dnd (Gtk::Widget& child);
-  virtual void stop_dnd (Gtk::Widget& child);
+  void start_dnd(Gtk::Widget& child);
+  void stop_dnd(Gtk::Widget& child);
 
   virtual void set_design_mode(bool value = true);
     
-  // Methods for the different layout object
+  // Methods for the different layout object,
+  // to be implemented in the derived class.
   virtual void on_dnd_add_layout_item_field (LayoutWidgetBase* above) = 0;
   virtual void on_dnd_add_layout_group(LayoutWidgetBase* above) = 0;
   virtual void on_dnd_add_layout_item_button (LayoutWidgetBase* above) = 0;

Modified: trunk/glom/utility_widgets/layouttoolbar.cc
==============================================================================
--- trunk/glom/utility_widgets/layouttoolbar.cc	(original)
+++ trunk/glom/utility_widgets/layouttoolbar.cc	Wed Aug 27 09:41:58 2008
@@ -52,54 +52,40 @@
   // Looks ugly otherwise:
   set_size_request(100, 200);
 	
-  Gtk::Image* image_item = 
-    Gtk::manage (new Gtk::Image(get_icon_path("glom-field.png")));
-  Gtk::Image* image_button = 
-    Gtk::manage (new Gtk::Image(get_icon_path("glom-button.png")));
-  Gtk::Image* image_text = 
-    Gtk::manage (new Gtk::Image(get_icon_path("glom-text.png")));
-  Gtk::Image* image_image = 
-    Gtk::manage (new Gtk::Image(get_icon_path("glom-image.png")));
-  
-  Gtk::Image* image_group = 
-    Gtk::manage (new Gtk::Image(get_icon_path("glom-group.png")));
-  Gtk::Image* image_notebook = 
-    Gtk::manage (new Gtk::Image(get_icon_path("glom-notebook.png")));  
-	
   LayoutToolbarButton* drag_group = 
-    Gtk::manage(new LayoutToolbarButton(*image_group, LayoutWidgetBase::TYPE_GROUP,
+    Gtk::manage(new LayoutToolbarButton("glom-group.png", LayoutWidgetBase::TYPE_GROUP,
                                         _("Group"), _("Drag this to the layout to add a new group.")));
   LayoutToolbarButton* drag_notebook = 
-    Gtk::manage(new LayoutToolbarButton(*image_notebook, LayoutWidgetBase::TYPE_NOTEBOOK,
+    Gtk::manage(new LayoutToolbarButton("glom-notebook.png", LayoutWidgetBase::TYPE_NOTEBOOK,
                                         _("Notebook"), _("Drag this to the layout to add a new notebook.")));  
   
   LayoutToolbarButton* drag_item = 
-    Gtk::manage(new LayoutToolbarButton(*image_item, LayoutWidgetBase::TYPE_FIELD,
-                                        _("Database field"), _("Drag this to the layout to add a new database field.")));
+    Gtk::manage(new LayoutToolbarButton("glom-field.png", LayoutWidgetBase::TYPE_FIELD,
+                                        _("Database Field"), _("Drag this to the layout to add a new database field.")));
   LayoutToolbarButton* drag_button = 
-    Gtk::manage(new LayoutToolbarButton(*image_button, LayoutWidgetBase::TYPE_BUTTON,
+    Gtk::manage(new LayoutToolbarButton("glom-button.png", LayoutWidgetBase::TYPE_BUTTON,
                                         _("Button"), _("Drag this to the layout to cadd a new button.")));
   LayoutToolbarButton* drag_text = 
-    Gtk::manage(new LayoutToolbarButton(*image_text, LayoutWidgetBase::TYPE_TEXT,
+    Gtk::manage(new LayoutToolbarButton("glom-group.png", LayoutWidgetBase::TYPE_TEXT,
                                         _("Group"), _("Drag this to the layout to add a new static text box.")));  
   LayoutToolbarButton* drag_image = 
-    Gtk::manage(new LayoutToolbarButton(*image_image, LayoutWidgetBase::TYPE_IMAGE,
+    Gtk::manage(new LayoutToolbarButton("glom-image.png", LayoutWidgetBase::TYPE_IMAGE,
                                         _("Image"), _("Drag this to the layout to add a new static image.")));
   
   //Note for translators: These are container layout items, containing child layout items, like container widgets in GTK+.
   GtkContainer* container_group = GTK_CONTAINER(egg_tool_item_group_new(_("Containers")));
-  gtk_container_add (container_group, GTK_WIDGET(drag_group->gobj()));
-  gtk_container_add (container_group, GTK_WIDGET(drag_notebook->gobj()));
+  gtk_container_add(container_group, GTK_WIDGET(drag_group->gobj()));
+  gtk_container_add(container_group, GTK_WIDGET(drag_notebook->gobj()));
 
   //Note for translators: These are layout items, like widgets in GTK+.
   GtkContainer* fields_group = GTK_CONTAINER(egg_tool_item_group_new(_("Items")));
-  gtk_container_add (fields_group, GTK_WIDGET(drag_item->gobj()));
-  gtk_container_add (fields_group, GTK_WIDGET(drag_button->gobj()));  
-  gtk_container_add (fields_group, GTK_WIDGET(drag_text->gobj()));
-  gtk_container_add (fields_group, GTK_WIDGET(drag_image->gobj()));
+  gtk_container_add(fields_group, GTK_WIDGET(drag_item->gobj()));
+  gtk_container_add(fields_group, GTK_WIDGET(drag_button->gobj()));  
+  gtk_container_add(fields_group, GTK_WIDGET(drag_text->gobj()));
+  gtk_container_add(fields_group, GTK_WIDGET(drag_image->gobj()));
   
-  add_group (EGG_TOOL_ITEM_GROUP(container_group));
-  add_group (EGG_TOOL_ITEM_GROUP(fields_group));
+  add_group(EGG_TOOL_ITEM_GROUP(container_group));
+  add_group(EGG_TOOL_ITEM_GROUP(fields_group));
 	
   set_drag_source();
   

Modified: trunk/glom/utility_widgets/layouttoolbarbutton.cc
==============================================================================
--- trunk/glom/utility_widgets/layouttoolbarbutton.cc	(original)
+++ trunk/glom/utility_widgets/layouttoolbarbutton.cc	Wed Aug 27 09:41:58 2008
@@ -20,12 +20,30 @@
  
 #include "layouttoolbarbutton.h"
 
+namespace
+{
+
+Glib::ustring get_icon_path(const Glib::ustring& filename)
+{
+#ifdef G_OS_WIN32
+  gchar* basepath = g_win32_get_package_installation_subdirectory(NULL, NULL, "share/glom/pixmaps");
+  Glib::ustring result = Glib::build_filename(basepath, filename);
+  g_free(basepath);
+  return result;
+#else
+  return Glib::build_filename(GLOM_ICON_DIR, filename);
+#endif
+}
+
+} //anonymous namespace
+
+
 namespace Glom
 {
-  
-LayoutToolbarButton::LayoutToolbarButton(Gtk::Image& image, LayoutWidgetBase::enumType type,
+
+LayoutToolbarButton::LayoutToolbarButton(const Glib::ustring& icon_name, LayoutWidgetBase::enumType type,
                                          const Glib::ustring& title, const Glib::ustring& tooltip)
-: Gtk::ToolButton(image)
+: Gtk::ToolButton( *(Gtk::manage (new Gtk::Image(get_icon_path(icon_name)))) )
 {
   m_type = type;
   g_object_set_data(G_OBJECT(gobj()), "glom-type", GINT_TO_POINTER(type));

Modified: trunk/glom/utility_widgets/layouttoolbarbutton.h
==============================================================================
--- trunk/glom/utility_widgets/layouttoolbarbutton.h	(original)
+++ trunk/glom/utility_widgets/layouttoolbarbutton.h	Wed Aug 27 09:41:58 2008
@@ -34,10 +34,11 @@
 class LayoutToolbarButton : public Gtk::ToolButton
 {
 public:
-  LayoutToolbarButton(Gtk::Image& image, LayoutWidgetBase::enumType type, const Glib::ustring& title, const Glib::ustring& tooltip);  
-  ~LayoutToolbarButton();
+  LayoutToolbarButton(const Glib::ustring& icon_name, LayoutWidgetBase::enumType type, const Glib::ustring& title, const Glib::ustring& tooltip);
+  virtual ~LayoutToolbarButton();
+
+protected:
 
-  
   //TODO: What is this for? murrayc.
   // We need an unique identifier for drag & drop! jhs
   static const gchar* get_target()
@@ -45,12 +46,11 @@
     return "flowtable";
   };
 
-protected:
-    virtual void on_drag_begin(const Glib::RefPtr<Gdk::DragContext>& drag_context);
-    virtual void on_drag_data_get(const Glib::RefPtr<Gdk::DragContext>&, Gtk::SelectionData& selection_data, guint, guint);
+  virtual void on_drag_begin(const Glib::RefPtr<Gdk::DragContext>& drag_context);
+  virtual void on_drag_data_get(const Glib::RefPtr<Gdk::DragContext>&, Gtk::SelectionData& selection_data, guint, guint);
   
-  private:
-    LayoutWidgetBase::enumType m_type;
+private:
+  LayoutWidgetBase::enumType m_type;
 };
 
 }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]