[gthumb] added a details page to the properties sidebar
- From: Paolo Bacchilega <paobac src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gthumb] added a details page to the properties sidebar
- Date: Thu, 30 Oct 2014 22:06:51 +0000 (UTC)
commit a4e5a16fd1b2e2af2a3ec6bc4353441d0396adb6
Author: Paolo Bacchilega <paobac src gnome org>
Date: Thu Oct 30 22:57:23 2014 +0100
added a details page to the properties sidebar
and removed the details button from the file properties page
data/org.gnome.gthumb.gschema.xml.in | 3 -
gthumb/Makefile.am | 2 +
gthumb/gth-file-details.c | 72 +++++++++++++++++++++
gthumb/gth-file-details.h | 52 +++++++++++++++
gthumb/gth-file-properties.c | 115 +++++++++++++++++++++------------
gthumb/gth-main-default-types.c | 2 +
gthumb/gth-preferences.h | 1 -
7 files changed, 201 insertions(+), 46 deletions(-)
---
diff --git a/data/org.gnome.gthumb.gschema.xml.in b/data/org.gnome.gthumb.gschema.xml.in
index 8ddd9d7..3677594 100644
--- a/data/org.gnome.gthumb.gschema.xml.in
+++ b/data/org.gnome.gthumb.gschema.xml.in
@@ -110,9 +110,6 @@
<key name="properties-on-the-right" type="b">
<default>false</default>
</key>
- <key name="properties-details" type="b">
- <default>false</default>
- </key>
<key name="thumbnail-list-visible" type="b">
<default>true</default>
</key>
diff --git a/gthumb/Makefile.am b/gthumb/Makefile.am
index 81e6f37..b95625c 100644
--- a/gthumb/Makefile.am
+++ b/gthumb/Makefile.am
@@ -131,6 +131,7 @@ PRIVATE_HEADER_FILES = \
dlg-preferences-general.h \
gth-browser-actions-callbacks.h \
gth-browser-actions-entries.h \
+ gth-file-details.h \
gth-metadata-provider-file.h \
dlg-personalize-filters.h \
dlg-preferences.h \
@@ -178,6 +179,7 @@ gthumb_SOURCES = \
gth-extensions.c \
gth-file-chooser-dialog.c \
gth-file-data.c \
+ gth-file-details.c \
gth-file-list.c \
gth-file-properties.c \
gth-file-selection.c \
diff --git a/gthumb/gth-file-details.c b/gthumb/gth-file-details.c
new file mode 100644
index 0000000..541418c
--- /dev/null
+++ b/gthumb/gth-file-details.c
@@ -0,0 +1,72 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+
+/*
+ * GThumb
+ *
+ * Copyright (C) 2009 Free Software Foundation, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <config.h>
+#include <glib/gi18n.h>
+#include "glib-utils.h"
+#include "gth-file-details.h"
+#include "gth-multipage.h"
+#include "gth-sidebar.h"
+
+
+static void gth_file_details_gth_multipage_child_interface_init (GthMultipageChildInterface *iface);
+
+
+G_DEFINE_TYPE_WITH_CODE (GthFileDetails,
+ gth_file_details,
+ GTH_TYPE_FILE_PROPERTIES,
+ G_IMPLEMENT_INTERFACE (GTH_TYPE_MULTIPAGE_CHILD,
+ gth_file_details_gth_multipage_child_interface_init))
+
+
+static const char *
+gth_file_details_real_get_name (GthMultipageChild *self)
+{
+ return _("Details");
+}
+
+
+static const char *
+gth_file_details_real_get_icon (GthMultipageChild *self)
+{
+ return "format-justify-fill-symbolic";
+}
+
+
+static void
+gth_file_details_class_init (GthFileDetailsClass *klass)
+{
+}
+
+
+static void
+gth_file_details_init (GthFileDetails *self)
+{
+ g_object_set (self, "show-details", TRUE, NULL);
+}
+
+
+static void
+gth_file_details_gth_multipage_child_interface_init (GthMultipageChildInterface *iface)
+{
+ iface->get_name = gth_file_details_real_get_name;
+ iface->get_icon = gth_file_details_real_get_icon;
+}
diff --git a/gthumb/gth-file-details.h b/gthumb/gth-file-details.h
new file mode 100644
index 0000000..d3ecaf6
--- /dev/null
+++ b/gthumb/gth-file-details.h
@@ -0,0 +1,52 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+
+/*
+ * GThumb
+ *
+ * Copyright (C) 2014 Free Software Foundation, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef GTH_FILE_DETAILS_H
+#define GTH_FILE_DETAILS_H
+
+#include <gtk/gtk.h>
+#include "gth-file-properties.h"
+
+G_BEGIN_DECLS
+
+#define GTH_TYPE_FILE_DETAILS (gth_file_details_get_type ())
+#define GTH_FILE_DETAILS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTH_TYPE_FILE_DETAILS,
GthFileDetails))
+#define GTH_FILE_DETAILS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTH_TYPE_FILE_DETAILS,
GthFileDetailsClass))
+#define GTH_IS_FILE_DETAILS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTH_TYPE_FILE_DETAILS))
+#define GTH_IS_FILE_DETAILS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTH_TYPE_FILE_DETAILS))
+#define GTH_FILE_DETAILS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTH_TYPE_FILE_DETAILS,
GthFileDetailsClass))
+
+typedef struct _GthFileDetails GthFileDetails;
+typedef struct _GthFileDetailsClass GthFileDetailsClass;
+
+struct _GthFileDetails {
+ GthFileProperties parent_instance;
+};
+
+struct _GthFileDetailsClass {
+ GthFilePropertiesClass parent_class;
+};
+
+GType gth_file_details_get_type (void);
+
+G_END_DECLS
+
+#endif /* GTH_FILE_DETAILS_H */
diff --git a/gthumb/gth-file-properties.c b/gthumb/gth-file-properties.c
index a5127ce..496dcff 100644
--- a/gthumb/gth-file-properties.c
+++ b/gthumb/gth-file-properties.c
@@ -25,7 +25,6 @@
#include "gth-file-properties.h"
#include "gth-main.h"
#include "gth-multipage.h"
-#include "gth-preferences.h"
#include "gth-sidebar.h"
#include "gth-string-list.h"
#include "gth-time.h"
@@ -40,6 +39,11 @@
#define MAX_ATTRIBUTE_LENGTH 128
#define GTH_STYLE_CLASS_COMMENT "comment"
+/* Properties */
+enum {
+ PROP_0,
+ PROP_SHOW_DETAILS
+};
enum {
SCALE_SET_COLUMN,
@@ -61,8 +65,8 @@ struct _GthFilePropertiesPrivate {
GtkWidget *comment_win;
GtkListStore *tree_model;
GtkWidget *popup_menu;
- GtkWidget *details_button;
gboolean show_details;
+ gboolean details_available;
GthFileData *last_file_data;
};
@@ -114,7 +118,6 @@ gth_file_properties_real_set_file (GthPropertyView *base,
GList *scan;
GtkTextBuffer *text_buffer;
char *comment;
- gboolean details_available;
self = GTH_FILE_PROPERTIES (base);
@@ -123,7 +126,6 @@ gth_file_properties_real_set_file (GthPropertyView *base,
self->priv->last_file_data = gth_file_data_dup (file_data);
}
- gtk_widget_set_sensitive (self->priv->details_button, FALSE);
gtk_list_store_clear (self->priv->tree_model);
if (file_data == NULL) {
@@ -133,7 +135,7 @@ gth_file_properties_real_set_file (GthPropertyView *base,
gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (self->priv->tree_model),
GTK_TREE_SORTABLE_UNSORTED_SORT_COLUMN_ID, 0);
- details_available = FALSE;
+ self->priv->details_available = FALSE;
category_hash = g_hash_table_new_full (g_str_hash, g_str_equal, (GDestroyNotify) g_free, NULL);
metadata_info = gth_main_get_all_metadata_info ();
for (scan = metadata_info; scan; scan = scan->next) {
@@ -152,17 +154,17 @@ gth_file_properties_real_set_file (GthPropertyView *base,
if (info->id != NULL) {
if (g_str_has_prefix (info->id, "Exif")) {
- details_available = TRUE;
+ self->priv->details_available = TRUE;
if (! self->priv->show_details)
continue;
}
if (g_str_has_prefix (info->id, "Iptc")) {
- details_available = TRUE;
+ self->priv->details_available = TRUE;
if (! self->priv->show_details)
continue;
}
if (g_str_has_prefix (info->id, "Xmp")) {
- details_available = TRUE;
+ self->priv->details_available = TRUE;
if (! self->priv->show_details)
continue;
}
@@ -212,14 +214,16 @@ gth_file_properties_real_set_file (GthPropertyView *base,
gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (self->priv->tree_model), POS_COLUMN,
GTK_SORT_ASCENDING);
gtk_tree_view_expand_all (GTK_TREE_VIEW (self->priv->tree_view));
- gtk_widget_set_sensitive (self->priv->details_button, details_available);
g_hash_table_destroy (category_hash);
/* comment */
- text_buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (self->priv->comment_view));
- comment = get_comment (file_data);
+ comment = NULL;
+ if (! self->priv->show_details) {
+ text_buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (self->priv->comment_view));
+ comment = get_comment (file_data);
+ }
if (comment != NULL) {
GtkTextIter iter;
GtkAdjustment *vadj;
@@ -270,11 +274,67 @@ gth_file_properties_finalize (GObject *base)
static void
+gth_file_properties_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GthFileProperties *self;
+
+ self = GTH_FILE_PROPERTIES (object);
+
+ switch (property_id) {
+ case PROP_SHOW_DETAILS:
+ self->priv->show_details = g_value_get_boolean (value);
+ break;
+ default:
+ break;
+ }
+}
+
+
+static void
+gth_file_properties_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GthFileProperties *self;
+
+ self = GTH_FILE_PROPERTIES (object);
+
+ switch (property_id) {
+ case PROP_SHOW_DETAILS:
+ g_value_set_boolean (value, self->priv->show_details);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+
+static void
gth_file_properties_class_init (GthFilePropertiesClass *klass)
{
+ GObjectClass *object_class;
+
g_type_class_add_private (klass, sizeof (GthFilePropertiesPrivate));
- G_OBJECT_CLASS (klass)->finalize = gth_file_properties_finalize;
+ object_class = G_OBJECT_CLASS (klass);
+ object_class->set_property = gth_file_properties_set_property;
+ object_class->get_property = gth_file_properties_get_property;
+ object_class->finalize = gth_file_properties_finalize;
+
+ /* properties */
+
+ g_object_class_install_property (object_class,
+ PROP_SHOW_DETAILS,
+ g_param_spec_boolean ("show-details",
+ "Show details",
+ "Whether to show all the file properties",
+ FALSE,
+ G_PARAM_READWRITE));
}
@@ -356,25 +416,8 @@ tree_view_popup_menu_cb (GtkWidget *widget,
static void
-details_button_toggled_cb (GtkToggleButton *button,
- gpointer user_data)
-{
- GthFileProperties *self = user_data;
- GSettings *settings;
-
- self->priv->show_details = gtk_toggle_button_get_active (button);
- gth_file_properties_real_set_file (GTH_PROPERTY_VIEW (self), self->priv->last_file_data);
-
- settings = g_settings_new (GTHUMB_BROWSER_SCHEMA);
- g_settings_set_boolean (settings, PREF_BROWSER_PROPERTIES_DETAILS, self->priv->show_details);
- g_object_unref (settings);
-}
-
-
-static void
gth_file_properties_init (GthFileProperties *self)
{
- GSettings *settings;
GtkWidget *vpaned;
GtkWidget *properties_box;
GtkWidget *scrolled_win;
@@ -383,14 +426,11 @@ gth_file_properties_init (GthFileProperties *self)
GtkCellRenderer *renderer;
GtkTreeViewColumn *column;
- settings = g_settings_new (GTHUMB_BROWSER_SCHEMA);
self->priv = GTH_FILE_PROPERTIES_GET_PRIVATE (self);
- self->priv->show_details = g_settings_get_boolean (settings, PREF_BROWSER_PROPERTIES_DETAILS);
+ self->priv->show_details = FALSE;
self->priv->last_file_data = NULL;
- g_object_unref (settings);
-
gtk_orientable_set_orientation (GTK_ORIENTABLE (self), GTK_ORIENTATION_VERTICAL);
gtk_box_set_spacing (GTK_BOX (self), 6);
@@ -413,15 +453,6 @@ gth_file_properties_init (GthFileProperties *self)
gtk_widget_show (button_box);
gtk_box_pack_start (GTK_BOX (properties_box), button_box, FALSE, FALSE, 2);
- self->priv->details_button = gtk_toggle_button_new_with_label (_("Details"));
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (self->priv->details_button),
self->priv->show_details);
- gtk_widget_show (self->priv->details_button);
- gtk_box_pack_start (GTK_BOX (button_box), self->priv->details_button, FALSE, FALSE, 0);
- g_signal_connect (self->priv->details_button,
- "toggled",
- G_CALLBACK (details_button_toggled_cb),
- self);
-
self->priv->tree_view = gtk_tree_view_new ();
gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (self->priv->tree_view), FALSE);
gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (self->priv->tree_view), TRUE);
diff --git a/gthumb/gth-main-default-types.c b/gthumb/gth-main-default-types.c
index 8d89f2c..19d03b2 100644
--- a/gthumb/gth-main-default-types.c
+++ b/gthumb/gth-main-default-types.c
@@ -25,6 +25,7 @@
#include "dlg-preferences-browser.h"
#include "dlg-preferences-extensions.h"
#include "dlg-preferences-general.h"
+#include "gth-file-details.h"
#include "gth-file-properties.h"
#include "gth-main.h"
#include "pixbuf-io.h"
@@ -61,6 +62,7 @@ void
gth_main_register_default_types (void)
{
gth_main_register_type ("file-properties", GTH_TYPE_FILE_PROPERTIES);
+ gth_main_register_type ("file-properties", GTH_TYPE_FILE_DETAILS);
gth_main_register_default_file_loader ();
gth_hook_add_callback ("dlg-preferences-construct", 1, G_CALLBACK
(general__dlg_preferences_construct_cb), NULL);
gth_hook_add_callback ("dlg-preferences-apply", 1, G_CALLBACK (general__dlg_preferences_apply), NULL);
diff --git a/gthumb/gth-preferences.h b/gthumb/gth-preferences.h
index 1e9337f..26799bd 100644
--- a/gthumb/gth-preferences.h
+++ b/gthumb/gth-preferences.h
@@ -71,7 +71,6 @@ G_BEGIN_DECLS
#define PREF_BROWSER_SIDEBAR_VISIBLE "sidebar-visible"
#define PREF_BROWSER_PROPERTIES_VISIBLE "properties-visible"
#define PREF_BROWSER_PROPERTIES_ON_THE_RIGHT "properties-on-the-right"
-#define PREF_BROWSER_PROPERTIES_DETAILS "properties-details"
#define PREF_BROWSER_THUMBNAIL_LIST_VISIBLE "thumbnail-list-visible"
#define PREF_BROWSER_THUMBNAIL_LIST_SIZE "thumbnail-list-size"
#define PREF_BROWSER_BROWSER_SIDEBAR_WIDTH "browser-sidebar-width"
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]