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

アーカイブの一覧に戻る

Yasumichi Akahoshi yasum****@users*****
2005年 5月 9日 (月) 19:56:18 JST


Index: cxplorer/src/cxplorer-window.c
diff -u cxplorer/src/cxplorer-window.c:1.44 cxplorer/src/cxplorer-window.c:1.45
--- cxplorer/src/cxplorer-window.c:1.44	Sun May  8 01:03:23 2005
+++ cxplorer/src/cxplorer-window.c	Mon May  9 19:56:17 2005
@@ -40,6 +40,10 @@
 #include "cxp-pref-dialog.h"
 #include "cxplorer-window.h"
 
+#define CXP_GCONF_DIR	"/apps/cxp"
+#define CXPLORER_GCONF_DIR	CXP_GCONF_DIR"/cxplorer"
+#define BOOKMARK_GCONF_DIR	CXPLORER_GCONF_DIR"/bookmark"
+
 /* If you use Pimpls, include the private structure 
  * definition here. Some people create a cxplorer-property_dialog-private.h header
  * which is included by the cxplorer-property_dialog.c file and which contains the
@@ -58,7 +62,6 @@
 	GtkWidget *right_pane;
 	GtkWidget *statusbar;
 	CxpProfile *sendto;
-	CxpProfile *bookmark;
 	gboolean dispose_has_run;
 } CxplorerWindowPrivate;
 
@@ -75,7 +78,8 @@
 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_menu_item_new_from_bookmark (gpointer key, gpointer value, 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);
 static void cxplorer_window_finalize (GObject * obj);
 static void cxplorer_window_entry_activate (GtkWidget *widget, gpointer user_data);
@@ -188,16 +192,15 @@
 	gchar *filter;
 
 	private->client = gconf_client_get_default ();
-	gconf_client_add_dir (private->client, "/apps/cxp/cxplorer", GCONF_CLIENT_PRELOAD_NONE, NULL);
-	show_dot_file = gconf_client_get_bool (private->client, "/apps/cxp/cxplorer/ShowDotFile", NULL);
-	filter = gconf_client_get_string (private->client, "/apps/cxp/cxplorer/FilenameFilter", NULL);
+	gconf_client_add_dir (private->client, CXPLORER_GCONF_DIR, GCONF_CLIENT_PRELOAD_NONE, NULL);
+	show_dot_file = gconf_client_get_bool (private->client, CXPLORER_GCONF_DIR"/ShowDotFile", NULL);
+	filter = gconf_client_get_string (private->client, CXPLORER_GCONF_DIR"/FilenameFilter", NULL);
 	if(filter != NULL)
 	{
 		cxp_utils_set_filename_filter (filter);
 		g_free (filter);
 	}
 
-	private->bookmark = cxp_profile_new ("cxplorer", "bookmark");
 	private->sendto	= cxp_profile_new ("common", "SendTo");
 
 	vbox = gtk_vbox_new (FALSE, 0);
@@ -229,8 +232,7 @@
 	g_hash_table_foreach (hash, cxplorer_window_menu_item_new_from_sendto, self);
 
 	/* ここでブックマークメニューを構築する。 */
-	hash = cxp_profile_get_hash_table (private->bookmark);
-	g_hash_table_foreach (hash, cxplorer_window_menu_item_new_from_bookmark, self);
+	cxplorer_window_bookmark_menu_init (self);
 
 	toolbar = gtk_ui_manager_get_widget (private->ui_manager, "/toolbar");
 	gtk_box_pack_start (GTK_BOX (vbox), toolbar, FALSE, FALSE, 0);
