On Thu, 2006-01-26 at 18:10 -0500, Tristan Van Berkom wrote:
> Hi all,
>      A few months and one menu-editor later, we give you the second 
> development
> snapshot of glade-3 or "the menu-editor snapshot", also heaping with new
> features and bugfixes :)
> 
> So please, have fun trying to break the editor and tell us what gives ;-)

Ha, I found some glitches :p

Juan Pablo

2006-01-30  Juan Pablo Ugarte <[EMAIL PROTECTED]>

        * src/glade-gtk.c:
          o glade_gtk_menu_editor_reorder () fixed, so you can move a
          submenu item into the menubar.

          o glade_gtk_menu_bar_append_new_item () now sets "stock"
          property.

          o glade_gtk_menu_editor_is_child () item has to be a
          GtkMenuItem. (this prevents treeview to be refresh when adding
          an image to an item :)

        * widgets/gtk+.xml.in: added new GtkMenuBar displayable values
          for properties child-pack-direction and pack-direction.
Index: src/glade-gtk.c
===================================================================
RCS file: /cvs/gnome/glade3/src/glade-gtk.c,v
retrieving revision 1.99
diff -u -r1.99 glade-gtk.c
--- src/glade-gtk.c	26 Jan 2006 22:17:17 -0000	1.99
+++ src/glade-gtk.c	30 Jan 2006 21:54:43 -0000
@@ -2261,18 +2261,29 @@
 		image_item_class = glade_widget_class_get_by_type (GTK_TYPE_IMAGE_MENU_ITEM);
 	}
 	
+	gitem = glade_widget_new (parent,
+				  (use_stock) ? image_item_class : item_class,
+				  project);
+	glade_widget_property_set (gitem, "use-underline", TRUE);
+	
 	if (use_stock)
 	{
-		gitem = glade_widget_new (parent, image_item_class, project);
-		glade_widget_property_set (gitem, "use-stock", TRUE);
+		GEnumClass *eclass;
+		GEnumValue *eval;
+		
+		eclass = g_type_class_ref (GLADE_TYPE_STOCK);
+		eval = g_enum_get_value_by_nick (eclass, label);
+		
+		if (eval)
+			glade_widget_property_set (gitem, "stock", eval->value);
+		
+		g_type_class_unref (eclass);
 	}
 	else
 	{
-		gitem = glade_widget_new (parent, item_class, project);
+		glade_widget_property_set (gitem, "label", label);
 	}
-
-	glade_widget_property_set (gitem, "use-underline", TRUE);
-	glade_widget_property_set (gitem, "label", label);
+	
 	item = glade_widget_get_object (gitem);
 	
 	glade_widget_class_container_add (glade_widget_get_class (parent),
@@ -2836,11 +2847,10 @@
 	}
 }
 
-static void
+static gboolean
 glade_gtk_menu_editor_find_child_real (GladeGtkMenuEditor *e,
 				       GladeWidget *child,
-				       GtkTreeIter *iter,
-				       gboolean select)
+				       GtkTreeIter *iter)
 {
 	GtkTreeModel *model = GTK_TREE_MODEL (e->store);
 	GtkTreeIter child_iter;
@@ -2850,30 +2860,39 @@
 	{
 		gtk_tree_model_get (model, iter, GLADEGTK_MENU_GWIDGET, &item, -1);
 	
-		if (item == child)
-		{
-			if (select) glade_gtk_menu_editor_set_cursor (e, iter);
-			return;
-		}
+		if (item == child) return TRUE;
 
 		if (gtk_tree_model_iter_children (model, &child_iter, iter))
-			glade_gtk_menu_editor_find_child_real (e, child, &child_iter, select);
+			if (glade_gtk_menu_editor_find_child_real (e, child, &child_iter))
+			{
+				*iter = child_iter;
+				return TRUE;
+			}
 	}
 	while (gtk_tree_model_iter_next (model, iter));
 	
-	return;
+	return FALSE;
+}
+
+static gboolean
+glade_gtk_menu_editor_find_child (GladeGtkMenuEditor *e,
+				  GladeWidget *child,
+				  GtkTreeIter *iter)
+{
+	if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (e->store), iter))
+		return glade_gtk_menu_editor_find_child_real (e, child, iter);
+	
+	return FALSE;
 }
 
 static void
 glade_gtk_menu_editor_select_child (GladeGtkMenuEditor *e,
 				    GladeWidget *child)
 {
-	GtkTreeModel *model = GTK_TREE_MODEL (e->store);
 	GtkTreeIter iter;
 	
-	gtk_tree_model_get_iter_first (model, &iter);
-	
-	glade_gtk_menu_editor_find_child_real (e, child, &iter, TRUE);
+	if (glade_gtk_menu_editor_find_child (e, child, &iter))
+		glade_gtk_menu_editor_set_cursor (e, &iter);
 }
 
 static void
