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

Zurück zum Archiv-Index

Yasumichi Akahoshi yasum****@users*****
2005年 4月 7日 (木) 23:11:44 JST


Index: cxplorer/src/cxp-dir-view.c
diff -u cxplorer/src/cxp-dir-view.c:1.7 cxplorer/src/cxp-dir-view.c:1.8
--- cxplorer/src/cxp-dir-view.c:1.7	Fri Apr  1 22:20:05 2005
+++ cxplorer/src/cxp-dir-view.c	Thu Apr  7 23:11:43 2005
@@ -20,7 +20,6 @@
 struct _CxpDirViewPrivate
 {
 	GtkWidget *dirview;
-	GtkWidget *scrolledWin;
 	GdkPixbuf *icon;
 	gboolean showDotFile;
 	gboolean dispose_has_run;
@@ -35,6 +34,7 @@
 	LAST_SIGNAL
 };
 
+static GObjectClass *parent_class = NULL;
 static guint cxp_dir_view_signals[LAST_SIGNAL] = { 0 };
 
 static void cxp_dir_view_init (GTypeInstance * instance, gpointer g_class);
@@ -114,15 +114,15 @@
 	gtk_scrolled_window_set_vadjustment (GTK_SCROLLED_WINDOW (self), NULL);
 	self->priv = g_new (CxpDirViewPrivate, 1);
 	self->priv->dirview = cxp_dir_view_tree_view_new (self);
+	gtk_container_add (GTK_CONTAINER (self), self->priv->dirview);
+	self->priv->icon = NULL;
+	self->priv->dispose_has_run = FALSE;
+
 	/* signal connect */
 	g_signal_connect (self->priv->dirview, "row_expanded",
 			  G_CALLBACK (cxp_dir_view_on_row_expanded), self);
 	g_signal_connect (self->priv->dirview, "cursor_changed",
 			  G_CALLBACK (cxp_dir_view_on_cursor_changed), self);
-
-	gtk_container_add (GTK_CONTAINER (self), self->priv->dirview);
-	self->priv->icon = NULL;
-	self->priv->dispose_has_run = FALSE;
 }
 
 /**
@@ -135,6 +135,10 @@
 {
 	GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
 
+	/* メソッド dispose()/finalize() をオーバーライドします。 */
+	gobject_class->dispose = cxp_dir_view_dispose;
+	gobject_class->finalize = cxp_dir_view_finalize;
+
 	cxp_dir_view_signals[DIRECTORY_CHANGED_SIGNAL] =
 		g_signal_new ("directory_changed",
 			      G_TYPE_FROM_CLASS (klass),
@@ -144,9 +148,7 @@
 			      NULL, g_cclosure_marshal_VOID__VOID,
 			      G_TYPE_NONE, 0);
 
-	/* メソッド dispose()/finalize() をオーバーライドします。 */
-	gobject_class->dispose = cxp_dir_view_dispose;
-	gobject_class->finalize = cxp_dir_view_finalize;
+	parent_class = g_type_class_peek_parent (klass);
 }
 
 /**
@@ -166,6 +168,9 @@
 	}
 	/* メソッド dispose() が二度実行されることがないようチェックします。 */
 	self->priv->dispose_has_run = TRUE;
+
+	/* Chain up to the parent class */
+	G_OBJECT_CLASS (parent_class)->dispose (obj);
 }
 
 /**
@@ -179,6 +184,9 @@
 	CxpDirView *self = (CxpDirView *) object;
 
 	g_free (self->priv);
+
+	/* Chain up to the parent class */
+	G_OBJECT_CLASS (parent_class)->finalize (object);
 }
 
 static GtkWidget *cxp_dir_view_tree_view_new (CxpDirView * self)
@@ -433,7 +441,14 @@
 static void cxp_dir_view_on_cursor_changed (GtkTreeView * treeview,
 					    gpointer user_data)
 {
-	g_signal_emit (G_OBJECT (user_data),
+	CxpDirView *self = CXP_DIR_VIEW (user_data);
+
+	if (self->priv->dispose_has_run)
+	{
+		return;
+	}
+
+	g_signal_emit (self,
 		       cxp_dir_view_signals[DIRECTORY_CHANGED_SIGNAL], 0);
 }
 
Index: cxplorer/src/cxp-right-pane.c
diff -u cxplorer/src/cxp-right-pane.c:1.21 cxplorer/src/cxp-right-pane.c:1.22
--- cxplorer/src/cxp-right-pane.c:1.21	Wed Apr  6 20:16:37 2005
+++ cxplorer/src/cxp-right-pane.c	Thu Apr  7 23:11:43 2005
@@ -191,6 +191,8 @@
 					       dir_double_clicked), NULL,
 			      NULL, g_cclosure_marshal_VOID__VOID,
 			      G_TYPE_NONE, 0);
+
+
 	parent_class = g_type_class_peek_parent (klass);
 }
 
@@ -219,20 +221,19 @@
 	gtk_text_view_set_editable (GTK_TEXT_VIEW (self->priv->preview), FALSE);
 	gtk_container_add (GTK_CONTAINER (scrolled_window),
 			   self->priv->preview);
-	gtk_paned_set_position (GTK_PANED (self), 250);
 	gtk_widget_show (self->priv->preview);
-
-	g_signal_connect (self->priv->file_list, "cursor_changed",
-			  G_CALLBACK (cxp_right_pane_on_cursor_changed), self);
-	g_signal_connect (self->priv->file_list, "row_activated",
-			  G_CALLBACK (cxp_right_pane_on_row_activated), self);
-
 	self->priv->show_dot_file = FALSE;
 	self->priv->dispose_has_run = FALSE;
 	self->priv->cur_dir = NULL;
 	self->priv->preview_text = NULL;
 	self->priv->preview_binary = NULL;
 	self->priv->handler = cxp_handler_new();
+
+	g_signal_connect (self->priv->file_list, "cursor_changed",
+			  G_CALLBACK (cxp_right_pane_on_cursor_changed), self);
+	g_signal_connect (self->priv->file_list, "row_activated",
+			  G_CALLBACK (cxp_right_pane_on_row_activated), self);
+
 }
 
 static void cxp_right_pane_dispose (GObject * obj)
@@ -457,6 +458,11 @@
 	GtkTreeModel *model;
 	GtkTreeIter iter;
 
+	if (right_pane->priv->dispose_has_run)
+	{
+		return;
+	}
+
 	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,
