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

Back to archive index

Yasumichi Akahoshi yasum****@users*****
2005年 4月 19日 (火) 23:47:08 JST


Index: cxplorer/src/cxplorer-window.c
diff -u cxplorer/src/cxplorer-window.c:1.27 cxplorer/src/cxplorer-window.c:1.28
--- cxplorer/src/cxplorer-window.c:1.27	Sat Apr 16 03:55:20 2005
+++ cxplorer/src/cxplorer-window.c	Tue Apr 19 23:47:08 2005
@@ -55,6 +55,7 @@
 	GtkWidget *right_pane;
 	GtkWidget *statusbar;
 	CxpProfile *profile;
+	CxpProfile *bookmark;
 	gboolean dispose_has_run;
 } CxplorerWindowPrivate;
 
@@ -70,6 +71,7 @@
 					gpointer g_class_data);
 static void cxplorer_window_instance_init (GTypeInstance * instance,
 					   gpointer g_class);
+static void cxplorer_window_menu_item_new_from_bookmark (gpointer key, gpointer 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);
@@ -77,6 +79,7 @@
 						  gpointer user_data);
 static void cxplorer_window_on_dir_double_clicked (CxpRightPane * right_pane,
 						   gpointer user_data);
+
 static void cxplorer_window_new_win_action (GtkWidget *widget, gpointer user_data);
 void cxplorer_window_new_file_action (GtkWidget * widget, gpointer user_data);
 void cxplorer_window_new_directory_action (GtkWidget *widget, gpointer user_data);
@@ -90,8 +93,11 @@
 static void cxplorer_window_refresh_views_action (GtkWidget *widget, gpointer user_data);
 static void cxplorer_window_go_up_action (GtkWidget *widget, gpointer user_data);
 static void cxplorer_window_go_home_action (GtkWidget *widget, gpointer user_data);
+static void cxplorer_window_bookmark_add_action (GtkWidget *widget, gpointer user_data);
 static void cxplorer_window_about_action (GtkWidget *widget, gpointer user_data);
 
+static void cxplorer_window_user_bookmark_activate (GtkWidget *widget, gpointer user_data);
+
 /**
  * Actions
  */
@@ -121,7 +127,7 @@
 	{"GoAction", NULL, N_("_Go"), NULL, NULL, NULL},
 	{"UpAction", "gtk-go-up", N_("_Up"), NULL, NULL, G_CALLBACK(cxplorer_window_go_up_action)},
 	{"HomeAct", "gtk-home", N_("_Home"), NULL, NULL, G_CALLBACK(cxplorer_window_go_home_action)},
-	{"BookmarkAct", NULL, N_("_Bookmark..."), NULL, NULL, NULL},
+	{"BookmarkAct", NULL, N_("_Bookmark..."), NULL, NULL, G_CALLBACK(cxplorer_window_bookmark_add_action)},
 	/* Help menu */
 	{"HelpAction", NULL, N_("_Help"), NULL, NULL, NULL},
 	{"AboutAction", NULL, N_("_About"), NULL, NULL, G_CALLBACK(cxplorer_window_about_action)}
@@ -169,6 +175,7 @@
 	GtkWidget *dirview;
 	GtkWidget *right_pane;
 	GtkWidget *statusbar;
+	GHashTable *hash;
 	gboolean show_dot_file;
 	gchar *current_dir;
 	gchar *preview_dir;
@@ -177,6 +184,7 @@
 	gchar *filter;
 
 	private->profile = cxp_profile_new ("cxplorer", "main");
+	private->bookmark = cxp_profile_new ("cxplorer", "bookmark");
 	show_dot_file = cxp_profile_get_integer(private->profile, "ShowDotFile");
 	filter = cxp_profile_get_string (private->profile, "FilenameFilter");
 	if(filter != NULL)
