[balsa/gtk3] Fix the address book editor accelerators
- From: Peter Bloomfield <peterb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [balsa/gtk3] Fix the address book editor accelerators
- Date: Thu, 19 Feb 2015 21:52:09 +0000 (UTC)
commit 2626243a0ef3da6ac52469db8bf5ca12b3b42b27
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date: Thu Feb 19 16:51:04 2015 -0500
Fix the address book editor accelerators
* libbalsa/application-helpers.c (libbalsa_window_set_accels):
new helper;
(libbalsa_window_get_menu_bar) use it.
* libbalsa/application-helpers.h: export it.
* src/ab-main.c (set_address_book_menu_items): use it.
ChangeLog | 10 ++++++++++
libbalsa/application-helpers.c | 25 ++++++++++++++++++++++---
libbalsa/application-helpers.h | 3 +++
src/ab-main.c | 10 +++++++---
4 files changed, 42 insertions(+), 6 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index a5db4f3..a442de0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,15 @@
2015-02-19 Peter Bloomfield <pbloomfield bellsouth net>
+ Make the address book editor accelerators actually work
+
+ * libbalsa/application-helpers.c (libbalsa_window_set_accels):
+ new helper;
+ (libbalsa_window_get_menu_bar) use it.
+ * libbalsa/application-helpers.h: export it.
+ * src/ab-main.c (set_address_book_menu_items): use it.
+
+2015-02-19 Peter Bloomfield <pbloomfield bellsouth net>
+
* libbalsa/address-book-text.c (lbab_text_group_address):
compile with MAKE_GROUP_BY_ORGANIZATION defined.
diff --git a/libbalsa/application-helpers.c b/libbalsa/application-helpers.c
index 399f585..cd28972 100644
--- a/libbalsa/application-helpers.c
+++ b/libbalsa/application-helpers.c
@@ -174,7 +174,6 @@ libbalsa_window_get_menu_bar(GtkApplicationWindow * window,
if (gtk_builder_add_from_file(builder, ui_file, error)) {
GMenuModel *menu_model;
GSList *accel_groups;
- GtkAccelGroup *accel_group;
menu_model =
G_MENU_MODEL(gtk_builder_get_object(builder, "menubar"));
@@ -187,8 +186,7 @@ libbalsa_window_get_menu_bar(GtkApplicationWindow * window,
/* Last is first... */
gtk_window_remove_accel_group(GTK_WINDOW(window),
accel_groups->data);
- accel_group = get_accel_group(menu_model, map);
- gtk_window_add_accel_group(GTK_WINDOW(window), accel_group);
+ libbalsa_window_set_accels(window, menu_model);
gtk_application_window_set_show_menubar(window, FALSE);
}
g_object_unref(builder);
@@ -197,6 +195,27 @@ libbalsa_window_get_menu_bar(GtkApplicationWindow * window,
}
/*
+ * libbalsa_window_set_accels
+ *
+ * Get the accelerators from a GMenuModel and add them to a
+ * GtkApplicationWindow
+ *
+ * window the GtkApplicationWindow
+ * menumodel the GMenuModel
+ */
+
+void
+libbalsa_window_set_accels(GtkApplicationWindow * window,
+ GMenuModel * menu_model)
+{
+ GtkAccelGroup *accel_group;
+
+ accel_group = get_accel_group(menu_model, G_ACTION_MAP(window));
+ gtk_window_add_accel_group(GTK_WINDOW(window), accel_group);
+ g_object_unref(accel_group);
+}
+
+/*
* libbalsa_window_add_accelerator
*
* Add an accelerator key combination for an action
diff --git a/libbalsa/application-helpers.h b/libbalsa/application-helpers.h
index b5da159..3d0804e 100644
--- a/libbalsa/application-helpers.h
+++ b/libbalsa/application-helpers.h
@@ -38,6 +38,9 @@ GtkWidget *libbalsa_window_get_menu_bar(GtkApplicationWindow * window,
GError ** error,
gpointer cb_data);
+void libbalsa_window_set_accels (GtkApplicationWindow * window,
+ GMenuModel * menu_model);
+
void libbalsa_window_add_accelerator (GtkApplicationWindow * window,
const gchar * accel,
const gchar * action_name);
diff --git a/src/ab-main.c b/src/ab-main.c
index 5fd7bc6..3bdddbc 100644
--- a/src/ab-main.c
+++ b/src/ab-main.c
@@ -262,6 +262,7 @@ set_address_book_menu_items(void)
guint pos;
gchar *s;
GtkBuilder *builder;
+ GMenuModel *menu_model;
pos = g_menu_model_get_n_items(G_MENU_MODEL (contacts_app.file_menu));
g_menu_remove(contacts_app.file_menu, --pos);
@@ -306,9 +307,12 @@ set_address_book_menu_items(void)
builder = gtk_builder_new_from_string(s, -1);
g_free(s);
- g_menu_append_section(contacts_app.file_menu, NULL,
- G_MENU_MODEL(gtk_builder_get_object
- (builder, "address-book-menu")));
+ menu_model =
+ G_MENU_MODEL(gtk_builder_get_object(builder, "address-book-menu"));
+ g_menu_append_section(contacts_app.file_menu, NULL, menu_model);
+ libbalsa_window_set_accels(GTK_APPLICATION_WINDOW(contacts_app.window),
+ menu_model);
+
g_object_unref(builder);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]