glom r1612 - in trunk: . glom glom/mode_data glom/utility_widgets



Author: jhs
Date: Sun May 18 12:42:33 2008
New Revision: 1612
URL: http://svn.gnome.org/viewvc/glom?rev=1612&view=rev

Log:
2008-05-18  Johannes Schmid  <johannes schmid openismus com>

	* glom/Makefile.am: Corrected indentation
	
	* glom/mode_data/flowtablewithfields.cc:
	(add_field_at_position):
	Put labels for fields into their own EventBox
	
	* glom/utility_widgets/flowtable_dnd.cc:
	  (start_dnd), (stop_dnd), (find_current_dnd_item), (on_child_drag_begin)
	  (on_child_drag_data_delete):
	* glom/utility_widgets/flowtable_dnd.h:
	Allow moving of items fields through drag and drop

Modified:
   trunk/ChangeLog
   trunk/glom/Makefile.am
   trunk/glom/mode_data/flowtablewithfields.cc
   trunk/glom/utility_widgets/flowtable_dnd.cc
   trunk/glom/utility_widgets/flowtable_dnd.h

Modified: trunk/glom/Makefile.am
==============================================================================
--- trunk/glom/Makefile.am	(original)
+++ trunk/glom/Makefile.am	Sun May 18 12:42:33 2008
@@ -41,9 +41,9 @@
                combobox_fields.h combobox_fields.cc \
                combobox_relationship.h combobox_relationship.cc \
                dialog_connection.h dialog_connection.cc \
-	       dialog_import_csv.h dialog_import_csv.cc \
-	       dialog_import_csv_progress.h dialog_import_csv_progress.cc \
-	       dialog_existing_or_new.h dialog_existing_or_new.cc \
+	             dialog_import_csv.h dialog_import_csv.cc \
+	             dialog_import_csv_progress.h dialog_import_csv_progress.cc \
+	             dialog_existing_or_new.h dialog_existing_or_new.cc \
                dialog_invalid_data.h dialog_invalid_data.cc \
                filechooser_export.h filechooser_export.cc \
                box_reports.h box_reports.cc \

Modified: trunk/glom/mode_data/flowtablewithfields.cc
==============================================================================
--- trunk/glom/mode_data/flowtablewithfields.cc	(original)
+++ trunk/glom/mode_data/flowtablewithfields.cc	Sun May 18 12:42:33 2008
@@ -526,12 +526,18 @@
     if(label)
       label->set_property("yalign", 0.0); //Equivalent to Gtk::ALIGN_TOP. Center is neater next to entries, but center is silly next to large images.
   }
-
+  
+  Gtk::EventBox* eventbox = new Gtk::EventBox();
+  eventbox->add (*info.m_first);
+  eventbox->set_visible_window (false);
+  eventbox->set_events (Gdk::ALL_EVENTS_MASK);
+  eventbox->show_all();
+  
 	Gtk::Widget* widget = dynamic_cast<Gtk::Widget*>(*add_before);
 	if (widget)
-		insert_before (*(info.m_first), *(info.m_second), *widget, expand_second);
+		insert_before (*eventbox, *(info.m_second), *widget, expand_second);
 	else
-		add(*(info.m_first), *(info.m_second), expand_second);
+		add(*eventbox, *(info.m_second), expand_second);
 
   info.m_second->signal_edited().connect( sigc::bind(sigc::mem_fun(*this, &FlowTableWithFields::on_entry_edited), layoutitem_field)  ); //TODO:  Is it a good idea to bind the LayoutItem? sigc::bind() probably stores a copy at this point.
 

Modified: trunk/glom/utility_widgets/flowtable_dnd.cc
==============================================================================
--- trunk/glom/utility_widgets/flowtable_dnd.cc	(original)
+++ trunk/glom/utility_widgets/flowtable_dnd.cc	Sun May 18 12:42:33 2008
@@ -68,14 +68,18 @@
       start_dnd (*(*cur_child));
     }
   }
