[gthumb] Allow to disable comment synchronization with embedded metadata



commit b0de33d894db6ca39227fa441b75fd79b8d58b84
Author: Paolo Bacchilega <paobac src gnome org>
Date:   Sat Jan 16 23:14:02 2010 +0100

    Allow to disable comment synchronization with embedded metadata
    
    [bug #604720]

 configure.ac                                       |    2 +
 extensions/comments/Makefile.am                    |    7 ++-
 extensions/comments/data/Makefile.am               |   18 ++++
 .../comments/data/gthumb-comments.schemas.in       |   17 ++++
 extensions/comments/data/ui/Makefile.am            |    5 +
 .../comments/data/ui/comments-preferences.ui       |   69 +++++++++++++++
 extensions/comments/dlg-comments-preferences.c     |   88 ++++++++++++++++++++
 extensions/comments/dlg-comments-preferences.h     |   30 +++++++
 extensions/comments/main.c                         |    8 ++-
 extensions/comments/preferences.h                  |   28 ++++++
 gthumb/dlg-extensions.c                            |   26 ++++++
 po/POTFILES.in                                     |    5 +
 12 files changed, 301 insertions(+), 2 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index e895394..ef27be0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -329,6 +329,8 @@ extensions/catalogs/Makefile
 extensions/catalogs/data/Makefile
 extensions/catalogs/data/ui/Makefile
 extensions/comments/Makefile
+extensions/comments/data/Makefile
+extensions/comments/data/ui/Makefile
 extensions/desktop_background/Makefile
 extensions/edit_metadata/Makefile
 extensions/edit_metadata/data/Makefile
diff --git a/extensions/comments/Makefile.am b/extensions/comments/Makefile.am
index d963033..e3aeb54 100644
--- a/extensions/comments/Makefile.am
+++ b/extensions/comments/Makefile.am
@@ -1,14 +1,19 @@
+SUBDIRS = data
+
 extensiondir = $(pkglibdir)/extensions
 extension_LTLIBRARIES = libcomments.la
 
 libcomments_la_SOURCES = 			\
+	dlg-comments-preferences.c		\
+	dlg-comments-preferences.h		\
 	gth-comment.c				\
 	gth-comment.h				\
 	gth-metadata-provider-comment.c		\
 	gth-metadata-provider-comment.h		\
 	gth-test-category.c			\
 	gth-test-category.h			\
-	main.c
+	main.c					\
+	preferences.h
 
 libcomments_la_CFLAGS = $(GTHUMB_CFLAGS) -I$(top_srcdir) -I$(top_builddir)/gthumb 
 libcomments_la_LDFLAGS = $(EXTENSION_LIBTOOL_FLAGS)
diff --git a/extensions/comments/data/Makefile.am b/extensions/comments/data/Makefile.am
new file mode 100644
index 0000000..7d6e39c
--- /dev/null
+++ b/extensions/comments/data/Makefile.am
@@ -0,0 +1,18 @@
+SUBDIRS = ui
+
+schemadir = @GCONF_SCHEMA_FILE_DIR@
+schema_in_files = gthumb-comments.schemas.in
+schema_DATA = $(schema_in_files:.schemas.in=.schemas)
+
+ INTLTOOL_SCHEMAS_RULE@
+
+if GCONF_SCHEMAS_INSTALL
+install-data-local:
+	GCONF_CONFIG_SOURCE=$(GCONF_SCHEMA_CONFIG_SOURCE) $(GCONFTOOL) --makefile-install-rule $(top_builddir)/extensions/comments/data/$(schema_DATA)
+endif
+
+EXTRA_DIST = $(schema_in_files)
+
+CLEANFILES = $(schema_DATA)
+
+-include $(top_srcdir)/git.mk
diff --git a/extensions/comments/data/gthumb-comments.schemas.in b/extensions/comments/data/gthumb-comments.schemas.in
new file mode 100644
index 0000000..c963839
--- /dev/null
+++ b/extensions/comments/data/gthumb-comments.schemas.in
@@ -0,0 +1,17 @@
+<gconfschemafile>
+    <schemalist>
+
+      <schema>
+	<key>/schemas/apps/gthumb/ext/comments/synchronize</key>
+	<applyto>/apps/gthumb/ext/comments/synchronize</applyto>
+	<owner>gthumb</owner>
+	<type>bool</type>
+	<default>true</default>
+	<locale name="C">
+	  <short></short>
+	  <long></long>
+	</locale>
+      </schema>
+
+    </schemalist>
+</gconfschemafile>
diff --git a/extensions/comments/data/ui/Makefile.am b/extensions/comments/data/ui/Makefile.am
new file mode 100644
index 0000000..b72b0eb
--- /dev/null
+++ b/extensions/comments/data/ui/Makefile.am
@@ -0,0 +1,5 @@
+uidir = $(pkgdatadir)/ui
+ui_DATA = comments-preferences.ui
+EXTRA_DIST = $(ui_DATA)
+
+-include $(top_srcdir)/git.mk
diff --git a/extensions/comments/data/ui/comments-preferences.ui b/extensions/comments/data/ui/comments-preferences.ui
new file mode 100644
index 0000000..a4aa68e
--- /dev/null
+++ b/extensions/comments/data/ui/comments-preferences.ui
@@ -0,0 +1,69 @@
+<?xml version="1.0"?>
+<interface>
+  <requires lib="gtk+" version="2.16"/>
+  <!-- interface-naming-policy project-wide -->
+  <object class="GtkDialog" id="preferences_dialog">
+    <property name="border_width">5</property>
+    <property name="title" translatable="yes">Preferences</property>
+    <property name="type_hint">dialog</property>
+    <property name="has_separator">False</property>
+    <child internal-child="vbox">
+      <object class="GtkVBox" id="dialog-vbox7">
+        <property name="visible">True</property>
+        <property name="orientation">vertical</property>
+        <child>
+          <object class="GtkVBox" id="vbox1">
+            <property name="visible">True</property>
+            <property name="border_width">5</property>
+            <property name="orientation">vertical</property>
+            <child>
+              <object class="GtkCheckButton" id="sync_checkbutton">
+                <property name="label" translatable="yes">_Synchronize with the embedded metadata</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">False</property>
+                <property name="use_underline">True</property>
+                <property name="draw_indicator">True</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="position">0</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="position">1</property>
+          </packing>
+        </child>
+        <child internal-child="action_area">
+          <object class="GtkHButtonBox" id="dialog-action_area7">
+            <property name="visible">True</property>
+            <property name="layout_style">end</property>
+            <child>
+              <object class="GtkButton" id="close_button">
+                <property name="label">gtk-close</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">True</property>
+                <property name="use_stock">True</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="position">0</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="pack_type">end</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+      </object>
+    </child>
+    <action-widgets>
+      <action-widget response="0">close_button</action-widget>
+    </action-widgets>
+  </object>
+</interface>
diff --git a/extensions/comments/dlg-comments-preferences.c b/extensions/comments/dlg-comments-preferences.c
new file mode 100644
index 0000000..b0aa028
--- /dev/null
+++ b/extensions/comments/dlg-comments-preferences.c
@@ -0,0 +1,88 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+
+/*
+ *  GThumb
+ *
+ *  Copyright (C) 2010 The 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, write to the Free Software
+ *  Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA.
+ */
+
+#include <config.h>
+#include <gtk/gtk.h>
+#include <gthumb.h>
+#include "preferences.h"
+
+
+typedef struct {
+	GtkBuilder *builder;
+	GtkWidget  *dialog;
+} DialogData;
+
+
+static void
+destroy_cb (GtkWidget  *widget, 
+	    DialogData *data)
+{
+	g_object_unref (data->builder);
+	g_free (data);
+}
+
+
+static void
+sync_checkbutton_clicked_cb (GtkWidget  *widget,
+			     DialogData *data)
+{
+	eel_gconf_set_boolean (PREF_COMMENTS_SYNCHRONIZE, gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (gtk_builder_get_object (data->builder, "sync_checkbutton"))));
+}
+
+
+void
+dlg_comments_preferences (GtkWindow *parent)
+{
+	DialogData *data;
+	
+	data = g_new0 (DialogData, 1);
+	data->builder = _gtk_builder_new_from_file ("comments-preferences.ui", "comments");
+
+	/* Get the widgets. */
+
+	data->dialog = _gtk_builder_get_widget (data->builder, "preferences_dialog");
+
+	/* Set widgets data. */
+
+	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (gtk_builder_get_object (data->builder, "sync_checkbutton")), eel_gconf_get_boolean (PREF_COMMENTS_SYNCHRONIZE, TRUE));
+
+	/* Set the signals handlers. */
+	
+	g_signal_connect (G_OBJECT (data->dialog), 
+			  "destroy",
+			  G_CALLBACK (destroy_cb),
+			  data);
+	g_signal_connect_swapped (gtk_builder_get_object (data->builder, "close_button"),
+				  "clicked",
+				  G_CALLBACK (gtk_widget_destroy),
+				  G_OBJECT (data->dialog));
+	g_signal_connect (gtk_builder_get_object (data->builder, "sync_checkbutton"),
+			  "clicked",
+			  G_CALLBACK (sync_checkbutton_clicked_cb),
+			  data);
+
+	/* run dialog. */
+
+	gtk_window_set_transient_for (GTK_WINDOW (data->dialog), parent);
+	gtk_window_set_modal (GTK_WINDOW (data->dialog), TRUE);
+	gtk_widget_show (data->dialog);
+}
diff --git a/extensions/comments/dlg-comments-preferences.h b/extensions/comments/dlg-comments-preferences.h
new file mode 100644
index 0000000..b472cb2
--- /dev/null
+++ b/extensions/comments/dlg-comments-preferences.h
@@ -0,0 +1,30 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+
+/*
+ *  GThumb
+ *
+ *  Copyright (C) 2010 The 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, write to the Free Software
+ *  Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef DLG_COMMENTS_PREFERENCES_H
+#define DLG_COMMENTS_PREFERENCES_H
+
+#include <gthumb.h>
+
+void dlg_comments_preferences (GtkWindow *parent);
+
+#endif /* DLG_COMMENTS_PREFERENCES_H */
diff --git a/extensions/comments/main.c b/extensions/comments/main.c
index 9bf7f5c..070a309 100644
--- a/extensions/comments/main.c
+++ b/extensions/comments/main.c
@@ -24,9 +24,11 @@
 #include <config.h>
 #include <gtk/gtk.h>
 #include <gthumb.h>
