[gnome-photos] Disable deleting from the preview while loading and if unsupported
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-photos] Disable deleting from the preview while loading and if unsupported
- Date: Mon, 8 Feb 2016 17:47:32 +0000 (UTC)
commit e8267ea270688a139de10459f28a67621eca80ac
Author: Rafael Fonseca <r4f4rfs gmail com>
Date: Tue Feb 2 16:53:58 2016 +0100
Disable deleting from the preview while loading and if unsupported
Take this opportunity to consolidate the enable/disable logic in one
place by using the GAction.
https://bugzilla.gnome.org/show_bug.cgi?id=761587
src/photos-application.c | 30 ++++++++++++++++++++++++------
src/photos-selection-toolbar.c | 7 -------
2 files changed, 24 insertions(+), 13 deletions(-)
---
diff --git a/src/photos-application.c b/src/photos-application.c
index 4a961fb..98fdcc6 100644
--- a/src/photos-application.c
+++ b/src/photos-application.c
@@ -71,6 +71,7 @@ struct _PhotosApplicationPrivate
GSettings *ss_settings;
GSimpleAction *brightness_contrast_action;
GSimpleAction *crop_action;
+ GSimpleAction *delete_action;
GSimpleAction *denoise_action;
GSimpleAction *edit_action;
GSimpleAction *edit_cancel_action;
@@ -294,13 +295,18 @@ photos_application_actions_update (PhotosApplication *self)
{
PhotosApplicationPrivate *priv = self->priv;
PhotosBaseItem *item;
+ GList *l;
+ GList *selection;
PhotosLoadState load_state;
PhotosWindowMode mode;
gboolean enable;
+ gboolean selection_mode;
item = photos_application_get_selection_or_active_item (self);
load_state = photos_item_manager_get_load_state (priv->state->item_mngr);
mode = photos_mode_controller_get_window_mode (priv->state->mode_cntrlr);
+ selection = photos_selection_controller_get_selection (priv->sel_cntrlr);
+ selection_mode = photos_selection_controller_get_selection_mode (priv->sel_cntrlr);
enable = (mode == PHOTOS_WINDOW_MODE_EDIT);
g_simple_action_set_enabled (priv->brightness_contrast_action, enable);
@@ -339,12 +345,24 @@ photos_application_actions_update (PhotosApplication *self)
g_simple_action_set_enabled (priv->set_ss_action, enable);
enable = ((load_state == PHOTOS_LOAD_STATE_FINISHED && mode == PHOTOS_WINDOW_MODE_PREVIEW)
- || (photos_selection_controller_get_selection_mode (priv->sel_cntrlr)
- && item != NULL
- && !photos_base_item_is_collection (item)));
+ || (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);
+ enable = ((load_state == PHOTOS_LOAD_STATE_FINISHED
+ && mode == PHOTOS_WINDOW_MODE_PREVIEW
+ && photos_base_item_can_trash (item))
+ || (selection_mode && selection != NULL));
+ for (l = selection; l != NULL; l = l->next)
+ {
+ PhotosBaseItem *selected_item;
+ const gchar *urn = (gchar *) l->data;
+
+ selected_item = PHOTOS_BASE_ITEM (photos_base_manager_get_object_by_id (priv->state->item_mngr, urn));
+ enable = enable && photos_base_item_can_trash (selected_item);
+ }
+ g_simple_action_set_enabled (priv->delete_action, enable);
+
enable = (load_state == PHOTOS_LOAD_STATE_FINISHED
&& mode == PHOTOS_WINDOW_MODE_PREVIEW
&& photos_base_item_can_edit (item));
@@ -1373,9 +1391,8 @@ photos_application_startup (GApplication *application)
g_action_map_add_action (G_ACTION_MAP (self), G_ACTION (priv->crop_action));
g_variant_type_free (parameter_type);
- action = g_simple_action_new ("delete", NULL);
- g_action_map_add_action (G_ACTION_MAP (self), G_ACTION (action));
- g_object_unref (action);
+ priv->delete_action = g_simple_action_new ("delete", NULL);
+ g_action_map_add_action (G_ACTION_MAP (self), G_ACTION (priv->delete_action));
priv->denoise_action = g_simple_action_new ("denoise-current", G_VARIANT_TYPE_UINT16);
g_action_map_add_action (G_ACTION_MAP (self), G_ACTION (priv->denoise_action));
@@ -1575,6 +1592,7 @@ photos_application_dispose (GObject *object)
g_clear_object (&priv->ss_settings);
g_clear_object (&priv->brightness_contrast_action);
g_clear_object (&priv->crop_action);
+ g_clear_object (&priv->delete_action);
g_clear_object (&priv->denoise_action);
g_clear_object (&priv->edit_action);
g_clear_object (&priv->edit_cancel_action);
diff --git a/src/photos-selection-toolbar.c b/src/photos-selection-toolbar.c
index a971b7b..cf03427 100644
--- a/src/photos-selection-toolbar.c
+++ b/src/photos-selection-toolbar.c
@@ -50,7 +50,6 @@ struct _PhotosSelectionToolbar
GtkWidget *toolbar_favorite;
GtkWidget *toolbar_open;
GtkWidget *toolbar_properties;
- GtkWidget *toolbar_trash;
PhotosBaseManager *item_mngr;
PhotosSelectionController *sel_cntrlr;
gboolean inside_refresh;
@@ -255,7 +254,6 @@ photos_selection_toolbar_set_item_visibility (PhotosSelectionToolbar *self)
gboolean show_favorite;
gboolean show_open;
gboolean show_properties;
- gboolean show_trash;
gchar *favorite_label;
gchar *open_label;
guint fav_count = 0;
@@ -270,7 +268,6 @@ photos_selection_toolbar_set_item_visibility (PhotosSelectionToolbar *self)
show_favorite = has_selection;
show_open = has_selection;
show_properties = has_selection;
- show_trash = has_selection;
for (l = selection; l != NULL; l = g_list_next (l))
{
@@ -288,8 +285,6 @@ photos_selection_toolbar_set_item_visibility (PhotosSelectionToolbar *self)
&& g_list_find_custom (apps, default_app_name, (GCompareFunc) g_strcmp0) == NULL)
apps = g_list_prepend (apps, (gpointer) g_strdup (default_app_name));
- show_trash = show_trash && photos_base_item_can_trash (item);
-
sel_length++;
}
@@ -329,7 +324,6 @@ photos_selection_toolbar_set_item_visibility (PhotosSelectionToolbar *self)
gtk_widget_set_sensitive (self->toolbar_collection, show_collection);
gtk_widget_set_sensitive (self->toolbar_properties, show_properties);
- gtk_widget_set_sensitive (self->toolbar_trash, show_trash);
gtk_widget_set_sensitive (self->toolbar_open, show_open);
gtk_widget_set_sensitive (self->toolbar_favorite, show_favorite);
@@ -448,7 +442,6 @@ 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_trash);
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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]