[patch] Add separators back to popup menus

Douglas Burke <[email protected]>
Newsgroups gmane.editors.conglomerate.devel
Message-ID <Pine.GSO.4.58.0410111855280.6399@lagado>
The attached patch adds separators back to the popup menus. I've
essentially no experience with the new "Action" approach to menus so this
patch is inspired guesswork :-)

Doug
cong.diff (text/plain, 6 KB)
Index: src/ChangeLog
===================================================================
RCS file: /cvs/gnome/conglomerate/src/ChangeLog,v
retrieving revision 1.725
diff -u -r1.725 ChangeLog
--- src/ChangeLog	10 Oct 2004 19:36:50 -0000	1.725
+++ src/ChangeLog	11 Oct 2004 22:53:44 -0000
@@ -1,3 +1,13 @@
+2004-10-11  Douglas Burke  <[email protected]>
+
+	* cong_util.c, cong_util.h, popup.c
+
+	Added separators back to the popup menus.
+
+	* cong-menus.c
+
+	Made the name of a separator tag unique.
+	
 2004-10-10  Dave Malcolm  <[email protected]>
 
 	* cong-plugin.c: 
Index: src/cong-menus.c
===================================================================
RCS file: /cvs/gnome/conglomerate/src/cong-menus.c,v
retrieving revision 1.73
diff -u -r1.73 cong-menus.c
--- src/cong-menus.c	26 Aug 2004 18:50:04 -0000	1.73
+++ src/cong-menus.c	11 Oct 2004 22:53:44 -0000
@@ -1653,7 +1653,7 @@
 "      <separator name='ContextSep1'/>"
 "      <menuitem action='Cut'/>"
 "      <menuitem action='Copy'/>"
-"      <separator name='ContextSep1'/>"
+"      <separator name='ContextSep2'/>"
 "      <menu action='NewSubelement'/>"
 "      <menu action='NewSibling'/>"
 "      <menu action='RemoveSpanTagSubmenu'/>"
Index: src/cong-util.c
===================================================================
RCS file: /cvs/gnome/conglomerate/src/cong-util.c,v
retrieving revision 1.51
diff -u -r1.51 cong-util.c
--- src/cong-util.c	7 Oct 2004 16:02:12 -0000	1.51
+++ src/cong-util.c	11 Oct 2004 22:53:45 -0000
@@ -43,6 +43,8 @@
 #include "cong-command.h"
 #include "cong-dispspec-registry.h"
 
+#include "cong-primary-window.h"
+
 #include <libxml/globals.h>
 #include <libxml/catalog.h>
 
@@ -1539,29 +1541,23 @@
 
 /**
  * cong_util_add_menu_separator:
+ * @primary_window:
  * @parent_ui_path:
  *
- * TODO: Write me
+ * Adds a separator to a menu.
  */
 void
-cong_util_add_menu_separator (const gchar *parent_ui_path)
+cong_util_add_menu_separator (CongPrimaryWindow *primary_window,
+			      const gchar *parent_ui_path)
 {
-#if 1
-	g_message ("writeme! cong_util_add_menu_separator");
-#else
-	GtkWidget *item = gtk_menu_item_new ();
-	GtkWidget *w0 = gtk_hseparator_new ();
-	gtk_container_add (GTK_CONTAINER (item), 
-			   w0);
-	gtk_menu_append (menu, 
-			 item);
-	gtk_widget_set_sensitive (item, 
-				  FALSE);
-	gtk_widget_show (w0);
-	gtk_widget_show (item);
-
-	return item;
-#endif
+	GtkUIManager *ui_manager = cong_primary_window_get_ui_manager (primary_window);
+	gtk_ui_manager_add_ui (ui_manager,
+			       gtk_ui_manager_new_merge_id (ui_manager),
+			       parent_ui_path,
+			       "dummy-name", /* FIXME: what should go here? */
+			       NULL,
+			       GTK_UI_MANAGER_SEPARATOR,
+			       FALSE);
 }
 
 /**
Index: src/cong-util.h
===================================================================
RCS file: /cvs/gnome/conglomerate/src/cong-util.h,v
retrieving revision 1.35
diff -u -r1.35 cong-util.h
--- src/cong-util.h	14 Aug 2004 03:31:51 -0000	1.35
+++ src/cong-util.h	11 Oct 2004 22:53:45 -0000
@@ -232,7 +232,8 @@
 					CongDocument *doc);
 
 void
-cong_util_add_menu_separator (const gchar *parent_ui_path);
+cong_util_add_menu_separator (CongPrimaryWindow *primary_window,
+			      const gchar *parent_ui_path);
 
 
 char *
Index: src/popup.c
===================================================================
RCS file: /cvs/gnome/conglomerate/src/popup.c,v
retrieving revision 1.93
diff -u -r1.93 popup.c
--- src/popup.c	14 Aug 2004 14:14:48 -0000	1.93
+++ src/popup.c	11 Oct 2004 22:53:45 -0000
@@ -277,6 +277,7 @@
 	
 	/* Add to the UI: */
 	/* Apparently the UI path must not have a leading slash; see http://mail.gnome.org/archives/gtk-app-devel-list/2004-July/msg00263.html */
