Revision: 4443 http://geany.svn.sourceforge.net/geany/?rev=4443&view=rev Author: eht16 Date: 2009-11-23 23:03:39 +0000 (Mon, 23 Nov 2009)
Log Message: ----------- Add a Help button to the preferences dialog. Handle Help keybinding events for the preferences dialog especially and open the manual with the corresponding anchor link to the current preferences page (same goes for the new Help button).
Modified Paths: -------------- trunk/ChangeLog trunk/geany.glade trunk/src/interface.c trunk/src/prefs.c
Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2009-11-23 22:59:36 UTC (rev 4442) +++ trunk/ChangeLog 2009-11-23 23:03:39 UTC (rev 4443) @@ -13,6 +13,11 @@ Geany's keybindings. * src/callbacks.c, src/utils.c, src/utils.h: Add and use utils_get_help_url(). + * geany.glade, src/interface.c, src/prefs.c: + Add a Help button to the preferences dialog. + Handle Help keybinding events for the preferences dialog especially + and open the manual with the corresponding anchor link to the current + preferences page (same goes for the new Help button).
2009-11-22 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
Modified: trunk/geany.glade =================================================================== --- trunk/geany.glade 2009-11-23 22:59:36 UTC (rev 4442) +++ trunk/geany.glade 2009-11-23 23:03:39 UTC (rev 4443) @@ -2832,6 +2832,19 @@ <property name="response_id">-5</property> </widget> </child> + + <child> + <widget class="GtkButton" id="button_help"> + <property name="visible">True</property> + <property name="can_default">True</property> + <property name="can_focus">True</property> + <property name="label">gtk-help</property> + <property name="use_stock">True</property> + <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> + <property name="response_id">-11</property> + </widget> + </child> </widget> <packing> <property name="padding">0</property>
Modified: trunk/src/interface.c =================================================================== --- trunk/src/interface.c 2009-11-23 22:59:36 UTC (rev 4442) +++ trunk/src/interface.c 2009-11-23 23:03:39 UTC (rev 4443) @@ -2704,6 +2704,7 @@ GtkWidget *button3; GtkWidget *button4; GtkWidget *button5; + GtkWidget *button_help; GtkTooltips *tooltips;
tooltips = gtk_tooltips_new (); @@ -4675,6 +4676,11 @@ gtk_dialog_add_action_widget (GTK_DIALOG (prefs_dialog), button5, GTK_RESPONSE_OK); GTK_WIDGET_SET_FLAGS (button5, GTK_CAN_DEFAULT);
+ button_help = gtk_button_new_from_stock ("gtk-help"); + gtk_widget_show (button_help); + gtk_dialog_add_action_widget (GTK_DIALOG (prefs_dialog), button_help, GTK_RESPONSE_HELP); + GTK_WIDGET_SET_FLAGS (button_help, GTK_CAN_DEFAULT); + g_signal_connect ((gpointer) button_customize_toolbar, "clicked", G_CALLBACK (on_button_customize_toolbar_clicked), NULL); @@ -5039,6 +5045,7 @@ GLADE_HOOKUP_OBJECT (prefs_dialog, button3, "button3"); GLADE_HOOKUP_OBJECT (prefs_dialog, button4, "button4"); GLADE_HOOKUP_OBJECT (prefs_dialog, button5, "button5"); + GLADE_HOOKUP_OBJECT (prefs_dialog, button_help, "button_help"); GLADE_HOOKUP_OBJECT_NO_REF (prefs_dialog, tooltips, "tooltips");
gtk_widget_grab_default (button5);
Modified: trunk/src/prefs.c =================================================================== --- trunk/src/prefs.c 2009-11-23 22:59:36 UTC (rev 4442) +++ trunk/src/prefs.c 2009-11-23 23:03:39 UTC (rev 4443) @@ -1456,6 +1456,77 @@ }
+static void open_preferences_help(void) +{ + gchar *uri; + const gchar *label, *suffix; + GtkNotebook *notebook = GTK_NOTEBOOK( + ui_lookup_widget(ui_widgets.prefs_dialog, "notebook2")); + gint page_nr = gtk_notebook_get_current_page(notebook); + GtkWidget *page = gtk_notebook_get_nth_page(notebook, page_nr); + + label = gtk_notebook_get_tab_label_text(notebook, page); + + /* TODO Find a better way to map the current notebook page to the + * corresponding chapter in the documentation, comparing translatable + * strings is easy to break. Maybe attach an identifying string to the + * tab label object. */ + if (utils_str_equal(label, _("General"))) + suffix = "#general-startup-preferences"; + else if (utils_str_equal(label, _("Interface"))) + suffix = "#interface-preferences"; + else if (utils_str_equal(label, _("Toolbar"))) + suffix = "#toolbar-preferences"; + else if (utils_str_equal(label, _("Editor"))) + suffix = "#editor-features-preferences"; + else if (utils_str_equal(label, _("Files"))) + suffix = "#files-preferences"; + else if (utils_str_equal(label, _("Tools"))) + suffix = "#tools-preferences"; + else if (utils_str_equal(label, _("Templates"))) + suffix = "#template-preferences"; + else if (utils_str_equal(label, _("Keybindings"))) + suffix = "#keybinding-preferences"; + else if (utils_str_equal(label, _("Printing"))) + suffix = "#printing-preferences"; + else if (utils_str_equal(label, _("Terminal"))) + suffix = "#terminal-vte-preferences"; + + uri = utils_get_help_url(suffix); + utils_open_browser(uri); + g_free(uri); +} + + +static gboolean prefs_dialog_key_press_response_cb(GtkWidget *dialog, GdkEventKey *event, + gpointer data) +{ + gint group, keybinding; + + if (keybindings_check_event(event, &group, &keybinding) != NULL) + { + if (group == GEANY_KEY_GROUP_HELP && keybinding == GEANY_KEYS_HELP_HELP) + { + open_preferences_help(); + return TRUE; + } + } + return FALSE; +} + + +static gboolean prefs_dialog_button_press_event_cb(GtkWidget *dialog, GdkEventButton *event, + gpointer data) +{ + if (event->button == 1) + { + open_preferences_help(); + return TRUE; + } + return FALSE; +} + + void prefs_show_dialog(void) { if (ui_widgets.prefs_dialog == NULL) @@ -1614,6 +1685,11 @@ "toggled", G_CALLBACK(on_use_folding_toggled), NULL); g_signal_connect(ui_lookup_widget(ui_widgets.prefs_dialog, "check_open_encoding"), "toggled", G_CALLBACK(on_open_encoding_toggled), NULL); + + g_signal_connect(ui_lookup_widget(ui_widgets.prefs_dialog, "button_help"), + "button-press-event", G_CALLBACK(prefs_dialog_button_press_event_cb), NULL); + g_signal_connect(ui_widgets.prefs_dialog, + "key-press-event", G_CALLBACK(prefs_dialog_key_press_response_cb), NULL); }
prefs_init_dialog();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.