+#include "dlg-comments-preferences.h"
 #include "gth-comment.h"
 #include "gth-metadata-provider-comment.h"
 #include "gth-test-category.h"
+#include "preferences.h"
 
 
 GthMetadataCategory comments_metadata_category[] = {
@@ -86,6 +88,9 @@ comments__read_metadata_ready_cb (GthFileData *file_data,
 	GthComment    *comment;
 	GthStringList *categories;
 
+	if (! eel_gconf_get_boolean (PREF_COMMENTS_SYNCHRONIZE, TRUE))
+		return;
+
 	comment = gth_comment_new ();
 	gth_comment_set_note (comment, g_file_info_get_attribute_string (file_data->info, "comment::note"));
 	gth_comment_set_caption (comment, g_file_info_get_attribute_string (file_data->info, "comment::caption"));
@@ -218,11 +223,12 @@ gthumb_extension_deactivate (void)
 G_MODULE_EXPORT gboolean
 gthumb_extension_is_configurable (void)
 {
-	return FALSE;
+	return TRUE;
 }
 
 
 G_MODULE_EXPORT void
 gthumb_extension_configure (GtkWindow *parent)
 {
+	dlg_comments_preferences (parent);
 }
diff --git a/extensions/comments/preferences.h b/extensions/comments/preferences.h
new file mode 100644
index 0000000..b47169c
--- /dev/null
+++ b/extensions/comments/preferences.h
@@ -0,0 +1,28 @@
+/* -*- 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, write to the Free Software
+ *  Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef PREFERENCES_H
+#define PREFERENCES_H
+
+#define  PREF_COMMENTS_SYNCHRONIZE "/apps/gthumb/ext/comments/synchronize"
+
+#endif /* PREFERENCES_H */
diff --git a/gthumb/dlg-extensions.c b/gthumb/dlg-extensions.c
index 7c4a41a..a3cfa5a 100644
--- a/gthumb/dlg-extensions.c
+++ b/gthumb/dlg-extensions.c
@@ -353,6 +353,28 @@ about_button_clicked_cb (GtkButton *button,
 }
 
 
+static void
+preferences_button_clicked_cb (GtkButton *button,
+			       gpointer   user_data)
+{
+	DialogData              *data = user_data;
+	GtkTreeModel            *model;
+	GtkTreeIter              iter;
+	GthExtensionDescription *description;
+	GthExtension            *extension;
+
+	model = GTK_TREE_MODEL (data->list_store);
+	if (! gtk_tree_selection_get_selected (gtk_tree_view_get_selection (GTK_TREE_VIEW (data->list_view)), &model, &iter))
+		return;
+
+	gtk_tree_model_get (model, &iter, 0, &description, -1);
+	extension = gth_extension_description_get_extension (description);
+	gth_extension_configure (extension, GTK_WINDOW (data->dialog));
+
+	g_object_unref (description);
+}
+
+
 void
 dlg_extensions (GthBrowser *browser)
 {
@@ -426,6 +448,10 @@ dlg_extensions (GthBrowser *browser)
 			  "clicked",
 			  G_CALLBACK (about_button_clicked_cb),
 			  data);
+	g_signal_connect (GET_WIDGET ("preferences_button"),
+			  "clicked",
+			  G_CALLBACK (preferences_button_clicked_cb),
+			  data);
 	g_signal_connect (gtk_tree_view_get_selection (GTK_TREE_VIEW (data->list_view)),
 			  "changed",
 			  G_CALLBACK (list_view_selection_changed_cb),
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 8735a75..17795b8 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -48,6 +48,10 @@ extensions/catalogs/gth-organize-task.c
 extensions/catalogs/gth-organize-task.h
 extensions/catalogs/main.c
 extensions/comments/comments.extension.in.in
+extensions/comments/data/gthumb-comments.schemas.in
+[type: gettext/glade]extensions/comments/data/ui/comments-preferences.ui
+extensions/comments/dlg-comments-preferences.c
+extensions/comments/dlg-comments-preferences.h
 extensions/comments/gth-comment.c
 extensions/comments/gth-comment.h
 extensions/comments/gth-metadata-provider-comment.c
@@ -55,6 +59,7 @@ extensions/comments/gth-metadata-provider-comment.h
 extensions/comments/gth-test-category.c
 extensions/comments/gth-test-category.h
 extensions/comments/main.c
+extensions/comments/preferences.h
 extensions/desktop_background/actions.c
 extensions/desktop_background/actions.h
 extensions/desktop_background/callbacks.c



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