+
 	gtk_ui_manager_add_ui (cong_primary_window_get_ui_manager (primary_window),
 			       gtk_ui_manager_new_merge_id (cong_primary_window_get_ui_manager (primary_window)),
 			       parent_ui_path,
@@ -600,7 +601,8 @@
 	default:
 		/* Convert to comment: */
 		{
-			cong_util_add_menu_separator (UI_PATH_CONTEXT_MENU);
+			cong_util_add_menu_separator (primary_window,UI_PATH_CONTEXT_MENU);
+
 			action = cong_action_new ("ConvertToComment",
 						  _("Convert to a comment"), 
 						  NULL, /* FIXME */
@@ -619,7 +621,8 @@
 	case CONG_NODE_TYPE_COMMENT:
 		/* Convert from comment: */
 		{
-			cong_util_add_menu_separator (UI_PATH_CONTEXT_MENU);
+			cong_util_add_menu_separator (primary_window,UI_PATH_CONTEXT_MENU);
+
 			action = cong_action_new ("ConvertFromComment",
 						  _("Uncomment"), 
 						  _("Convert a comment containing XML source code into the corresponding code"),
@@ -729,7 +732,7 @@
 								&callback_data);
 		}
 		
-		cong_util_add_menu_separator(UI_PATH_CONTEXT_MENU);
+		cong_util_add_menu_separator (primary_window,UI_PATH_CONTEXT_MENU);
 	}
 
 	
@@ -775,7 +778,7 @@
 			      GTK_UI_MANAGER_MENUITEM);
 
 	if (present_span_tags_list != NULL) {
-		cong_util_add_menu_separator(UI_PATH_CONTEXT_MENU);
+		cong_util_add_menu_separator (primary_window,UI_PATH_CONTEXT_MENU);
 		
 		span_tag_removal_popup_init (dispspec,
 					     cursor, 
@@ -786,7 +789,7 @@
 					     primary_window);
 	}
 	
-	cong_util_add_menu_separator(UI_PATH_CONTEXT_MENU);
+	cong_util_add_menu_separator (primary_window,UI_PATH_CONTEXT_MENU);
 
 	if (available_span_tags_desc_list) {
 		GList *iter;
@@ -1032,7 +1035,7 @@
 	if (cong_node_type(node)==CONG_NODE_TYPE_ELEMENT) {
 
 #if 0
-		cong_util_add_menu_separator (UI_PATH_CONTEXT_MENU);
+		cong_util_add_menu_separator (primary_window,UI_PATH_CONTEXT_MENU);
 
 		add_action_to_popup_with_callback_Document_SelectedNode_ParentWindow (UI_PATH_CONTEXT_MENU,
 										      cong_action_new_from_stock ("NodeCut",
@@ -1085,7 +1088,7 @@
 										      primary_window);
 	}
 	
-	cong_util_add_menu_separator (UI_PATH_CONTEXT_MENU);
+	cong_util_add_menu_separator (primary_window,UI_PATH_CONTEXT_MENU);
 
 
 	/* The "New Sub-element" submenu: */
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.