From 234826859721eee82be872512e2524a8ca456e55 Mon Sep 17 00:00:00 2001 From: Colomban Wendling Date: Tue, 9 Aug 2016 01:35:28 +0200 Subject: [PATCH 01/11] Simplify and unify code for opening the help --- src/callbacks.c | 6 +----- src/prefs.c | 5 +---- src/utils.c | 12 +++++++++++- src/utils.h | 2 +- 4 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/callbacks.c b/src/callbacks.c index 1177925a0e..ad7aa525eb 100644 --- a/src/callbacks.c +++ b/src/callbacks.c @@ -941,11 +941,7 @@ void on_toolbutton_goto_clicked(GtkAction *action, gpointer user_data) void on_help1_activate(GtkMenuItem *menuitem, gpointer user_data) { - gchar *uri; - - uri = utils_get_help_url(NULL); - utils_open_browser(uri); - g_free(uri); + utils_open_help(NULL); } diff --git a/src/prefs.c b/src/prefs.c index ed8d80c3f3..7aa29b62d4 100644 --- a/src/prefs.c +++ b/src/prefs.c @@ -1588,7 +1588,6 @@ static void on_prefs_print_page_header_toggled(GtkToggleButton *togglebutton, gp static void open_preferences_help(void) { - gchar *uri; const gchar *label, *suffix = NULL; GtkNotebook *notebook = GTK_NOTEBOOK( ui_lookup_widget(ui_widgets.prefs_dialog, "notebook2")); @@ -1624,9 +1623,7 @@ static void open_preferences_help(void) else if (utils_str_equal(label, _("Terminal"))) suffix = "#terminal-vte-preferences"; - uri = utils_get_help_url(suffix); - utils_open_browser(uri); - g_free(uri); + utils_open_help(suffix); } diff --git a/src/utils.c b/src/utils.c index b5ea73dac5..86e508749d 100644 --- a/src/utils.c +++ b/src/utils.c @@ -1886,7 +1886,7 @@ GSList *utils_get_config_files(const gchar *subdir) /* Suffix can be NULL or a string which should be appended to the Help URL like * an anchor link, e.g. "#some_anchor". */ -gchar *utils_get_help_url(const gchar *suffix) +static gchar *utils_get_help_url(const gchar *suffix) { gint skip; gchar *uri; @@ -1915,6 +1915,16 @@ gchar *utils_get_help_url(const gchar *suffix) } +void utils_open_help(const gchar *suffix) +{ + gchar *uri; + + uri = utils_get_help_url(suffix); + utils_open_browser(uri); + g_free(uri); +} + + static gboolean str_in_array(const gchar **haystack, const gchar *needle) { const gchar **p; diff --git a/src/utils.h b/src/utils.h index 7dd8f38b58..03366259fc 100644 --- a/src/utils.h +++ b/src/utils.h @@ -301,7 +301,7 @@ gchar **utils_strv_join(gchar **first, gchar **second) G_GNUC_WARN_UNUSED_RESULT GSList *utils_get_config_files(const gchar *subdir); -gchar *utils_get_help_url(const gchar *suffix); +void utils_open_help(const gchar *suffix); gboolean utils_str_has_upper(const gchar *str); From 46522cfd1e47b84485c20c15af206dcb7141bb90 Mon Sep 17 00:00:00 2001 From: Colomban Wendling Date: Tue, 9 Aug 2016 01:36:11 +0200 Subject: [PATCH 02/11] Add a help button to the Find dialog --- src/search.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/search.c b/src/search.c index 82fdaa0a08..3c89c4acf2 100644 --- a/src/search.c +++ b/src/search.c @@ -463,6 +463,7 @@ static void create_find_dialog(void) find_dlg.dialog = gtk_dialog_new_with_buttons(_("Find"), GTK_WINDOW(main_widgets.window), GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_STOCK_HELP, GTK_RESPONSE_HELP, GTK_STOCK_CLOSE, GTK_RESPONSE_CANCEL, NULL); vbox = ui_dialog_vbox_new(GTK_DIALOG(find_dlg.dialog)); gtk_widget_set_name(find_dlg.dialog, "GeanyDialogSearch"); @@ -1298,6 +1299,8 @@ on_find_dialog_response(GtkDialog *dialog, gint response, gpointer user_data) if (response == GTK_RESPONSE_CANCEL || response == GTK_RESPONSE_DELETE_EVENT) gtk_widget_hide(find_dlg.dialog); + else if (response == GTK_RESPONSE_HELP) + utils_open_help("#find"); else { GeanyDocument *doc = document_get_current(); From 3f1487cc5895c6414e5c287168022eeb9605caff Mon Sep 17 00:00:00 2001 From: Colomban Wendling Date: Tue, 9 Aug 2016 01:36:40 +0200 Subject: [PATCH 03/11] Add a help button to the Replace dialog --- src/search.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/search.c b/src/search.c index 3c89c4acf2..b3150f6e74 100644 --- a/src/search.c +++ b/src/search.c @@ -617,6 +617,7 @@ static void create_replace_dialog(void) replace_dlg.dialog = gtk_dialog_new_with_buttons(_("Replace"), GTK_WINDOW(main_widgets.window), GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_STOCK_HELP, GTK_RESPONSE_HELP, GTK_STOCK_CLOSE, GTK_RESPONSE_CANCEL, NULL); vbox = ui_dialog_vbox_new(GTK_DIALOG(replace_dlg.dialog)); gtk_box_set_spacing(GTK_BOX(vbox), 9); @@ -1453,6 +1454,11 @@ on_replace_dialog_response(GtkDialog *dialog, gint response, gpointer user_data) gtk_widget_hide(replace_dlg.dialog); return; } + else if (response == GTK_RESPONSE_HELP) + { + utils_open_help("#replace"); + return; + } search_backwards_re = settings.replace_search_backwards; search_replace_escape_re = settings.replace_escape_sequences; From b8ce7433f11e494b0452c967e4a024c99485f8c4 Mon Sep 17 00:00:00 2001 From: Colomban Wendling Date: Tue, 9 Aug 2016 01:37:11 +0200 Subject: [PATCH 04/11] Add a help button to the Find in Files dialog --- src/search.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/search.c b/src/search.c index b3150f6e74..64a532448f 100644 --- a/src/search.c +++ b/src/search.c @@ -867,6 +867,7 @@ static void create_fif_dialog(void) fif_dlg.dialog = gtk_dialog_new_with_buttons( _("Find in Files"), GTK_WINDOW(main_widgets.window), GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_STOCK_HELP, GTK_RESPONSE_HELP, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, NULL); vbox = ui_dialog_vbox_new(GTK_DIALOG(fif_dlg.dialog)); gtk_box_set_spacing(GTK_BOX(vbox), 9); @@ -1641,6 +1642,8 @@ on_find_in_files_dialog_response(GtkDialog *dialog, gint response, else ui_set_statusbar(FALSE, _("No text to find.")); } + else if (response == GTK_RESPONSE_HELP) + utils_open_help("#find-in-files"); else gtk_widget_hide(fif_dlg.dialog); } From 3c9a3744da1100920df68793cdabc62bca6b1c19 Mon Sep 17 00:00:00 2001 From: Colomban Wendling Date: Wed, 10 Aug 2016 02:28:50 +0200 Subject: [PATCH 05/11] Reintroduce utils_get_help_url() Can be useful to build help URLs to put in labels. --- src/utils.c | 2 +- src/utils.h | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/utils.c b/src/utils.c index 86e508749d..85528365b6 100644 --- a/src/utils.c +++ b/src/utils.c @@ -1886,7 +1886,7 @@ GSList *utils_get_config_files(const gchar *subdir) /* Suffix can be NULL or a string which should be appended to the Help URL like * an anchor link, e.g. "#some_anchor". */ -static gchar *utils_get_help_url(const gchar *suffix) +gchar *utils_get_help_url(const gchar *suffix) { gint skip; gchar *uri; diff --git a/src/utils.h b/src/utils.h index 03366259fc..1c7ac0f027 100644 --- a/src/utils.h +++ b/src/utils.h @@ -301,6 +301,8 @@ gchar **utils_strv_join(gchar **first, gchar **second) G_GNUC_WARN_UNUSED_RESULT GSList *utils_get_config_files(const gchar *subdir); +gchar *utils_get_help_url(const gchar *suffix); + void utils_open_help(const gchar *suffix); gboolean utils_str_has_upper(const gchar *str); From 047b90be065b72e18fff5b33931bbc0f354c06a1 Mon Sep 17 00:00:00 2001 From: Colomban Wendling Date: Wed, 10 Aug 2016 02:43:32 +0200 Subject: [PATCH 06/11] Add help button and link to the Set Build Commands dialog --- src/build.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/build.c b/src/build.c index 3cfcbe4238..a3c026cc63 100644 --- a/src/build.c +++ b/src/build.c @@ -1898,6 +1898,7 @@ GtkWidget *build_commands_table(GeanyDocument *doc, GeanyBuildSource dst, BuildT GtkTable *table; const gchar **ch; gchar *txt; + gchar *help_uri; guint col, row, cmdindex; guint cmd; guint src; @@ -2008,8 +2009,14 @@ GtkWidget *build_commands_table(GeanyDocument *doc, GeanyBuildSource dst, BuildT entry_x_padding, sep_padding); ++row; label = gtk_label_new(NULL); - ui_label_set_markup(GTK_LABEL(label), "%s", - _("%d, %e, %f, %p, %l are substituted in command and directory fields, see manual for details.")); + help_uri = utils_get_help_url("#substitutions-in-commands-and-working-directories"); + txt = g_strdup_printf(_("%%d, %%e, %%f, %%p, %%l are substituted in command and directory fields, " + "see the manual for details."), help_uri); + SETPTR(txt, g_strconcat("", txt, "", NULL)); + gtk_label_set_text(GTK_LABEL(label), txt); + gtk_label_set_use_markup(GTK_LABEL(label), TRUE); + g_free(help_uri); + g_free(txt); gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); gtk_table_attach(table, label, 0, DC_N_COL, row, row + 1, GTK_FILL, GTK_FILL | GTK_EXPAND, entry_x_padding, entry_y_padding); @@ -2176,6 +2183,7 @@ static void show_build_commands_dialog(void) ft = doc->file_type; dialog = gtk_dialog_new_with_buttons(title, GTK_WINDOW(main_widgets.window), GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_STOCK_HELP, GTK_RESPONSE_HELP, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, NULL); table = build_commands_table(doc, GEANY_BCS_PREF, &table_data, ft); @@ -2183,7 +2191,14 @@ static void show_build_commands_dialog(void) gtk_box_pack_start(GTK_BOX(vbox), table, TRUE, TRUE, 0); gtk_widget_show_all(dialog); /* run modally to prevent user changing idx filetype */ - response = gtk_dialog_run(GTK_DIALOG(dialog)); + do + { + response = gtk_dialog_run(GTK_DIALOG(dialog)); + + if (response == GTK_RESPONSE_HELP) + utils_open_help("#build-menu-commands-dialog"); + } + while (response == GTK_RESPONSE_HELP); prefdsts.dst[GEANY_GBG_NON_FT] = &non_ft_pref; if (ft != NULL) From 51f40913155246a3e3d7e62f4bb381829bb678ae Mon Sep 17 00:00:00 2001 From: Colomban Wendling Date: Wed, 10 Aug 2016 03:27:12 +0200 Subject: [PATCH 07/11] Use explicit anchors in the documentations --- doc/geany.txt | 10 ++++++++++ src/build.c | 4 ++-- src/search.c | 6 +++--- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/doc/geany.txt b/doc/geany.txt index 609f4c7b31..57bba4816a 100644 --- a/doc/geany.txt +++ b/doc/geany.txt @@ -1149,6 +1149,8 @@ the toolbar. This performs a case-insensitive search in the current document whilst you type. Pressing Enter will search again, and pressing Shift-Enter will search backwards. +.. _find-dialog: + Find ^^^^ @@ -1252,6 +1254,8 @@ shown in the Messages tab of the Message Window. menu. +.. _find-in-files-dialog: + Find in files ^^^^^^^^^^^^^ @@ -1319,6 +1323,8 @@ SVN Example: ``--exclude=*.svn-base`` The --exclude argument only matches the file name part, not the path. +.. _replace-dialog: + Replace ^^^^^^^ @@ -3084,6 +3090,8 @@ The following notes on the table reference cells by coordinate as (group,source) editing the appropriate file, see `Preferences file format`_ and `Project file format`_. +.. _set-build-commands-dialog: + Build menu commands dialog ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -3126,6 +3134,8 @@ When you do this the command from the next lower priority source will be shown. To hide lower priority menu items without having anything show in the menu configure with a nothing in the label but at least one character in the command. +.. _build-command-substitutions: + Substitutions in commands and working directories ````````````````````````````````````````````````` diff --git a/src/build.c b/src/build.c index a3c026cc63..52f60cd1cd 100644 --- a/src/build.c +++ b/src/build.c @@ -2009,7 +2009,7 @@ GtkWidget *build_commands_table(GeanyDocument *doc, GeanyBuildSource dst, BuildT entry_x_padding, sep_padding); ++row; label = gtk_label_new(NULL); - help_uri = utils_get_help_url("#substitutions-in-commands-and-working-directories"); + help_uri = utils_get_help_url("#build-command-substitutions"); txt = g_strdup_printf(_("%%d, %%e, %%f, %%p, %%l are substituted in command and directory fields, " "see the manual for details."), help_uri); SETPTR(txt, g_strconcat("", txt, "", NULL)); @@ -2196,7 +2196,7 @@ static void show_build_commands_dialog(void) response = gtk_dialog_run(GTK_DIALOG(dialog)); if (response == GTK_RESPONSE_HELP) - utils_open_help("#build-menu-commands-dialog"); + utils_open_help("#set-build-commands-dialog"); } while (response == GTK_RESPONSE_HELP); diff --git a/src/search.c b/src/search.c index 64a532448f..54ae46b812 100644 --- a/src/search.c +++ b/src/search.c @@ -1302,7 +1302,7 @@ on_find_dialog_response(GtkDialog *dialog, gint response, gpointer user_data) if (response == GTK_RESPONSE_CANCEL || response == GTK_RESPONSE_DELETE_EVENT) gtk_widget_hide(find_dlg.dialog); else if (response == GTK_RESPONSE_HELP) - utils_open_help("#find"); + utils_open_help("#find-dialog"); else { GeanyDocument *doc = document_get_current(); @@ -1457,7 +1457,7 @@ on_replace_dialog_response(GtkDialog *dialog, gint response, gpointer user_data) } else if (response == GTK_RESPONSE_HELP) { - utils_open_help("#replace"); + utils_open_help("#replace-dialog"); return; } @@ -1643,7 +1643,7 @@ on_find_in_files_dialog_response(GtkDialog *dialog, gint response, ui_set_statusbar(FALSE, _("No text to find.")); } else if (response == GTK_RESPONSE_HELP) - utils_open_help("#find-in-files"); + utils_open_help("#find-in-files-dialog"); else gtk_widget_hide(fif_dlg.dialog); } From 9d42dedfdc1fecbff9dd0ced44ef78832049edc7 Mon Sep 17 00:00:00 2001 From: Colomban Wendling Date: Wed, 10 Aug 2016 04:05:47 +0200 Subject: [PATCH 08/11] Add help button to the Project Properties dialog Each page opens a specific help URI attached to it. --- data/geany.glade | 24 ++++++++++++++++++++---- doc/geany.txt | 8 ++++++++ src/project.c | 46 ++++++++++++++++++++++++++++++++++++++++++++-- 3 files changed, 72 insertions(+), 6 deletions(-) diff --git a/data/geany.glade b/data/geany.glade index 224c049371..23649fb0d4 100644 --- a/data/geany.glade +++ b/data/geany.glade @@ -8473,6 +8473,21 @@ 1 + + + gtk-help + True + True + True + True + + + False + False + 2 + True + + False @@ -8487,7 +8502,7 @@ True 6 - + True False 6 @@ -8709,7 +8724,7 @@ - + True False 6 @@ -8925,7 +8940,7 @@ - + True False 5 @@ -9227,7 +9242,7 @@ - + True False 5 @@ -9354,6 +9369,7 @@ cancelbutton1 okbutton1 + button6 diff --git a/doc/geany.txt b/doc/geany.txt index 57bba4816a..7ccb59b275 100644 --- a/doc/geany.txt +++ b/doc/geany.txt @@ -2022,6 +2022,8 @@ Icon size The choice System default uses whatever icon size is set by GTK. +.. _project-dialog-editor: + Editor Features preferences ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -2071,6 +2073,8 @@ Comment toggle marker It is used to mark the comment as toggled. +.. _project-dialog-indentation: + Editor Indentation preferences ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -2332,6 +2336,8 @@ Default end of line characters characters to mark line breaks. On Unix-like systems, LF is default and CR is used on MAC systems. +.. _project-dialog-files: + Saving files ```````````` Perform formatting operations when a document is saved. These @@ -2760,6 +2766,8 @@ can safely be set to any existing path -- it will not touch the file structure contained in it. +.. _project-dialog-project: + Project properties ^^^^^^^^^^^^^^^^^^ diff --git a/src/project.c b/src/project.c index eda00faa2a..ae76002201 100644 --- a/src/project.c +++ b/src/project.c @@ -497,6 +497,13 @@ static void on_project_properties_base_path_button_clicked(GtkWidget *button, } +static void page_set_help_url(GtkWidget *widget, const gchar *suffix) +{ + gchar *uri = utils_get_help_url(suffix); + g_object_set_data_full(G_OBJECT(widget), "geany-help-uri", uri, g_free); +} + + static void insert_build_page(PropertyDialogElements *e) { GtkWidget *build_table, *label; @@ -511,6 +518,17 @@ static void insert_build_page(PropertyDialogElements *e) label = gtk_label_new(_("Build")); e->build_page_num = gtk_notebook_append_page(GTK_NOTEBOOK(e->notebook), build_table, label); + + page_set_help_url(build_table, "#set-build-commands-dialog"); +} + + +static void on_project_properties_switch_page(GtkNotebook *notebook, GtkWidget *page, + guint page_num, GtkDialog *dialog) +{ + const gchar *uri = g_object_get_data(G_OBJECT(page), "geany-help-uri"); + + gtk_dialog_set_response_sensitive(dialog, GTK_RESPONSE_HELP, uri != NULL); } @@ -553,6 +571,13 @@ static void create_properties_dialog(PropertyDialogElements *e) G_CALLBACK(on_radio_long_line_custom_toggled), ui_lookup_widget(e->dialog, "spin_long_line_project")); } + + page_set_help_url(ui_lookup_widget(e->dialog, "project_dialog_page_project"), "#project-dialog-project"); + page_set_help_url(ui_lookup_widget(e->dialog, "project_dialog_page_indentation"), "#project-dialog-indentation"); + page_set_help_url(ui_lookup_widget(e->dialog, "project_dialog_page_editor"), "#project-dialog-editor"); + page_set_help_url(ui_lookup_widget(e->dialog, "project_dialog_page_files"), "#project-dialog-files"); + + g_signal_connect(e->notebook, "switch-page", G_CALLBACK(on_project_properties_switch_page), e->dialog); } @@ -565,6 +590,7 @@ static void show_project_properties(gboolean show_build) GSList *node; gchar *entry_text; GtkTextBuffer *buffer; + gint response; g_return_if_fail(app->project != NULL); @@ -612,9 +638,11 @@ static void show_project_properties(gboolean show_build) else gtk_notebook_set_current_page(GTK_NOTEBOOK(e.notebook), 0); - while (gtk_dialog_run(GTK_DIALOG(e.dialog)) == GTK_RESPONSE_OK) + do { - if (update_config(&e, FALSE)) + response = gtk_dialog_run(GTK_DIALOG(e.dialog)); + + if (response == GTK_RESPONSE_OK && update_config(&e, FALSE)) { g_signal_emit_by_name(geany_object, "project-dialog-confirmed", e.notebook); if (!write_config(TRUE)) @@ -625,7 +653,21 @@ static void show_project_properties(gboolean show_build) break; } } + else if (response == GTK_RESPONSE_HELP) + { + gint current_page = gtk_notebook_get_current_page(GTK_NOTEBOOK(e.notebook)); + GtkWidget *page = gtk_notebook_get_nth_page(GTK_NOTEBOOK(e.notebook), current_page); + + if (page) + { + const gchar *uri = g_object_get_data(G_OBJECT(page), "geany-help-uri"); + + if (uri) + utils_open_browser(uri); + } + } } + while (response == GTK_RESPONSE_OK || response == GTK_RESPONSE_HELP); build_free_fields(e.build_properties); g_signal_emit_by_name(geany_object, "project-dialog-close", e.notebook); From 38c458f871a69b253feffd7c7de1c0468cf1a31e Mon Sep 17 00:00:00 2001 From: Colomban Wendling Date: Wed, 10 Aug 2016 15:01:29 +0200 Subject: [PATCH 09/11] Add help button to the New Project dialog --- doc/geany.txt | 2 ++ src/project.c | 9 +++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/doc/geany.txt b/doc/geany.txt index 7ccb59b275..b4526acda6 100644 --- a/doc/geany.txt +++ b/doc/geany.txt @@ -2753,6 +2753,8 @@ file that was in use at the end of the last session will be reopened. The project menu items are detailed below. +.. _new-project-dialog: + New project ^^^^^^^^^^^ diff --git a/src/project.c b/src/project.c index ae76002201..8b5e7edd33 100644 --- a/src/project.c +++ b/src/project.c @@ -152,6 +152,7 @@ void project_new(void) e.dialog = gtk_dialog_new_with_buttons(_("New Project"), GTK_WINDOW(main_widgets.window), GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_STOCK_HELP, GTK_RESPONSE_HELP, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, NULL); gtk_widget_set_name(e.dialog, "GeanyDialogProject"); @@ -228,7 +229,11 @@ void project_new(void) while (1) { - if (gtk_dialog_run(GTK_DIALOG(e.dialog)) != GTK_RESPONSE_OK) + gint response = gtk_dialog_run(GTK_DIALOG(e.dialog)); + + if (response == GTK_RESPONSE_HELP) + utils_open_help("#new-project-dialog"); + else if (response != GTK_RESPONSE_OK) { // any open docs were meant to be moved into the project // rewrite default session because it was cleared @@ -243,7 +248,7 @@ void project_new(void) break; } // dialog confirmed - if (update_config(&e, TRUE)) + else if (update_config(&e, TRUE)) { // app->project is now set if (!write_config(TRUE)) From a40a040c1d3b39cbb5ea848c2983603e97eae736 Mon Sep 17 00:00:00 2001 From: Colomban Wendling Date: Wed, 10 Aug 2016 15:32:02 +0200 Subject: [PATCH 10/11] Add help button to the Plugin Preferences dialog The button calls the plugin's help method, if any. --- src/pluginutils.c | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/src/pluginutils.c b/src/pluginutils.c index fbbe78ba6d..98b0e4bfd8 100644 --- a/src/pluginutils.c +++ b/src/pluginutils.c @@ -392,6 +392,15 @@ static GtkWidget *create_pref_page(Plugin *p, GtkWidget *dialog) } +static void on_plugin_configure_switch_page(GtkNotebook *notebook, GtkWidget *page, + guint page_num, GtkDialog *dialog) +{ + Plugin *p = g_object_get_data(G_OBJECT(page), "geany-plugin"); + + gtk_dialog_set_response_sensitive(dialog, GTK_RESPONSE_HELP, p && p->cbs.help); +} + + /* multiple plugin configure dialog * current_plugin can be NULL */ static void configure_plugins(Plugin *current_plugin) @@ -402,6 +411,7 @@ static void configure_plugins(Plugin *current_plugin) dialog = gtk_dialog_new_with_buttons(_("Configure Plugins"), GTK_WINDOW(main_widgets.window), GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_STOCK_HELP, GTK_RESPONSE_HELP, GTK_STOCK_APPLY, GTK_RESPONSE_APPLY, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OK, GTK_RESPONSE_OK, NULL); @@ -412,6 +422,8 @@ static void configure_plugins(Plugin *current_plugin) gtk_notebook_set_scrollable(GTK_NOTEBOOK(nb), TRUE); gtk_box_pack_start(GTK_BOX(vbox), nb, TRUE, TRUE, 0); + g_signal_connect(nb, "switch-page", G_CALLBACK(on_plugin_configure_switch_page), dialog); + foreach_list(node, active_plugin_list) { Plugin *p = node->data; @@ -422,18 +434,42 @@ static void configure_plugins(Plugin *current_plugin) GtkWidget *label = gtk_label_new(p->info.name); gint n = gtk_notebook_append_page(GTK_NOTEBOOK(nb), page, label); + g_object_set_data(G_OBJECT(page), "geany-plugin", p); + if (p == current_plugin) cur_page = n; } } if (gtk_notebook_get_n_pages(GTK_NOTEBOOK(nb))) { + gint response; + gtk_widget_show_all(vbox); if (cur_page >= 0) gtk_notebook_set_current_page(GTK_NOTEBOOK(nb), cur_page); /* run the dialog */ - while (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_APPLY); + do + { + response = gtk_dialog_run(GTK_DIALOG(dialog)); + + if (response == GTK_RESPONSE_HELP) + { + GtkWidget *page; + + cur_page = gtk_notebook_get_current_page(GTK_NOTEBOOK(nb)); + page = gtk_notebook_get_nth_page(GTK_NOTEBOOK(nb), cur_page); + + if (page) + { + Plugin *p = g_object_get_data(G_OBJECT(page), "geany-plugin"); + + if (p && p->cbs.help) + p->cbs.help(&p->public, p->cb_data); + } + } + } + while (response == GTK_RESPONSE_APPLY || response == GTK_RESPONSE_HELP); } else utils_beep(); From 134ca8420f2eb18da2a7c777d9e0c57e56d617b9 Mon Sep 17 00:00:00 2001 From: Colomban Wendling Date: Wed, 10 Aug 2016 15:44:33 +0200 Subject: [PATCH 11/11] Add help button to the Set Custom Commands dialog --- doc/geany.txt | 2 ++ src/tools.c | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/doc/geany.txt b/doc/geany.txt index b4526acda6..740d8e58ec 100644 --- a/doc/geany.txt +++ b/doc/geany.txt @@ -843,6 +843,8 @@ location". This makes it easier to navigate in e.g. foreign code and between different files. +.. _custom-commands-dialog: + Sending text through custom commands ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/tools.c b/src/tools.c index 706394812a..e117982c02 100644 --- a/src/tools.c +++ b/src/tools.c @@ -351,11 +351,13 @@ static void cc_show_dialog_custom_commands(void) GtkWidget *dialog, *label, *vbox, *scroll, *buttonbox; GtkCellRenderer *renderer; GtkTreeViewColumn *column; + gint response; guint i; struct cc_dialog cc; dialog = gtk_dialog_new_with_buttons(_("Set Custom Commands"), GTK_WINDOW(main_widgets.window), GTK_DIALOG_DESTROY_WITH_PARENT, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, + GTK_STOCK_HELP, GTK_RESPONSE_HELP, GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, NULL); gtk_window_set_default_size(GTK_WINDOW(dialog), 300, 300); /* give a reasonable minimal default size */ vbox = ui_dialog_vbox_new(GTK_DIALOG(dialog)); @@ -454,7 +456,10 @@ static void cc_show_dialog_custom_commands(void) gtk_widget_show_all(vbox); - if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) + while ((response = gtk_dialog_run(GTK_DIALOG(dialog))) == GTK_RESPONSE_HELP) + utils_open_help("#custom-commands-dialog"); + + if (response == GTK_RESPONSE_ACCEPT) { GSList *cmd_list = NULL; GSList *lbl_list = NULL;