Kaydet (Commit) 7ae07014 authored tarafından Nick Treleaven's avatar Nick Treleaven

Move dialogs_show_keyboard_shortcuts() to keybindings.c.

git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@1415 ea778897-0a13-0410-b9d1-a72fbfd435f5
üst eb8834d5
......@@ -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>
......
......@@ -1415,7 +1415,7 @@ void
on_help_shortcuts1_activate (GtkMenuItem *menuitem,
gpointer user_data)
{
dialogs_show_keyboard_shortcuts();
keybindings_show_shortcuts();
}
......
......@@ -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 @@ gboolean dialogs_show_question_full(const gchar *yes_btn, const gchar *no_btn,
}
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);
}
......@@ -57,8 +57,6 @@ gboolean dialogs_show_question(const gchar *text, ...) G_GNUC_PRINTF (1, 2);
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
......@@ -419,6 +419,84 @@ void keybindings_free(void)
}
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 @@ static void cb_func_menu_insert_specialchars(G_GNUC_UNUSED guint key_id)
{
on_menu_insert_special_chars1_activate(NULL, NULL);
}
......@@ -130,6 +130,8 @@ void keybindings_free(void);
/* 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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment