Yasumichi Akahoshi
yasum****@users*****
2005年 4月 8日 (金) 01:35:51 JST
Index: cxplorer/src/cxplorer-window.c diff -u cxplorer/src/cxplorer-window.c:1.1 cxplorer/src/cxplorer-window.c:1.2 --- cxplorer/src/cxplorer-window.c:1.1 Thu Apr 7 23:11:43 2005 +++ cxplorer/src/cxplorer-window.c Fri Apr 8 01:35:51 2005 @@ -45,6 +45,8 @@ gboolean dispose_has_run; }; +#define CXPLORER_WINDOW_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), CXPLORER_TYPE_WINDOW, CxplorerWindowPrivate)) + static GObjectClass *parent_class = NULL; @@ -70,14 +72,16 @@ gobject_class->dispose = cxplorer_window_dispose; gobject_class->finalize = cxplorer_window_finalize; - parent_class = g_type_class_peek_parent (klass); + g_type_class_add_private (klass, sizeof (CxplorerWindowPrivate)); + parent_class = g_type_class_peek_parent (klass); } static void cxplorer_window_instance_init (GTypeInstance * instance, gpointer g_class) { CxplorerWindow *self = CXPLORER_WINDOW (instance); + CxplorerWindowPrivate *private = CXPLORER_WINDOW_GET_PRIVATE(instance); GtkWidget *vbox; GtkWidget *hpaned; GtkWidget *hbox; @@ -88,8 +92,7 @@ GtkWidget *statusbar; gchar *current_dir; - self->private = g_new (CxplorerWindowPrivate, 1); - self->private->profile = cxp_profile_new ("cxplorer", "main"); + private->profile = cxp_profile_new ("cxplorer", "main"); g_object_set (G_OBJECT(self), "type", GTK_WINDOW_TOPLEVEL, NULL); @@ -129,11 +132,11 @@ 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; + private->entry = entry; + private->dirview = dirview; + private->right_pane = right_pane; + private->statusbar = statusbar; + private->dispose_has_run = FALSE; g_signal_connect (dirview, "directory_changed", G_CALLBACK (cxplorer_window_on_directory_changed), @@ -146,15 +149,15 @@ static void cxplorer_window_dispose (GObject * obj) { - CxplorerWindow *self = CXPLORER_WINDOW (obj); + CxplorerWindowPrivate *private = CXPLORER_WINDOW_GET_PRIVATE(obj); - if (self->private->dispose_has_run) + if (private->dispose_has_run) { /* If dispose did already run, return. */ return; } /* Make sure dispose does not run twice. */ - self->private->dispose_has_run = TRUE; + private->dispose_has_run = TRUE; /* * In dispose, you are supposed to free all types referenced from this @@ -162,7 +165,7 @@ * the most simple solution is to unref all members on which you own a * reference. */ - g_object_unref (self->private->profile); + g_object_unref (private->profile); /* Chain up to the parent class */ G_OBJECT_CLASS (parent_class)->dispose (obj); @@ -170,15 +173,6 @@ 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); } @@ -224,35 +218,24 @@ */ static void cxplorer_window_on_directory_changed (CxpDirView *dirview, gpointer user_data) { - CxplorerWindow *window = CXPLORER_WINDOW(user_data); + CxplorerWindowPrivate *private = CXPLORER_WINDOW_GET_PRIVATE(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), + gtk_entry_set_text (GTK_ENTRY (private->entry), fullpath); + cxp_right_pane_change_directory (CXP_RIGHT_PANE (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); + CxplorerWindowPrivate *private = CXPLORER_WINDOW_GET_PRIVATE(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); + dir_name = cxp_right_pane_get_active_file_name (right_pane); + cxp_dir_view_change_directory (CXP_DIR_VIEW(private->dirview), dir_name); + gtk_entry_set_text (GTK_ENTRY (private->entry), dir_name); g_free (dir_name); }