Branch: refs/heads/master Author: Pavel Roschin roshin@scriptumplus.ru Committer: Matthew Brush matt@geany.org Date: Sat, 25 May 2013 23:49:06 UTC Commit: 169a2f49577457b2c1484fcf4e5ebf6c222547c0 https://github.com/geany/geany/commit/169a2f49577457b2c1484fcf4e5ebf6c222547...
Log Message: ----------- Keybindings for plugins
Modified Paths: -------------- src/keybindings.c src/keybindings.h src/plugins.c src/prefs.c src/prefs.h
Modified: src/keybindings.c 38 files changed, 26 insertions(+), 12 deletions(-) =================================================================== @@ -907,6 +907,31 @@ static GtkWidget *create_dialog(void) }
+static void key_dialog_show_prefs() +{ + GtkWidget *wid; + + prefs_show_dialog(); + /* select the KB page */ + wid = ui_lookup_widget(ui_widgets.prefs_dialog, "frame22"); + if (wid != NULL) + { + GtkNotebook *nb = GTK_NOTEBOOK(ui_lookup_widget(ui_widgets.prefs_dialog, "notebook2")); + if (nb != NULL) + { + gtk_notebook_set_current_page(nb, gtk_notebook_page_num(nb, wid)); + } + } +} + + +void keybindings_dialog_show_prefs_scroll(const gchar *name) +{ + key_dialog_show_prefs(); + prefs_kb_search_name(name); +} + + /* non-modal keyboard shortcuts dialog, so user can edit whilst seeing the shortcuts */ static GtkWidget *key_dialog = NULL;
@@ -914,18 +939,7 @@ static void on_dialog_response(GtkWidget *dialog, gint response, gpointer user_d { if (response == GTK_RESPONSE_APPLY) { - GtkWidget *wid; - - prefs_show_dialog(); - /* select the KB page */ - wid = ui_lookup_widget(ui_widgets.prefs_dialog, "frame22"); - if (wid != NULL) - { - GtkNotebook *nb = GTK_NOTEBOOK(ui_lookup_widget(ui_widgets.prefs_dialog, "notebook2")); - - if (nb != NULL) - gtk_notebook_set_current_page(nb, gtk_notebook_page_num(nb, wid)); - } + key_dialog_show_prefs(); } gtk_widget_destroy(dialog); key_dialog = NULL;
Modified: src/keybindings.h 2 files changed, 2 insertions(+), 0 deletions(-) =================================================================== @@ -286,6 +286,8 @@ GeanyKeyBinding *keybindings_set_item(GeanyKeyGroup *group, gsize key_id,
gboolean keybindings_check_event(GdkEventKey *ev, GeanyKeyBinding *kb);
+void keybindings_dialog_show_prefs_scroll(const gchar *name); + G_END_DECLS
#endif
Modified: src/plugins.c 14 files changed, 13 insertions(+), 1 deletions(-) =================================================================== @@ -1160,6 +1160,7 @@ enum PLUGIN_COLUMN_DESCRIPTION, PLUGIN_COLUMN_PLUGIN, PLUGIN_N_COLUMNS, + PM_BUTTON_KEYBINDINGS, PM_BUTTON_CONFIGURE, PM_BUTTON_HELP }; @@ -1173,6 +1174,7 @@ enum GtkWidget *filename_label; GtkWidget *author_label; GtkWidget *configure_button; + GtkWidget *keybindings_button; GtkWidget *help_button; } PluginManagerWidgets; @@ -1188,6 +1190,8 @@ static void pm_update_buttons(Plugin *p) gtk_widget_set_sensitive(pm_widgets.configure_button, (p->configure || p->configure_single) && is_active); gtk_widget_set_sensitive(pm_widgets.help_button, p->help != NULL && is_active); + gtk_widget_set_sensitive(pm_widgets.keybindings_button, + p->key_group && p->key_group->plugin_key_count > 0 && is_active); }
@@ -1356,6 +1360,8 @@ static void pm_on_plugin_button_clicked(GtkButton *button, gpointer user_data) plugin_show_configure(&p->public); else if (GPOINTER_TO_INT(user_data) == PM_BUTTON_HELP && p->help != NULL) p->help(); + else if (GPOINTER_TO_INT(user_data) == PM_BUTTON_KEYBINDINGS && p->key_group && p->key_group->plugin_key_count > 0) + keybindings_dialog_show_prefs_scroll(p->info.name); } } } @@ -1434,6 +1440,11 @@ static void pm_show_dialog(GtkMenuItem *menuitem, gpointer user_data)
label = geany_wrap_label_new(_("Choose which plugins should be loaded at startup:"));
+ pm_widgets.keybindings_button = gtk_button_new_with_label(_("Keybindings")); + gtk_widget_set_sensitive(pm_widgets.keybindings_button, FALSE); + g_signal_connect(pm_widgets.keybindings_button, "clicked", + G_CALLBACK(pm_on_plugin_button_clicked), GINT_TO_POINTER(PM_BUTTON_KEYBINDINGS)); + pm_widgets.configure_button = gtk_button_new_from_stock(GTK_STOCK_PREFERENCES); gtk_widget_set_sensitive(pm_widgets.configure_button, FALSE); g_signal_connect(pm_widgets.configure_button, "clicked", @@ -1468,7 +1479,8 @@ static void pm_show_dialog(GtkMenuItem *menuitem, gpointer user_data) hbox = gtk_hbox_new(FALSE, 0); gtk_box_pack_start(GTK_BOX(hbox), label2, TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(hbox), pm_widgets.help_button, FALSE, FALSE, 4); - gtk_box_pack_start(GTK_BOX(hbox), pm_widgets.configure_button, FALSE, FALSE, 0); + gtk_box_pack_start(GTK_BOX(hbox), pm_widgets.configure_button, FALSE, FALSE, 4); + gtk_box_pack_start(GTK_BOX(hbox), pm_widgets.keybindings_button, FALSE, FALSE, 0);
label_vbox = gtk_vbox_new(FALSE, 3); gtk_box_pack_start(GTK_BOX(label_vbox), hbox, FALSE, FALSE, 0);
Modified: src/prefs.c 23 files changed, 23 insertions(+), 0 deletions(-) =================================================================== @@ -334,6 +334,29 @@ static void kb_set_shortcut(GtkTreeStore *store, GtkTreeIter *iter, }
+void prefs_kb_search_name(const gchar *search) +{ + GtkTreeIter iter; + gboolean valid; + GtkTreeModel *model; + gchar *name; + model = gtk_tree_view_get_model(tree); + valid = gtk_tree_model_get_iter_first(model, &iter); + while (valid) + { + gtk_tree_model_get(model, &iter, KB_TREE_ACTION, &name, -1); + if(g_strcmp0(name, search) == 0) + { + GtkTreePath *path = gtk_tree_model_get_path(model, &iter); + gtk_tree_view_scroll_to_cell(tree, path, NULL, FALSE, .0f, .0f); + gtk_tree_path_free(path); + break; + } + valid = gtk_tree_model_iter_next(model, &iter); + } +} + + static void kb_init(void) { GtkTreeIter parent, iter;
Modified: src/prefs.h 2 files changed, 2 insertions(+), 0 deletions(-) =================================================================== @@ -58,6 +58,8 @@
void prefs_show_dialog(void);
+void prefs_kb_search_name(const gchar *search); + G_END_DECLS
#endif
-------------- This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).