+  // 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),
+                        Gdk::DragAction(GDK_ACTION_COPY | GDK_ACTION_MOVE));
+  child.signal_drag_begin().connect (sigc::bind<Gtk::Widget*>(sigc::mem_fun (*this, &FlowTableDnd::on_child_drag_begin), &child), false);
+  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))
-  {
-    // 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::BUTTON1_MASK|Gdk::BUTTON3_MASK, 
-                           Gdk::ACTION_MOVE | Gdk::ACTION_COPY);
-    
+  { 
     std::list<Gtk::TargetEntry> drag_targets;
     Gtk::TargetEntry toolbar_target (egg_tool_palette_get_drag_target_item());
     Gtk::TargetEntry move_target(MOVE_TARGET);
@@ -99,10 +103,6 @@
                                         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_begin().connect (sigc::bind<Gtk::Widget*>(sigc::mem_fun (*this, &FlowTableDnd::on_child_drag_begin), &child), false);
-    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);
   }
 }
 
@@ -124,10 +124,7 @@
       stop_dnd (*(*cur_child));
     }
   }
-  if (!(child.get_flags() & Gtk::NO_WINDOW))
-  {
-    child.drag_source_unset();
-  }
+  child.drag_source_unset();
 }
 
 bool FlowTableDnd::on_drag_motion(const Glib::RefPtr<Gdk::DragContext>& drag_context, int x, int y, guint time)
@@ -317,7 +314,7 @@
     {
       break;
     }
-    Gtk::Bin* bin = dynamic_cast<Gtk::Bin*>(cur_child->m_second);
+    Gtk::EventBox* bin = dynamic_cast<Gtk::EventBox*>(cur_child->m_second);
     // The widget was added inside a Gtk::EventBox
     if (bin)
     {
@@ -325,6 +322,13 @@
           bin->get_child() == child->get_parent())
         break;
     }
+    bin = dynamic_cast<Gtk::EventBox*>(cur_child->m_first);
+    if (bin)
+    {
+      if (bin->get_child() == child ||
+          bin->get_child() == child->get_parent())
+        break;
+    }
   }
   if (cur_child != m_children.end())
     item = &(*cur_child);
@@ -332,7 +336,7 @@
     item = 0;
   
   // Allow dragging at-the-end
-  if (cur_child == --m_children.end())
+  if (cur_child == --m_children.end() && y > 0)
   {
     Gdk::Rectangle rect = child->get_allocation();
     if (y > (rect.get_y() + rect.get_height() / 2) &&
@@ -387,13 +391,27 @@
 void FlowTableDnd::on_child_drag_begin (const Glib::RefPtr<Gdk::DragContext>& drag_context,
                           Gtk::Widget* child)
 {
+  std::cout << "Drag begin type: " << G_OBJECT_TYPE_NAME (child->gobj()) << std::endl;
+  Gtk::Container* container = dynamic_cast<Gtk::Container*>(child);
+  while (container)
+  {
+    std::list<Gtk::Widget*> children = container->get_children();
+    for (std::list<Gtk::Widget*>::const_iterator CI (children.begin());
+         CI != children.end(); CI++)
+      std::cout << "Drag begin child: " << G_OBJECT_TYPE_NAME ((*CI)->gobj()) << std::endl;
+    Gtk::Bin* bin = dynamic_cast<Gtk::Bin*>(container);
+    container = dynamic_cast<Gtk::Container*>(bin->get_child());
+  }
   FlowTableItem* item = find_current_dnd_item (child);
   if (!item)
+  {
     return;
+  }
   if (item->m_first)
     item->m_first->hide();
   if (item->m_second)
     item->m_second->hide();
+  std::cout << "Drag begin item: " << G_OBJECT_TYPE_NAME (item->m_first->gobj()) << std::endl;
   LayoutWidgetBase* base = dnd_datawidget_from_item (item);
   base->set_dnd_in_progress(); 
 }
@@ -421,6 +439,12 @@
   signal_layout_changed().emit();
 }
 
+void FlowTableDnd::on_child_drag_data_delete(const Glib::RefPtr<Gdk::DragContext>& drag_context,
+                               Gtk::Widget* child)
+{
+  // Do nothing for now  
+}
+
 void FlowTableDnd::set_design_mode(bool value)
 {
   FlowTable::set_design_mode(value);

Modified: trunk/glom/utility_widgets/flowtable_dnd.h
==============================================================================
--- trunk/glom/utility_widgets/flowtable_dnd.h	(original)
+++ trunk/glom/utility_widgets/flowtable_dnd.h	Sun May 18 12:42:33 2008
@@ -50,7 +50,8 @@
   virtual 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, 
-                                           Gtk::SelectionData& selection_data, guint, guint time, Gtk::Widget* child);  
+                                           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);    
     



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