Revision: 1415 http://svn.sourceforge.net/geany/?rev=1415&view=rev Author: ntrel Date: 2007-03-23 09:34:54 -0700 (Fri, 23 Mar 2007)
Log Message: ----------- Move dialogs_show_keyboard_shortcuts() to keybindings.c.
Modified Paths: -------------- trunk/ChangeLog trunk/src/callbacks.c trunk/src/dialogs.c trunk/src/dialogs.h trunk/src/keybindings.c trunk/src/keybindings.h
Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2007-03-23 16:03:52 UTC (rev 1414) +++ trunk/ChangeLog 2007-03-23 16:34:54 UTC (rev 1415) @@ -2,6 +2,9 @@
* src/dialogs.c: Add Edit button to Keyboard Shortcuts dialog. + * src/keybindings.c, src/keybindings.h, src/dialogs.c, src/dialogs.h, + src/callbacks.c: + Move dialogs_show_keyboard_shortcuts() to keybindings.c.
2007-03-22 Enrico Tröger enrico.troeger@uvena.de
Modified: trunk/src/callbacks.c =================================================================== --- trunk/src/callbacks.c 2007-03-23 16:03:52 UTC (rev 1414) +++ trunk/src/callbacks.c 2007-03-23 16:34:54 UTC (rev 1415) @@ -1415,7 +1415,7 @@ on_help_shortcuts1_activate (GtkMenuItem *menuitem, gpointer user_data) { - dialogs_show_keyboard_shortcuts(); + keybindings_show_shortcuts(); }
Modified: trunk/src/dialogs.c =================================================================== --- trunk/src/dialogs.c 2007-03-23 16:03:52 UTC (rev 1414) +++ trunk/src/dialogs.c 2007-03-23 16:34:54 UTC (rev 1415) @@ -51,7 +51,6 @@ #include "ui_utils.h" #include "keybindings.h" #include "encodings.h" -#include "prefs.h"
#if ! GEANY_USE_WIN32_DIALOG @@ -1298,80 +1297,3 @@ }
-void dialogs_show_keyboard_shortcuts() -{ - GtkWidget *dialog, *hbox, *label1, *label2, *label3, *swin, *vbox; - GString *text_names = g_string_sized_new(600); - GString *text_keys = g_string_sized_new(600); - gchar *shortcut; - guint i; - gint height, response; - - dialog = gtk_dialog_new_with_buttons(_("Keyboard shortcuts"), GTK_WINDOW(app->window), - GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_STOCK_EDIT, GTK_RESPONSE_APPLY, - GTK_STOCK_CLOSE, GTK_RESPONSE_CANCEL, NULL); - vbox = ui_dialog_vbox_new(GTK_DIALOG(dialog)); - gtk_box_set_spacing(GTK_BOX(vbox), 6); - - height = GEANY_WINDOW_MINIMAL_HEIGHT; - gtk_window_set_default_size(GTK_WINDOW(dialog), height * 0.8, height); - gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_CANCEL); - - label3 = gtk_label_new(_("The following keyboard shortcuts are defined:")); - gtk_misc_set_alignment(GTK_MISC(label3), 0, 0.5); - - hbox = gtk_hbox_new(FALSE, 6); - - label1 = gtk_label_new(NULL); - - label2 = gtk_label_new(NULL); - - for (i = 0; i < GEANY_MAX_KEYS; i++) - { - shortcut = gtk_accelerator_get_label(keys[i]->key, keys[i]->mods); - g_string_append(text_names, keys[i]->label); - g_string_append(text_names, "\n"); - g_string_append(text_keys, shortcut); - g_string_append(text_keys, "\n"); - g_free(shortcut); - } - - gtk_label_set_text(GTK_LABEL(label1), text_names->str); - gtk_label_set_text(GTK_LABEL(label2), text_keys->str); - - gtk_container_add(GTK_CONTAINER(hbox), label1); - gtk_container_add(GTK_CONTAINER(hbox), label2); - - swin = gtk_scrolled_window_new(NULL, NULL); - gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(swin), GTK_POLICY_AUTOMATIC, - GTK_POLICY_AUTOMATIC); - gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(swin), hbox); - - gtk_box_pack_start(GTK_BOX(vbox), label3, FALSE, FALSE, 6); - gtk_box_pack_start(GTK_BOX(vbox), swin, TRUE, TRUE, 0); - - gtk_widget_show_all(dialog); - response = gtk_dialog_run(GTK_DIALOG(dialog)); - if (response == GTK_RESPONSE_APPLY) - { - GtkWidget *wid; - - dialogs_show_prefs_dialog(); - // select the KB page - wid = lookup_widget(app->prefs_dialog, "frame22"); - if (wid != NULL) - { - GtkNotebook *nb = GTK_NOTEBOOK(lookup_widget(app->prefs_dialog, "notebook2")); - - if (nb != NULL) - gtk_notebook_set_current_page(nb, gtk_notebook_page_num(nb, wid)); - } - } - - gtk_widget_destroy(dialog); - - g_string_free(text_names, TRUE); - g_string_free(text_keys, TRUE); -} -
Modified: trunk/src/dialogs.h =================================================================== --- trunk/src/dialogs.h 2007-03-23 16:03:52 UTC (rev 1414) +++ trunk/src/dialogs.h 2007-03-23 16:34:54 UTC (rev 1415) @@ -57,8 +57,6 @@ gboolean dialogs_show_question_full(const gchar *yes_btn, const gchar *no_btn, const gchar *extra_text, const gchar *main_text, ...) G_GNUC_PRINTF (4, 5);
-void dialogs_show_keyboard_shortcuts(); - void dialogs_show_msgbox(gint type, const gchar *text, ...);
#endif
Modified: trunk/src/keybindings.c =================================================================== --- trunk/src/keybindings.c 2007-03-23 16:03:52 UTC (rev 1414) +++ trunk/src/keybindings.c 2007-03-23 16:34:54 UTC (rev 1415) @@ -419,6 +419,84 @@ }
+void keybindings_show_shortcuts() +{ + GtkWidget *dialog, *hbox, *label1, *label2, *label3, *swin, *vbox; + GString *text_names = g_string_sized_new(600); + GString *text_keys = g_string_sized_new(600); + gchar *shortcut; + guint i; + gint height, response; + + dialog = gtk_dialog_new_with_buttons(_("Keyboard shortcuts"), GTK_WINDOW(app->window), + GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_STOCK_EDIT, GTK_RESPONSE_APPLY, + GTK_STOCK_CLOSE, GTK_RESPONSE_CANCEL, NULL); + vbox = ui_dialog_vbox_new(GTK_DIALOG(dialog)); + gtk_box_set_spacing(GTK_BOX(vbox), 6); + + height = GEANY_WINDOW_MINIMAL_HEIGHT; + gtk_window_set_default_size(GTK_WINDOW(dialog), height * 0.8, height); + gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_CANCEL); + + label3 = gtk_label_new(_("The following keyboard shortcuts are defined:")); + gtk_misc_set_alignment(GTK_MISC(label3), 0, 0.5); + + hbox = gtk_hbox_new(FALSE, 6); + + label1 = gtk_label_new(NULL); + + label2 = gtk_label_new(NULL); + + for (i = 0; i < GEANY_MAX_KEYS; i++) + { + shortcut = gtk_accelerator_get_label(keys[i]->key, keys[i]->mods); + g_string_append(text_names, keys[i]->label); + g_string_append(text_names, "\n"); + g_string_append(text_keys, shortcut); + g_string_append(text_keys, "\n"); + g_free(shortcut); + } + + gtk_label_set_text(GTK_LABEL(label1), text_names->str); + gtk_label_set_text(GTK_LABEL(label2), text_keys->str); + + gtk_container_add(GTK_CONTAINER(hbox), label1); + gtk_container_add(GTK_CONTAINER(hbox), label2); + + swin = gtk_scrolled_window_new(NULL, NULL); + gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(swin), GTK_POLICY_AUTOMATIC, + GTK_POLICY_AUTOMATIC); + gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(swin), hbox); + + gtk_box_pack_start(GTK_BOX(vbox), label3, FALSE, FALSE, 6); + gtk_box_pack_start(GTK_BOX(vbox), swin, TRUE, TRUE, 0); + + gtk_widget_show_all(dialog); + response = gtk_dialog_run(GTK_DIALOG(dialog)); + if (response == GTK_RESPONSE_APPLY) + { + GtkWidget *wid; + + dialogs_show_prefs_dialog(); + // select the KB page + wid = lookup_widget(app->prefs_dialog, "frame22"); + if (wid != NULL) + { + GtkNotebook *nb = GTK_NOTEBOOK(lookup_widget(app->prefs_dialog, "notebook2")); + + if (nb != NULL) + gtk_notebook_set_current_page(nb, gtk_notebook_page_num(nb, wid)); + } + } + + gtk_widget_destroy(dialog); + + g_string_free(text_names, TRUE); + g_string_free(text_keys, TRUE); +} + + static gboolean check_fixed_kb(GdkEventKey *event) { // check alt-0 to alt-9 for setting current notebook page @@ -949,3 +1027,4 @@ { on_menu_insert_special_chars1_activate(NULL, NULL); } +
Modified: trunk/src/keybindings.h =================================================================== --- trunk/src/keybindings.h 2007-03-23 16:03:52 UTC (rev 1414) +++ trunk/src/keybindings.h 2007-03-23 16:34:54 UTC (rev 1415) @@ -130,6 +130,8 @@ /* just write the content of the keys array to the config file */ void keybindings_write_to_file(void);
+void keybindings_show_shortcuts(); + /* central keypress event handler, almost all keypress events go to this function */ gboolean keybindings_got_event(GtkWidget *widget, GdkEventKey *event, gpointer user_data);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.