Yasumichi Akahoshi
yasum****@users*****
2005年 5月 7日 (土) 21:50:40 JST
Index: cxplorer/src/cxp-right-pane.c diff -u cxplorer/src/cxp-right-pane.c:1.35 cxplorer/src/cxp-right-pane.c:1.36 --- cxplorer/src/cxp-right-pane.c:1.35 Wed Apr 27 22:17:12 2005 +++ cxplorer/src/cxp-right-pane.c Sat May 7 21:50:40 2005 @@ -5,6 +5,7 @@ #endif #include <glib/gi18n.h> +#include <gconf/gconf-client.h> #include <errno.h> #include <fcntl.h> #include <magic.h> @@ -24,15 +25,13 @@ typedef struct { + GConfClient *client; GtkWidget *file_list; GtkWidget *preview; GtkWidget *popup_menu; gboolean show_dot_file; gboolean dispose_has_run; gchar *cur_dir; - gchar *preview_dir; - gchar *preview_text; - gchar *preview_binary; GdkPixbuf *cxp_dir; GdkPixbuf *cxp_unknown; magic_t normal_cookie; @@ -48,9 +47,7 @@ */ enum { - CXP_RIGHT_PANE_PREVIEW_DIR = 1, - CXP_RIGHT_PANE_PREVIEW_TEXT, - CXP_RIGHT_PANE_PREVIEW_BINARY, + CXP_RIGHT_PANE_GCONF_CLIENT = 1, }; /* @@ -159,29 +156,13 @@ g_type_class_add_private (klass, sizeof (CxpRightPanePrivate)); /* install properties. */ - pspec = g_param_spec_string ("preview-dir", - "Command to preview directory", - "Set command line to preview directory", - NULL, - G_PARAM_CONSTRUCT | G_PARAM_READWRITE); + pspec = g_param_spec_object ("gconf_client", + "GConfClient", + "Set GConfClient", + GCONF_TYPE_CLIENT, + G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE); g_object_class_install_property (gobject_class, - CXP_RIGHT_PANE_PREVIEW_DIR, pspec); - - pspec = g_param_spec_string ("preview-text", - "Command to preview text file", - "Set command line to preview text file", - NULL, - G_PARAM_CONSTRUCT | G_PARAM_READWRITE); - g_object_class_install_property (gobject_class, - CXP_RIGHT_PANE_PREVIEW_TEXT, pspec); - - pspec = g_param_spec_string ("preview-binary", - "Command to preview binary file", - "Set command line to preview binary file", - NULL, - G_PARAM_CONSTRUCT | G_PARAM_READWRITE); - g_object_class_install_property (gobject_class, - CXP_RIGHT_PANE_PREVIEW_BINARY, pspec); + CXP_RIGHT_PANE_GCONF_CLIENT, pspec); cxp_right_pane_signals[DIR_DOUBLE_CLICKED_SIGNAL] = g_signal_new ("dir_double_clicked", @@ -202,6 +183,8 @@ GtkWidget *scrolled_window; PangoFontDescription *font_desc; + priv->client = NULL; + priv->normal_cookie = magic_open (MAGIC_NONE); magic_load (priv->normal_cookie, NULL); priv->mime_cookie = magic_open (MAGIC_MIME); @@ -234,8 +217,6 @@ priv->show_dot_file = FALSE; priv->dispose_has_run = FALSE; priv->cur_dir = NULL; - priv->preview_text = NULL; - priv->preview_binary = NULL; priv->handler = cxp_handler_new (); g_signal_connect (priv->file_list, "cursor_changed", @@ -287,17 +268,8 @@ switch (property_id) { - case CXP_RIGHT_PANE_PREVIEW_DIR: - g_free (priv->preview_dir); - priv->preview_dir = g_value_dup_string (value); - break; - case CXP_RIGHT_PANE_PREVIEW_TEXT: - g_free (priv->preview_text); - priv->preview_text = g_value_dup_string (value); - break; - case CXP_RIGHT_PANE_PREVIEW_BINARY: - g_free (priv->preview_binary); - priv->preview_binary = g_value_dup_string (value); + case CXP_RIGHT_PANE_GCONF_CLIENT: + priv->client = GCONF_CLIENT(g_value_dup_object (value)); break; default: /* We don't have any other property... */ @@ -314,14 +286,8 @@ switch (property_id) { - case CXP_RIGHT_PANE_PREVIEW_DIR: - g_value_set_string (value, priv->preview_dir); - break; - case CXP_RIGHT_PANE_PREVIEW_TEXT: - g_value_set_string (value, priv->preview_text); - break; - case CXP_RIGHT_PANE_PREVIEW_BINARY: - g_value_set_string (value, priv->preview_binary); + case CXP_RIGHT_PANE_GCONF_CLIENT: + g_value_set_object (value, priv->client); break; default: /* We don't have any other property... */ @@ -467,6 +433,7 @@ return; } + g_object_unref (priv->client); model = gtk_tree_view_get_model (treeview); gtk_tree_model_get_iter (model, &iter, path); gtk_tree_model_get (model, &iter, COL_FILE_PATH, &fullpath, @@ -666,15 +633,14 @@ if (g_file_test (filename, G_FILE_TEST_IS_DIR)) { - cmd = g_strdup_printf ("%s '%s'", priv->preview_dir, filename); + cmd = g_strdup_printf ("%s '%s'", gconf_client_get_string (priv->client,"/apps/cxp/cxplorer/PreviewDir", NULL), filename); } else { filetype = magic_file (priv->normal_cookie, filename); if (g_strrstr (filetype, "text") != NULL) { - cmd = g_strdup_printf ("%s '%s'", - priv->preview_text, filename); + cmd = g_strdup_printf ("%s '%s'", gconf_client_get_string (priv->client,"/apps/cxp/cxplorer/PreviewText", NULL), filename); } else if (strstr (filetype, "fifo") != NULL) { @@ -686,8 +652,7 @@ } else { - cmd = g_strdup_printf ("%s '%s'", - priv->preview_binary, filename); + cmd = g_strdup_printf ("%s '%s'", gconf_client_get_string (priv->client,"/apps/cxp/cxplorer/PreviewBinary", NULL), filename); } } g_spawn_command_line_sync (cmd, &standard_output, NULL, @@ -739,9 +704,9 @@ * API */ -GtkWidget *cxp_right_pane_new (void) +GtkWidget *cxp_right_pane_new (GConfClient *client) { - return GTK_WIDGET (g_object_new (CXP_TYPE_RIGHT_PANE, NULL)); + return GTK_WIDGET (g_object_new (CXP_TYPE_RIGHT_PANE, "gconf-client", client, NULL)); } /** Index: cxplorer/src/cxp-right-pane.h diff -u cxplorer/src/cxp-right-pane.h:1.12 cxplorer/src/cxp-right-pane.h:1.13 --- cxplorer/src/cxp-right-pane.h:1.12 Wed Apr 27 22:17:12 2005 +++ cxplorer/src/cxp-right-pane.h Sat May 7 21:50:40 2005 @@ -48,7 +48,7 @@ GType cxp_right_pane_get_type (void); /* API. */ -GtkWidget *cxp_right_pane_new (void); +GtkWidget *cxp_right_pane_new (GConfClient *client); void cxp_right_pane_change_directory (CxpRightPane *self, const gchar *dirname); gchar *cxp_right_pane_get_active_file_name (CxpRightPane *right_pane); void cxp_right_pane_set_show_dot_file (CxpRightPane *right_pane, gboolean show_dot_file); Index: cxplorer/src/cxplorer-window.c diff -u cxplorer/src/cxplorer-window.c:1.39 cxplorer/src/cxplorer-window.c:1.40 --- cxplorer/src/cxplorer-window.c:1.39 Sat May 7 20:34:29 2005 +++ cxplorer/src/cxplorer-window.c Sat May 7 21:50:40 2005 @@ -186,9 +186,6 @@ gboolean show_dot_file; gchar *current_dir; gchar *current_dir_utf8; - gchar *preview_dir; - gchar *preview_text; - gchar *preview_binary; gchar *filter; private->client = gconf_client_get_default (); @@ -260,20 +257,11 @@ gtk_paned_pack1 (GTK_PANED (hpaned), dirview, FALSE, FALSE); gtk_widget_show (dirview); - preview_text = gconf_client_get_string (private->client, "/apps/cxp/cxplorer/PreviewText", NULL); - preview_binary = gconf_client_get_string (private->client, "/apps/cxp/cxplorer/PreviewBinary", NULL); - preview_dir = gconf_client_get_string (private->client, "/apps/cxp/cxplorer/PreviewDir", NULL); - right_pane = cxp_right_pane_new (); + right_pane = cxp_right_pane_new (private->client); cxp_right_pane_set_show_dot_file (CXP_RIGHT_PANE(right_pane), show_dot_file); - g_object_set (right_pane, "preview_text", preview_text, - "preview_binary", preview_binary, - "preview_dir", preview_dir, NULL); gtk_paned_pack2 (GTK_PANED (hpaned), right_pane, TRUE, FALSE); gtk_widget_show (right_pane); gtk_widget_show (hpaned); - g_free (preview_text); - g_free (preview_binary); - g_free (preview_dir); cxp_right_pane_set_popup_menu (CXP_RIGHT_PANE (right_pane), gtk_ui_manager_get_widget (private->ui_manager, "/popup"));