@@ -3066,7 +3085,7 @@
 							gparent, NULL, e->project);
 	}
 	else
-		gparent = glade_widget_get_parent (gitem);
+		gparent = e->gmenubar;
 
 	list.data = gitem;
 	glade_command_cut (&list);
@@ -3273,6 +3292,9 @@
 static gboolean
 glade_gtk_menu_editor_is_child (GladeGtkMenuEditor *e, GladeWidget *item)
 {
+	if (!GTK_IS_MENU_ITEM (glade_widget_get_object (item)))
+		return FALSE;
+	
 	while ((item = glade_widget_get_parent (item)))
 		if (item == e->gmenubar) return TRUE;
 
@@ -3319,8 +3341,14 @@
 	}
 	
 	if (glade_gtk_menu_editor_is_child (e, widget))
-		glade_gtk_menu_editor_update_treeview_idle (e);
-
+	{
+		GtkTreeIter iter;
+		if (glade_gtk_menu_editor_find_child (e, widget, &iter))
+		{
+			gtk_tree_store_remove (e->store, &iter);
+			glade_gtk_menu_editor_clear (e);
+		}
+	}
 }
 
 static void
Index: widgets/gtk+.xml.in
===================================================================
RCS file: /cvs/gnome/glade3/widgets/gtk+.xml.in,v
retrieving revision 1.29
diff -u -r1.29 gtk+.xml.in
--- widgets/gtk+.xml.in	15 Jan 2006 21:14:56 -0000	1.29
+++ widgets/gtk+.xml.in	30 Jan 2006 21:54:50 -0000
@@ -249,6 +249,24 @@
       <post-create-function>glade_gtk_menu_bar_post_create</post-create-function>
       <launch-editor-function>glade_gtk_menu_bar_launch_editor</launch-editor-function>
       <!-- menubar is a container you can't add placeholders to it -->
+      <properties>
+        <property id="child-pack-direction">
+          <displayable-values>
+	    <value id="GTK_PACK_DIRECTION_LTR" _name="Left to Right"/>
+	    <value id="GTK_PACK_DIRECTION_RTL" _name="Right to Left"/>
+	    <value id="GTK_PACK_DIRECTION_TTB" _name="Top to Bottom"/>
+	    <value id="GTK_PACK_DIRECTION_BTT" _name="Bottom to Top"/>
+	  </displayable-values>
+	</property>
+        <property id="pack-direction">
+          <displayable-values>
+	    <value id="GTK_PACK_DIRECTION_LTR" _name="Left to Right"/>
+	    <value id="GTK_PACK_DIRECTION_RTL" _name="Right to Left"/>
+	    <value id="GTK_PACK_DIRECTION_TTB" _name="Top to Bottom"/>
+	    <value id="GTK_PACK_DIRECTION_BTT" _name="Bottom to Top"/>
+	  </displayable-values>
+	</property>
+      </properties>
       <packing-defaults>
 	<parent-class name="GtkVBox">
 	  <child-property id="expand" default="false"/>
_______________________________________________
Glade-devel maillist  -  Glade-devel@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/glade-devel

Reply via email to