[gnome-photos] application, selection-toolbar: Use the GAction for properties



commit 1d89b08a3834a34eb3ae7e0a72a8c694146c5389
Author: Rafael Fonseca <r4f4rfs gmail com>
Date:   Mon Feb 29 20:39:31 2016 +0100

    application, selection-toolbar: Use the GAction for properties
    
    https://bugzilla.gnome.org/show_bug.cgi?id=761587

 src/photos-application.c        |   21 ++++++++++++++---
 src/photos-selection-toolbar.c  |   45 ---------------------------------------
 src/photos-selection-toolbar.ui |    3 +-
 3 files changed, 18 insertions(+), 51 deletions(-)
---
diff --git a/src/photos-application.c b/src/photos-application.c
index aae059b..a3eaa99 100644
--- a/src/photos-application.c
+++ b/src/photos-application.c
@@ -339,11 +339,14 @@ photos_application_actions_update (PhotosApplication *self)
 
   enable = (load_state == PHOTOS_LOAD_STATE_FINISHED && mode == PHOTOS_WINDOW_MODE_PREVIEW);
   g_simple_action_set_enabled (priv->gear_action, enable);
-  g_simple_action_set_enabled (priv->properties_action, enable);
   g_simple_action_set_enabled (priv->set_bg_action, enable);
   g_simple_action_set_enabled (priv->set_ss_action, enable);
 
   enable = ((load_state == PHOTOS_LOAD_STATE_FINISHED && mode == PHOTOS_WINDOW_MODE_PREVIEW)
+            || (selection_mode && item != NULL));
+  g_simple_action_set_enabled (priv->properties_action, enable);
+
+  enable = ((load_state == PHOTOS_LOAD_STATE_FINISHED && mode == PHOTOS_WINDOW_MODE_PREVIEW)
             || (selection_mode && item != NULL && !photos_base_item_is_collection (item)));
   g_simple_action_set_enabled (priv->print_action, enable);
   g_simple_action_set_enabled (priv->save_action, enable);
@@ -842,20 +845,30 @@ photos_application_print_current (PhotosApplication *self)
 
 
 static void
+photos_application_properties_response (GtkDialog *dialog, gint response_id, gpointer user_data)
+{
+  PhotosApplication *self = PHOTOS_APPLICATION (user_data);
+
+  gtk_widget_destroy (GTK_WIDGET (dialog));
+  photos_selection_controller_set_selection_mode (self->priv->sel_cntrlr, FALSE);
+}
+
+
+static void
 photos_application_properties (PhotosApplication *self)
 {
   PhotosApplicationPrivate *priv = self->priv;
-  GObject *item;
   GtkWidget *dialog;
+  PhotosBaseItem *item;
   const gchar *id;
 
-  item = photos_base_manager_get_active_object (priv->state->item_mngr);
+  item = photos_application_get_selection_or_active_item (self);
   g_return_if_fail (item != NULL);
 
   id = photos_filterable_get_id (PHOTOS_FILTERABLE (item));
   dialog = photos_properties_dialog_new (GTK_WINDOW (priv->main_window), id);
   gtk_widget_show_all (dialog);
-  g_signal_connect (dialog, "response", G_CALLBACK (gtk_widget_destroy), NULL);
+  g_signal_connect (dialog, "response", G_CALLBACK (photos_application_properties_response), self);
 }
 
 
diff --git a/src/photos-selection-toolbar.c b/src/photos-selection-toolbar.c
index f0fcb3b..d14fa0b 100644
--- a/src/photos-selection-toolbar.c
+++ b/src/photos-selection-toolbar.c
@@ -35,7 +35,6 @@
 #include "photos-delete-notification.h"
 #include "photos-icons.h"
 #include "photos-organize-collection-dialog.h"
-#include "photos-properties-dialog.h"
 #include "photos-search-context.h"
 #include "photos-selection-controller.h"
 #include "photos-selection-toolbar.h"
@@ -49,7 +48,6 @@ struct _PhotosSelectionToolbar
   GtkWidget *toolbar_collection;
   GtkWidget *toolbar_favorite;
   GtkWidget *toolbar_open;
-  GtkWidget *toolbar_properties;
   PhotosBaseManager *item_mngr;
   PhotosSelectionController *sel_cntrlr;
   gboolean inside_refresh;
