[gnome-photos] edit-palette, preview-view: Consolidate the mode changed handlers
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-photos] edit-palette, preview-view: Consolidate the mode changed handlers
- Date: Fri, 27 Nov 2015 17:55:53 +0000 (UTC)
commit 9547ce2efcc3e1af6c2234cbe81f5a791b4652ca
Author: Debarshi Ray <debarshir gnome org>
Date: Fri Nov 27 18:20:53 2015 +0100
edit-palette, preview-view: Consolidate the mode changed handlers
Relying on the order in which signal handlers are invoked is a recipe
for disaster. There is no reason why we need two different signal
handlers here, so let's consolidate them.
src/photos-edit-palette.c | 43 +++++++++++++------------------------------
src/photos-edit-palette.h | 2 ++
src/photos-preview-view.c | 10 ++++++----
3 files changed, 21 insertions(+), 34 deletions(-)
---
diff --git a/src/photos-edit-palette.c b/src/photos-edit-palette.c
index 956b253..ffddb8c 100644
--- a/src/photos-edit-palette.c
+++ b/src/photos-edit-palette.c
@@ -25,8 +25,6 @@
#include "photos-edit-palette.h"
#include "photos-edit-palette-row.h"
-#include "photos-item-manager.h"
-#include "photos-search-context.h"
#include "photos-tool.h"
#include "photos-utils.h"
@@ -35,7 +33,6 @@ struct _PhotosEditPalette
{
GtkListBox parent_instance;
GList *tools;
- PhotosModeController *mode_cntrlr;
};
struct _PhotosEditPaletteClass
@@ -80,19 +77,6 @@ photos_edit_palette_hide_requested (PhotosEditPalette *self)
static void
-photos_edit_palette_window_mode_changed (PhotosEditPalette *self, PhotosWindowMode mode, PhotosWindowMode
old_mode)
-{
- GtkListBoxRow *row;
- gint i;
-
- for (i = 0; (row = gtk_list_box_get_row_at_index (GTK_LIST_BOX (self), i)) != NULL; i++)
- photos_edit_palette_row_hide_details (PHOTOS_EDIT_PALETTE_ROW (row));
-
- g_signal_emit (self, signals[TOOL_CHANGED], 0, NULL);
-}
-
-
-static void
photos_edit_palette_row_activated (GtkListBox *box, GtkListBoxRow *row)
{
PhotosEditPalette *self = PHOTOS_EDIT_PALETTE (box);
@@ -144,8 +128,6 @@ photos_edit_palette_dispose (GObject *object)
g_list_free_full (self->tools, g_object_unref);
self->tools = NULL;
- g_clear_object (&self->mode_cntrlr);
-
G_OBJECT_CLASS (photos_edit_palette_parent_class)->dispose (object);
}
@@ -153,15 +135,10 @@ photos_edit_palette_dispose (GObject *object)
static void
photos_edit_palette_init (PhotosEditPalette *self)
{
- GApplication *app;
GIOExtensionPoint *extension_point;
GList *extensions;
GList *l;
GtkSizeGroup *size_group;
- PhotosSearchContextState *state;
-
- app = g_application_get_default ();
- state = photos_search_context_get_state (PHOTOS_SEARCH_CONTEXT (app));
gtk_widget_set_vexpand (GTK_WIDGET (self), TRUE);
gtk_list_box_set_selection_mode (GTK_LIST_BOX (self), GTK_SELECTION_NONE);
@@ -196,13 +173,6 @@ photos_edit_palette_init (PhotosEditPalette *self)
g_object_unref (tool);
}
- self->mode_cntrlr = g_object_ref (state->mode_cntrlr);
- g_signal_connect_object (self->mode_cntrlr,
- "window-mode-changed",
- G_CALLBACK (photos_edit_palette_window_mode_changed),
- self,
- G_CONNECT_SWAPPED);
-
gtk_widget_show_all (GTK_WIDGET (self));
g_object_unref (size_group);
g_list_free (extensions);
@@ -236,3 +206,16 @@ photos_edit_palette_new (void)
{
return g_object_new (PHOTOS_TYPE_EDIT_PALETTE, NULL);
}
+
+
+void
+photos_edit_palette_hide_details (PhotosEditPalette *self)
+{
+ GtkListBoxRow *row;
+ gint i;
+
+ for (i = 0; (row = gtk_list_box_get_row_at_index (GTK_LIST_BOX (self), i)) != NULL; i++)
+ photos_edit_palette_row_hide_details (PHOTOS_EDIT_PALETTE_ROW (row));
+
+ g_signal_emit (self, signals[TOOL_CHANGED], 0, NULL);
+}
diff --git a/src/photos-edit-palette.h b/src/photos-edit-palette.h
index f8150c1..f9bffc9 100644
--- a/src/photos-edit-palette.h
+++ b/src/photos-edit-palette.h
@@ -42,6 +42,8 @@ GType photos_edit_palette_get_type (void) G_GNUC_
GtkWidget *photos_edit_palette_new (void);
+void photos_edit_palette_hide_details (PhotosEditPalette *self);
+
G_END_DECLS
#endif /* PHOTOS_EDIT_PALETTE_H */
diff --git a/src/photos-preview-view.c b/src/photos-preview-view.c
index 2478639..0f6bd8c 100644
--- a/src/photos-preview-view.c
+++ b/src/photos-preview-view.c
@@ -44,6 +44,7 @@ struct _PhotosPreviewViewPrivate
{
GeglNode *node;
GtkWidget *overlay;
+ GtkWidget *palette;
GtkWidget *revealer;
GtkWidget *stack;
GtkWidget *view;
@@ -471,6 +472,7 @@ photos_preview_view_window_mode_changed (PhotosPreviewView *self, PhotosWindowMo
case PHOTOS_WINDOW_MODE_OVERVIEW:
case PHOTOS_WINDOW_MODE_SEARCH:
gtk_revealer_set_reveal_child (GTK_REVEALER (priv->revealer), FALSE);
+ photos_edit_palette_hide_details (PHOTOS_EDIT_PALETTE (priv->palette));
photos_preview_nav_buttons_hide (priv->nav_buttons);
photos_preview_nav_buttons_set_model (priv->nav_buttons, NULL, NULL);
break;
@@ -482,6 +484,7 @@ photos_preview_view_window_mode_changed (PhotosPreviewView *self, PhotosWindowMo
case PHOTOS_WINDOW_MODE_PREVIEW:
gtk_revealer_set_reveal_child (GTK_REVEALER (priv->revealer), FALSE);
+ photos_edit_palette_hide_details (PHOTOS_EDIT_PALETTE (priv->palette));
photos_preview_nav_buttons_show (priv->nav_buttons);
break;
@@ -547,7 +550,6 @@ photos_preview_view_init (PhotosPreviewView *self)
GAction *action;
GApplication *app;
GtkWidget *grid;
- GtkWidget *palette;
GtkWidget *sw;
GtkWidget *view_container;
PhotosSearchContextState *state;
@@ -594,9 +596,9 @@ photos_preview_view_init (PhotosPreviewView *self)
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw), GTK_SHADOW_IN);
gtk_container_add (GTK_CONTAINER (priv->revealer), sw);
- palette = photos_edit_palette_new ();
- gtk_container_add (GTK_CONTAINER (sw), palette);
- g_signal_connect_swapped (palette, "tool-changed", G_CALLBACK (photos_preview_view_tool_changed), self);
+ priv->palette = photos_edit_palette_new ();
+ gtk_container_add (GTK_CONTAINER (sw), priv->palette);
+ g_signal_connect_swapped (priv->palette, "tool-changed", G_CALLBACK (photos_preview_view_tool_changed),
self);
action = g_action_map_lookup_action (G_ACTION_MAP (app), "brightness-contrast-current");
g_signal_connect_object (action,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]