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

Back to archive index

Yasumichi Akahoshi yasum****@users*****
2005年 5月 7日 (土) 23:10:19 JST


Index: cxplorer/src/cxp-dir-view.c
diff -u cxplorer/src/cxp-dir-view.c:1.15 cxplorer/src/cxp-dir-view.c:1.16
--- cxplorer/src/cxp-dir-view.c:1.15	Fri Apr 22 23:14:06 2005
+++ cxplorer/src/cxp-dir-view.c	Sat May  7 23:10:19 2005
@@ -2,6 +2,7 @@
 #  include <config.h>
 #endif
 
+#include <gconf/gconf-client.h>
 #include <glib/gi18n.h>
 #include <string.h>
 #include <cxp.h>
@@ -21,14 +22,19 @@
 
 typedef struct
 {
+	GConfClient *client;
 	GtkWidget *dirview;
 	GdkPixbuf *icon;
-	gboolean showDotFile;
 	gboolean dispose_has_run;
 } CxpDirViewPrivate;
 
 #define CXP_DIR_VIEW_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), CXP_TYPE_DIR_VIEW, CxpDirViewPrivate))
 
+enum
+{
+	CXP_DIR_VIEW_GCONF_CLIENT = 1,
+};
+
 /**
  * This enumeration define signal.
  */
@@ -45,6 +51,13 @@
 static void cxp_dir_view_class_init (CxpDirViewClass * klass);
 static void cxp_dir_view_dispose (GObject * obj);
 static void cxp_dir_view_finalize (GObject * object);
+static void cxp_dir_view_set_property (GObject * object,
+					 guint property_id,
+					 const GValue * value,
+					 GParamSpec * pspec);
+static void cxp_dir_view_get_property (GObject * object,
+					 guint property_id,
+					 GValue * value, GParamSpec * pspec);
 static GtkWidget *cxp_dir_view_tree_view_new (CxpDirView * self);
 static GtkTreeModel *cxp_dir_view_model_new (void);
 static gint cxp_dir_view_compare_node (GtkTreeModel * model,
@@ -52,10 +65,10 @@
 				       GtkTreeIter * iterB, gpointer data);
 static void cxp_dir_view_prepend_dummy (GtkTreeStore * store,
 					GtkTreeIter * parent_iter);
-static void cxp_dir_view_set_child_dirctory (GtkTreeStore * treestore,
-					     GtkTreeIter * parent,
-					     gchar * parentPath,
-					     gboolean showDotFile);
+static void cxp_dir_view_set_child_dirctory (CxpDirView *self, 
+		GtkTreeStore * treestore,
+		GtkTreeIter * parent,
+		gchar * parentPath);
 static void cxp_dir_view_on_row_expanded (GtkTreeView * treeview,
 					  GtkTreeIter * iter,
 					  GtkTreePath * path,
@@ -134,10 +147,22 @@
 static void cxp_dir_view_class_init (CxpDirViewClass * klass)
 {
 	GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+	GParamSpec *pspec;
 
 	/* メソッド dispose()/finalize() をオーバーライドします。 */
 	gobject_class->dispose = cxp_dir_view_dispose;
 	gobject_class->finalize = cxp_dir_view_finalize;
+	gobject_class->set_property = cxp_dir_view_set_property;
+	gobject_class->get_property = cxp_dir_view_get_property;
+
+	/* install properties. */
+	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_DIR_VIEW_GCONF_CLIENT, pspec);
 
 	cxp_dir_view_signals[DIRECTORY_CHANGED_SIGNAL] =
 		g_signal_new ("directory_changed",
@@ -186,6 +211,43 @@
 	G_OBJECT_CLASS (parent_class)->finalize (object);
 }
 
+static void cxp_dir_view_set_property (GObject * object,
+					 guint property_id,
+					 const GValue * value,
+					 GParamSpec * pspec)
+{
+	CxpDirViewPrivate *priv = CXP_DIR_VIEW_GET_PRIVATE (object);
+
+	switch (property_id)
+	{
+	case CXP_DIR_VIEW_GCONF_CLIENT:
+		priv->client = GCONF_CLIENT(g_value_dup_object (value));
+		break;
+	default:
+		/* We don't have any other property... */
+		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+		break;
+	}
+}
+
+static void cxp_dir_view_get_property (GObject * object,
+					 guint property_id,
+					 GValue * value, GParamSpec * pspec)
+{
+	CxpDirViewPrivate *priv = CXP_DIR_VIEW_GET_PRIVATE (object);
+
+	switch (property_id)
+	{
+	case CXP_DIR_VIEW_GCONF_CLIENT:
+		g_value_set_object (value, priv->client);
+		break;
+	default:
+		/* We don't have any other property... */
+		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+		break;
+	}
+}
+
 static GtkWidget *cxp_dir_view_tree_view_new (CxpDirView * self)
 {
 	GtkWidget *treeview;
@@ -313,16 +375,20 @@
 	}
 }
 