@@ -185,39 +183,6 @@ photos_selection_toolbar_favorite_clicked (GtkButton *button, gpointer user_data
 
 
 static void
-photos_selection_toolbar_properties_response (GtkDialog *dialog, gint response_id, gpointer user_data)
-{
-  PhotosSelectionToolbar *self = PHOTOS_SELECTION_TOOLBAR (user_data);
-
-  gtk_widget_destroy (GTK_WIDGET (dialog));
-  photos_selection_controller_set_selection_mode (self->sel_cntrlr, FALSE);
-}
-
-
-static void
-photos_selection_toolbar_properties_clicked (GtkButton *button, gpointer user_data)
-{
-  PhotosSelectionToolbar *self = PHOTOS_SELECTION_TOOLBAR (user_data);
-  GList *selection;
-  GList *windows;
-  GApplication *app;
-  GtkWidget *dialog;
-  const gchar *urn;
-
-  app = g_application_get_default ();
-  windows = gtk_application_get_windows (GTK_APPLICATION (app));
-
-  selection = photos_selection_controller_get_selection (self->sel_cntrlr);
-  urn = (gchar *) selection->data;
-
-  dialog = photos_properties_dialog_new (GTK_WINDOW (windows->data), urn);
-  gtk_widget_show_all (dialog);
-
-  g_signal_connect (dialog, "response", G_CALLBACK (photos_selection_toolbar_properties_response), self);
-}
-
-
-static void
 photos_selection_toolbar_set_item_visibility (PhotosSelectionToolbar *self)
 {
   GList *apps = NULL;
@@ -227,7 +192,6 @@ photos_selection_toolbar_set_item_visibility (PhotosSelectionToolbar *self)
   gboolean has_selection;
   gboolean show_collection;
   gboolean show_favorite;
-  gboolean show_properties;
   gchar *favorite_label;
   gchar *open_label;
   guint fav_count = 0;
@@ -240,7 +204,6 @@ photos_selection_toolbar_set_item_visibility (PhotosSelectionToolbar *self)
 
   show_collection = has_selection;
   show_favorite = has_selection;
-  show_properties = has_selection;
 
   for (l = selection; l != NULL; l = g_list_next (l))
     {
@@ -263,11 +226,6 @@ photos_selection_toolbar_set_item_visibility (PhotosSelectionToolbar *self)
 
   show_favorite = show_favorite && ((fav_count == 0) || (fav_count == sel_length));
 
-  if (sel_length > 1)
-    {
-      show_properties = FALSE;
-    }
-
   if (apps != NULL && apps->next == NULL) /* length == 1 */
     /* Translators: this is the Open action in a context menu */
     open_label = g_strdup_printf (_("Open with %s"), (gchar *) apps->data);
@@ -295,7 +253,6 @@ photos_selection_toolbar_set_item_visibility (PhotosSelectionToolbar *self)
   g_free (favorite_label);
 
   gtk_widget_set_sensitive (self->toolbar_collection, show_collection);
-  gtk_widget_set_sensitive (self->toolbar_properties, show_properties);
   gtk_widget_set_sensitive (self->toolbar_favorite, show_favorite);
 
   self->inside_refresh = FALSE;
@@ -413,10 +370,8 @@ photos_selection_toolbar_class_init (PhotosSelectionToolbarClass *class)
   gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/Photos/selection-toolbar.ui");
   gtk_widget_class_bind_template_child (widget_class, PhotosSelectionToolbar, toolbar_favorite);
   gtk_widget_class_bind_template_child (widget_class, PhotosSelectionToolbar, toolbar_open);
-  gtk_widget_class_bind_template_child (widget_class, PhotosSelectionToolbar, toolbar_properties);
   gtk_widget_class_bind_template_child (widget_class, PhotosSelectionToolbar, toolbar_collection);
   gtk_widget_class_bind_template_callback (widget_class, photos_selection_toolbar_favorite_clicked);
-  gtk_widget_class_bind_template_callback (widget_class, photos_selection_toolbar_properties_clicked);
   gtk_widget_class_bind_template_callback (widget_class, photos_selection_toolbar_collection_clicked);
 }
 
diff --git a/src/photos-selection-toolbar.ui b/src/photos-selection-toolbar.ui
index ec69bec..656c0ce 100644
--- a/src/photos-selection-toolbar.ui
+++ b/src/photos-selection-toolbar.ui
@@ -82,8 +82,7 @@
         <object class="GtkButton" id="toolbar_properties">
           <property name="visible">1</property>
           <property name="label" translatable="yes">Properties</property>
-          <signal name="clicked" object="PhotosSelectionToolbar" swapped="no"
-                  handler="photos_selection_toolbar_properties_clicked" />
+          <property name="action_name">app.properties</property>
         </object>
         <packing>
           <property name="pack_type">end</property>


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