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

Back to archive index

Yasumichi Akahoshi yasum****@users*****
2005年 5月 8日 (日) 01:03:23 JST


Index: cxplorer/src/cxp-pref-dialog.c
diff -u cxplorer/src/cxp-pref-dialog.c:1.1 cxplorer/src/cxp-pref-dialog.c:1.2
--- cxplorer/src/cxp-pref-dialog.c:1.1	Sat May  7 03:21:54 2005
+++ cxplorer/src/cxp-pref-dialog.c	Sun May  8 01:03:23 2005
@@ -5,13 +5,14 @@
  * A widget of Property dialog
  * @author Yasumichi Akahoshi <yasum****@users*****>
  * @date Sun Apr 3 02:53:00 2005
- * $Revision: 1.1 $
+ * $Revision: 1.2 $
  ****************************************************************************/
 
 #ifdef HAVE_CONFIG_H
 #  include <config.h>
 #endif
 
+#include <gconf/gconf-client.h>
 #include <cxp.h>
 #include <glib/gi18n.h>
 #include <magic.h>
@@ -28,7 +29,14 @@
 	ENTRY_PREVIEW_BINARY,
 	ENTRY_PREVIEW_DIRECTORY,
 	ENTRY_ATTACH_MAIL,
-	ENTRY_COUNT
+	ENTRY_COUNT,
+};
+
+gchar *config_key[] = {
+	"/apps/cxp/cxplorer/PreviewText",
+	"/apps/cxp/cxplorer/PreviewBinary",
+	"/apps/cxp/cxplorer/PreviewDir",
+	"/apps/cxp/cxplorer/AttachCommand",
 };
 
 /**
@@ -36,6 +44,7 @@
  */
 typedef struct
 {
+	GConfClient *client;
 	GtkWidget *entry[ENTRY_COUNT];
 	gboolean dispose_has_run;
 } CxpPrefDialogPrivate;
@@ -46,13 +55,14 @@
 
 enum
 {
-	CXP_PREF_DIALOG_FILENAME = 1,
+	CXP_PREF_DIALOG_GCONF_CLIENT = 1,
 };
 
 static void cxp_pref_dialog_class_init (CxpPrefDialogClass *klass);
 static void cxp_pref_dialog_instance_init (GTypeInstance * instance,
 					       gpointer g_class);
-/*
+static GObject * cxp_pref_dialog_constructor (GType type, guint n_construct_properties, GObjectConstructParam *construct_properties);
+static void cxp_pref_dialog_construct_child (CxpPrefDialog *self);
 static void cxp_pref_dialog_set_property (GObject * object,
 					      guint property_id,
 					      const GValue * value,
@@ -60,34 +70,31 @@
 static void cxp_pref_dialog_get_property (GObject * object,
 					      guint property_id, GValue * value,
 					      GParamSpec * pspec);
-					      */
 static void cxp_pref_dialog_dispose (GObject * obj);
 static void cxp_pref_dialog_finalize (GObject * obj);
+static void cxp_pref_dialog_ok_button_clicked (GtkWidget *button, CxpPrefDialog *dialog);
 
 static void cxp_pref_dialog_class_init (CxpPrefDialogClass *klass)
 {
 	GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
 	GParamSpec *pspec;
 
-	/*
+	gobject_class->constructor = cxp_pref_dialog_constructor;
 	gobject_class->set_property = cxp_pref_dialog_set_property;
 	gobject_class->get_property = cxp_pref_dialog_get_property;
-	*/
 	gobject_class->dispose = cxp_pref_dialog_dispose;
 	gobject_class->finalize = cxp_pref_dialog_finalize;
 
 	parent_class = g_type_class_peek_parent (klass);
 
-	/*
-	pspec = g_param_spec_string ("filename",
+	pspec = g_param_spec_object ("gconf-client",
 			"CxpPrefDialog construct prop",
-			"Set filename",
-			NULL,	
-			G_PARAM_READWRITE);
+			"Set gconf-client",
+			GCONF_TYPE_CLIENT,	
+			G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE);
 	g_object_class_install_property (gobject_class,
-			CXP_PREF_DIALOG_FILENAME,
+			CXP_PREF_DIALOG_GCONF_CLIENT,
 			pspec);
-			*/
 
 	g_type_class_add_private (klass, sizeof (CxpPrefDialogPrivate));
 }
