[Cxplorer-cvs 01098] CVS update: cxplorer/src

Zurück zum Archiv-Index

Yasumichi Akahoshi yasum****@users*****
2005年 5月 9日 (月) 23:33:11 JST


Index: cxplorer/src/cxplorer-window.c
diff -u cxplorer/src/cxplorer-window.c:1.45 cxplorer/src/cxplorer-window.c:1.46
--- cxplorer/src/cxplorer-window.c:1.45	Mon May  9 19:56:17 2005
+++ cxplorer/src/cxplorer-window.c	Mon May  9 23:33:10 2005
@@ -43,6 +43,7 @@
 #define CXP_GCONF_DIR	"/apps/cxp"
 #define CXPLORER_GCONF_DIR	CXP_GCONF_DIR"/cxplorer"
 #define BOOKMARK_GCONF_DIR	CXPLORER_GCONF_DIR"/bookmark"
+#define SENDTO_GCONF_DIR	CXP_GCONF_DIR"/SendTo"
 
 /* If you use Pimpls, include the private structure 
  * definition here. Some people create a cxplorer-property_dialog-private.h header
@@ -77,7 +78,8 @@
 					gpointer g_class_data);
 static void cxplorer_window_instance_init (GTypeInstance * instance,
 					   gpointer g_class);
-static void cxplorer_window_menu_item_new_from_sendto (gpointer key, gpointer value, gpointer user_data);
+static void cxplorer_window_sendto_menu_init (CxplorerWindow *self);
+static void cxplorer_window_menu_item_new_from_sendto (const gchar *caption, const gchar *command, gpointer user_data);
 static void cxplorer_window_bookmark_menu_init (CxplorerWindow *self);
 static void cxplorer_window_menu_item_new_from_bookmark (const gchar *key, const gchar *value, gpointer user_data);
 static void cxplorer_window_dispose (GObject * obj);
@@ -185,7 +187,6 @@
 	GtkWidget *dirview;
 	GtkWidget *right_pane;
 	GtkWidget *statusbar;
-	GHashTable *hash;
 	gboolean show_dot_file;
 	gchar *current_dir;
 	gchar *current_dir_utf8;
@@ -201,8 +202,6 @@
 		g_free (filter);
 	}
 
-	private->sendto	= cxp_profile_new ("common", "SendTo");
-
 	vbox = gtk_vbox_new (FALSE, 0);
 	gtk_container_add (GTK_CONTAINER (self), vbox);
 
@@ -228,8 +227,7 @@
 	gtk_widget_show (menubar);
 
 	/*  ここで送るメニューを構築する。 */
-	hash = cxp_profile_get_hash_table (private->sendto);
-	g_hash_table_foreach (hash, cxplorer_window_menu_item_new_from_sendto, self);
+	cxplorer_window_sendto_menu_init (self);
 
 	/* ここでブックマークメニューを構築する。 */
 	cxplorer_window_bookmark_menu_init (self);
@@ -300,13 +298,41 @@
 
 /**
  * \if japanese
+ * 送るメニューの初期化
+ * \endif
+ */
+static void cxplorer_window_sendto_menu_init (CxplorerWindow *self)
+{
+	CxplorerWindowPrivate *private = CXPLORER_WINDOW_GET_PRIVATE (self);
+	GSList *sendto_list;
+	GSList *node;
+	GConfEntry *entry;
+
+	sendto_list = gconf_client_all_entries (private->client, SENDTO_GCONF_DIR, NULL);
+	node = sendto_list;
+	while (node != NULL)
+	{
+		entry = node->data;
+		cxplorer_window_menu_item_new_from_sendto (
+				gconf_value_get_string(gconf_value_get_car(gconf_entry_get_value(entry))),
+				gconf_value_get_string(gconf_value_get_cdr(gconf_entry_get_value(entry))),
+				self);
+		gconf_entry_free (entry);
+		node = g_slist_next(node);
+	}
+
+	g_slist_free (sendto_list);
+}
+
+/**
+ * \if japanese
  * 送るメニューに項目を追加する
  * @param [in] key ハッシュのキー
  * @param [in] value ハッシュの値
  * @param [in] user_data CxplorerWindow
  * \endif
  */
-static void cxplorer_window_menu_item_new_from_sendto (gpointer key, gpointer value, gpointer user_data)
+static void cxplorer_window_menu_item_new_from_sendto (const gchar *caption, const gchar *command, gpointer user_data)
 {
 	CxplorerWindowPrivate *private = CXPLORER_WINDOW_GET_PRIVATE (user_data);
 	GtkWidget *menu;
@@ -315,7 +341,8 @@
 	if((menuitem = gtk_ui_manager_get_widget (private->ui_manager, "/menubar/FileMenu/SendMenu")) != NULL)
 	{
 		menu = gtk_menu_item_get_submenu(GTK_MENU_ITEM(menuitem));
-		menuitem = gtk_menu_item_new_with_label (key);
+		menuitem = gtk_menu_item_new_with_label (caption);
+		g_object_set_data (G_OBJECT (menuitem), "command", g_strdup(command));
 		gtk_container_add (GTK_CONTAINER(menu), menuitem);
 		g_signal_connect (menuitem, "activate", G_CALLBACK(cxplorer_window_sendto_activate), user_data);
 		gtk_widget_show (menuitem);
@@ -858,33 +885,27 @@
 	gchar *filename;
 	gchar *cmd;
 	gchar *fullcmd;
-	GtkWidget *label;
 	GtkWidget *dialog;
 	GError *gerror = NULL;
 
-	label = gtk_bin_get_child (GTK_BIN(widget));
-	if (GTK_IS_LABEL(label))
+	if((cmd = g_object_get_data (G_OBJECT (widget), "command")) != NULL)
 	{
-		if((cmd = cxp_profile_get_string (private->sendto, gtk_label_get_text (GTK_LABEL(label)))) != NULL)
+		if((filename = cxp_right_pane_get_active_file_name (CXP_RIGHT_PANE(private->right_pane))) != NULL)
 		{
-			if((filename = cxp_right_pane_get_active_file_name (CXP_RIGHT_PANE(private->right_pane))) != NULL)
+			fullcmd = g_strdup_printf ("%s '%s'", cmd, filename);
+			if(g_spawn_command_line_async (fullcmd, &gerror) == FALSE)
 			{
-				fullcmd = g_strdup_printf ("%s '%s'", cmd, filename);
-				if(g_spawn_command_line_async (fullcmd, &gerror) == FALSE)
-				{
-					dialog = gtk_message_dialog_new (NULL,
-							GTK_DIALOG_DESTROY_WITH_PARENT,
-							GTK_MESSAGE_ERROR,
-							GTK_BUTTONS_CLOSE,
-							"%s",
-							gerror->message);
-					gtk_dialog_run (GTK_DIALOG (dialog));
-					gtk_widget_destroy (dialog);
-				}
-				g_free (fullcmd);
-				g_free (filename);
+				dialog = gtk_message_dialog_new (NULL,
+						GTK_DIALOG_DESTROY_WITH_PARENT,
+						GTK_MESSAGE_ERROR,
+						GTK_BUTTONS_CLOSE,
+						"%s",
+						gerror->message);
+				gtk_dialog_run (GTK_DIALOG (dialog));
+				gtk_widget_destroy (dialog);
 			}
-			g_free (cmd);
+			g_free (fullcmd);
+			g_free (filename);
 		}
 	}
 }


Cxplorer-cvs メーリングリストの案内
Zurück zum Archiv-Index