Yasumichi Akahoshi
yasum****@users*****
2005年 5月 7日 (土) 03:21:54 JST
Index: cxplorer/src/Makefile.am diff -u cxplorer/src/Makefile.am:1.18 cxplorer/src/Makefile.am:1.19 --- cxplorer/src/Makefile.am:1.18 Sat Apr 9 02:48:16 2005 +++ cxplorer/src/Makefile.am Sat May 7 03:21:54 2005 @@ -17,6 +17,8 @@ main.c\ cxp-property-dialog.c\ cxp-property-dialog.h\ + cxp-pref-dialog.c \ + cxp-pref-dialog.h \ cxp-dir-view.h\ cxp-dir-view.c \ cxp-right-pane.h \ Index: cxplorer/src/Makefile.in diff -u cxplorer/src/Makefile.in:1.22 cxplorer/src/Makefile.in:1.23 --- cxplorer/src/Makefile.in:1.22 Sat Apr 9 02:48:16 2005 +++ cxplorer/src/Makefile.in Sat May 7 03:21:54 2005 @@ -143,7 +143,7 @@ bin_PROGRAMS = cxplorer -cxplorer_SOURCES = main.c cxp-property-dialog.c cxp-property-dialog.h cxp-dir-view.h cxp-dir-view.c cxp-right-pane.h cxp-right-pane.c cxplorer-window.h cxplorer-window.c +cxplorer_SOURCES = main.c cxp-property-dialog.c cxp-property-dialog.h cxp-pref-dialog.c cxp-pref-dialog.h cxp-dir-view.h cxp-dir-view.c cxp-right-pane.h cxp-right-pane.c cxplorer-window.h cxplorer-window.c cxplorer_LDFLAGS = @@ -162,8 +162,8 @@ LDFLAGS = @LDFLAGS@ LIBS = @LIBS@ cxplorer_OBJECTS = main.$(OBJEXT) cxp-property-dialog.$(OBJEXT) \ -cxp-dir-view.$(OBJEXT) cxp-right-pane.$(OBJEXT) \ -cxplorer-window.$(OBJEXT) +cxp-pref-dialog.$(OBJEXT) cxp-dir-view.$(OBJEXT) \ +cxp-right-pane.$(OBJEXT) cxplorer-window.$(OBJEXT) cxplorer_DEPENDENCIES = COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) @@ -176,8 +176,9 @@ TAR = tar GZIP_ENV = --best -DEP_FILES = .deps/cxp-dir-view.P .deps/cxp-property-dialog.P \ -.deps/cxp-right-pane.P .deps/cxplorer-window.P .deps/main.P +DEP_FILES = .deps/cxp-dir-view.P .deps/cxp-pref-dialog.P \ +.deps/cxp-property-dialog.P .deps/cxp-right-pane.P \ +.deps/cxplorer-window.P .deps/main.P SOURCES = $(cxplorer_SOURCES) OBJECTS = $(cxplorer_OBJECTS) Index: cxplorer/src/cxp-pref-dialog.c diff -u /dev/null cxplorer/src/cxp-pref-dialog.c:1.1 --- /dev/null Sat May 7 03:21:54 2005 +++ cxplorer/src/cxp-pref-dialog.c Sat May 7 03:21:54 2005 @@ -0,0 +1,260 @@ +/** + * @file + * @brief A widget of Property dialog + * + * A widget of Property dialog + * @author Yasumichi Akahoshi <yasum****@users*****> + * @date Sun Apr 3 02:53:00 2005 + * $Revision: 1.1 $ + ****************************************************************************/ + +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif + +#include <cxp.h> +#include <glib/gi18n.h> +#include <magic.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <unistd.h> +#include <grp.h> +#include <pwd.h> +#include "cxp-pref-dialog.h" + +enum +{ + ENTRY_PREVIEW_TEXT = 0, + ENTRY_PREVIEW_BINARY, + ENTRY_PREVIEW_DIRECTORY, + ENTRY_ATTACH_MAIL, + ENTRY_COUNT +}; + +/** + * the private structure + */ +typedef struct +{ + GtkWidget *entry[ENTRY_COUNT]; + gboolean dispose_has_run; +} CxpPrefDialogPrivate; + +#define CXP_PREF_DIALOG_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), CXP_TYPE_PREF_DIALOG, CxpPrefDialogPrivate)) + +static GObjectClass *parent_class = NULL; + +enum +{ + CXP_PREF_DIALOG_FILENAME = 1, +}; + +static void cxp_pref_dialog_class_init (CxpPrefDialogClass *klass); +static void cxp_pref_dialog_instance_init (GTypeInstance * instance, + gpointer g_class); +/* +static void cxp_pref_dialog_set_property (GObject * object, + guint property_id, + const GValue * value, + GParamSpec * pspec); +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_class_init (CxpPrefDialogClass *klass) +{ + GObjectClass *gobject_class = G_OBJECT_CLASS (klass); + GParamSpec *pspec; + + /* + 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", + "CxpPrefDialog construct prop", + "Set filename", + NULL, + G_PARAM_READWRITE); + g_object_class_install_property (gobject_class, + CXP_PREF_DIALOG_FILENAME, + pspec); + */ + + g_type_class_add_private (klass, sizeof (CxpPrefDialogPrivate)); +} + +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(self); + GtkWidget *close_button; + GtkWidget *notebook; + GtkWidget *table; + GtkWidget *label; + GtkWidget *vbox; + GtkWidget *hbox; + gchar *entry_title[] = { + N_("Text File"), + N_("Binary File"), + N_("Directory") + }; + 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")); + + notebook = gtk_notebook_new (); + gtk_box_pack_start(GTK_BOX(GTK_DIALOG(self)->vbox), notebook, FALSE, FALSE, 0); + gtk_widget_show (notebook); + + table = gtk_table_new (3, 2, FALSE); + for(index=0; index < 3; index++) + { + 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_table_attach_defaults (GTK_TABLE(table), private->entry[index], 1, 2, index, index+1); + } + gtk_widget_show_all (table); + + label = gtk_label_new (_("Preview Command")); + gtk_notebook_append_page (GTK_NOTEBOOK(notebook), table, label); + + vbox = gtk_vbox_new (FALSE, 2); + hbox = gtk_hbox_new (FALSE, 2); + gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, TRUE, 2); + 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_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); +} + +/* +static void cxp_pref_dialog_set_property (GObject * object, + guint property_id, + const GValue * value, + GParamSpec * pspec) +{ + CxpPrefDialog *self = CXP_PREF_DIALOG (object); + CxpPrefDialogPrivate *private = CXP_PREF_DIALOG_GET_PRIVATE(self); + + switch (property_id) + { + case CXP_PREF_DIALOG_FILENAME: + if (private->filename != NULL) + { + g_free (private->filename); + } + private->filename = g_value_dup_string (value); + break; + default: + G_OBJECT_WARN_INVALID_PREF_ID (object, property_id, pspec); + break; + } +} +*/ + +/* +static void cxp_pref_dialog_get_property (GObject * object, + guint property_id, GValue * value, + GParamSpec * pspec) +{ + CxpPrefDialogPrivate *private = CXP_PREF_DIALOG_GET_PRIVATE(object); + + switch (property_id) + { + case CXP_PREF_DIALOG_FILENAME: + g_value_set_string (value, private->filename); + break; + default: + G_OBJECT_WARN_INVALID_PREF_ID (object, property_id, pspec); + break; + } +} +*/ + +static void cxp_pref_dialog_dispose (GObject * obj) +{ + CxpPrefDialogPrivate *private = CXP_PREF_DIALOG_GET_PRIVATE(obj); + + if (private->dispose_has_run) + { + /* If dispose did already run, return. */ + return; + } + /* Make sure dispose does not run twice. */ + 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. + */ + + /* Chain up to the parent class */ + G_OBJECT_CLASS (parent_class)->dispose (obj); +} + +static void cxp_pref_dialog_finalize (GObject * obj) +{ + /* Chain up to the parent class */ + G_OBJECT_CLASS (parent_class)->finalize (obj); +} + +GType cxp_pref_dialog_get_type (void) +{ + static GType type = 0; + + if (type == 0) + { + static const GTypeInfo info = { + sizeof (CxpPrefDialogClass), + NULL, /* base_init */ + NULL, /* base_finalize */ + (GClassInitFunc) cxp_pref_dialog_class_init, /* class_init */ + NULL, /* class_finalize */ + NULL, /* class_data */ + sizeof (CxpPrefDialog), + 0, /* n_preallocs */ + cxp_pref_dialog_instance_init /* instance_init */ + }; + type = g_type_register_static (GTK_TYPE_DIALOG, + "CxpPrefDialogType", + &info, 0); + } + return type; +} + +/** + * Creates a new dialog box which show detail of file. + */ +GtkWidget *cxp_pref_dialog_new(void) +{ + CxpPrefDialog *dialog; + + dialog = g_object_new(CXP_TYPE_PREF_DIALOG, NULL); + + return GTK_WIDGET(dialog); +} + Index: cxplorer/src/cxp-pref-dialog.h diff -u /dev/null cxplorer/src/cxp-pref-dialog.h:1.1 --- /dev/null Sat May 7 03:21:54 2005 +++ cxplorer/src/cxp-pref-dialog.h Sat May 7 03:21:54 2005 @@ -0,0 +1,39 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */ +/* + * Copyright/Licensing information. + */ + +#ifndef CXP_PREF_DIALOG_H +#define CXP_PREF_DIALOG_H + +/* + * Potentially, include other headers on which this header depends. + */ +#include <gtk/gtk.h> +#include <glib-object.h> + +#define CXP_TYPE_PREF_DIALOG (cxp_pref_dialog_get_type ()) +#define CXP_PREF_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CXP_TYPE_PREF_DIALOG, CxpPrefDialog)) +#define CXP_PREF_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CXP_TYPE_PREF_DIALOG, CxpPrefDialogClass)) +#define CXP_IS_PREF_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CXP_TYPE_PREF_DIALOG)) +#define CXP_IS_PREF_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CXP_TYPE_PREF_DIALOG)) +#define CXP_PREF_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CXP_TYPE_PREF_DIALOG, CxpPrefDialogClass)) + +typedef struct _CxpPrefDialog CxpPrefDialog; +typedef struct _CxpPrefDialogClass CxpPrefDialogClass; + +struct _CxpPrefDialog { + GtkDialog parent; +}; + +struct _CxpPrefDialogClass { + GtkDialogClass parent; +}; + +/* used by CXP_TYPE_PREF_DIALOG */ +GType cxp_pref_dialog_get_type (void); + +/* API. */ +GtkWidget *cxp_pref_dialog_new(void); + +#endif /* CXP_PREF_DIALOG_H */ Index: cxplorer/src/cxplorer-window.c diff -u cxplorer/src/cxplorer-window.c:1.36 cxplorer/src/cxplorer-window.c:1.37 --- cxplorer/src/cxplorer-window.c:1.36 Wed Apr 27 22:17:12 2005 +++ cxplorer/src/cxplorer-window.c Sat May 7 03:21:54 2005 @@ -36,6 +36,7 @@ #include "cxp-dir-view.h" #include "cxp-right-pane.h" #include "cxp-property-dialog.h" +#include "cxp-pref-dialog.h" #include "cxplorer-window.h" /* If you use Pimpls, include the private structure @@ -91,6 +92,7 @@ static void cxplorer_window_property_action (GtkWidget * widget, gpointer user_data); static void cxplorer_window_copy_action (GtkWidget * widget, gpointer user_data); static void cxplorer_window_paste_action (GtkWidget *widget, gpointer user_data); +static void cxplorer_window_pref_action (GtkWidget *widget, gpointer user_data); static void cxplorer_window_show_dot_file_toggled (GtkToggleAction *action, gpointer user_data); static void cxplorer_window_refresh_views_action (GtkWidget *widget, gpointer user_data); static void cxplorer_window_go_up_action (GtkWidget *widget, gpointer user_data); @@ -122,7 +124,7 @@ {"EditAction", NULL, N_("_Edit"), NULL, NULL, NULL}, {"CopyAction", "gtk-copy", N_("_Copy"), NULL, NULL, G_CALLBACK(cxplorer_window_copy_action)}, {"PasteAction", "gtk-paste", N_("_Paste"), NULL, NULL, G_CALLBACK(cxplorer_window_paste_action)}, - {"PrefAction", "gtk-preferences", N_("_Preferences"), NULL, NULL, NULL}, + {"PrefAction", "gtk-preferences", N_("_Preferences"), NULL, NULL, G_CALLBACK(cxplorer_window_pref_action)}, /* View menu */ {"ViewAction", NULL, N_("_View"), NULL, NULL, NULL}, {"RefreshAct", "gtk-refresh", N_("_Refresh"), NULL, NULL, G_CALLBACK(cxplorer_window_refresh_views_action)}, @@ -169,7 +171,6 @@ GdkPixbuf *pixbuf; GtkAction *dot_file_act; GtkWidget *menubar; - GtkWidget *menuitem; GtkWidget *toolbar; GtkWidget *vbox; GtkWidget *hpaned; @@ -223,10 +224,6 @@ gtk_box_pack_start (GTK_BOX (vbox), menubar, FALSE, FALSE, 0); gtk_widget_show (menubar); - /* ToDo: 設定ダイアログの実装。とりあえず、メニューを使用不可にする。 */ - menuitem = gtk_ui_manager_get_widget (private->ui_manager, "/menubar/EditMenu/PrefMenu"); - gtk_widget_set_sensitive (menuitem, FALSE); - /* ここで送るメニューを構築する。 */ hash = cxp_profile_get_hash_table (private->sendto); g_hash_table_foreach (hash, cxplorer_window_menu_item_new_from_sendto, self); @@ -696,6 +693,16 @@ cxp_right_pane_paste_from_clipboard (CXP_RIGHT_PANE(private->right_pane)); } +static void cxplorer_window_pref_action (GtkWidget *widget, gpointer user_data) +{ + CxplorerWindowPrivate *private = CXPLORER_WINDOW_GET_PRIVATE (user_data); + GtkWidget *dialog; + + dialog = cxp_pref_dialog_new (); + gtk_dialog_run (GTK_DIALOG(dialog)); + gtk_widget_destroy (dialog); +} + /** * This function called back when "Show dot file" is toggled. * @param gcmItem [in] Pointer to menu item "View->Show dot file".