-static void cxp_dir_view_set_child_dirctory (GtkTreeStore * treestore,
+static void cxp_dir_view_set_child_dirctory (CxpDirView *self,
+					     GtkTreeStore * treestore,
 					     GtkTreeIter * parent,
-					     gchar * parentPath,
-					     gboolean showDotFile)
+					     gchar * parentPath)
 {
+	CxpDirViewPrivate *priv = CXP_DIR_VIEW_GET_PRIVATE (self);
 	const gchar *childName;
 	gchar *fullpath;
 	gchar *dispname;
 	GDir *gdir;
 	GtkTreeIter child;
+	gboolean showDotFile;
+
+	showDotFile = gconf_client_get_bool (priv->client, "/apps/cxp/cxplorer/ShowDotFile", NULL);
 
 	/* open directory */
 	gdir = g_dir_open (parentPath, 0, NULL);
@@ -401,8 +467,7 @@
 	{
 		gtk_tree_model_get (GTK_TREE_MODEL (store), iter,
 				    COL_FULL_PATH, &fullpath, COL_TERMINATOR);
-		cxp_dir_view_set_child_dirctory (store, iter, fullpath,
-						 priv->showDotFile);
+		cxp_dir_view_set_child_dirctory (CXP_DIR_VIEW(user_data), store, iter, fullpath);
 		gtk_tree_store_remove (store, &child);
 
 		g_free (fullpath);
@@ -456,15 +521,14 @@
  *
  */
 
-GtkWidget *cxp_dir_view_new (gboolean showDotFile, GdkPixbuf * icon)
+GtkWidget *cxp_dir_view_new (GConfClient *client, GdkPixbuf * icon)
 {
 	CxpDirView *object;
 	CxpDirViewPrivate *priv;
 
-	object = CXP_DIR_VIEW (g_object_new (CXP_TYPE_DIR_VIEW, NULL));
+	object = CXP_DIR_VIEW (g_object_new (CXP_TYPE_DIR_VIEW, "gconf-client", client, NULL));
 
 	priv = CXP_DIR_VIEW_GET_PRIVATE (object);
-	priv->showDotFile = showDotFile;
 	priv->icon = icon;
 
 	return GTK_WIDGET (object);
@@ -558,14 +622,6 @@
 	return TRUE;
 }
 
-void cxp_dir_view_set_show_dot_file (CxpDirView * instance,
-				     gboolean showDotFile)
-{
-	CxpDirViewPrivate *priv = CXP_DIR_VIEW_GET_PRIVATE (instance);
-
-	priv->showDotFile = showDotFile;
-}
-
 void cxp_dir_view_refresh (CxpDirView * instance)
 {
 	CxpDirViewPrivate *priv = CXP_DIR_VIEW_GET_PRIVATE (instance);
@@ -587,8 +643,7 @@
 	gtk_tree_store_prepend (GTK_TREE_STORE (model), &root, NULL);
 	gtk_tree_store_set (GTK_TREE_STORE (model), &root, COL_DISP_NAME, "/",
 			    COL_FULL_PATH, "/", COL_IS_DUMMY, FALSE, -1);
-	cxp_dir_view_set_child_dirctory (GTK_TREE_STORE (model), &root, "/",
-					 priv->showDotFile);
+	cxp_dir_view_set_child_dirctory (CXP_DIR_VIEW(instance), GTK_TREE_STORE (model), &root, "/");
 	cxp_dir_view_change_directory (instance, currentDirectory);
 	g_free (currentDirectory);
 }
Index: cxplorer/src/cxp-dir-view.h
diff -u cxplorer/src/cxp-dir-view.h:1.8 cxplorer/src/cxp-dir-view.h:1.9
--- cxplorer/src/cxp-dir-view.h:1.8	Fri Apr  8 01:53:09 2005
+++ cxplorer/src/cxp-dir-view.h	Sat May  7 23:10:19 2005
@@ -36,10 +36,9 @@
 /*
  * API
  */
-GtkWidget *cxp_dir_view_new (gboolean showDotFile, GdkPixbuf *icon);
+GtkWidget *cxp_dir_view_new (GConfClient *client, GdkPixbuf *icon);
 gchar *cxp_dir_view_get_current_directory (CxpDirView *instance);
 gboolean cxp_dir_view_change_directory (CxpDirView *instance, const gchar *fullpath);
-void cxp_dir_view_set_show_dot_file(CxpDirView *instance, gboolean showDotFile);
 void cxp_dir_view_refresh (CxpDirView *instance);
 
 #endif /* CXP_DIR_VIEW_H */
Index: cxplorer/src/cxplorer-window.c
diff -u cxplorer/src/cxplorer-window.c:1.42 cxplorer/src/cxplorer-window.c:1.43
--- cxplorer/src/cxplorer-window.c:1.42	Sat May  7 22:52:40 2005
+++ cxplorer/src/cxplorer-window.c	Sat May  7 23:10:19 2005
@@ -251,7 +251,7 @@
 	gtk_box_pack_start_defaults (GTK_BOX (vbox), hpaned);
 
 	pixbuf = create_pixbuf ("cxp_dir.png");
-	dirview = cxp_dir_view_new (show_dot_file, pixbuf);
+	dirview = cxp_dir_view_new (private->client, pixbuf);
 	gtk_paned_pack1 (GTK_PANED (hpaned), dirview, FALSE, FALSE);
 	gtk_widget_show (dirview);
 
@@ -706,7 +706,6 @@
 
 	show_dot_file = gtk_toggle_action_get_active(action);
 	gconf_client_set_bool (private->client, "/apps/cxp/cxplorer/ShowDotFile", show_dot_file, NULL);
-	cxp_dir_view_set_show_dot_file (CXP_DIR_VIEW(private->dirview), show_dot_file);
 	cxp_dir_view_refresh (CXP_DIR_VIEW(private->dirview));
 }
 


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