Merge lp:~ballogy/gloobus-preview/drop-gconf into lp:gloobus-preview

Proposed by Balló György
Status: Merged
Merged at revision: 297
Proposed branch: lp:~ballogy/gloobus-preview/drop-gconf
Merge into: lp:gloobus-preview
Diff against target: 305 lines (+86/-84)
7 files modified
configure.ac (+0/-1)
src/Makefile.am (+0/-2)
src/gloobus-preview-config.cpp (+17/-25)
src/gloobus-preview-config.h (+1/-5)
src/gloobus-preview-configuration (+48/-45)
src/plugin-pixbuf/plugin-pixbuf.cpp (+10/-4)
src/plugin-text/plugin-text.cpp (+10/-2)
To merge this branch: bzr merge lp:~ballogy/gloobus-preview/drop-gconf
Reviewer Review Type Date Requested Status
Gloobus Developers Pending
Review via email: mp+245322@code.launchpad.net

Description of the change

Update locations of GNOME configuration

In GNOME 3, these settings were moved from GConf to GSettings. Remove GConf dependency.

To post a comment you must log in.
293. By Balló György

Small fix

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'configure.ac'
2--- configure.ac 2014-12-23 10:30:25 +0000
3+++ configure.ac 2014-12-23 10:46:51 +0000
4@@ -42,7 +42,6 @@
5 PKG_CHECK_MODULES(ATK, atk)
6 PKG_CHECK_MODULES(GTK, gtk+-3.0 >= 3.0)
7 PKG_CHECK_MODULES(GTKSOURCEVIEW, gtksourceview-3.0)
8-PKG_CHECK_MODULES(GCONF2, gconf-2.0)
9 PKG_CHECK_MODULES(CAIRO, cairo)
10 PKG_CHECK_MODULES(GSTREAMER, gstreamer-1.0)
11 PKG_CHECK_MODULES(GSTREAMER_PLUGINS, gstreamer-plugins-base-1.0)
12
13=== modified file 'src/Makefile.am'
14--- src/Makefile.am 2014-12-22 06:30:44 +0000
15+++ src/Makefile.am 2014-12-23 10:46:51 +0000
16@@ -21,7 +21,6 @@
17 AM_CPPFLAGS += \
18 $(CAIRO_CFLAGS) \
19 $(GTK_CFLAGS) \
20- $(GCONF2_CFLAGS) \
21 $(PTHREAD_CFLAGS) \
22 $(GTKSOURCEVIEW_CFLAGS) \
23 $(GLIB_CFLAGS) \
24@@ -33,7 +32,6 @@
25 $(PTHREAD_LIBS) \
26 $(CAIRO_LIBS) \
27 $(GTK_LIBS) \
28- $(GCONF2_LIBS) \
29 $(GTKSOURCEVIEW_LIBS) \
30 $(GLIB_LIBS) \
31 $(DBUS_LIBS) \
32
33=== modified file 'src/gloobus-preview-config.cpp'
34--- src/gloobus-preview-config.cpp 2010-08-29 14:37:10 +0000
35+++ src/gloobus-preview-config.cpp 2014-12-23 10:46:51 +0000
36@@ -1,7 +1,7 @@
37 #include <string>
38 #include <glib.h>
39+#include <gio/gio.h>
40 #include "gloobus-preview-config.h"
41-#include <gconf/gconf-client.h>
42 #include "config.h"
43
44 GloobusConfig::GloobusConfig( void )
45@@ -21,20 +21,22 @@
46
47 GloobusConfig::~GloobusConfig( void ){}
48
49-bool GloobusConfig::get_gconf_win_layout()
50+bool GloobusConfig::get_gsettings_win_layout()
51 {
52- GConfClient* client_;
53- GError* error = NULL;
54- client_ = gconf_client_get_default();
55- if (!client_) {
56- g_debug("Unable to create a gconf client");
57- return false;
58- }
59- gchar* gconf_value = gconf_client_get_string(client_, "/apps/metacity/general/button_layout", &error);
60- if (!gconf_value) {
61- return false;
62- }
63- if (int(string(gconf_value).find("close")) - int(string(gconf_value).find(":")) > 0)
64+ gchar* button_layout;
65+ GSettingsSchemaSource *schema_source = g_settings_schema_source_get_default ();
66+ GSettingsSchema *wm_schema = g_settings_schema_source_lookup (schema_source, "org.gnome.desktop.wm.preferences", FALSE);
67+ if (wm_schema) {
68+ GSettings *wm_settings = g_settings_new ("org.gnome.desktop.wm.preferences");
69+ button_layout = g_settings_get_string (wm_settings, "button-layout");
70+ g_object_unref (wm_settings);
71+ g_settings_schema_unref (wm_schema);
72+ }
73+
74+ if (!button_layout) {
75+ return false;
76+ }
77+ if (int(string(button_layout).find("close")) - int(string(button_layout).find(":")) > 0)
78 m_winbar_layout = false;
79 else
80 m_winbar_layout = true;
81@@ -42,16 +44,6 @@
82 return true;
83 }
84
85-char* GloobusConfig::get_gconf_value_string( const char* key) {
86- GConfClient* client_;
87- client_ = gconf_client_get_default();
88- if (!client_) {
89- g_debug("Unable to create a gconf client");
90- return 0;
91- }
92- return gconf_client_get_string(client_, key, NULL);
93-}
94-
95 //============== LOAD CONFIG ==============//
96 bool GloobusConfig::load_config()
97 {
98@@ -67,7 +59,7 @@
99 m_focus = g_key_file_get_boolean( keyFile,"Main","focus", NULL );
100 theme_gtk = g_key_file_get_boolean( keyFile,"Theme","gtk", NULL );
101
102- if (!get_gconf_win_layout())
103+ if (!get_gsettings_win_layout())
104 m_winbar_layout = (bool)g_key_file_get_integer ( keyFile,"Main","winbar_layout", NULL );
105 g_key_file_free ( keyFile );
106
107
108=== modified file 'src/gloobus-preview-config.h'
109--- src/gloobus-preview-config.h 2010-05-01 14:34:16 +0000
110+++ src/gloobus-preview-config.h 2014-12-23 10:46:51 +0000
111@@ -45,7 +45,7 @@
112 bool load_config (void);
113
114
115- bool get_gconf_win_layout(void);
116+ bool get_gsettings_win_layout(void);
117
118 /* Returns if show gloobus-preview in taskbar
119 * */
120@@ -78,10 +78,6 @@
121 * */
122 gp_action get_cli_action (void);
123
124- /* get a gconf value
125- * */
126- char* get_gconf_value_string( const char*);
127-
128 char* get_theme ( void );
129
130 bool get_theme_gtk ( void );
131
132=== modified file 'src/gloobus-preview-configuration'
133--- src/gloobus-preview-configuration 2014-12-20 21:18:38 +0000
134+++ src/gloobus-preview-configuration 2014-12-23 10:46:51 +0000
135@@ -6,52 +6,52 @@
136 import os
137 import sys
138 import glob
139-from gi.repository import Gtk, GConf
140+from gi.repository import Gtk, GConf, Gio
141 import signal
142 import gettext
143 #import config
144
145 #=========================== CLASS COLORS =======================================================#
146-class colors:
147-
148- colors_code = ["\033[1;37m","\033[1;36m","\033[1;33m","\033[1;31m","\033[1;m"]
149- colors_name = ["white","blue","yellow","red", "reset"]
150- levels_name = ["info","debug","warning","error","reset"]
151- debugMode = False
152-
153-
154- #=================== GET CODE BY COLOR ===================#
155- def color(self,color):
156- self.debug = debug
157-
158- for i in range(len(self.colors_name)):
159- if color == self.colors_name[i]:
160- return self.colors_code[i]
161- return ""
162-
163- #=================== GET CODE BY LEVEL ===================#
164- def level(self,level):
165- for i in range(len(self.colors_name)):
166- if level == self.levels_name[i]:
167- return self.colors_code[i]
168- return ""
169-
170- #====================== SET DEBUG =======================#
171- def set_debug(self,debug):
172- self.debugMode = debug
173-
174- #================= PREDEFINED MACROS =======================#
175- def debug(self,string):
176- if self.debugMode:
177- print self.level('debug') + "[DEBUG] " + self.level('reset') + string
178-
179- def info(self,string):
180- print self.level('info') + "[INFO] " + self.level('reset') + string
181-
182- def warning(self,string):
183- print self.level('warning') + "[WARNING] " + self.level('reset') + string
184-
185- def error(self,string):
186+class colors:
187+
188+ colors_code = ["\033[1;37m","\033[1;36m","\033[1;33m","\033[1;31m","\033[1;m"]
189+ colors_name = ["white","blue","yellow","red", "reset"]
190+ levels_name = ["info","debug","warning","error","reset"]
191+ debugMode = False
192+
193+
194+ #=================== GET CODE BY COLOR ===================#
195+ def color(self,color):
196+ self.debug = debug
197+
198+ for i in range(len(self.colors_name)):
199+ if color == self.colors_name[i]:
200+ return self.colors_code[i]
201+ return ""
202+
203+ #=================== GET CODE BY LEVEL ===================#
204+ def level(self,level):
205+ for i in range(len(self.colors_name)):
206+ if level == self.levels_name[i]:
207+ return self.colors_code[i]
208+ return ""
209+
210+ #====================== SET DEBUG =======================#
211+ def set_debug(self,debug):
212+ self.debugMode = debug
213+
214+ #================= PREDEFINED MACROS =======================#
215+ def debug(self,string):
216+ if self.debugMode:
217+ print self.level('debug') + "[DEBUG] " + self.level('reset') + string
218+
219+ def info(self,string):
220+ print self.level('info') + "[INFO] " + self.level('reset') + string
221+
222+ def warning(self,string):
223+ print self.level('warning') + "[WARNING] " + self.level('reset') + string
224+
225+ def error(self,string):
226 print self.level('error') + "[ERROR] " + self.level('reset') + string
227
228
229@@ -62,14 +62,17 @@
230 entry2 = None #Allways on top
231 entry3 = None #Quit on lose focus
232 entry4 = None #Win bar layout
233- gconf_win_layout = None
234+ gsettings_win_layout = None
235 config = None
236
237 def __init__(self):
238 self.config = config_load()
239
240- self.client = GConf.Client.get_default()
241- self.gconf_win_layout = self.client.get_string('/apps/metacity/general/button_layout')
242+ schema_source = Gio.SettingsSchemaSource.get_default()
243+ wm_schema =Gio.SettingsSchemaSource.lookup(schema_source, "org.gnome.desktop.wm.preferences", False)
244+ if wm_schema:
245+ wm_settings = Gio.Settings.new("org.gnome.desktop.wm.preferences")
246+ self.gsettings_win_layout = wm_settings.get_string("button-layout")
247
248 #================= Show In Taskbar ================= #
249 self.entry1 = Gtk.CheckButton(label=_("Show in TaskBar"), use_underline=False)
250@@ -124,7 +127,7 @@
251 general_container.add(self.entry2) #Always on top
252 general_container.add(self.entry3) #Always on top
253 general_container.add(self.theme_gtk_entry)
254- if self.gconf_win_layout == None:
255+ if self.gsettings_win_layout == None:
256 general_container.add(self.entry4) #Always on top
257
258 general_container.add(Gtk.HSeparator())
259
260=== modified file 'src/plugin-pixbuf/plugin-pixbuf.cpp'
261--- src/plugin-pixbuf/plugin-pixbuf.cpp 2010-08-29 14:37:10 +0000
262+++ src/plugin-pixbuf/plugin-pixbuf.cpp 2014-12-23 10:46:51 +0000
263@@ -121,9 +121,15 @@
264
265 void iPixbuf::set_as_background_cb()
266 {
267- //gconftool-2 --type string --set /desktop/gnome/background/picture_filename /path/to/image.jpg
268- g_debug("Set as background current image %s", Gloobus::instance()->get_filename().c_str());
269+ const gchar *uri = g_file_get_uri (Gloobus::instance()->get_file());
270+ g_debug("Set as background current image %s", uri);
271
272- string cmd = "gconftool-2 --type string --set /desktop/gnome/background/picture_filename "+ Gloobus::instance()->get_filename();
273- g_spawn_command_line_async(cmd.c_str(), NULL);
274+ GSettingsSchemaSource *schema_source = g_settings_schema_source_get_default ();
275+ GSettingsSchema *background_schema = g_settings_schema_source_lookup (schema_source, "org.gnome.desktop.background", FALSE);
276+ if (background_schema) {
277+ GSettings *background_settings = g_settings_new ("org.gnome.desktop.background");
278+ g_settings_set_string (background_settings, "picture-uri", uri);
279+ g_object_unref (background_settings);
280+ g_settings_schema_unref (background_schema);
281+ }
282 }
283
284=== modified file 'src/plugin-text/plugin-text.cpp'
285--- src/plugin-text/plugin-text.cpp 2010-03-27 15:55:08 +0000
286+++ src/plugin-text/plugin-text.cpp 2014-12-23 10:46:51 +0000
287@@ -29,8 +29,16 @@
288 return 0;
289 }
290
291- GloobusConfig * config = Gloobus::instance()->get_config();
292- char* theme = config->get_gconf_value_string("/apps/gedit-2/preferences/editor/colors/scheme");
293+ char* theme;
294+ GSettingsSchemaSource *schema_source = g_settings_schema_source_get_default ();
295+ GSettingsSchema *gedit_schema = g_settings_schema_source_lookup (schema_source, "org.gnome.gedit.preferences.editor", FALSE);
296+ if (gedit_schema) {
297+ GSettings *gedit_settings = g_settings_new ("org.gnome.gedit.preferences.editor");
298+ theme = g_settings_get_string (gedit_settings, "scheme");
299+ g_object_unref (gedit_settings);
300+ g_settings_schema_unref (gedit_schema);
301+ }
302+
303 if(theme) {
304 GtkSourceStyleSchemeManager * sc_manager;
305 sc_manager = gtk_source_style_scheme_manager_get_default();

Subscribers

People subscribed via source and target branches