[almanah] resources: Moved the UI file to GResource



commit 5ac492a9e4a26466e1ff9e391e9fbf70f9f2b715
Author: Álvaro Peña <alvaropg gmail com>
Date:   Sat Feb 14 19:18:00 2015 +0100

    resources: Moved the UI file to GResource
    
    The UI file has been moved into the GResource and removed the function
    to retrieve the UI file path.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=743086

 data/Makefile.am              |   10 ----------
 po/POTFILES.in                |    2 +-
 src/almanah.gresource.xml     |    1 +
 src/date-entry-dialog.c       |   11 +++++------
 src/import-export-dialog.c    |   20 ++++++++++++--------
 src/interface.c               |    9 ---------
 src/interface.h               |    1 -
 src/main-window.c             |   11 +++++------
 src/preferences-dialog.c      |   11 +++++------
 src/search-dialog.c           |   11 +++++------
 {data => src/ui}/almanah.ui   |    0
 src/uri-entry-dialog.c        |   11 +++++------
 src/widgets/calendar-button.c |    5 ++---
 13 files changed, 41 insertions(+), 62 deletions(-)
---
diff --git a/data/Makefile.am b/data/Makefile.am
index 76b6579..312aa91 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -21,16 +21,6 @@ update-icon-cache:
        fi
 
 ###############################################################################
-# UI file
-###############################################################################
-
-uidir = $(datadir)/almanah
-ui_DATA = \
-       almanah.ui
-
-EXTRA_DIST += $(ui_DATA)
-
-###############################################################################
 # Desktop file
 ###############################################################################
 
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 89c4800..10ac25d 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -2,7 +2,7 @@
 [encoding: UTF-8]
 data/almanah.appdata.xml.in
 data/almanah.desktop.in
-[type: gettext/glade]data/almanah.ui
+[type: gettext/glade]src/ui/almanah.ui
 [type: gettext/gsettings]data/org.gnome.almanah.gschema.xml.in
 src/application.c
 src/date-entry-dialog.c
diff --git a/src/almanah.gresource.xml b/src/almanah.gresource.xml
index d4239d7..8d78cde 100644
--- a/src/almanah.gresource.xml
+++ b/src/almanah.gresource.xml
@@ -3,5 +3,6 @@
   <gresource prefix="/org/gnome/Almanah">
     <file preprocess="xml-stripblanks">gtk/menus.ui</file>
     <file>css/almanah.css</file>
+    <file preprocess="xml-stripblanks">ui/almanah.ui</file>
   </gresource>
 </gresources>
diff --git a/src/date-entry-dialog.c b/src/date-entry-dialog.c
index ed77391..96d16ca 100644
--- a/src/date-entry-dialog.c
+++ b/src/date-entry-dialog.c
@@ -111,7 +111,6 @@ almanah_date_entry_dialog_new (void)
        AlmanahDateEntryDialog *date_entry_dialog;
        AlmanahDateEntryDialogPrivate *priv;
        GError *error = NULL;
-       const gchar *interface_filename = almanah_get_interface_filename ();
        const gchar *object_names[] = {
                "almanah_date_entry_dialog",
                "almanah_ui_manager", /* HACK: work around bgo#672789 */
@@ -120,13 +119,13 @@ almanah_date_entry_dialog_new (void)
 
        builder = gtk_builder_new ();
 
-       if (gtk_builder_add_objects_from_file (builder, interface_filename, (gchar**) object_names, &error) 
== FALSE) {
+       if (gtk_builder_add_objects_from_resource (builder, "/org/gnome/Almanah/ui/almanah.ui", (gchar**) 
object_names, &error) == 0) {
                /* Show an error */
                GtkWidget *dialog = gtk_message_dialog_new (NULL,
-                               GTK_DIALOG_MODAL,
-                               GTK_MESSAGE_ERROR,
-                               GTK_BUTTONS_OK,
-                               _("UI file \"%s\" could not be loaded"), interface_filename);
+                                                           GTK_DIALOG_MODAL,
+                                                           GTK_MESSAGE_ERROR,
+                                                           GTK_BUTTONS_OK,
+                                                           _("UI data could not be loaded"));
                gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog), "%s", error->message);
                gtk_dialog_run (GTK_DIALOG (dialog));
                gtk_widget_destroy (dialog);
