[gnome-photos/wip/search: 1/22] all: Use g_application_get_default instead of photos_application_new



commit 1f64e0152878a3cc7dbdf46144c9782accf8a62a
Author: Debarshi Ray <debarshir gnome org>
Date:   Sat Feb 15 09:55:22 2014 +0100

    all: Use g_application_get_default instead of photos_application_new
    
    ... so that PhotosApplication can stop being a singleton. Plus it is
    more convenient.

 src/photos-embed.c              |    6 ++----
 src/photos-main-toolbar.c       |   11 ++++-------
 src/photos-overview-searchbar.c |    6 ++----
 src/photos-searchbar.c          |    7 ++-----
 src/photos-selection-toolbar.c  |    9 +++------
 src/photos-view-container.c     |    7 ++-----
 6 files changed, 15 insertions(+), 31 deletions(-)
---
diff --git a/src/photos-embed.c b/src/photos-embed.c
index f2daeef..281f68f 100644
--- a/src/photos-embed.c
+++ b/src/photos-embed.c
@@ -29,7 +29,6 @@
 #include <gegl.h>
 #include <glib/gi18n.h>
 
-#include "photos-application.h"
 #include "photos-collection-manager.h"
 #include "photos-embed.h"
 #include "photos-filterable.h"
@@ -610,16 +609,15 @@ static void
 photos_embed_init (PhotosEmbed *self)
 {
   PhotosEmbedPrivate *priv;
-  GtkApplication *app;
+  GApplication *app;
   gboolean querying;
 
   self->priv = photos_embed_get_instance_private (self);
   priv = self->priv;
 
-  app = photos_application_new ();
+  app = g_application_get_default ();
   priv->search_action = g_action_map_lookup_action (G_ACTION_MAP (app), "search");
   g_signal_connect_swapped (app, "window-added", G_CALLBACK (photos_embed_window_added), self);
-  g_object_unref (app);
 
   gtk_orientable_set_orientation (GTK_ORIENTABLE (self), GTK_ORIENTATION_VERTICAL);
   gtk_widget_show (GTK_WIDGET (self));
diff --git a/src/photos-main-toolbar.c b/src/photos-main-toolbar.c
index 8252661..f657c7a 100644
--- a/src/photos-main-toolbar.c
+++ b/src/photos-main-toolbar.c
@@ -30,7 +30,6 @@
 #include <glib/gi18n.h>
 #include <libgd/gd.h>
 
-#include "photos-application.h"
 #include "photos-collection-manager.h"
 #include "photos-dlna-renderers-manager.h"
 #include "photos-dropdown.h"
@@ -511,7 +510,7 @@ photos_main_toolbar_populate_for_preview (PhotosMainToolbar *self)
   GMenu *preview_menu;
   GtkWidget *back_button;
   GtkWidget *menu_button;
-  GtkApplication *app;
+  GApplication *app;
   gboolean remote_display_available;
   GAction *remote_display_action;
 
@@ -532,11 +531,10 @@ photos_main_toolbar_populate_for_preview (PhotosMainToolbar *self)
 
   /* Disable the remote-display-current action if the dLeyna services are not
    * available */
-  app = photos_application_new ();
+  app = g_application_get_default ();
   remote_display_action = g_action_map_lookup_action (G_ACTION_MAP (app), "remote-display-current");
   remote_display_available = photos_dlna_renderers_manager_is_available ();
   g_simple_action_set_enabled (G_SIMPLE_ACTION (remote_display_action), remote_display_available);
-  g_object_unref (app);
 
   g_signal_connect (priv->item_mngr, "active-changed", G_CALLBACK (photos_main_toolbar_item_active_changed), 
self);
 }
