[gnome-calendar] app: automatically load resources from base path
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-calendar] app: automatically load resources from base path
- Date: Tue, 16 Feb 2016 20:26:47 +0000 (UTC)
commit 9ff5e05f9c7c30a326d90ab2675c239bf5e62b2b
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Tue Feb 16 18:12:18 2016 -0200
app: automatically load resources from base path
We don't have to load most of the menus we're currently loading
by using the very handy automatic resource loading.
This patch fixup so the app loads resources automagically.
data/calendar.gresource.xml | 5 ++++-
data/ui/menus.ui | 4 ++--
src/gcal-application.c | 32 +++++++-------------------------
src/gcal-source-dialog.c | 2 +-
src/gcal-window.c | 16 ++++++++--------
5 files changed, 22 insertions(+), 37 deletions(-)
---
diff --git a/data/calendar.gresource.xml b/data/calendar.gresource.xml
index 70a5116..c456eb2 100644
--- a/data/calendar.gresource.xml
+++ b/data/calendar.gresource.xml
@@ -4,7 +4,6 @@
<file alias="calendar-row.ui" compressed="true" preprocess="xml-stripblanks">ui/calendar-row.ui</file>
<file alias="date-selector.ui" compressed="true" preprocess="xml-stripblanks">ui/date-selector.ui</file>
<file alias="edit-dialog.ui" compressed="true" preprocess="xml-stripblanks">ui/edit-dialog.ui</file>
- <file alias="menus.ui" compressed="true" preprocess="xml-stripblanks">ui/menus.ui</file>
<file alias="online-account-row.ui" compressed="true"
preprocess="xml-stripblanks">ui/online-account-row.ui</file>
<file alias="quick-add-popover.ui" compressed="true"
preprocess="xml-stripblanks">ui/quick-add-popover.ui</file>
<file alias="search-view.ui" compressed="true" preprocess="xml-stripblanks">ui/search-view.ui</file>
@@ -14,4 +13,8 @@
<file alias="year-view.ui" compressed="true" preprocess="xml-stripblanks">ui/year-view.ui</file>
<file alias="gtk-styles.css" compressed="true">theme/gtk-styles.css</file>
</gresource>
+
+ <gresource prefix="/org/gnome/calendar/gtk">
+ <file alias="menus.ui" compressed="true" preprocess="xml-stripblanks">ui/menus.ui</file>
+ </gresource>
</gresources>
diff --git a/data/ui/menus.ui b/data/ui/menus.ui
index 3ba78c6..b25f70d 100644
--- a/data/ui/menus.ui
+++ b/data/ui/menus.ui
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
<interface>
- <menu id="appmenu">
+ <menu id="app-menu">
<section>
<item>
<attribute name="label" translatable="yes">Add Eve_nt…</attribute>
@@ -25,7 +25,7 @@
</item>
</section>
</menu>
- <menu id="winmenu">
+ <menu id="win-menu">
<section>
<item>
<attribute name="label" translatable="yes">Add Eve_nt…</attribute>
diff --git a/src/gcal-application.c b/src/gcal-application.c
index 784503f..1a6304c 100644
--- a/src/gcal-application.c
+++ b/src/gcal-application.c
@@ -60,8 +60,6 @@ static void gcal_application_startup (GApplication *
static gint gcal_application_command_line (GApplication *app,
GApplicationCommandLine *command_line);
-static void gcal_application_set_app_menu (GApplication *app);
-
static void gcal_application_create_new_event (GSimpleAction *new_event,
GVariant *parameter,
gpointer app);
@@ -260,8 +258,6 @@ gcal_application_activate (GApplication *application)
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION + 2);
}
- gcal_application_set_app_menu (application);
-
if (self->window != NULL)
{
gtk_window_present (GTK_WINDOW (self->window));
@@ -299,6 +295,12 @@ gcal_application_activate (GApplication *application)
static void
gcal_application_startup (GApplication *app)
{
+ /* add actions */
+ g_action_map_add_action_entries (G_ACTION_MAP (app),
+ gcal_app_entries,
+ G_N_ELEMENTS (gcal_app_entries),
+ app);
+
G_APPLICATION_CLASS (gcal_application_parent_class)->startup (app);
/* We're assuming the application is called as a service only by the shell search system */
@@ -412,27 +414,6 @@ gcal_application_dbus_unregister (GApplication *application,
}
static void
-gcal_application_set_app_menu (GApplication *app)
-{
- GtkBuilder *builder;
- GMenuModel *appmenu;
-
- builder = gtk_builder_new ();
- gtk_builder_add_from_resource (builder, "/org/gnome/calendar/menus.ui", NULL);
-
- appmenu = (GMenuModel *)gtk_builder_get_object (builder, "appmenu");
-
- g_action_map_add_action_entries (G_ACTION_MAP (app),
- gcal_app_entries,
- G_N_ELEMENTS (gcal_app_entries),
- app);
-
- gtk_application_set_app_menu (GTK_APPLICATION (app), appmenu);
-
- g_object_unref (builder);
-}
-
-static void
gcal_application_create_new_event (GSimpleAction *new_event,
GVariant *parameter,
gpointer app)
@@ -528,6 +509,7 @@ gcal_application_new (void)
g_set_application_name ("Calendar");
return g_object_new (gcal_application_get_type (),
+ "resource-base-path", "/org/gnome/calendar",
"application-id", "org.gnome.Calendar",
"flags", G_APPLICATION_HANDLES_COMMAND_LINE,
NULL);
diff --git a/src/gcal-source-dialog.c b/src/gcal-source-dialog.c
index cc6a6d7..ea61d79 100644
--- a/src/gcal-source-dialog.c
+++ b/src/gcal-source-dialog.c
@@ -1812,7 +1812,7 @@ gcal_source_dialog_constructed (GObject *object)
g_action_map_add_action_entries (G_ACTION_MAP (self->action_group), actions, G_N_ELEMENTS (actions),
object);
// Load the "Add" button menu
- builder = gtk_builder_new_from_resource ("/org/gnome/calendar/menus.ui");
+ builder = gtk_builder_new_from_resource ("/org/gnome/calendar/gtk/menus.ui");
menu = G_MENU_MODEL (gtk_builder_get_object (builder, "add-source-menu"));
gtk_menu_button_set_menu_model (GTK_MENU_BUTTON (self->add_calendar_menu_button), menu);
diff --git a/src/gcal-window.c b/src/gcal-window.c
index 9bcdf49..8cd8b98 100644
--- a/src/gcal-window.c
+++ b/src/gcal-window.c
@@ -1305,6 +1305,12 @@ gcal_window_class_init(GcalWindowClass *klass)
static void
gcal_window_init (GcalWindow *self)
{
+ /* Setup actions */
+ g_action_map_add_action_entries (G_ACTION_MAP (self),
+ actions,
+ G_N_ELEMENTS (actions),
+ self);
+
gtk_widget_init_template (GTK_WIDGET (self));
/* source dialog */
@@ -1336,19 +1342,13 @@ gcal_window_constructed (GObject *object)
g_free (clock_format);
g_object_unref (helper_settings);
- // Setup actions
- g_action_map_add_action_entries (G_ACTION_MAP (object),
- actions,
- G_N_ELEMENTS (actions),
- object);
-
/* header_bar: menu */
builder = gtk_builder_new ();
gtk_builder_add_from_resource (builder,
- "/org/gnome/calendar/menus.ui",
+ "/org/gnome/calendar/gtk/menus.ui",
NULL);
- winmenu = (GMenuModel *)gtk_builder_get_object (builder, "winmenu");
+ winmenu = (GMenuModel *)gtk_builder_get_object (builder, "win-menu");
gtk_menu_button_set_menu_model (GTK_MENU_BUTTON (window->menu_button),
winmenu);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]