glom r1689 - in trunk: . glom/mode_data glom/utility_widgets icons/16x16



Author: jhs
Date: Fri Sep 26 14:26:34 2008
New Revision: 1689
URL: http://svn.gnome.org/viewvc/glom?rev=1689&view=rev

Log:
2008-09-26  Johannes Schmid  <johannes schmid openismus com>

	* configure.in: Require correct version for bonobo and goocanvasmm
	
	* glom/mode_data/flowtablewithfields.cc:
	* glom/mode_data/flowtablewithfields.h:
	* glom/utility_widgets/flowtable_dnd.cc:
	* glom/utility_widgets/flowtable_dnd.h:
	* glom/utility_widgets/layouttoolbar.cc:
	Added support for dragging related records to the layout. See #358092

Modified:
   trunk/ChangeLog
   trunk/configure.in
   trunk/glom/mode_data/flowtablewithfields.cc
   trunk/glom/mode_data/flowtablewithfields.h
   trunk/glom/utility_widgets/flowtable_dnd.cc
   trunk/glom/utility_widgets/flowtable_dnd.h
   trunk/glom/utility_widgets/layouttoolbar.cc
   trunk/icons/16x16/glom-related-records.png

Modified: trunk/configure.in
==============================================================================
--- trunk/configure.in	(original)
+++ trunk/configure.in	Fri Sep 26 14:26:34 2008
@@ -86,7 +86,7 @@
 fi
 
 # Do not require, goocanvas and gtksourceviewmm in client only mode
-REQUIRED_LIBS="bakery-2.6 >= 2.4.2 gtkmm-2.4 >= 2.10 gthread-2.0 libxslt >= 1.1.10 pygda-3.0 pygtk-2.0 >= 2.6.0 libgdamm-3.0 >= 2.9.82 libgda-3.0 >= 3.0.1 libgda-postgres-3.0 goocanvasmm-1.0 >= 0.11.0"
+REQUIRED_LIBS="bakery-2.6 >= 2.4.2 gtkmm-2.4 >= 2.10 gthread-2.0 libxslt >= 1.1.10 pygda-3.0 pygtk-2.0 >= 2.6.0 libgdamm-3.0 >= 2.9.82 libgda-3.0 >= 3.0.1 libgda-postgres-3.0 goocanvasmm-1.0 >= 0.9.0"
 if test $enable_client_only != yes; then
 	REQUIRED_LIBS="$REQUIRED_LIBS gtksourceviewmm-2.0"
 fi

Modified: trunk/glom/mode_data/flowtablewithfields.cc
==============================================================================
--- trunk/glom/mode_data/flowtablewithfields.cc	(original)
+++ trunk/glom/mode_data/flowtablewithfields.cc	Fri Sep 26 14:26:34 2008
@@ -1112,39 +1112,7 @@
   }
   else if(item_type == LayoutWidgetBase::TYPE_PORTAL)
   {
-    try
-    {
-      Glib::RefPtr<Gnome::Glade::Xml> refXml = Gnome::Glade::Xml::create(Utils::get_glade_file_path("glom_developer.glade"), "dialog_choose_relationship");
-
-      Dialog_ChooseRelationship* dialog = 0;
-      refXml->get_widget_derived("dialog_choose_relationship", dialog);
-
-      if(dialog)
-      {
-        Document_Glom* pDocument = static_cast<Document_Glom*>(get_document());
-        dialog->set_document(pDocument, m_table_name);
-        //TODO: dialog->set_transient_for(*get_app_window());
-        const int response = dialog->run();
-        dialog->hide();
-        if(response == Gtk::RESPONSE_OK)
-        {
-          //Get the chosen relationship:
-          sharedptr<Relationship> relationship  = dialog->get_relationship_chosen();
-          if(relationship)
-          {
-            sharedptr<LayoutItem_Portal> layout_item = sharedptr<LayoutItem_Portal>::create();
-            layout_item->set_relationship(relationship);
-            layout_item_new = layout_item;
-          }
-        }
-
-        delete dialog;
-      }
-    }
-    catch(const Gnome::Glade::XmlError& ex)
-    {
-      std::cerr << ex.what() << std::endl;
-    }
+    layout_item_new = get_portal_relationship();
   }
   else if(item_type == LayoutWidgetBase::TYPE_BUTTON)
   {
@@ -1250,6 +1218,20 @@
   signal_layout_changed().emit();
 }
 
+void FlowTableWithFields::on_dnd_add_layout_portal (LayoutWidgetBase* above)
+{
+  sharedptr<LayoutItem_Portal> portal = get_portal_relationship();
+  
+  if (portal)
+  {
+    sharedptr<LayoutItem> item = sharedptr<LayoutItem>::cast_dynamic(portal);
+    dnd_add_to_layout_group (item, above);
+    
+    //Tell the parent to tell the document to save the layout
+    signal_layout_changed().emit();
+  }
+}
+
 void FlowTableWithFields::on_dnd_add_layout_group(LayoutWidgetBase* above)
 {  
   sharedptr<LayoutGroup> group(new LayoutGroup());
@@ -1492,6 +1474,44 @@
   }
   return Gtk::Widget::on_button_press_event(event);
 }