@@ -95,9 +102,32 @@
 static void cxp_pref_dialog_instance_init (GTypeInstance * instance,
 					       gpointer g_class)
 {
-	CxpPrefDialog *self = CXP_PREF_DIALOG (instance);
+	CxpPrefDialogPrivate *private = CXP_PREF_DIALOG_GET_PRIVATE(instance);
+
+	private->dispose_has_run = FALSE;
+}
+
+static GObject * cxp_pref_dialog_constructor (GType type, guint n_construct_properties, GObjectConstructParam *construct_properties)
+{
+	GObject *obj;
+	CxpPrefDialogClass *klass;
+
+	klass = CXP_PREF_DIALOG_CLASS (g_type_class_peek (CXP_TYPE_PREF_DIALOG));
+	obj = parent_class->constructor (type,
+			n_construct_properties,
+			construct_properties);
+
+	cxp_pref_dialog_construct_child (CXP_PREF_DIALOG(obj));
+
+	return obj;
+}
+
+static void cxp_pref_dialog_construct_child (CxpPrefDialog *self)
+{
 	CxpPrefDialogPrivate *private = CXP_PREF_DIALOG_GET_PRIVATE(self);
-	GtkWidget *close_button;
+	GtkWidget *apply_button;
+	GtkWidget *cancel_button;
+	GtkWidget *ok_button;
 	GtkWidget *notebook;
 	GtkWidget *table;
 	GtkWidget *label;
@@ -110,8 +140,6 @@
 	};
 	gint index;
 
-	private->dispose_has_run = FALSE;
-
 	gtk_window_set_destroy_with_parent(GTK_WINDOW(self), TRUE);
 	gtk_window_set_title(GTK_WINDOW(self), _("Preferences"));
 
@@ -125,6 +153,8 @@
 		label = gtk_label_new (_(entry_title[index]));
 		gtk_table_attach_defaults (GTK_TABLE(table), label, 0, 1, index, index+1);
 		private->entry[index] = gtk_entry_new ();
+		gtk_entry_set_text (GTK_ENTRY(private->entry[index]), gconf_client_get_string (private->client, config_key[index], NULL));
+		gtk_entry_set_width_chars (GTK_ENTRY(private->entry[index]), 40);
 		gtk_table_attach_defaults (GTK_TABLE(table), private->entry[index], 1, 2, index, index+1);
 	}
 	gtk_widget_show_all (table);
@@ -138,18 +168,30 @@
 	label = gtk_label_new (_("Attach"));
 	gtk_box_pack_start (GTK_BOX(hbox), label, FALSE, FALSE, 2);
 	private->entry[ENTRY_ATTACH_MAIL] = gtk_entry_new ();
+	gtk_entry_set_text (GTK_ENTRY(private->entry[ENTRY_ATTACH_MAIL]), gconf_client_get_string (private->client, config_key[ENTRY_ATTACH_MAIL], NULL));
+	gtk_entry_set_width_chars (GTK_ENTRY(private->entry[ENTRY_ATTACH_MAIL]), 40);
 	gtk_box_pack_start (GTK_BOX(hbox), private->entry[ENTRY_ATTACH_MAIL], FALSE, TRUE, 2);
 	gtk_widget_show_all (vbox);
 
 	label = gtk_label_new (_("Send To"));
 	gtk_notebook_append_page (GTK_NOTEBOOK(notebook), vbox, label);
 
-	close_button = gtk_button_new_from_stock("gtk-close");
-	gtk_dialog_add_action_widget (GTK_DIALOG (self), close_button, GTK_RESPONSE_CLOSE);
-	gtk_widget_show (close_button);
+	/*
+	apply_button = gtk_button_new_from_stock("gtk-apply");
+	gtk_dialog_add_action_widget (GTK_DIALOG (self), apply_button, GTK_RESPONSE_NONE);
+	gtk_widget_show (apply_button);
+	*/
+
+	cancel_button = gtk_button_new_from_stock("gtk-cancel");
+	gtk_dialog_add_action_widget (GTK_DIALOG (self), cancel_button, GTK_RESPONSE_CANCEL);
+	gtk_widget_show (cancel_button);
+
+	ok_button = gtk_button_new_from_stock("gtk-ok");
+	gtk_dialog_add_action_widget (GTK_DIALOG (self), ok_button, GTK_RESPONSE_OK);
+	gtk_widget_show (ok_button);
+	g_signal_connect (ok_button, "clicked", G_CALLBACK(cxp_pref_dialog_ok_button_clicked), self);
 }
 
-/*
 static void cxp_pref_dialog_set_property (GObject * object,
 					      guint property_id,
 					      const GValue * value,
@@ -160,21 +202,19 @@
 
 	switch (property_id)
 	{
-	case CXP_PREF_DIALOG_FILENAME:
-		if (private->filename != NULL)
+	case CXP_PREF_DIALOG_GCONF_CLIENT:
+		if (private->client != NULL)
 		{
-			g_free (private->filename);
+			g_object_unref (private->client);
 		}
-		private->filename = g_value_dup_string (value);
+		private->client = GCONF_CLIENT(g_value_dup_object (value));
 		break;
 	default:
-		G_OBJECT_WARN_INVALID_PREF_ID (object, property_id, pspec);
+		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
 		break;
 	}
 }
-*/
 
