From 5797c032955bc1b085c464044956190ce14e0bed Mon Sep 17 00:00:00 2001 From: Michael Natterer Date: Tue, 8 Apr 2003 10:02:42 +0000 Subject: [PATCH] app/config/gimpguiconfig.[ch] added "gboolean save_accels" and "gboolean 2003-04-08 Michael Natterer * app/config/gimpguiconfig.[ch] * app/config/gimprc-blurbs.h: added "gboolean save_accels" and "gboolean restore_accels". * app/gui/menus.[ch]: added menus_restore(), menus_save() and menus_clear(). * app/gui/session.[ch]: added session_clear(). * app/gui/gui.c: call menus_restore() and menus_save(). * app/gui/preferences-dialog.c: brought the full core config options overkill to the GUI. Needs to be simplified. Cleaned up the "Interface" page a bit. --- ChangeLog | 17 ++++++++ app/config/gimpguiconfig.c | 22 ++++++++++ app/config/gimpguiconfig.h | 2 + app/config/gimprc-blurbs.h | 6 +++ app/dialogs/preferences-dialog.c | 69 ++++++++++++++++++++++++++------ app/gui/gui.c | 9 +++-- app/gui/menus.c | 50 +++++++++++++++++------ app/gui/menus.h | 3 ++ app/gui/preferences-dialog.c | 69 ++++++++++++++++++++++++++------ app/gui/session.c | 8 ++++ app/gui/session.h | 1 + app/menus/menus.c | 50 +++++++++++++++++------ app/menus/menus.h | 3 ++ 13 files changed, 257 insertions(+), 52 deletions(-) diff --git a/ChangeLog b/ChangeLog index 75549b81fe..5af9f3bff9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,20 @@ +2003-04-08 Michael Natterer + + * app/config/gimpguiconfig.[ch] + * app/config/gimprc-blurbs.h: added "gboolean save_accels" and + "gboolean restore_accels". + + * app/gui/menus.[ch]: added menus_restore(), menus_save() and + menus_clear(). + + * app/gui/session.[ch]: added session_clear(). + + * app/gui/gui.c: call menus_restore() and menus_save(). + + * app/gui/preferences-dialog.c: brought the full core config + options overkill to the GUI. Needs to be simplified. Cleaned + up the "Interface" page a bit. + 2003-04-07 Sven Neumann * app/tools/gimpeditselectiontool.c (selection_transform_segs): diff --git a/app/config/gimpguiconfig.c b/app/config/gimpguiconfig.c index 98edb29924..dbab8985d9 100644 --- a/app/config/gimpguiconfig.c +++ b/app/config/gimpguiconfig.c @@ -66,6 +66,8 @@ enum PROP_SHOW_TOOL_TIPS, PROP_TEAROFF_MENUS, PROP_CAN_CHANGE_ACCELS, + PROP_SAVE_ACCELS, + PROP_RESTORE_ACCELS, PROP_LAST_OPENED_SIZE, PROP_MAX_NEW_IMAGE_SIZE, PROP_THEME_PATH, @@ -170,6 +172,14 @@ gimp_gui_config_class_init (GimpGuiConfigClass *klass) "can-change-accels", CAN_CHANGE_ACCELS_BLURB, FALSE, 0); + GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_SAVE_ACCELS, + "save-accels", SAVE_ACCELS_BLURB, + TRUE, + 0); + GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_RESTORE_ACCELS, + "restore-accels", RESTORE_ACCELS_BLURB, + TRUE, + 0); GIMP_CONFIG_INSTALL_PROP_INT (object_class, PROP_LAST_OPENED_SIZE, "last-opened-size", LAST_OPENED_SIZE_BLURB, 0, 1024, 4, @@ -260,6 +270,12 @@ gimp_gui_config_set_property (GObject *object, case PROP_CAN_CHANGE_ACCELS: gui_config->can_change_accels = g_value_get_boolean (value); break; + case PROP_SAVE_ACCELS: + gui_config->save_accels = g_value_get_boolean (value); + break; + case PROP_RESTORE_ACCELS: + gui_config->restore_accels = g_value_get_boolean (value); + break; case PROP_LAST_OPENED_SIZE: gui_config->last_opened_size = g_value_get_int (value); break; @@ -335,6 +351,12 @@ gimp_gui_config_get_property (GObject *object, case PROP_CAN_CHANGE_ACCELS: g_value_set_boolean (value, gui_config->can_change_accels); break; + case PROP_SAVE_ACCELS: + g_value_set_boolean (value, gui_config->save_accels); + break; + case PROP_RESTORE_ACCELS: + g_value_set_boolean (value, gui_config->restore_accels); + break; case PROP_LAST_OPENED_SIZE: g_value_set_int (value, gui_config->last_opened_size); break; diff --git a/app/config/gimpguiconfig.h b/app/config/gimpguiconfig.h index 9dc3102f40..441569d3ff 100644 --- a/app/config/gimpguiconfig.h +++ b/app/config/gimpguiconfig.h @@ -52,6 +52,8 @@ struct _GimpGuiConfig gboolean show_tool_tips; gboolean tearoff_menus; gboolean can_change_accels; + gboolean save_accels; + gboolean restore_accels; gint last_opened_size; gulong max_new_image_size; gchar *theme_path; diff --git a/app/config/gimprc-blurbs.h b/app/config/gimprc-blurbs.h index 2c6ef77eb4..77c7fd3f04 100644 --- a/app/config/gimprc-blurbs.h +++ b/app/config/gimprc-blurbs.h @@ -280,6 +280,12 @@ N_("When enabled, menus can be torn off.") #define CAN_CHANGE_ACCELS_BLURB \ N_("When enabled, you can change keyboard shortcuts for menu items on the fly.") +#define SAVE_ACCELS_BLURB \ +N_("Save changed keyboard shortcuts when the GIMP exits.") + +#define RESTORE_ACCELS_BLURB \ +N_("Restore saved keyboard shortcuts on each GIMP startup.") + #define TEMP_PATH_BLURB \ N_("Sets the temporary storage directory. Files will appear here " \ "during the course of running the GIMP. Most files will disappear " \ diff --git a/app/dialogs/preferences-dialog.c b/app/dialogs/preferences-dialog.c index eef0adf426..e5f03fc1d3 100644 --- a/app/dialogs/preferences-dialog.c +++ b/app/dialogs/preferences-dialog.c @@ -42,6 +42,7 @@ #include "widgets/gimppropwidgets.h" #include "gui.h" +#include "menus.h" #include "resolution-calibrate-dialog.h" #include "session.h" @@ -1092,13 +1093,13 @@ prefs_dialog_new (Gimp *gimp, page_index++); /* General */ - vbox2 = prefs_frame_new (_("General"), GTK_CONTAINER (vbox), FALSE); + vbox2 = prefs_frame_new (_("Previews"), GTK_CONTAINER (vbox), FALSE); prefs_check_button_add (config, "layer-previews", _("_Enable Layer & Channel Previews"), GTK_BOX (vbox2)); - table = prefs_table_new (4, GTK_CONTAINER (vbox2), FALSE); + table = prefs_table_new (2, GTK_CONTAINER (vbox2), FALSE); prefs_enum_option_menu_add (config, "layer-preview-size", 0, 0, _("_Layer & Channel Preview Size:"), @@ -1106,9 +1107,6 @@ prefs_dialog_new (Gimp *gimp, prefs_enum_option_menu_add (config, "navigation-preview-size", 0, 0, _("_Navigation Preview Size:"), GTK_TABLE (table), 1); - prefs_spin_button_add (config, "last-opened-size", 1.0, 5.0, 0, - _("_Recent Documents List Size:"), - GTK_TABLE (table), 3); /* Dialog Bahavior */ vbox2 = prefs_frame_new (_("Dialog Behavior"), GTK_CONTAINER (vbox), FALSE); @@ -1124,9 +1122,47 @@ prefs_dialog_new (Gimp *gimp, _("Enable _Tearoff Menus"), GTK_BOX (vbox2)); + table = prefs_table_new (1, GTK_CONTAINER (vbox2), FALSE); + + prefs_spin_button_add (config, "last-opened-size", 1.0, 5.0, 0, + _("Open _Recent Menu Size:"), + GTK_TABLE (table), 3); + + /* Keyboard Shortcuts */ + vbox2 = prefs_frame_new (_("Keyboard Shortcuts"), GTK_CONTAINER (vbox), FALSE); + prefs_check_button_add (config, "can-change-accels", _("Dynamic _Keyboard Shortcuts"), GTK_BOX (vbox2)); + prefs_check_button_add (config, "save-accels", + _("Save Keyboard Shortcuts on Exit"), + GTK_BOX (vbox2)); + prefs_check_button_add (config, "restore-accels", + _("Restore Saved Keyboard Shortcuts on Start-up"), + GTK_BOX (vbox2)); + + hbox = gtk_hbox_new (FALSE, 4); + gtk_container_set_border_width (GTK_CONTAINER (hbox), 4); + gtk_box_pack_start (GTK_BOX (vbox2), hbox, FALSE, FALSE, 0); + gtk_widget_show (hbox); + + button = gtk_button_new_with_label (_("Save Keyboard Shortcuts Now")); + gtk_misc_set_padding (GTK_MISC (GTK_BIN (button)->child), 2, 0); + gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0); + gtk_widget_show (button); + + g_signal_connect_swapped (button, "clicked", + G_CALLBACK (menus_save), + gimp); + + button = gtk_button_new_with_label (_("Clear Saved Keyboard Shortcuts Now")); + gtk_misc_set_padding (GTK_MISC (GTK_BIN (button)->child), 2, 0); + gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0); + gtk_widget_show (button); + + g_signal_connect_swapped (button, "clicked", + G_CALLBACK (menus_clear), + gimp); /* Window Positions */ vbox2 = prefs_frame_new (_("Window Positions"), GTK_CONTAINER (vbox), FALSE); @@ -1138,19 +1174,28 @@ prefs_dialog_new (Gimp *gimp, _("R_estore Saved Window Positions on Start-up"), GTK_BOX (vbox2)); - hbox = gtk_hbox_new (FALSE, 2); + hbox = gtk_hbox_new (FALSE, 4); gtk_container_set_border_width (GTK_CONTAINER (hbox), 4); gtk_box_pack_start (GTK_BOX (vbox2), hbox, FALSE, FALSE, 0); gtk_widget_show (hbox); - - button = gtk_button_new_with_label (_("Clear Saved Window Positions Now")); + + button = gtk_button_new_with_label (_("Save Window Positions Now")); gtk_misc_set_padding (GTK_MISC (GTK_BIN (button)->child), 2, 0); - gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0); + gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0); gtk_widget_show (button); - g_signal_connect (button, "clicked", - G_CALLBACK (gimp_dialog_factories_session_clear), - NULL); + g_signal_connect_swapped (button, "clicked", + G_CALLBACK (session_save), + gimp); + + button = gtk_button_new_with_label (_("Clear Saved Window Positions Now")); + gtk_misc_set_padding (GTK_MISC (GTK_BIN (button)->child), 2, 0); + gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0); + gtk_widget_show (button); + + g_signal_connect_swapped (button, "clicked", + G_CALLBACK (session_clear), + gimp); /*****************************/ diff --git a/app/gui/gui.c b/app/gui/gui.c index 50eef155af..d2c3f43a59 100644 --- a/app/gui/gui.c +++ b/app/gui/gui.c @@ -290,6 +290,8 @@ gui_restore (Gimp *gimp, gimp->message_handler = GIMP_MESSAGE_BOX; + menus_restore (gimp); + toolbox_item_factory = gimp_menu_factory_menu_new (global_menu_factory, "", GTK_TYPE_MENU_BAR, @@ -329,10 +331,8 @@ gui_post_init (Gimp *gimp) g_return_if_fail (GIMP_IS_GIMP (gimp)); if (GIMP_GUI_CONFIG (gimp->config)->show_tips) - { - gimp_dialog_factory_dialog_new (global_dialog_factory, - "gimp-tips-dialog", -1); - } + gimp_dialog_factory_dialog_new (global_dialog_factory, + "gimp-tips-dialog", -1); } void @@ -561,6 +561,7 @@ gui_exit_callback (Gimp *gimp, gimp->message_handler = GIMP_CONSOLE; session_save (gimp); + menus_save (gimp); if (GIMP_GUI_CONFIG (gimp->config)->save_device_status) gimp_devices_save (gimp); diff --git a/app/gui/menus.c b/app/gui/menus.c index ca00a4d6b6..c5289d94ec 100644 --- a/app/gui/menus.c +++ b/app/gui/menus.c @@ -91,8 +91,6 @@ static gboolean menus_initialized = FALSE; void menus_init (Gimp *gimp) { - gchar *filename; - g_return_if_fail (GIMP_IS_GIMP (gimp)); g_return_if_fail (menus_initialized == FALSE); @@ -234,23 +232,13 @@ menus_init (Gimp *gimp) NULL, qmask_menu_update, TRUE, n_qmask_menu_entries, qmask_menu_entries); - - filename = gimp_personal_rc_file ("menurc"); - gtk_accel_map_load (filename); - g_free (filename); } void menus_exit (Gimp *gimp) { - gchar *filename; - g_return_if_fail (GIMP_IS_GIMP (gimp)); - filename = gimp_personal_rc_file ("menurc"); - gtk_accel_map_save (filename); - g_free (filename); - g_object_unref (global_menu_factory); global_menu_factory = NULL; @@ -259,6 +247,44 @@ menus_exit (Gimp *gimp) NULL); } +void +menus_restore (Gimp *gimp) +{ + g_return_if_fail (GIMP_IS_GIMP (gimp)); + + if (GIMP_GUI_CONFIG (gimp->config)->restore_accels) + { + gchar *filename; + + filename = gimp_personal_rc_file ("menurc"); + gtk_accel_map_load (filename); + g_free (filename); + } +} + +void +menus_save (Gimp *gimp) +{ + g_return_if_fail (GIMP_IS_GIMP (gimp)); + + if (GIMP_GUI_CONFIG (gimp->config)->save_accels) + { + gchar *filename; + + filename = gimp_personal_rc_file ("menurc"); + gtk_accel_map_save (filename); + g_free (filename); + } +} + +void +menus_clear (Gimp *gimp) +{ + g_return_if_fail (GIMP_IS_GIMP (gimp)); + + g_print ("TODO: implement menus_clear()\n"); +} + void menus_last_opened_add (GimpItemFactory *item_factory, Gimp *gimp) diff --git a/app/gui/menus.h b/app/gui/menus.h index 58be122692..837a805466 100644 --- a/app/gui/menus.h +++ b/app/gui/menus.h @@ -32,6 +32,9 @@ extern GimpMenuFactory *global_menu_factory; void menus_init (Gimp *gimp); void menus_exit (Gimp *gimp); +void menus_restore (Gimp *gimp); +void menus_save (Gimp *gimp); +void menus_clear (Gimp *gimp); void menus_last_opened_add (GimpItemFactory *item_factory, Gimp *gimp); diff --git a/app/gui/preferences-dialog.c b/app/gui/preferences-dialog.c index eef0adf426..e5f03fc1d3 100644 --- a/app/gui/preferences-dialog.c +++ b/app/gui/preferences-dialog.c @@ -42,6 +42,7 @@ #include "widgets/gimppropwidgets.h" #include "gui.h" +#include "menus.h" #include "resolution-calibrate-dialog.h" #include "session.h" @@ -1092,13 +1093,13 @@ prefs_dialog_new (Gimp *gimp, page_index++); /* General */ - vbox2 = prefs_frame_new (_("General"), GTK_CONTAINER (vbox), FALSE); + vbox2 = prefs_frame_new (_("Previews"), GTK_CONTAINER (vbox), FALSE); prefs_check_button_add (config, "layer-previews", _("_Enable Layer & Channel Previews"), GTK_BOX (vbox2)); - table = prefs_table_new (4, GTK_CONTAINER (vbox2), FALSE); + table = prefs_table_new (2, GTK_CONTAINER (vbox2), FALSE); prefs_enum_option_menu_add (config, "layer-preview-size", 0, 0, _("_Layer & Channel Preview Size:"), @@ -1106,9 +1107,6 @@ prefs_dialog_new (Gimp *gimp, prefs_enum_option_menu_add (config, "navigation-preview-size", 0, 0, _("_Navigation Preview Size:"), GTK_TABLE (table), 1); - prefs_spin_button_add (config, "last-opened-size", 1.0, 5.0, 0, - _("_Recent Documents List Size:"), - GTK_TABLE (table), 3); /* Dialog Bahavior */ vbox2 = prefs_frame_new (_("Dialog Behavior"), GTK_CONTAINER (vbox), FALSE); @@ -1124,9 +1122,47 @@ prefs_dialog_new (Gimp *gimp, _("Enable _Tearoff Menus"), GTK_BOX (vbox2)); + table = prefs_table_new (1, GTK_CONTAINER (vbox2), FALSE); + + prefs_spin_button_add (config, "last-opened-size", 1.0, 5.0, 0, + _("Open _Recent Menu Size:"), + GTK_TABLE (table), 3); + + /* Keyboard Shortcuts */ + vbox2 = prefs_frame_new (_("Keyboard Shortcuts"), GTK_CONTAINER (vbox), FALSE); + prefs_check_button_add (config, "can-change-accels", _("Dynamic _Keyboard Shortcuts"), GTK_BOX (vbox2)); + prefs_check_button_add (config, "save-accels", + _("Save Keyboard Shortcuts on Exit"), + GTK_BOX (vbox2)); + prefs_check_button_add (config, "restore-accels", + _("Restore Saved Keyboard Shortcuts on Start-up"), + GTK_BOX (vbox2)); + + hbox = gtk_hbox_new (FALSE, 4); + gtk_container_set_border_width (GTK_CONTAINER (hbox), 4); + gtk_box_pack_start (GTK_BOX (vbox2), hbox, FALSE, FALSE, 0); + gtk_widget_show (hbox); + + button = gtk_button_new_with_label (_("Save Keyboard Shortcuts Now")); + gtk_misc_set_padding (GTK_MISC (GTK_BIN (button)->child), 2, 0); + gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0); + gtk_widget_show (button); + + g_signal_connect_swapped (button, "clicked", + G_CALLBACK (menus_save), + gimp); + + button = gtk_button_new_with_label (_("Clear Saved Keyboard Shortcuts Now")); + gtk_misc_set_padding (GTK_MISC (GTK_BIN (button)->child), 2, 0); + gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0); + gtk_widget_show (button); + + g_signal_connect_swapped (button, "clicked", + G_CALLBACK (menus_clear), + gimp); /* Window Positions */ vbox2 = prefs_frame_new (_("Window Positions"), GTK_CONTAINER (vbox), FALSE); @@ -1138,19 +1174,28 @@ prefs_dialog_new (Gimp *gimp, _("R_estore Saved Window Positions on Start-up"), GTK_BOX (vbox2)); - hbox = gtk_hbox_new (FALSE, 2); + hbox = gtk_hbox_new (FALSE, 4); gtk_container_set_border_width (GTK_CONTAINER (hbox), 4); gtk_box_pack_start (GTK_BOX (vbox2), hbox, FALSE, FALSE, 0); gtk_widget_show (hbox); - - button = gtk_button_new_with_label (_("Clear Saved Window Positions Now")); + + button = gtk_button_new_with_label (_("Save Window Positions Now")); gtk_misc_set_padding (GTK_MISC (GTK_BIN (button)->child), 2, 0); - gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0); + gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0); gtk_widget_show (button); - g_signal_connect (button, "clicked", - G_CALLBACK (gimp_dialog_factories_session_clear), - NULL); + g_signal_connect_swapped (button, "clicked", + G_CALLBACK (session_save), + gimp); + + button = gtk_button_new_with_label (_("Clear Saved Window Positions Now")); + gtk_misc_set_padding (GTK_MISC (GTK_BIN (button)->child), 2, 0); + gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0); + gtk_widget_show (button); + + g_signal_connect_swapped (button, "clicked", + G_CALLBACK (session_clear), + gimp); /*****************************/ diff --git a/app/gui/session.c b/app/gui/session.c index c296f19030..ee13f3c998 100644 --- a/app/gui/session.c +++ b/app/gui/session.c @@ -236,6 +236,14 @@ session_save (Gimp *gimp) gimp_config_writer_finish (writer, "end of sessionrc", NULL); } +void +session_clear (Gimp *gimp) +{ + g_return_if_fail (GIMP_IS_GIMP (gimp)); + + g_print ("TODO: implement session_clear()\n"); +} + /* private functions */ diff --git a/app/gui/session.h b/app/gui/session.h index dc7c9395c0..d91a928aa9 100644 --- a/app/gui/session.h +++ b/app/gui/session.h @@ -23,6 +23,7 @@ void session_init (Gimp *gimp); void session_restore (Gimp *gimp); void session_save (Gimp *gimp); +void session_clear (Gimp *gimp); #endif /* __SESSION_H__ */ diff --git a/app/menus/menus.c b/app/menus/menus.c index ca00a4d6b6..c5289d94ec 100644 --- a/app/menus/menus.c +++ b/app/menus/menus.c @@ -91,8 +91,6 @@ static gboolean menus_initialized = FALSE; void menus_init (Gimp *gimp) { - gchar *filename; - g_return_if_fail (GIMP_IS_GIMP (gimp)); g_return_if_fail (menus_initialized == FALSE); @@ -234,23 +232,13 @@ menus_init (Gimp *gimp) NULL, qmask_menu_update, TRUE, n_qmask_menu_entries, qmask_menu_entries); - - filename = gimp_personal_rc_file ("menurc"); - gtk_accel_map_load (filename); - g_free (filename); } void menus_exit (Gimp *gimp) { - gchar *filename; - g_return_if_fail (GIMP_IS_GIMP (gimp)); - filename = gimp_personal_rc_file ("menurc"); - gtk_accel_map_save (filename); - g_free (filename); - g_object_unref (global_menu_factory); global_menu_factory = NULL; @@ -259,6 +247,44 @@ menus_exit (Gimp *gimp) NULL); } +void +menus_restore (Gimp *gimp) +{ + g_return_if_fail (GIMP_IS_GIMP (gimp)); + + if (GIMP_GUI_CONFIG (gimp->config)->restore_accels) + { + gchar *filename; + + filename = gimp_personal_rc_file ("menurc"); + gtk_accel_map_load (filename); + g_free (filename); + } +} + +void +menus_save (Gimp *gimp) +{ + g_return_if_fail (GIMP_IS_GIMP (gimp)); + + if (GIMP_GUI_CONFIG (gimp->config)->save_accels) + { + gchar *filename; + + filename = gimp_personal_rc_file ("menurc"); + gtk_accel_map_save (filename); + g_free (filename); + } +} + +void +menus_clear (Gimp *gimp) +{ + g_return_if_fail (GIMP_IS_GIMP (gimp)); + + g_print ("TODO: implement menus_clear()\n"); +} + void menus_last_opened_add (GimpItemFactory *item_factory, Gimp *gimp) diff --git a/app/menus/menus.h b/app/menus/menus.h index 58be122692..837a805466 100644 --- a/app/menus/menus.h +++ b/app/menus/menus.h @@ -32,6 +32,9 @@ extern GimpMenuFactory *global_menu_factory; void menus_init (Gimp *gimp); void menus_exit (Gimp *gimp); +void menus_restore (Gimp *gimp); +void menus_save (Gimp *gimp); +void menus_clear (Gimp *gimp); void menus_last_opened_add (GimpItemFactory *item_factory, Gimp *gimp);