Revision: 4929 http://geany.svn.sourceforge.net/geany/?rev=4929&view=rev Author: eht16 Date: 2010-05-16 18:22:24 +0000 (Sun, 16 May 2010)
Log Message: ----------- Add a preference for choosing between GTK and native File Open/Save dialogs (only available on Windows).
Modified Paths: -------------- trunk/ChangeLog trunk/geany.glade trunk/src/dialogs.c trunk/src/geany.h trunk/src/interface.c trunk/src/keyfile.c trunk/src/prefs.c trunk/src/ui_utils.h
Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2010-05-16 17:45:39 UTC (rev 4928) +++ trunk/ChangeLog 2010-05-16 18:22:24 UTC (rev 4929) @@ -27,6 +27,10 @@ src/main.c, src/notebook.c, src/prefs.c: Add preference to add new document tabs beside the current one (patch by Colomban Wendling, thanks). + * geany.glade, src/dialogs.c, src/geany.h, src/interface.c, + src/keyfile.c, src/prefs.c, src/ui_utils.h: + Add a preference for choosing between GTK and native + File Open/Save dialogs (only available on Windows).
2010-05-15 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
Modified: trunk/geany.glade =================================================================== --- trunk/geany.glade 2010-05-16 17:45:39 UTC (rev 4928) +++ trunk/geany.glade 2010-05-16 18:22:24 UTC (rev 4929) @@ -3472,6 +3472,26 @@ <property name="fill">False</property> </packing> </child> + + <child> + <widget class="GtkCheckButton" id="check_native_windows_dialogs"> + <property name="visible">True</property> + <property name="tooltip" translatable="yes">Defines whether to use the native Windows File Open/Save dialogs or whether to use the GTK default dialogs</property> + <property name="can_focus">True</property> + <property name="label" translatable="yes">Use Windows File Open/Save dialogs</property> + <property name="use_underline">True</property> + <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> + <property name="active">False</property> + <property name="inconsistent">False</property> + <property name="draw_indicator">True</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> </widget> </child> </widget>
Modified: trunk/src/dialogs.c =================================================================== --- trunk/src/dialogs.c 2010-05-16 17:45:39 UTC (rev 4928) +++ trunk/src/dialogs.c 2010-05-16 18:22:24 UTC (rev 4929) @@ -69,7 +69,7 @@ static gboolean handle_save_as(const gchar *utf8_filename, gboolean open_new_tab, gboolean rename_file);
-#if ! GEANY_USE_WIN32_DIALOG + static GtkWidget *add_file_open_extra_widget(void);
@@ -207,7 +207,6 @@ g_signal_connect(ui_widgets.open_filesel, "response", G_CALLBACK(on_file_open_dialog_response), NULL); } -#endif
/* This shows the file selection dialog to open a file. */ @@ -225,34 +224,35 @@
setptr(initdir, utils_get_locale_from_utf8(initdir));
-#if GEANY_USE_WIN32_DIALOG - win32_show_document_open_dialog(GTK_WINDOW(main_widgets.window), _("Open File"), initdir); -#else /* X11, not win32: use GTK_FILE_CHOOSER */ - - /* We use the same file selection widget each time, so first of all we create it - * if it hasn't already been created. */ - if (ui_widgets.open_filesel == NULL) - create_open_file_dialog(); - - if (initdir != NULL) +#ifdef G_OS_WIN32 + if (interface_prefs.use_native_windows_dialogs) + win32_show_document_open_dialog(GTK_WINDOW(main_widgets.window), _("Open File"), initdir); + else +#endif { - if (g_path_is_absolute(initdir)) - gtk_file_chooser_set_current_folder( - GTK_FILE_CHOOSER(ui_widgets.open_filesel), initdir); - } + /* We use the same file selection widget each time, so first of all we create it + * if it hasn't already been created. */ + if (ui_widgets.open_filesel == NULL) + create_open_file_dialog();
- if (app->project && NZV(app->project->base_path)) - gtk_file_chooser_add_shortcut_folder(GTK_FILE_CHOOSER(ui_widgets.open_filesel), - app->project->base_path, NULL); + if (initdir != NULL) + { + if (g_path_is_absolute(initdir)) + gtk_file_chooser_set_current_folder( + GTK_FILE_CHOOSER(ui_widgets.open_filesel), initdir); + }
- gtk_file_chooser_unselect_all(GTK_FILE_CHOOSER(ui_widgets.open_filesel)); - gtk_window_present(GTK_WINDOW(ui_widgets.open_filesel)); -#endif + if (app->project && NZV(app->project->base_path)) + gtk_file_chooser_add_shortcut_folder(GTK_FILE_CHOOSER(ui_widgets.open_filesel), + app->project->base_path, NULL); + + gtk_file_chooser_unselect_all(GTK_FILE_CHOOSER(ui_widgets.open_filesel)); + gtk_window_present(GTK_WINDOW(ui_widgets.open_filesel)); + } g_free(initdir); }
-#if ! GEANY_USE_WIN32_DIALOG static GtkWidget *add_file_open_extra_widget() { GtkWidget *expander, *vbox, *table, *check_hidden; @@ -325,16 +325,13 @@
return expander; } -#endif
-#if ! GEANY_USE_WIN32_DIALOG static void on_save_as_new_tab_toggled(GtkToggleButton *togglebutton, gpointer user_data) { gtk_widget_set_sensitive(GTK_WIDGET(user_data), ! gtk_toggle_button_get_active(togglebutton)); } -#endif
static gboolean handle_save_as(const gchar *utf8_filename, gboolean open_new_tab, gboolean rename_file) @@ -369,7 +366,6 @@ }
-#if ! GEANY_USE_WIN32_DIALOG static void on_file_save_dialog_response (GtkDialog *dialog, gint response, @@ -416,10 +412,8 @@ if (success) gtk_widget_hide(ui_widgets.save_filesel); } -#endif
-#if ! GEANY_USE_WIN32_DIALOG static void create_save_file_dialog(void) { GtkWidget *vbox, *check_open_new_tab, *rename_btn; @@ -476,10 +470,8 @@
gtk_window_set_transient_for(GTK_WINDOW(ui_widgets.save_filesel), GTK_WINDOW(main_widgets.window)); } -#endif
-#if ! GEANY_USE_WIN32_DIALOG static gboolean gtk_show_save_as(void) { GeanyDocument *doc = document_get_current(); @@ -541,7 +533,6 @@
return (resp == GTK_RESPONSE_ACCEPT); } -#endif
/** @@ -553,15 +544,18 @@ { gboolean result = FALSE;
-#if GEANY_USE_WIN32_DIALOG - GeanyDocument *doc = document_get_current(); - gchar *utf8_name = win32_show_document_save_as_dialog(GTK_WINDOW(main_widgets.window), - _("Save File"), DOC_FILENAME(doc)); - if (utf8_name != NULL) - result = handle_save_as(utf8_name, FALSE, FALSE); -#else - result = gtk_show_save_as(); +#ifdef G_OS_WIN32 + if (interface_prefs.use_native_windows_dialogs) + { + GeanyDocument *doc = document_get_current(); + gchar *utf8_name = win32_show_document_save_as_dialog(GTK_WINDOW(main_widgets.window), + _("Save File"), DOC_FILENAME(doc)); + if (utf8_name != NULL) + result = handle_save_as(utf8_name, FALSE, FALSE); + } + else #endif + result = gtk_show_save_as(); return result; }
Modified: trunk/src/geany.h =================================================================== --- trunk/src/geany.h 2010-05-16 17:45:39 UTC (rev 4928) +++ trunk/src/geany.h 2010-05-16 18:22:24 UTC (rev 4929) @@ -49,7 +49,6 @@ #define GEANY_TEMPLATES_SUBDIR "templates" #define GEANY_CODENAME "Vellam" #define GEANY_HOMEPAGE "http://www.geany.org/" -#define GEANY_USE_WIN32_DIALOG 0 #define GEANY_STRING_UNTITLED _("untitled") #define GEANY_DEFAULT_DIALOG_HEIGHT 350 #define GEANY_WINDOW_DEFAULT_WIDTH 900
Modified: trunk/src/interface.c =================================================================== --- trunk/src/interface.c 2010-05-16 17:45:39 UTC (rev 4928) +++ trunk/src/interface.c 2010-05-16 18:22:24 UTC (rev 4929) @@ -2308,6 +2308,7 @@ GtkWidget *check_switch_pages; GtkWidget *check_suppress_status_msgs; GtkWidget *check_auto_focus; + GtkWidget *check_native_windows_dialogs; GtkWidget *label199; GtkWidget *frame36; GtkWidget *alignment39; @@ -2887,6 +2888,11 @@ gtk_box_pack_start (GTK_BOX (vbox21), check_auto_focus, FALSE, FALSE, 0); gtk_tooltips_set_tip (tooltips, check_auto_focus, _("Gives the focus automatically to widgets below the mouse cursor. Works for the main editor widget, the scribble, the toolbar search and goto line fields and the VTE."), NULL);
+ check_native_windows_dialogs = gtk_check_button_new_with_mnemonic (_("Use Windows File Open/Save dialogs")); + gtk_widget_show (check_native_windows_dialogs); + gtk_box_pack_start (GTK_BOX (vbox21), check_native_windows_dialogs, FALSE, FALSE, 0); + gtk_tooltips_set_tip (tooltips, check_native_windows_dialogs, _("Defines whether to use the native Windows File Open/Save dialogs or whether to use the GTK default dialogs"), NULL); + label199 = gtk_label_new (_("<b>Miscellaneous</b>")); gtk_widget_show (label199); gtk_frame_set_label_widget (GTK_FRAME (frame19), label199); @@ -4784,6 +4790,7 @@ GLADE_HOOKUP_OBJECT (prefs_dialog, check_switch_pages, "check_switch_pages"); GLADE_HOOKUP_OBJECT (prefs_dialog, check_suppress_status_msgs, "check_suppress_status_msgs"); GLADE_HOOKUP_OBJECT (prefs_dialog, check_auto_focus, "check_auto_focus"); + GLADE_HOOKUP_OBJECT (prefs_dialog, check_native_windows_dialogs, "check_native_windows_dialogs"); GLADE_HOOKUP_OBJECT (prefs_dialog, label199, "label199"); GLADE_HOOKUP_OBJECT (prefs_dialog, frame36, "frame36"); GLADE_HOOKUP_OBJECT (prefs_dialog, alignment39, "alignment39");
Modified: trunk/src/keyfile.c =================================================================== --- trunk/src/keyfile.c 2010-05-16 17:45:39 UTC (rev 4928) +++ trunk/src/keyfile.c 2010-05-16 18:22:24 UTC (rev 4929) @@ -364,6 +364,7 @@ g_key_file_set_boolean(config, PACKAGE, "msgwin_compiler_visible", interface_prefs.msgwin_compiler_visible); g_key_file_set_boolean(config, PACKAGE, "msgwin_messages_visible", interface_prefs.msgwin_messages_visible); g_key_file_set_boolean(config, PACKAGE, "msgwin_scribble_visible", interface_prefs.msgwin_scribble_visible); + g_key_file_set_boolean(config, PACKAGE, "use_native_windows_dialogs", interface_prefs.use_native_windows_dialogs);
/* display */ g_key_file_set_boolean(config, PACKAGE, "show_indent_guide", editor_prefs.show_indent_guide); @@ -657,6 +658,7 @@ interface_prefs.msgwin_compiler_visible = utils_get_setting_boolean(config, PACKAGE, "msgwin_compiler_visible", TRUE); interface_prefs.msgwin_messages_visible = utils_get_setting_boolean(config, PACKAGE, "msgwin_messages_visible", TRUE); interface_prefs.msgwin_scribble_visible = utils_get_setting_boolean(config, PACKAGE, "msgwin_scribble_visible", TRUE); + interface_prefs.use_native_windows_dialogs = utils_get_setting_boolean(config, PACKAGE, "use_native_windows_dialogs", FALSE);
/* display, editor */ editor_prefs.long_line_global_enabled = utils_get_setting_boolean(config, PACKAGE, "long_line_enabled", TRUE);
Modified: trunk/src/prefs.c =================================================================== --- trunk/src/prefs.c 2010-05-16 17:45:39 UTC (rev 4928) +++ trunk/src/prefs.c 2010-05-16 18:22:24 UTC (rev 4929) @@ -375,6 +375,10 @@ widget = ui_lookup_widget(ui_widgets.prefs_dialog, "check_auto_focus"); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), prefs.auto_focus);
+ widget = ui_lookup_widget(ui_widgets.prefs_dialog, "check_native_windows_dialogs"); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), + interface_prefs.use_native_windows_dialogs); + widget = ui_lookup_widget(ui_widgets.prefs_dialog, "entry_contextaction"); gtk_entry_set_text(GTK_ENTRY(widget), tool_prefs.context_action_cmd);
@@ -800,6 +804,10 @@ widget = ui_lookup_widget(ui_widgets.prefs_dialog, "check_auto_focus"); prefs.auto_focus = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
+ widget = ui_lookup_widget(ui_widgets.prefs_dialog, "check_native_windows_dialogs"); + interface_prefs.use_native_windows_dialogs = + gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); + widget = ui_lookup_widget(ui_widgets.prefs_dialog, "entry_contextaction"); g_free(tool_prefs.context_action_cmd); tool_prefs.context_action_cmd = g_strdup(gtk_entry_get_text(GTK_ENTRY(widget))); @@ -1673,6 +1681,9 @@ vte_append_preferences_tab(); #endif
+#ifndef G_OS_WIN32 + gtk_widget_hide(ui_lookup_widget(ui_widgets.prefs_dialog, "check_native_windows_dialogs")); +#endif ui_setup_open_button_callback(ui_lookup_widget(ui_widgets.prefs_dialog, "startup_path_button"), NULL, GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER, GTK_ENTRY(ui_lookup_widget(ui_widgets.prefs_dialog, "startup_path_entry"))); ui_setup_open_button_callback(ui_lookup_widget(ui_widgets.prefs_dialog, "extra_plugin_path_button"), NULL,
Modified: trunk/src/ui_utils.h =================================================================== --- trunk/src/ui_utils.h 2010-05-16 17:45:39 UTC (rev 4928) +++ trunk/src/ui_utils.h 2010-05-16 18:22:24 UTC (rev 4929) @@ -57,6 +57,7 @@ gboolean msgwin_compiler_visible; gboolean msgwin_messages_visible; gboolean msgwin_scribble_visible; + gboolean use_native_windows_dialogs; /* only used on Windows */ } GeanyInterfacePrefs;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.