@@ -209,6 +217,10 @@
 	gtk_box_pack_start (GTK_BOX (vbox), menubar, FALSE, FALSE, 0);
 	gtk_widget_show (menubar);
 
+	/* ToDo: ここでブックマークメニューを構築する。 */
+	hash = cxp_profile_get_hash_table (private->bookmark);
+	g_hash_table_foreach (hash, cxplorer_window_menu_item_new_from_bookmark, self);
+
 	toolbar = gtk_ui_manager_get_widget (private->ui_manager, "/toolbar");
 	gtk_box_pack_start (GTK_BOX (vbox), toolbar, FALSE, FALSE, 0);
 	gtk_widget_show (toolbar);
@@ -279,6 +291,27 @@
 			  self);
 }
 
+/**
+ * \if japanese
+ * ブックマーク毎にメニューを作成する。
+ * \endif
+ */
+static void cxplorer_window_menu_item_new_from_bookmark (gpointer key, gpointer value, gpointer user_data)
+{
+	CxplorerWindowPrivate *private = CXPLORER_WINDOW_GET_PRIVATE (user_data);
+	GtkWidget *menu;
+	GtkWidget *menuitem;
+
+	if((menuitem = gtk_ui_manager_get_widget (private->ui_manager, "/menubar/GoMenu")) != NULL)
+	{
+		menu = gtk_menu_item_get_submenu(GTK_MENU_ITEM(menuitem));
+		menuitem = gtk_menu_item_new_with_label (key);
+		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);
+	}
+}
+
 static void cxplorer_window_dispose (GObject * obj)
 {
 	CxplorerWindowPrivate *private = CXPLORER_WINDOW_GET_PRIVATE (obj);
@@ -298,6 +331,7 @@
 	 * reference.
 	 */
 	g_object_unref (private->profile);
+	g_object_unref (private->bookmark);
 	g_object_unref (private->action_group);
 	g_object_unref (private->ui_manager);
 	cxp_utils_free_filename_filter ();
@@ -677,6 +711,36 @@
 	cxp_dir_view_change_directory (CXP_DIR_VIEW(private->dirview), g_get_home_dir ());
 }
 
+static void cxplorer_window_bookmark_add_action (GtkWidget *widget, gpointer user_data)
+{
+	CxplorerWindowPrivate *private = CXPLORER_WINDOW_GET_PRIVATE (user_data);
+	GtkWidget *dialog;
+	gchar *cur_dir;
+	gchar *dir_utf8;
+	gchar *message;
+	gchar *alias;
+
+	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);
+	message = g_strdup_printf (_("Please input the title of the bookmark to directory '%s'."), dir_utf8);
+
+	dialog = cxp_entry_dialog_new (_("Add Bookmark"), message, dir_utf8);
+
+	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, cur_dir);
+		cxplorer_window_menu_item_new_from_bookmark (alias, cur_dir, user_data);
+		g_free (alias);
+	}
+
+	gtk_widget_destroy (dialog);
+
+	g_free (message);
+	g_free (dir_utf8);
+	g_free (cur_dir);
+}
+
 /**
  * This function show about dialog when user click "Help->About".
  * @param menuitem [in] Pointer to menu item "Help->About".
@@ -691,3 +755,22 @@
 	gtk_dialog_run (GTK_DIALOG (dialog));
 	gtk_widget_destroy (dialog);
 }
+
+/**
+ * \if japanese
+ * ユーザが追加したブックマークへの移動
+ * \endif
+ */
+static void cxplorer_window_user_bookmark_activate (GtkWidget *widget, gpointer user_data)
+{
+	CxplorerWindowPrivate *private = CXPLORER_WINDOW_GET_PRIVATE (user_data);
+	gchar *dirname;
+	GtkWidget *label;
+
+	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)));
+		cxp_dir_view_change_directory (CXP_DIR_VIEW(private->dirview), dirname);
+	}
+}


Cxplorer-cvs メーリングリストの案内
Back to archive index