@@ -464,7 +470,7 @@
 
 	if (g_file_test (fullpath, G_FILE_TEST_IS_DIR))
 	{
-		g_signal_emit (G_OBJECT (right_pane),
+		g_signal_emit (right_pane,
 			       cxp_right_pane_signals
 			       [DIR_DOUBLE_CLICKED_SIGNAL], 0);
 	}
Index: cxplorer/src/cxplorer-window.c
diff -u /dev/null cxplorer/src/cxplorer-window.c:1.1
--- /dev/null	Thu Apr  7 23:11:43 2005
+++ cxplorer/src/cxplorer-window.c	Thu Apr  7 23:11:43 2005
@@ -0,0 +1,258 @@
+/***************************************************************************
+ *            cxplorer-entry-dialog.c
+ *
+ *  Sun Feb 13 23:50:30 2005
+ *  Copyright  2005  Yasumichi Akahoshi
+ *  yasum****@users*****
+ ****************************************************************************/
+
+/*
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+ 
+
+#include <cxp.h>
+#include <glib/gi18n.h>
+#include "cxp-dir-view.h"
+#include "cxp-right-pane.h"
+#include "cxplorer-window.h"
+
+/* 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
+ * definition for this private structure.
+ */
+
+struct _CxplorerWindowPrivate
+{
+	GtkWidget *entry;
+	GtkWidget *dirview;
+	GtkWidget *right_pane;
+	GtkWidget *statusbar;
+	CxpProfile *profile;
+	gboolean dispose_has_run;
+};
+
+static GObjectClass *parent_class = NULL;
+
+
+/*
+ * Prototypes of private methods.
+ */
+static void cxplorer_window_class_init (gpointer g_class,
+					    gpointer g_class_data);
+static void cxplorer_window_instance_init (GTypeInstance * instance,
+					       gpointer g_class);
+static void cxplorer_window_dispose (GObject * obj);
+static void cxplorer_window_finalize (GObject * obj);
+static void cxplorer_window_on_directory_changed (CxpDirView *dirview, gpointer user_data);
+static void cxplorer_window_on_dir_double_clicked (CxpRightPane *right_pane, gpointer user_data);
+
+
+static void cxplorer_window_class_init (gpointer g_class,
+					    gpointer g_class_data)
+{
+	GObjectClass *gobject_class = G_OBJECT_CLASS (g_class);
+	CxplorerWindowClass *klass = CXPLORER_WINDOW_CLASS (g_class);
+
+	gobject_class->dispose = cxplorer_window_dispose;
+	gobject_class->finalize = cxplorer_window_finalize;
+
+	parent_class = g_type_class_peek_parent (klass);
+
+}
+
+static void cxplorer_window_instance_init (GTypeInstance * instance,
+					       gpointer g_class)
+{
+	CxplorerWindow *self = CXPLORER_WINDOW (instance);
+	GtkWidget *vbox;
+	GtkWidget *hpaned;
+	GtkWidget *hbox;
+	GtkWidget *label;
+	GtkWidget *entry;
+	GtkWidget *dirview;
+	GtkWidget *right_pane;
+	GtkWidget *statusbar;
+	gchar *current_dir;
+
+	self->private = g_new (CxplorerWindowPrivate, 1);
+	self->private->profile = cxp_profile_new ("cxplorer", "main");
+
+	g_object_set (G_OBJECT(self), "type", GTK_WINDOW_TOPLEVEL, NULL);
+
+	vbox = gtk_vbox_new(FALSE, 0);
+	gtk_container_add (GTK_CONTAINER(self), vbox);
+
+	hbox = gtk_hbox_new (FALSE, 5);
+	gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, TRUE, 5);
+	label = gtk_label_new (_("Adress:"));
+	gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 5);
+	gtk_widget_show (label);
+	entry = gtk_entry_new ();
+	gtk_box_pack_start (GTK_BOX (hbox), entry, TRUE, TRUE, 0);
+	gtk_widget_show (entry);
+	gtk_widget_show (hbox);
+
+	hpaned = gtk_hpaned_new();
+	gtk_box_pack_start_defaults (GTK_BOX(vbox), hpaned);
+
+	dirview = cxp_dir_view_new(FALSE, NULL);
+	gtk_paned_pack1 (GTK_PANED(hpaned), dirview, FALSE, FALSE);
+	gtk_widget_show (dirview);
+
+	right_pane = cxp_right_pane_new();
+	g_object_set(right_pane, "preview_text", "head -n 20", "preview_binary", "od -t x1z -A x -N 112 --width=16", "preview_dir", "ls",NULL);
+	gtk_paned_pack2 (GTK_PANED(hpaned), right_pane, TRUE, FALSE);
+	gtk_widget_show (right_pane);
+	gtk_widget_show (hpaned);
+	statusbar = gtk_statusbar_new ();
+	gtk_box_pack_start (GTK_BOX(vbox), statusbar, FALSE, FALSE, 0);
+	gtk_widget_show (statusbar);
+	gtk_widget_show (vbox);
+
+	current_dir = g_get_current_dir();
+	gtk_entry_set_text (GTK_ENTRY (entry), current_dir);
+	cxp_dir_view_change_directory (CXP_DIR_VIEW(dirview), current_dir);
+	cxp_right_pane_change_directory (CXP_RIGHT_PANE(right_pane), current_dir);
+	g_free (current_dir);
+
+	self->private->entry = entry;
+	self->private->dirview = dirview;
+	self->private->right_pane = right_pane;
+	self->private->statusbar = statusbar;
+	self->private->dispose_has_run = FALSE;
+
+	g_signal_connect (dirview, "directory_changed",
+			  G_CALLBACK (cxplorer_window_on_directory_changed),
+			  self);
+	g_signal_connect (G_OBJECT (right_pane), "dir_double_clicked",
+			  G_CALLBACK (cxplorer_window_on_dir_double_clicked),
+			  (gpointer) self);
+
+}
+
+static void cxplorer_window_dispose (GObject * obj)
+{
+	CxplorerWindow *self = CXPLORER_WINDOW (obj);
+
+	if (self->private->dispose_has_run)
+	{
+		/* If dispose did already run, return. */
+		return;
+	}
+	/* Make sure dispose does not run twice. */
+	self->private->dispose_has_run = TRUE;
+
+	/* 
+	 * In dispose, you are supposed to free all types referenced from this
+	 * object which might themselves hold a reference to self. Generally,
+	 * the most simple solution is to unref all members on which you own a 
+	 * reference.
+	 */
+	g_object_unref (self->private->profile);
+
+	/* Chain up to the parent class */
+	G_OBJECT_CLASS (parent_class)->dispose (obj);
+}
+
+static void cxplorer_window_finalize (GObject * obj)
+{
+	CxplorerWindow *self = CXPLORER_WINDOW (obj);
+
+	/*
+	 * Here, complete object destruction.
+	 * You might not need to do much...
+	 */
+
+	g_free (self->private);
+
+	/* Chain up to the parent class */
+	G_OBJECT_CLASS (parent_class)->finalize (obj);
+}
+
+GType cxplorer_window_get_type (void)
+{
+	static GType type = 0;
+
+	if (type == 0)
+	{
+		static const GTypeInfo info = {
+			sizeof (CxplorerWindowClass),
+			NULL,	/* base_init */
+			NULL,	/* base_finalize */
+			cxplorer_window_class_init,	/* class_init */
+			NULL,	/* class_finalize */
+			NULL,	/* class_data */
+			sizeof (CxplorerWindow),
+			0,	/* n_preallocs */
+			cxplorer_window_instance_init	/* instance_init */
+		};
+		type = g_type_register_static (GTK_TYPE_WINDOW,
+					       "CxplorerWindowType",
+					       &info, 0);
+	}
+	return type;
+}
+
+GtkWidget *cxplorer_window_new(void)
+{
+	GtkWidget *window;
+
+	window = GTK_WIDGET(g_object_new(CXPLORER_TYPE_WINDOW, NULL));
+
+	return	window;
+}
+
+/**
+ * This function is called back when cursor is changed on directory view.
+ * It have file list view shown file list.
+ * @param treeview [in] Pointer to directory view.
+ * @param user_data [in] Pointer to instance of Cxplorer is casted.
+ */
+static void cxplorer_window_on_directory_changed (CxpDirView *dirview, gpointer user_data)
+{
+	CxplorerWindow *window = CXPLORER_WINDOW(user_data);
+	gchar *fullpath;
+	
+	if (window->private->dispose_has_run)
+	{
+		return;
+	}
+
+	fullpath = cxp_dir_view_get_current_directory (dirview);
+	gtk_entry_set_text (GTK_ENTRY (window->private->entry), fullpath);
+	cxp_right_pane_change_directory (CXP_RIGHT_PANE (window->private->right_pane),
+					 fullpath);
+	g_free (fullpath);
+}
+
+static void cxplorer_window_on_dir_double_clicked (CxpRightPane *right_pane, gpointer user_data)
+{
+	CxplorerWindow *window = CXPLORER_WINDOW(user_data);
+	gchar *dir_name;
+
+	if (window->private->dispose_has_run)
+	{
+		return;
+	}
+
+	dir_name =
+		cxp_right_pane_get_active_file_name (right_pane);
+	cxp_dir_view_change_directory (CXP_DIR_VIEW(window->private->dirview), dir_name);
+	gtk_entry_set_text (GTK_ENTRY (window->private->entry), dir_name);
+	g_free (dir_name);
+}
+
Index: cxplorer/src/cxplorer-window.h
diff -u /dev/null cxplorer/src/cxplorer-window.h:1.1
--- /dev/null	Thu Apr  7 23:11:43 2005
+++ cxplorer/src/cxplorer-window.h	Thu Apr  7 23:11:43 2005
@@ -0,0 +1,64 @@
+/***************************************************************************
+ *            cxplorer-entry-dialog.h
+ *
+ *  Sun Feb 13 23:49:57 2005
+ *  Copyright  2005  Yasumichi Akahoshi
+ *  yasum****@users*****
+ ****************************************************************************/
+
+/*
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+ 
+
+#ifndef CXPLORER_WINDOW_H
+#define CXPLORER_WINDOW_H
+
+/*
+ * Potentially, include other headers on which this header depends.
+ */
+#include <gtk/gtk.h>
+#include <glib-object.h>
+
+#define CXPLORER_TYPE_WINDOW		  (cxplorer_window_get_type ())
+#define CXPLORER_WINDOW(obj)		  (G_TYPE_CHECK_INSTANCE_CAST ((obj), CXPLORER_TYPE_WINDOW, CxplorerWindow))
+#define CXPLORER_WINDOW_CLASS(klass)	  (G_TYPE_CHECK_CLASS_CAST ((klass), CXPLORER_TYPE_WINDOW, CxplorerWindowClass))
+#define CXPLORER_IS_WINDOW(obj)	  (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CXPLORER_TYPE_WINDOW))
+#define CXPLORER_IS_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CXPLORER_TYPE_WINDOW))
+#define CXPLORER_WINDOW_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), CXPLORER_TYPE_WINDOW, CxplorerWindowClass))
+
+typedef struct _CxplorerWindow CxplorerWindow;
+typedef struct _CxplorerWindowClass CxplorerWindowClass;
+typedef struct _CxplorerWindowPrivate CxplorerWindowPrivate;
+
+struct _CxplorerWindow {
+	GtkWindow parent;
+	/* instance members */
+        CxplorerWindowPrivate *private;
+};
+
+struct _CxplorerWindowClass {
+	GtkWindowClass parent;
+
+	/* class members */
+};
+
+/* used by CXPLORER_TYPE_WINDOW */
+GType cxplorer_window_get_type (void);
+
+/* API. */
+
+#endif /* CXPLORER_WINDOW_H */
+GtkWidget *cxplorer_window_new(void);
Index: cxplorer/src/main.c
diff -u cxplorer/src/main.c:1.5 cxplorer/src/main.c:1.6
--- cxplorer/src/main.c:1.5	Mon Feb 14 00:35:09 2005
+++ cxplorer/src/main.c	Thu Apr  7 23:11:43 2005
@@ -5,7 +5,7 @@
  * This file contains main function which init cxplorer and run main loop.
  * @author Yasumichi Akahoshi <yasum****@users*****>
  * @date 2004