+
+sharedptr<LayoutItem_Portal> FlowTableWithFields::get_portal_relationship()
+{
+  try
+  {
+    Glib::RefPtr<Gnome::Glade::Xml> refXml = Gnome::Glade::Xml::create(Utils::get_glade_file_path("glom_developer.glade"), "dialog_choose_relationship");
+    
+    Dialog_ChooseRelationship* dialog = 0;
+    refXml->get_widget_derived("dialog_choose_relationship", dialog);
+    
+    if(dialog)
+    {
+      Document_Glom* pDocument = static_cast<Document_Glom*>(get_document());
+      dialog->set_document(pDocument, m_table_name);
+      //TODO: dialog->set_transient_for(*get_app_window());
+      const int response = dialog->run();
+      dialog->hide();
+      if(response == Gtk::RESPONSE_OK)
+      {
+        //Get the chosen relationship:
+        sharedptr<Relationship> relationship  = dialog->get_relationship_chosen();
+        if(relationship)
+        {
+          sharedptr<LayoutItem_Portal> layout_item = sharedptr<LayoutItem_Portal>::create();
+          layout_item->set_relationship(relationship);
+          return layout_item;
+        }
+      }
+      
+      delete dialog;
+    }
+  }
+  catch(const Gnome::Glade::XmlError& ex)
+  {
+    std::cerr << ex.what() << std::endl;
+  }
+  return sharedptr<LayoutItem_Portal>();
+}
 #endif // !GLOM_ENABLE_CLIENT_ONLY
 
 } //namespace Glom

Modified: trunk/glom/mode_data/flowtablewithfields.h
==============================================================================
--- trunk/glom/mode_data/flowtablewithfields.h	(original)
+++ trunk/glom/mode_data/flowtablewithfields.h	Fri Sep 26 14:26:34 2008
@@ -217,10 +217,11 @@
   virtual void on_dnd_add_layout_item_text (LayoutWidgetBase* above);
   virtual void on_dnd_add_layout_item_image (LayoutWidgetBase* above);
   virtual void on_dnd_add_layout_notebook (LayoutWidgetBase* above);
+  virtual void on_dnd_add_layout_portal (LayoutWidgetBase* above);
   virtual void on_dnd_add_layout_item (LayoutWidgetBase* above,
                                        sharedptr<LayoutItem>& item);
   
-  bool get_field_information (sharedptr<LayoutItem>& item);
+  sharedptr<LayoutItem_Portal> get_portal_relationship ();
   void dnd_notify_failed_drop();
   bool dnd_add_to_layout_group (sharedptr<LayoutItem>& item, 
                                 LayoutWidgetBase* layoutwidget,

Modified: trunk/glom/utility_widgets/flowtable_dnd.cc
==============================================================================
--- trunk/glom/utility_widgets/flowtable_dnd.cc	(original)
+++ trunk/glom/utility_widgets/flowtable_dnd.cc	Fri Sep 26 14:26:34 2008
@@ -187,6 +187,9 @@
       case LayoutWidgetBase::TYPE_NOTEBOOK:
         on_dnd_add_layout_notebook(above);
         break;
+      case LayoutWidgetBase::TYPE_PORTAL:
+        on_dnd_add_layout_portal(above);
+        break;
       default:
         std::cerr << "Unknown drop type: " << type << std::endl;
     }

Modified: trunk/glom/utility_widgets/flowtable_dnd.h
==============================================================================
--- trunk/glom/utility_widgets/flowtable_dnd.h	(original)
+++ trunk/glom/utility_widgets/flowtable_dnd.h	Fri Sep 26 14:26:34 2008
@@ -68,6 +68,7 @@
   virtual void on_dnd_add_layout_item_text(LayoutWidgetBase* above) = 0;
   virtual void on_dnd_add_layout_item_image(LayoutWidgetBase* above) = 0;
   virtual void on_dnd_add_layout_notebook(LayoutWidgetBase* above) = 0;
+  virtual void on_dnd_add_layout_portal(LayoutWidgetBase* above) = 0;
   virtual void on_dnd_add_layout_item(LayoutWidgetBase* above,
                                        sharedptr<LayoutItem>& item) = 0;
   

Modified: trunk/glom/utility_widgets/layouttoolbar.cc
==============================================================================
--- trunk/glom/utility_widgets/layouttoolbar.cc	(original)
+++ trunk/glom/utility_widgets/layouttoolbar.cc	Fri Sep 26 14:26:34 2008
@@ -62,7 +62,10 @@
   LayoutToolbarButton* drag_item = 
     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 = 
+  LayoutToolbarButton* drag_portal = 
+    Gtk::manage(new LayoutToolbarButton("glom-related-records.png", LayoutWidgetBase::TYPE_PORTAL,
+                                        _("Related Records"), _("Drag this to the layout to add a new Related Record.")));
+	LayoutToolbarButton* drag_button = 
     Gtk::manage(new LayoutToolbarButton("glom-button.png", LayoutWidgetBase::TYPE_BUTTON,
                                         _("Button"), _("Drag this to the layout to add a new button.")));
   LayoutToolbarButton* drag_text = 
@@ -81,8 +84,9 @@
 
   //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_portal->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_button->gobj()));  
   gtk_container_add(fields_group, GTK_WIDGET(drag_text->gobj()));
   gtk_container_add(fields_group, GTK_WIDGET(drag_image->gobj()));
   

Modified: trunk/icons/16x16/glom-related-records.png
==============================================================================
Binary files. No diff available.



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