1 /* Exif-display Plugin - Configuration Interface
2 *
3 * Copyright (C) 2009-2011 The Free Software Foundation
4 *
5 * Author: Felix Riemann <friemann@gnome.org>
6 * Based on code by Emmanuel Touzery <emmanuel.touzery@free.fr>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software Foundation, Inc.,
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 */
22
23 #ifdef HAVE_CONFIG_H
24 #include <config.h>
25 #endif
26
27 #include <gtk/gtk.h>
28
29 #include <glib/gi18n-lib.h>
30 #include <eog/eog-debug.h>
31
32 #include <libpeas-gtk/peas-gtk-configurable.h>
33
34 #include "eog-exif-display-plugin-settings.h"
35
36 #include "eog-exif-display-plugin-setup.h"
37
38 #define GRESOURCE_PATH "/org/gnome/eog/plugins/exif-display/exif-display-config.ui"
39
40
41 static void
42 peas_gtk_configurable_iface_init (PeasGtkConfigurableInterface *iface);
43
44 G_DEFINE_DYNAMIC_TYPE_EXTENDED (EogExifDisplayPluginSetup,
45 eog_exif_display_plugin_setup, PEAS_TYPE_EXTENSION_BASE, 0,
46 G_IMPLEMENT_INTERFACE_DYNAMIC(PEAS_GTK_TYPE_CONFIGURABLE,
47 peas_gtk_configurable_iface_init))
48
49
50 static void
eog_exif_display_plugin_setup_init(EogExifDisplayPluginSetup * setup)51 eog_exif_display_plugin_setup_init (EogExifDisplayPluginSetup *setup)
52 {
53
54 }
55
56 static GtkWidget *
impl_create_config_widget(PeasGtkConfigurable * configurable)57 impl_create_config_widget (PeasGtkConfigurable *configurable)
58 {
59 GSettings *settings;
60 GtkBuilder *config_builder;
61 GError *error = NULL;
62 GtkWidget *display_channels_histogram_widget;
63 GtkWidget *display_rgb_histogram_widget;
64 GtkWidget *display_camera_settings_in_statusbar;
65 GObject *result;
66 gchar *object_ids[] = {"vbox1", NULL};
67
68 settings = g_settings_new (EOG_EXIF_DISPLAY_CONF_SCHEMA_ID);
69
70 config_builder = gtk_builder_new ();
71 gtk_builder_set_translation_domain (config_builder, GETTEXT_PACKAGE);
72 if (!gtk_builder_add_objects_from_resource (config_builder, GRESOURCE_PATH, object_ids, &error))
73 {
74 g_warning ("Couldn't load UI resource: %s", error->message);
75 g_error_free (error);
76 }
77
78 // Add a reference to keep the box alive after the builder is gone
79 result = g_object_ref (gtk_builder_get_object (config_builder, "vbox1"));
80 display_channels_histogram_widget = GTK_WIDGET (
81 gtk_builder_get_object (config_builder, "display_per_channel_histogram"));
82 display_rgb_histogram_widget = GTK_WIDGET (
83 gtk_builder_get_object (config_builder, "display_rgb_histogram"));
84 display_camera_settings_in_statusbar = GTK_WIDGET (
85 gtk_builder_get_object (config_builder, "display_camerasettings_statusbar"));
86
87 g_settings_bind (settings, EOG_EXIF_DISPLAY_CONF_CHANNELS_HISTOGRAM,
88 display_channels_histogram_widget,
89 "active", G_SETTINGS_BIND_DEFAULT);
90 g_settings_bind (settings, EOG_EXIF_DISPLAY_CONF_RGB_HISTOGRAM,
91 display_rgb_histogram_widget,
92 "active", G_SETTINGS_BIND_DEFAULT);
93 g_settings_bind (settings, EOG_EXIF_DISPLAY_CONF_EXIF_IN_STATUSBAR,
94 display_camera_settings_in_statusbar,
95 "active", G_SETTINGS_BIND_DEFAULT);
96
97 g_object_unref (config_builder);
98 g_object_unref (settings);
99
100 return GTK_WIDGET(result);
101 }
102
103
104 static void
eog_exif_display_plugin_setup_dispose(GObject * object)105 eog_exif_display_plugin_setup_dispose (GObject *object)
106 {
107 eog_debug_message (DEBUG_PLUGINS,
108 "EogExifDisplayPluginSetup disposing");
109
110 G_OBJECT_CLASS (eog_exif_display_plugin_setup_parent_class)->dispose (object);
111 }
112
113 static void
eog_exif_display_plugin_setup_class_init(EogExifDisplayPluginSetupClass * klass)114 eog_exif_display_plugin_setup_class_init (EogExifDisplayPluginSetupClass *klass)
115 {
116 GObjectClass *object_class = G_OBJECT_CLASS (klass);
117
118 object_class->dispose = eog_exif_display_plugin_setup_dispose;
119 }
120
121 static void
peas_gtk_configurable_iface_init(PeasGtkConfigurableInterface * iface)122 peas_gtk_configurable_iface_init (PeasGtkConfigurableInterface *iface)
123 {
124 iface->create_configure_widget = impl_create_config_widget;
125 }
126
127 static void
eog_exif_display_plugin_setup_class_finalize(EogExifDisplayPluginSetupClass * klass)128 eog_exif_display_plugin_setup_class_finalize (EogExifDisplayPluginSetupClass *klass)
129 {
130 /* Dummy needed for G_DEFINE_DYNAMIC_TYPE_EXTENDED */
131 }
132
133 void
eog_exif_display_plugin_setup_register_types(PeasObjectModule * module)134 eog_exif_display_plugin_setup_register_types (PeasObjectModule *module)
135 {
136 eog_exif_display_plugin_setup_register_type (G_TYPE_MODULE (module));
137 peas_object_module_register_extension_type (module,
138 PEAS_GTK_TYPE_CONFIGURABLE,
139 EOG_TYPE_EXIF_DISPLAY_PLUGIN_SETUP);
140 }
141