[gnome-photos/wip/abono/sidebar: 8/8] application: Add action to show/hide properties sidebar
- From: Alessandro Bono <abono src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-photos/wip/abono/sidebar: 8/8] application: Add action to show/hide properties sidebar
- Date: Mon, 7 Nov 2016 14:18:35 +0000 (UTC)
commit ab5dc9b1e577a484fe8d4fe0addbd094d176a1bc
Author: Alessandro Bono <abono gnome org>
Date: Thu Oct 27 13:15:46 2016 +0200
application: Add action to show/hide properties sidebar
The state of the action is tied to its gsetting key
value to make it persistent
data/org.gnome.photos.gschema.xml | 7 ++++++-
src/photos-application.c | 9 +++++++++
src/photos-preview-menu.ui | 4 ++--
src/photos-preview-view.c | 22 ++++++++++++++++++++++
4 files changed, 39 insertions(+), 3 deletions(-)
---
diff --git a/data/org.gnome.photos.gschema.xml b/data/org.gnome.photos.gschema.xml
index 7bbd903..d4da2ba 100644
--- a/data/org.gnome.photos.gschema.xml
+++ b/data/org.gnome.photos.gschema.xml
@@ -1,6 +1,11 @@
<schemalist gettext-domain="gnome-photos">
<schema id="org.gnome.photos" path="/org/gnome/photos/">
- <key name="window-size" type="ai">
+ <key name="show-properties-sidebar" type="b">
+ <default>false</default>
+ <summary>Show the properties sidebar</summary>
+ <description>Show the properties sidebar while viewing an image</description>
+ </key>
+ <key name="window-size" type="ai">
<default>[960, 600]</default>
<summary>Window size</summary>
<description>Window size (width and height).</description>
diff --git a/src/photos-application.c b/src/photos-application.c
index 6b7f3a3..4bb95a9 100644
--- a/src/photos-application.c
+++ b/src/photos-application.c
@@ -54,6 +54,7 @@
#include "photos-search-type.h"
#include "photos-search-provider.h"
#include "photos-selection-controller.h"
+#include "photos-settings.h"
#include "photos-single-item-job.h"
#include "photos-source.h"
#include "photos-source-manager.h"
@@ -355,6 +356,7 @@ photos_application_actions_update (PhotosApplication *self)
g_simple_action_set_enabled (self->gear_action, enable);
g_simple_action_set_enabled (self->set_bg_action, enable);
g_simple_action_set_enabled (self->set_ss_action, enable);
+ //g_simple_action_set_enabled (self->show_properties_sidebar_action, enable);
enable = ((load_state == PHOTOS_LOAD_STATE_FINISHED && mode == PHOTOS_WINDOW_MODE_PREVIEW)
|| (selection_mode && item != NULL));
@@ -1615,9 +1617,11 @@ static void
photos_application_startup (GApplication *application)
{
PhotosApplication *self = PHOTOS_APPLICATION (application);
+ GAction *t_action;
GError *error;
GSimpleAction *action;
GrlRegistry *registry;
+ GSettings *t_settings;
GtkIconTheme *icon_theme;
GtkSettings *settings;
GVariant *state;
@@ -1834,6 +1838,11 @@ photos_application_startup (GApplication *application)
self->sharpen_action = g_simple_action_new ("sharpen-current", G_VARIANT_TYPE_DOUBLE);
g_action_map_add_action (G_ACTION_MAP (self), G_ACTION (self->sharpen_action));
+ t_settings = photos_settings_new ();
+ t_action = g_settings_create_action (G_SETTINGS (t_settings), "show-properties-sidebar");
+ g_action_map_add_action (G_ACTION_MAP (self), G_ACTION (t_action));
+ g_clear_object (&t_settings);
+
g_signal_connect_swapped (self->state->mode_cntrlr,
"window-mode-changed",
G_CALLBACK (photos_application_window_mode_changed),
diff --git a/src/photos-preview-menu.ui b/src/photos-preview-menu.ui
index b72ff3b..69163a4 100644
--- a/src/photos-preview-menu.ui
+++ b/src/photos-preview-menu.ui
@@ -33,8 +33,8 @@
</section>
<section>
<item>
- <attribute name="action">app.properties</attribute>
- <attribute name="label" translatable="yes">Properties</attribute>
+ <attribute name="action">app.show-properties-sidebar</attribute>
+ <attribute name="label" translatable="yes">Show Properties</attribute>
</item>
</section>
</menu>
diff --git a/src/photos-preview-view.c b/src/photos-preview-view.c
index c863f51..021f0b3 100644
--- a/src/photos-preview-view.c
+++ b/src/photos-preview-view.c
@@ -40,6 +40,7 @@
#include "photos-preview-view.h"
#include "photos-properties-sidebar.h"
#include "photos-search-context.h"
+#include "photos-settings.h"
#include "photos-tool.h"
@@ -472,6 +473,18 @@ photos_preview_view_sharpen (PhotosPreviewView *self, GVariant *parameter)
NULL);
}
+static void
+photos_preview_set_properties_sidebar_visibility_from_settings (PhotosPreviewView *self)
+{
+ gboolean value;
+ GSettings *settings;
+
+ settings = photos_settings_new ();
+ value = g_settings_get_boolean (settings, "show-properties-sidebar");
+ g_clear_object (&settings);
+
+ gtk_revealer_set_reveal_child (GTK_REVEALER (self->properties_revealer), value);
+}
static void
photos_preview_view_tool_activated (PhotosTool *tool, gpointer user_data)
@@ -590,12 +603,14 @@ photos_preview_view_window_mode_changed (PhotosPreviewView *self, PhotosWindowMo
break;
case PHOTOS_WINDOW_MODE_EDIT:
+ gtk_revealer_set_reveal_child (GTK_REVEALER (self->properties_revealer), FALSE);
gtk_revealer_set_reveal_child (GTK_REVEALER (self->edit_revealer), TRUE);
photos_edit_palette_show (PHOTOS_EDIT_PALETTE (self->palette));
photos_preview_nav_buttons_hide (self->nav_buttons);
break;
case PHOTOS_WINDOW_MODE_PREVIEW:
+ photos_preview_set_properties_sidebar_visibility_from_settings (self);
gtk_revealer_set_reveal_child (GTK_REVEALER (self->edit_revealer), FALSE);
photos_edit_palette_hide_details (PHOTOS_EDIT_PALETTE (self->palette));
photos_preview_nav_buttons_show (self->nav_buttons);
@@ -646,6 +661,7 @@ photos_preview_view_init (PhotosPreviewView *self)
{
GAction *action;
GApplication *app;
+ GSettings *settings;
GtkWidget *overlay;
GtkWidget *sw;
GtkWidget *view_container;
@@ -696,6 +712,12 @@ photos_preview_view_init (PhotosPreviewView *self)
self->properties = photos_properties_sidebar_new ();
gtk_container_add (GTK_CONTAINER (self->properties_revealer), self->properties);
+ settings = photos_settings_new ();
+ g_signal_connect_swapped (settings,
+ "changed::show-properties-sidebar",
+ G_CALLBACK (photos_preview_set_properties_sidebar_visibility_from_settings),
+ self);
+ g_clear_object (&settings);
sw = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]