diff --git a/src/import-export-dialog.c b/src/import-export-dialog.c
index a43e354..099d9ed 100644
--- a/src/import-export-dialog.c
+++ b/src/import-export-dialog.c
@@ -150,7 +150,6 @@ almanah_import_export_dialog_new (AlmanahStorageManager *storage_manager, gboole
        AlmanahImportExportDialog *import_export_dialog;
        AlmanahImportExportDialogPrivate *priv;
        GError *error = NULL;
-       const gchar *interface_filename = almanah_get_interface_filename ();
        const gchar *object_names[] = {
                "almanah_ied_mode_store",
                "almanah_import_export_dialog",
@@ -162,10 +161,13 @@ almanah_import_export_dialog_new (AlmanahStorageManager *storage_manager, gboole
 
        builder = gtk_builder_new ();
 
-       if (gtk_builder_add_objects_from_file (builder, interface_filename, (gchar**) object_names, &error) 
== FALSE) {
+       if (gtk_builder_add_objects_from_resource (builder, "/org/gnome/Almanah/ui/almanah.ui", (gchar**) 
object_names, &error) == 0) {
                /* Show an error */
-               GtkWidget *dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, 
GTK_BUTTONS_OK,
-                                                           _("UI file \"%s\" could not be loaded"), 
interface_filename);
+               GtkWidget *dialog = gtk_message_dialog_new (NULL,
+                                                           GTK_DIALOG_MODAL,
+                                                           GTK_MESSAGE_ERROR,
+                                                           GTK_BUTTONS_OK,
+                                                           _("UI data could not be loaded"));
                gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog), "%s", error->message);
                gtk_dialog_run (GTK_DIALOG (dialog));
                gtk_widget_destroy (dialog);
@@ -454,7 +456,6 @@ almanah_import_results_dialog_new (void)
        AlmanahImportResultsDialog *results_dialog;
        AlmanahImportResultsDialogPrivate *priv;
        GError *error = NULL;
-       const gchar *interface_filename = almanah_get_interface_filename ();
        const gchar *object_names[] = {
                "almanah_ird_view_store",
                "almanah_ird_results_store",
@@ -466,10 +467,13 @@ almanah_import_results_dialog_new (void)
 
        builder = gtk_builder_new ();
 
-       if (gtk_builder_add_objects_from_file (builder, interface_filename, (gchar**) object_names, &error) 
== FALSE) {
+       if (gtk_builder_add_objects_from_resource (builder, "/org/gnome/Almanah/ui/almanah.ui", (gchar**) 
object_names, &error) == 0) {
                /* Show an error */
-               GtkWidget *dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, 
GTK_BUTTONS_OK,
-                                                           _("UI file \"%s\" could not be loaded"), 
interface_filename);
+               GtkWidget *dialog = gtk_message_dialog_new (NULL,
+                                                           GTK_DIALOG_MODAL,
+                                                           GTK_MESSAGE_ERROR,
+                                                           GTK_BUTTONS_OK,
+                                                           _("UI data could not be loaded"));
                gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog), "%s", error->message);
                gtk_dialog_run (GTK_DIALOG (dialog));
                gtk_widget_destroy (dialog);
diff --git a/src/interface.c b/src/interface.c
index cd302b0..c83823f 100644
--- a/src/interface.c
+++ b/src/interface.c
@@ -26,15 +26,6 @@
 #include "interface.h"
 
 const gchar *
-almanah_get_interface_filename (void)
-{
-       if (g_file_test ("./data/almanah.ui", G_FILE_TEST_EXISTS) == TRUE)
-               return "./data/almanah.ui";
-       else
-               return PACKAGE_DATA_DIR"/almanah/almanah.ui";
-}
-
-const gchar *
 almanah_get_interface_app_menu_filename (void)
 {
        if (g_file_test ("./data/almanah-app-menu.ui", G_FILE_TEST_EXISTS) == TRUE)
diff --git a/src/interface.h b/src/interface.h
index 6591b5d..f025b8b 100644
--- a/src/interface.h
+++ b/src/interface.h
@@ -24,7 +24,6 @@
 
 G_BEGIN_DECLS
 
-const gchar *almanah_get_interface_filename (void);
 const gchar *almanah_get_interface_app_menu_filename (void);
 void almanah_interface_create_text_tags (GtkTextBuffer *text_buffer, gboolean connect_events);
 void almanah_calendar_month_changed_cb (GtkCalendar *calendar, gpointer user_data);
diff --git a/src/main-window.c b/src/main-window.c
index f3f8e6e..6a427c9 100644
--- a/src/main-window.c
+++ b/src/main-window.c
@@ -187,7 +187,6 @@ almanah_main_window_new (AlmanahApplication *application)
        AlmanahMainWindowPrivate *priv;
        GError *error = NULL;
        AlmanahStorageManager *storage_manager;
-       const gchar *interface_filename = almanah_get_interface_filename ();
        const gchar *object_names[] = {
                "almanah_main_window",
                "almanah_mw_event_store",
@@ -198,13 +197,13 @@ almanah_main_window_new (AlmanahApplication *application)
 
        builder = gtk_builder_new ();
 
-       if (gtk_builder_add_objects_from_file (builder, interface_filename, (gchar**) object_names, &error) 
== FALSE) {
+       if (gtk_builder_add_objects_from_resource (builder, "/org/gnome/Almanah/ui/almanah.ui", (gchar**) 
object_names, &error) == 0) {
                /* Show an error */
                GtkWidget *dialog = gtk_message_dialog_new (NULL,
-                               GTK_DIALOG_MODAL,
-                               GTK_MESSAGE_ERROR,
-                               GTK_BUTTONS_OK,
-                               _("UI file \"%s\" could not be loaded"), interface_filename);
+                                                           GTK_DIALOG_MODAL,
+                                                           GTK_MESSAGE_ERROR,
+                                                           GTK_BUTTONS_OK,
+                                                           _("UI data could not be loaded"));
                gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog), "%s", error->message);
                gtk_dialog_run (GTK_DIALOG (dialog));
                gtk_widget_destroy (dialog);
diff --git a/src/preferences-dialog.c b/src/preferences-dialog.c
index 3f9d912..9bfd612 100644
--- a/src/preferences-dialog.c
+++ b/src/preferences-dialog.c
@@ -161,7 +161,6 @@ almanah_preferences_dialog_new (GSettings *settings)
        AlmanahPreferencesDialog *preferences_dialog;
        AlmanahPreferencesDialogPrivate *priv;
        GError *error = NULL;
-       const gchar *interface_filename = almanah_get_interface_filename ();
        const gchar *object_names[] = {
                "almanah_preferences_dialog",
                "almanah_ui_manager", /* HACK: work around bgo#672789 */
@@ -172,13 +171,13 @@ almanah_preferences_dialog_new (GSettings *settings)
 
        builder = gtk_builder_new ();
 
-       if (gtk_builder_add_objects_from_file (builder, interface_filename, (gchar**) object_names, &error) 
== FALSE) {
+       if (gtk_builder_add_objects_from_resource (builder, "/org/gnome/Almanah/ui/almanah.ui", (gchar**) 
object_names, &error) == 0) {
                /* Show an error */
                GtkWidget *dialog = gtk_message_dialog_new (NULL,
-                               GTK_DIALOG_MODAL,
-                               GTK_MESSAGE_ERROR,
-                               GTK_BUTTONS_OK,
-                               _("UI file \"%s\" could not be loaded"), interface_filename);
+                                                           GTK_DIALOG_MODAL,
+                                                           GTK_MESSAGE_ERROR,
+                                                           GTK_BUTTONS_OK,
+                                                           _("UI data could not be loaded"));
                gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog), "%s", error->message);
                gtk_dialog_run (GTK_DIALOG (dialog));
                gtk_widget_destroy (dialog);
diff --git a/src/search-dialog.c b/src/search-dialog.c
index d8b75e3..90d9bf8 100644
--- a/src/search-dialog.c
+++ b/src/search-dialog.c
@@ -76,7 +76,6 @@ almanah_search_dialog_new (void)
        AlmanahSearchDialog *search_dialog;
        AlmanahSearchDialogPrivate *priv;
        GError *error = NULL;
-       const gchar *interface_filename = almanah_get_interface_filename ();
        const gchar *object_names[] = {
                "almanah_search_dialog",
                "almanah_sd_search_button_image",
@@ -88,13 +87,13 @@ almanah_search_dialog_new (void)
 
        builder = gtk_builder_new ();
 
-       if (gtk_builder_add_objects_from_file (builder, interface_filename, (gchar**) object_names, &error) 
== FALSE) {
+       if (gtk_builder_add_objects_from_resource (builder, "/org/gnome/Almanah/ui/almanah.ui", (gchar**) 
object_names, &error) == 0) {
                /* Show an error */
                GtkWidget *dialog = gtk_message_dialog_new (NULL,
-                               GTK_DIALOG_MODAL,
-                               GTK_MESSAGE_ERROR,
-                               GTK_BUTTONS_OK,
-                               _("UI file \"%s\" could not be loaded"), interface_filename);
+                                                           GTK_DIALOG_MODAL,
+                                                           GTK_MESSAGE_ERROR,
+                                                           GTK_BUTTONS_OK,
+                                                           _("UI data could not be loaded"));
                gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog), "%s", error->message);
                gtk_dialog_run (GTK_DIALOG (dialog));
                gtk_widget_destroy (dialog);
diff --git a/data/almanah.ui b/src/ui/almanah.ui
similarity index 100%
rename from data/almanah.ui
rename to src/ui/almanah.ui
diff --git a/src/uri-entry-dialog.c b/src/uri-entry-dialog.c
index 7ac129c..7c2f270 100644
--- a/src/uri-entry-dialog.c
+++ b/src/uri-entry-dialog.c
@@ -110,7 +110,6 @@ almanah_uri_entry_dialog_new (void)
        AlmanahUriEntryDialog *uri_entry_dialog;
        AlmanahUriEntryDialogPrivate *priv;
        GError *error = NULL;
-       const gchar *interface_filename = almanah_get_interface_filename ();
        const gchar *object_names[] = {
                "almanah_uri_entry_dialog",
                "almanah_ui_manager", /* HACK: work around bgo#672789 */
@@ -119,13 +118,13 @@ almanah_uri_entry_dialog_new (void)
 
        builder = gtk_builder_new ();
 
-       if (gtk_builder_add_objects_from_file (builder, interface_filename, (gchar**) object_names, &error) 
== FALSE) {
+       if (gtk_builder_add_objects_from_resource (builder, "/org/gnome/Almanah/ui/almanah.ui", (gchar**) 
object_names, &error) == 0) {
                /* Show an error */
                GtkWidget *dialog = gtk_message_dialog_new (NULL,
-                               GTK_DIALOG_MODAL,
-                               GTK_MESSAGE_ERROR,
-                               GTK_BUTTONS_OK,
-                               _("UI file \"%s\" could not be loaded"), interface_filename);
+                                                           GTK_DIALOG_MODAL,
+                                                           GTK_MESSAGE_ERROR,
+                                                           GTK_BUTTONS_OK,
+                                                           _("UI data could not be loaded"));
                gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog), "%s", error->message);
                gtk_dialog_run (GTK_DIALOG (dialog));
                gtk_widget_destroy (dialog);
diff --git a/src/widgets/calendar-button.c b/src/widgets/calendar-button.c
index 8e9b706..8888f2e 100644
--- a/src/widgets/calendar-button.c
+++ b/src/widgets/calendar-button.c
@@ -130,7 +130,6 @@ almanah_calendar_button_init (AlmanahCalendarButton *self)
        GtkBox *main_box;
        GtkBuilder *builder;
        GError *error = NULL;
-       const gchar *interface_filename = almanah_get_interface_filename ();
        const gchar *object_names[] = {
                "almanah_calendar_window",
                NULL
@@ -153,8 +152,8 @@ almanah_calendar_button_init (AlmanahCalendarButton *self)
 
        /* Calendar dock window from the UI file */
        builder = gtk_builder_new ();
-       if (gtk_builder_add_objects_from_file (builder, interface_filename, (gchar **) object_names, &error) 
== FALSE) {
-               g_warning (_("UI file \"%s\" could not be loaded: %s"), interface_filename, error->message);
+       if (gtk_builder_add_objects_from_resource (builder, "/org/gnome/Almanah/ui/almanah.ui", (gchar **) 
object_names, &error) == 0) {
+               g_warning (_("UI data could not be loaded: %s"), error->message);
                g_error_free (error);
                g_object_unref (builder);
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]