- * $Revision: 1.5 $
+ * $Revision: 1.6 $
  */
 
 /**
@@ -32,10 +32,8 @@
 #endif
 
 #include <gtk/gtk.h>
-
-#include "cxplorer.h"
-#include "interface.h"
-#include "cxp-right-pane.h"
+#include <glib/gi18n.h>
+#include "cxplorer-window.h"
 
 /**
  * main init cxplorer and run main loop.
@@ -46,7 +44,7 @@
  */
 int main (int argc, char *argv[])
 {
-	Cxplorer *cxplorer;
+	GtkWidget *window;
 
 #ifdef ENABLE_NLS
 	bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR);
@@ -57,19 +55,22 @@
 	gtk_set_locale ();
 	gtk_init (&argc, &argv);
 
+	/*
 	add_pixmap_directory (PACKAGE_SOURCE_DIR"/pixmaps");
 	add_pixmap_directory (PACKAGE_PIXMAPS_DIR "/");
+	*/
+	add_pixmap_directory ("/home/yasu/SFJP/cxplorer/cxplorer/pixmaps");
 
 	/*
 	 * The following code was added by Glade to create one of each component
 	 * (except popup menus), just so that you see something after building
 	 * the project. Delete any components that you don't want shown initially.
 	 */
-	cxplorer = cxplorer_window_new ();
-
-	cxp_right_pane_change_directory(CXP_RIGHT_PANE(cxplorer->right_pane), cxplorer->gsCurrentPath->str);
-	
-	gtk_widget_show_all (cxplorer->gwWindow);
+	window = cxplorer_window_new ();
+	g_signal_connect (window, "delete_event", gtk_main_quit, NULL);
+	gtk_window_set_title (GTK_WINDOW (window), _("Cxplorer"));
+	gtk_window_set_default_size (GTK_WINDOW (window), 500, 500);
+	gtk_widget_show (window);
 
 	gtk_main ();
 	


Cxplorer-cvs メーリングリストの案内
Zurück zum Archiv-Index