menu item properties



hello-
the attached patch is for gnome-panel, addressing bugzilla bug 162177
(adding a 'menu item properties' item in the gnome menu context menu):
http://bugzilla.gnome.org/show_bug.cgi?id=162177

issues that come to my mind:
* i'm not sure what i have to do for i18n besides enclosing translatable
strings in _().  do i have to edit any other files, or is that the
translators' job?
* vincent untz's comment on bugzilla implies making some/all of the menu
item properties editable, is this desired?
* this is my first gnome patch, please be kind =)

Michael

-- 
                                      .~.
Michael Frank                         /v\
msfrank syntaxjockey com             // \\
                                    /(   )\
GPG Fingerprint:                     ^`-'^
2A44 DF32 91A5 ADA9 0E86 4F65 4051 870D 8B51 6EE0
Index: menu.c
===================================================================
RCS file: /cvs/gnome/gnome-panel/gnome-panel/menu.c,v
retrieving revision 1.756
diff -u -p -r1.756 menu.c
--- menu.c	7 Mar 2006 17:59:52 -0000	1.756
+++ menu.c	29 Mar 2006 06:12:55 -0000
@@ -668,6 +668,97 @@ add_app_to_desktop (GtkWidget      *item
 	g_free (target_uri);
 }
 
+static void
+retrieve_app_properties(GtkWidget	*item,
+			GMenuTreeEntry	*entry)
+{
+	const gchar *dpath;
+	GnomeDesktopItem *ditem;
+	GError *error = NULL;
+	GtkWidget *dialog, *table, *name, *value;
+
+	g_return_if_fail (entry != NULL);
+
+	dpath = gmenu_tree_entry_get_desktop_file_path (entry);
+	g_return_if_fail (dpath != NULL);
+
+	ditem = gnome_desktop_item_new_from_file (dpath,
+    			GNOME_DESKTOP_ITEM_LOAD_ONLY_IF_EXISTS,
+    			&error);
+	if (error != NULL) {
+		g_warning ("failed to load desktop item %s: %s",
+			dpath, error->message);
+		g_error_free (error);
+		return;
+	}
+
+	dialog = gtk_dialog_new_with_buttons (_("Menu Item Properties"),
+			NULL,
+			GTK_DIALOG_DESTROY_WITH_PARENT,
+			GTK_STOCK_CLOSE,
+			GTK_RESPONSE_NONE,
+			NULL);
+	gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
+
+	table = gtk_table_new (5, 2, FALSE);
+	gtk_container_set_border_width (GTK_CONTAINER (table), 6);
+	gtk_box_pack_start(GTK_BOX (GTK_DIALOG (dialog)->vbox),
+		table, FALSE, FALSE, 6);
+
+	name = gtk_label_new (_("Item Name:"));
+	gtk_misc_set_alignment (GTK_MISC (name), 1.0, 0.5);
+	gtk_table_attach (GTK_TABLE (table), name, 0, 1, 0, 1,
+		GTK_EXPAND|GTK_FILL, 0, 6, 4);
+	value = gtk_label_new (gnome_desktop_item_get_string (ditem, "Name"));
+	gtk_misc_set_alignment (GTK_MISC (value), 0.0, 0.5);
+	gtk_table_attach (GTK_TABLE (table), value, 1, 2, 0, 1,
+		GTK_EXPAND|GTK_FILL, 0, 6, 4);
+
+	name = gtk_label_new (_("Location:"));
+	gtk_misc_set_alignment (GTK_MISC (name), 1.0, 0.5);
+	gtk_table_attach (GTK_TABLE (table), name, 0, 1, 1, 2,
+		GTK_EXPAND|GTK_FILL, 0, 6, 4);
+	value = gtk_entry_new ();
+	gtk_entry_set_text (GTK_ENTRY (value),
+		gnome_desktop_item_get_location (ditem));
+	gtk_entry_set_editable (GTK_ENTRY (value), FALSE);
+	gtk_table_attach (GTK_TABLE (table), value, 1, 2, 1, 2,
+		GTK_EXPAND|GTK_FILL, 0, 6, 4);
+
+	name = gtk_label_new (_("Generic Name:"));
+	gtk_misc_set_alignment (GTK_MISC (name), 1.0, 0.5);
+	gtk_table_attach (GTK_TABLE (table), name, 0, 1, 2, 3,
+		GTK_EXPAND|GTK_FILL, 0, 6, 4);
+	value = gtk_label_new (gnome_desktop_item_get_string (ditem, "GenericName"));
+	gtk_misc_set_alignment (GTK_MISC (value), 0.0, 0.5);
+	gtk_table_attach (GTK_TABLE (table), value, 1, 2, 2, 3,
+		GTK_EXPAND|GTK_FILL, 0, 6, 4);
+
+	name = gtk_label_new (_("Executes:"));
+	gtk_misc_set_alignment (GTK_MISC (name), 1.0, 0.5);
+	gtk_table_attach (GTK_TABLE (table), name, 0, 1, 3, 4,
+		GTK_EXPAND|GTK_FILL, 0, 6, 4);
+	value = gtk_label_new (gnome_desktop_item_get_string (ditem, "Exec"));
+	gtk_label_set_selectable (GTK_LABEL (value), TRUE);
+	gtk_misc_set_alignment (GTK_MISC (value), 0.0, 0.5);
+	gtk_table_attach (GTK_TABLE (table), value, 1, 2, 3, 4,
+		GTK_EXPAND|GTK_FILL, 0, 6, 4);
+
+	name = gtk_label_new (_("Comment:"));
+	gtk_misc_set_alignment (GTK_MISC (name), 1.0, 0.5);
+	gtk_table_attach (GTK_TABLE (table), name, 0, 1, 4, 5,
+		GTK_EXPAND|GTK_FILL, 0, 6, 4);
+	value = gtk_label_new (gnome_desktop_item_get_string (ditem, "Comment"));
+	gtk_label_set_line_wrap (GTK_LABEL (value), TRUE);
+	gtk_misc_set_alignment (GTK_MISC (value), 0.0, 0.5);
+	gtk_table_attach (GTK_TABLE (table), value, 1, 2, 4, 5,
+		GTK_EXPAND|GTK_FILL, 0, 6, 4);
+
+	g_signal_connect_swapped (dialog, "response",
+		G_CALLBACK (gtk_widget_destroy), dialog);
+	gtk_widget_show_all (dialog);
+	gnome_desktop_item_unref (ditem);
+}
 
 static void add_drawers_from_dir (GMenuTreeDirectory *directory,
 				  int                 pos,
@@ -950,6 +1041,16 @@ create_item_context_menu (GtkWidget   *i
 	gtk_widget_set_sensitive (menuitem, id_lists_writable);
 	gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
 
+	menuitem = gtk_image_menu_item_new ();
+	setup_menuitem (menuitem,
+			panel_menu_icon_get_size (),
+			NULL,
+			_("P_roperties"),
+			FALSE);
+	g_signal_connect (menuitem, "activate",
+			  G_CALLBACK (retrieve_app_properties), entry);
+	gtk_widget_set_sensitive (menuitem, id_lists_writable);
+	gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
 
 	submenu = create_empty_menu ();
 


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