-/*
 static void cxp_pref_dialog_get_property (GObject * object,
 					      guint property_id, GValue * value,
 					      GParamSpec * pspec)
@@ -183,15 +223,14 @@
 
 	switch (property_id)
 	{
-	case CXP_PREF_DIALOG_FILENAME:
-		g_value_set_string (value, private->filename);
+	case CXP_PREF_DIALOG_GCONF_CLIENT:
+		g_value_set_object (value, private->client);
 		break;
 	default:
-		G_OBJECT_WARN_INVALID_PREF_ID (object, property_id, pspec);
+		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
 		break;
 	}
 }
-*/
 
 static void cxp_pref_dialog_dispose (GObject * obj)
 {
@@ -211,6 +250,7 @@
 	 * the most simple solution is to unref all members on which you own a 
 	 * reference.
 	 */
+	g_object_unref (private->client);
 
 	/* Chain up to the parent class */
 	G_OBJECT_CLASS (parent_class)->dispose (obj);
@@ -222,6 +262,17 @@
 	G_OBJECT_CLASS (parent_class)->finalize (obj);
 }
 
+static void cxp_pref_dialog_ok_button_clicked (GtkWidget *button, CxpPrefDialog *dialog)
+{
+	CxpPrefDialogPrivate *private = CXP_PREF_DIALOG_GET_PRIVATE(dialog);
+	gint index;
+
+	for (index=0; index<ENTRY_COUNT; index++)
+	{
+		gconf_client_set_string (private->client, config_key[index], g_strdup(gtk_entry_get_text(GTK_ENTRY(private->entry[index]))), NULL);
+	}
+}
+
 GType cxp_pref_dialog_get_type (void)
 {
 	static GType type = 0;
@@ -249,11 +300,11 @@
 /**
  * Creates a new dialog box which show detail of file.
  */
-GtkWidget *cxp_pref_dialog_new(void)
+GtkWidget *cxp_pref_dialog_new(GConfClient *client)
 {
 	CxpPrefDialog *dialog;
 
-	dialog = g_object_new(CXP_TYPE_PREF_DIALOG, NULL);
+	dialog = g_object_new(CXP_TYPE_PREF_DIALOG, "gconf-client", client, NULL);
 
 	return	GTK_WIDGET(dialog);
 }
Index: cxplorer/src/cxp-pref-dialog.h
diff -u cxplorer/src/cxp-pref-dialog.h:1.1 cxplorer/src/cxp-pref-dialog.h:1.2
--- cxplorer/src/cxp-pref-dialog.h:1.1	Sat May  7 03:21:54 2005
+++ cxplorer/src/cxp-pref-dialog.h	Sun May  8 01:03:23 2005
@@ -34,6 +34,6 @@
 GType cxp_pref_dialog_get_type (void);
 
 /* API. */
-GtkWidget *cxp_pref_dialog_new(void);
+GtkWidget *cxp_pref_dialog_new(GConfClient *client);
 
 #endif /* CXP_PREF_DIALOG_H */
Index: cxplorer/src/cxplorer-window.c
diff -u cxplorer/src/cxplorer-window.c:1.43 cxplorer/src/cxplorer-window.c:1.44
--- cxplorer/src/cxplorer-window.c:1.43	Sat May  7 23:10:19 2005
+++ cxplorer/src/cxplorer-window.c	Sun May  8 01:03:23 2005
@@ -606,7 +606,6 @@
 	if ((fullpath = cxp_right_pane_get_active_file_name (CXP_RIGHT_PANE(private->right_pane))) != NULL)
 	{
 		cmd = g_strdup_printf(cmd_format, fullpath);
-		g_print("%s\n", cmd);
 		if(g_spawn_command_line_async (cmd, &gerror) == FALSE)
 		{
 			dialog = gtk_message_dialog_new (NULL,
@@ -689,7 +688,7 @@
 	CxplorerWindowPrivate *private = CXPLORER_WINDOW_GET_PRIVATE (user_data);
 	GtkWidget *dialog;
 
-	dialog = cxp_pref_dialog_new ();
+	dialog = cxp_pref_dialog_new (private->client);
 	gtk_dialog_run (GTK_DIALOG(dialog));
 	gtk_widget_destroy (dialog);
 }


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