@@ -322,13 +324,41 @@
 
 /**
  * \if japanese
+ * ブックマークメニューの初期化
+ * \endif
+ */
+static void cxplorer_window_bookmark_menu_init (CxplorerWindow *self)
+{
+	CxplorerWindowPrivate *private = CXPLORER_WINDOW_GET_PRIVATE (self);
+	GSList *bookmark_list;
+	GSList *node;
+	GConfEntry *entry;
+
+	bookmark_list = gconf_client_all_entries (private->client, BOOKMARK_GCONF_DIR, NULL);
+	node = bookmark_list;
+	while (node != NULL)
+	{
+		entry = node->data;
+		cxplorer_window_menu_item_new_from_bookmark (
+				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 (bookmark_list);
+}
+
+/**
+ * \if japanese
  * ブックマーク毎にメニューを作成する。
  * @param [in] key ハッシュのキー
  * @param [in] value ハッシュの値
  * @param [in] user_data CxplorerWindow
  * \endif
  */
-static void cxplorer_window_menu_item_new_from_bookmark (gpointer key, gpointer value, gpointer user_data)
+static void cxplorer_window_menu_item_new_from_bookmark (const gchar *key, const gchar *value, gpointer user_data)
 {
 	CxplorerWindowPrivate *private = CXPLORER_WINDOW_GET_PRIVATE (user_data);
 	GtkWidget *menu;
@@ -338,6 +368,7 @@
 	{
 		menu = gtk_menu_item_get_submenu(GTK_MENU_ITEM(menuitem));
 		menuitem = gtk_menu_item_new_with_label (key);
+		g_object_set_data (G_OBJECT (menuitem), "dirname", g_strdup(value));
 		gtk_container_add (GTK_CONTAINER(menu), menuitem);
 		g_signal_connect (menuitem, "activate", G_CALLBACK(cxplorer_window_user_bookmark_activate), user_data);
 		gtk_widget_show (menuitem);
@@ -363,7 +394,6 @@
 	 * reference.
 	 */
 	g_object_unref (private->client);
-	g_object_unref (private->bookmark);
 	g_object_unref (private->action_group);
 	g_object_unref (private->ui_manager);
 	cxp_utils_free_filename_filter ();
@@ -601,7 +631,7 @@
 	GtkWidget *dialog;
 
 
-	cmd_format = gconf_client_get_string (private->client, "/apps/cxp/cxplorer/AttachCommand", NULL);
+	cmd_format = gconf_client_get_string (private->client, CXPLORER_GCONF_DIR"/AttachCommand", NULL);
 	g_return_if_fail (cmd_format != NULL);
 	if ((fullpath = cxp_right_pane_get_active_file_name (CXP_RIGHT_PANE(private->right_pane))) != NULL)
 	{
@@ -704,7 +734,7 @@
 	gboolean show_dot_file;
 
 	show_dot_file = gtk_toggle_action_get_active(action);
-	gconf_client_set_bool (private->client, "/apps/cxp/cxplorer/ShowDotFile", show_dot_file, NULL);
+	gconf_client_set_bool (private->client, CXPLORER_GCONF_DIR"/ShowDotFile", show_dot_file, NULL);
 	cxp_dir_view_refresh (CXP_DIR_VIEW(private->dirview));
 }
 
@@ -756,6 +786,11 @@
 	g_free (utf8_path);
 }
 
+/**
+ * \if japanese
+ * ブックマークの追加を要求された場合の処理
+ * \endif
+ */
 static void cxplorer_window_bookmark_add_action (GtkWidget *widget, gpointer user_data)
 {
 	CxplorerWindowPrivate *private = CXPLORER_WINDOW_GET_PRIVATE (user_data);
@@ -764,6 +799,8 @@
 	gchar *dir_utf8;
 	gchar *message;
 	gchar *alias;
+	gchar *bookmark_name;
+	gchar *bookmark_key;
 
 	cur_dir = cxp_dir_view_get_current_directory (CXP_DIR_VIEW(private->dirview));
 	dir_utf8 = g_locale_to_utf8 (cur_dir, -1, NULL, NULL, NULL);
@@ -774,9 +811,16 @@
 	if (gtk_dialog_run (GTK_DIALOG(dialog)) == GTK_RESPONSE_OK)
 	{
 		alias = cxp_entry_dialog_get_entry_text (CXP_ENTRY_DIALOG(dialog));
-		cxp_profile_set_string (private->bookmark, alias, dir_utf8);
+		bookmark_name = g_strdup (dir_utf8);	/* エントリのname属性をディレクトリ名から求める */
+		g_strdelimit (bookmark_name, "/", '_');
+		bookmark_key = g_build_path ("/", BOOKMARK_GCONF_DIR, bookmark_name, NULL);
+
+		/* ブックマーク名とディレクトリ名のペアを登録する */
+		gconf_client_set_pair (private->client, bookmark_key, GCONF_VALUE_STRING, GCONF_VALUE_STRING, &alias, &dir_utf8, NULL);
 		cxplorer_window_menu_item_new_from_bookmark (alias, cur_dir, user_data);
 		g_free (alias);
+		g_free (bookmark_name);
+		g_free (bookmark_key);
 	}
 
 	gtk_widget_destroy (dialog);
@@ -861,7 +905,7 @@
 	label = gtk_bin_get_child (GTK_BIN(widget));
 	if (GTK_IS_LABEL(label))
 	{
-		dirname = cxp_profile_get_string (private->bookmark, gtk_label_get_text (GTK_LABEL(label)));
+		dirname = g_object_get_data (G_OBJECT(widget), "dirname");
 		cxp_dir_view_change_directory (CXP_DIR_VIEW(private->dirview), dirname);
 	}
 }


Cxplorer-cvs メーリングリストの案内
アーカイブの一覧に戻る