@@ -704,7 +702,7 @@ photos_main_toolbar_init (PhotosMainToolbar *self)
 {
   PhotosMainToolbarPrivate *priv;
   GMenu *selection_menu;
-  GtkApplication *app;
+  GApplication *app;
   GtkBuilder *builder;
 
   self->priv = photos_main_toolbar_get_instance_private (self);
@@ -717,10 +715,9 @@ photos_main_toolbar_init (PhotosMainToolbar *self)
   gtk_container_add (GTK_CONTAINER (self), priv->toolbar);
   gtk_widget_show (priv->toolbar);
 
-  app = photos_application_new ();
+  app = g_application_get_default ();
   priv->gear_menu = G_SIMPLE_ACTION (g_action_map_lookup_action (G_ACTION_MAP (app), "gear-menu"));
   priv->search = g_action_map_lookup_action (G_ACTION_MAP (app), "search");
-  g_object_unref (app);
 
   builder = gtk_builder_new ();
   gtk_builder_add_from_resource (builder, "/org/gnome/photos/selection-menu.ui", NULL);
diff --git a/src/photos-overview-searchbar.c b/src/photos-overview-searchbar.c
index 78dd9c5..ec5f592 100644
--- a/src/photos-overview-searchbar.c
+++ b/src/photos-overview-searchbar.c
@@ -28,7 +28,6 @@
 #include <gio/gio.h>
 #include <libgd/gd.h>
 
-#include "photos-application.h"
 #include "photos-collection-manager.h"
 #include "photos-filterable.h"
 #include "photos-overview-searchbar.h"
@@ -345,14 +344,13 @@ static void
 photos_overview_searchbar_init (PhotosOverviewSearchbar *self)
 {
   PhotosOverviewSearchbarPrivate *priv;
-  GtkApplication *app;
+  GApplication *app;
 
   self->priv = photos_overview_searchbar_get_instance_private (self);
   priv = self->priv;
 
-  app = photos_application_new ();
+  app = g_application_get_default ();
   priv->select_all = g_action_map_lookup_action (G_ACTION_MAP (app), "select-all");
-  g_object_unref (app);
 
   priv->src_mngr = photos_source_manager_dup_singleton ();
   g_signal_connect_object (priv->src_mngr,
diff --git a/src/photos-searchbar.c b/src/photos-searchbar.c
index 63ace78..de765ea 100644
--- a/src/photos-searchbar.c
+++ b/src/photos-searchbar.c
@@ -28,13 +28,12 @@
 #include <glib.h>
 #include <libgd/gd.h>
 
-#include "photos-application.h"
 #include "photos-searchbar.h"
 
 
 struct _PhotosSearchbarPrivate
 {
-  GtkApplication *app;
+  GApplication *app;
   GtkWidget *search_container;
   GtkWidget *search_entry;
   GtkWidget *toolbar;
@@ -220,8 +219,6 @@ photos_searchbar_dispose (GObject *object)
   if (priv->app != NULL)
     photos_searchbar_enable_search (self, FALSE);
 
-  g_clear_object (&priv->app);
-
   G_OBJECT_CLASS (photos_searchbar_parent_class)->dispose (object);
 }
 
@@ -235,7 +232,7 @@ photos_searchbar_init (PhotosSearchbar *self)
   self->priv = photos_searchbar_get_instance_private (self);
   priv = self->priv;
 
-  priv->app = photos_application_new ();
+  priv->app = g_application_get_default ();
 
   priv->toolbar = gtk_toolbar_new ();
   context = gtk_widget_get_style_context (priv->toolbar);
diff --git a/src/photos-selection-toolbar.c b/src/photos-selection-toolbar.c
index 5aa3221..332d7fc 100644
--- a/src/photos-selection-toolbar.c
+++ b/src/photos-selection-toolbar.c
@@ -29,7 +29,6 @@
 #include <glib/gi18n.h>
 #include <libgd/gd.h>
 
-#include "photos-application.h"
 #include "photos-base-item.h"
 #include "photos-icons.h"
 #include "photos-item-manager.h"
@@ -193,12 +192,12 @@ photos_selection_toolbar_properties_clicked (GtkButton *button, gpointer user_da
   PhotosSelectionToolbarPrivate *priv = self->priv;
   GList *selection;
   GList *windows;
-  GtkApplication *app;
+  GApplication *app;
   GtkWidget *dialog;
   const gchar *urn;
 
-  app = photos_application_new ();
-  windows = gtk_application_get_windows (app);
+  app = g_application_get_default ();
+  windows = gtk_application_get_windows (GTK_APPLICATION (app));
 
   selection = photos_selection_controller_get_selection (priv->sel_cntrlr);
   urn = (gchar *) selection->data;
@@ -206,8 +205,6 @@ photos_selection_toolbar_properties_clicked (GtkButton *button, gpointer user_da
   dialog = photos_properties_dialog_new (GTK_WINDOW (windows->data), urn);
   gtk_widget_show_all (dialog);
 
-  g_object_unref (app);
-
   g_signal_connect (dialog, "response", G_CALLBACK (photos_selection_toolbar_properties_response), self);
 }
 
diff --git a/src/photos-view-container.c b/src/photos-view-container.c
index c06e7e0..e794d19 100644
--- a/src/photos-view-container.c
+++ b/src/photos-view-container.c
@@ -26,7 +26,6 @@
 #include "config.h"
 #include <libgd/gd.h>
 
-#include "photos-application.h"
 #include "photos-empty-results-box.h"
 #include "photos-enums.h"
 #include "photos-error-box.h"
@@ -283,7 +282,7 @@ photos_view_container_constructed (GObject *object)
   PhotosViewContainer *self = PHOTOS_VIEW_CONTAINER (object);
   PhotosViewContainerPrivate *priv = self->priv;
   GAction *action;
-  GtkApplication *app;
+  GApplication *app;
   GtkWidget *grid;
   gboolean status;
 
@@ -367,7 +366,7 @@ photos_view_container_constructed (GObject *object)
       break;
     }
 
-  app = photos_application_new ();
+  app = g_application_get_default ();
 
   action = g_action_map_lookup_action (G_ACTION_MAP (app), "select-all");
   g_signal_connect_swapped (action, "activate", G_CALLBACK (gd_main_view_select_all), priv->view);
@@ -375,8 +374,6 @@ photos_view_container_constructed (GObject *object)
   action = g_action_map_lookup_action (G_ACTION_MAP (app), "select-none");
   g_signal_connect_swapped (action, "activate", G_CALLBACK (gd_main_view_unselect_all), priv->view);
 
-  g_object_unref (app);
-
   g_signal_connect_object (priv->offset_cntrlr,
                            "count-changed",
                            G_CALLBACK (photos_view_container_count_changed),


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