1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
|
---
Allow gconf-editor to build without policykit.
configure.in | 25 ++++++++++++++----
src/Makefile.am | 15 +++++++----
src/gconf-editor-window.c | 62 ++++++++++++++++++++++++++++++++++++----------
3 files changed, 79 insertions(+), 23 deletions(-)
Index: b/configure.in
===================================================================
--- a/configure.in
+++ b/configure.in
@@ -34,9 +34,7 @@ changequote([,])dnl
PKG_CHECK_MODULES(GCONF_EDITOR,
gconf-2.0 >= 2.9.2
- gtk+-2.0 >= 2.12.0
- polkit-dbus >= 0.7
- dbus-glib-1 >= 0.71)
+ gtk+-2.0 >= 2.12.0)
if test "$enable_maintainer_mode" = "yes"; then
DISABLE_DEPRECATED_CFLAGS="-DG_DISABLE_DEPRECATED -DGTK_DISABLE_DEPRECATED \
@@ -55,6 +53,22 @@ GNOME_COMMON_INIT
GNOME_COMPILE_WARNINGS([maximum])
GNOME_MAINTAINER_MODE_DEFINES
+dnl Enable or not the policykit support
+AC_ARG_WITH([policykit],
+ AC_HELP_STRING([--with-policykit],
+ [Compile with policykit support @<:@default=yes@:>@]),
+ [with_polkit=$withval],
+ [with_polkit=yes])
+
+if test x$with_polkit = xyes; then
+ AC_DEFINE([HAVE_POLICYKIT], 1, [PolicyKit support is required])
+ PKG_CHECK_MODULES(GCONF_EDITOR_POLKIT,
+ polkit-dbus >= 0.7
+ dbus-glib-1 >= 0.71)
+fi
+
+AM_CONDITIONAL([HAVE_POLICYKIT], [test x$with_polkit = xyes])
+
dnl Get the GConf defaults source, and sed it to make the mandatory source.
GCONF_DEFAULTS_SOURCE=`gconftool-2 --get-default-source`
AC_ARG_WITH(gconf-defaults-source,
@@ -86,5 +100,6 @@ AC_OUTPUT
echo "
Configuration Sources:
-GConf default values source: ${GCONF_DEFAULTS_SOURCE}
-GConf mandatory values source: ${GCONF_MANDATORY_SOURCE}"
+GConf default values source: ${GCONF_DEFAULTS_SOURCE}
+GConf mandatory values source: ${GCONF_MANDATORY_SOURCE}
+PolicyKit support: ${with_polkit}"
Index: b/src/Makefile.am
===================================================================
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -3,14 +3,15 @@ INCLUDES = \
-DDATADIR=\""$(pkgdatadir)"\" \
-DICONDIR="\"$(pkgdatadir)/icons\"" \
$(DISABLE_DEPRECATED_CFLAGS) \
- $(GCONF_EDITOR_CFLAGS)
+ $(GCONF_EDITOR_CFLAGS) \
+ $(GCONF_EDITOR_POLKIT_CFLAGS)
bin_PROGRAMS = gconf-editor
gconf_editor_built_headers = gconf-marshal.h
gconf_editor_built_cfiles = gconf-marshal.c
-gconf_editor_SOURCES = \
+gconf_editor_SOURCES = \
gconf-bookmarks.c \
gconf-bookmarks.h \
gconf-bookmarks-dialog.c \
@@ -33,8 +34,6 @@ gconf_editor_SOURCES = \
gconf-util.h \
gedit-output-window.c \
gedit-output-window.h \
- gconf-policykit.c \
- gconf-policykit.h \
gconf-search.h \
gconf-search.c \
gconf-search-dialog.h \
@@ -43,6 +42,11 @@ gconf_editor_SOURCES = \
$(gconf_editor_built_headers) \
$(gconf_editor_built_cfiles)
+if HAVE_POLICYKIT
+gconf_editor_SOURCES += gconf-policykit.h \
+ gconf-policykit.c
+endif
+
## we just punt on built sources, and check them into svn, manually updating
## when required.
regenerate-built-sources:
@@ -54,7 +58,8 @@ regenerate-built-sources:
gconf_editor_LDADD = \
- $(GCONF_EDITOR_LIBS)
+ $(GCONF_EDITOR_LIBS) \
+ $(GCONF_EDITOR_POLKIT_LIBS)
EXTRA_DIST = \
gconf-marshal.list
Index: b/src/gconf-editor-window.c
===================================================================
--- a/src/gconf-editor-window.c
+++ b/src/gconf-editor-window.c
@@ -27,7 +27,9 @@
#include "gconf-cell-renderer.h"
#include "gconf-editor-application.h"
#include "gconf-key-editor.h"
-#include "gconf-policykit.h"
+#ifdef HAVE_POLICYKIT
+# include "gconf-policykit.h"
+#endif
#include "gconf-stock-icons.h"
#include "gconf-util.h"
#include "gedit-output-window.h"
@@ -640,26 +642,34 @@ gconf_editor_window_row_expanded (GtkTre
gdk_display_flush (gtk_widget_get_display (GTK_WIDGET (gconfwindow)));
}
+#ifdef HAVE_POLICYKIT
+/* QA Warning: Only used with policykit support ,
+ so avoiding ' defined but not used' warning
+*/
static void
gconf_editor_popup_policykit_callback (GtkWindow *window, GError *error)
{
if (error)
gconf_editor_window_popup_error_dialog (window, _("Could not set value. Error was:\n%s"), error);
}
+#endif
static void
gconf_editor_popup_window_set_as_default (GtkAction *action, GtkWidget *callback_data)
{
GConfEditorWindow *gconfwindow = GCONF_EDITOR_WINDOW (callback_data);
- GtkWindow *window = GTK_WINDOW (callback_data);
GtkTreeIter iter;
GConfValue *value;
char *path = NULL;
+
+#ifdef HAVE_POLICYKIT
+ /* QA Warning: unsed variable if policykit is disable */
+ GtkWindow *window = GTK_WINDOW (callback_data);
gboolean can_use_pk;
can_use_pk = (gconfwindow->type == GCONF_EDITOR_WINDOW_TYPE_NORMAL);
-
+#endif
gtk_tree_selection_get_selected (gtk_tree_view_get_selection (GTK_TREE_VIEW (gconfwindow->list_view)),
NULL, &iter);
gtk_tree_model_get (gconfwindow->sorted_list_model, &iter,
@@ -680,12 +690,13 @@ gconf_editor_popup_window_set_as_default
if (!error)
return;
-
+#ifdef HAVE_POLICYKIT
if (!can_use_pk)
gconf_editor_window_popup_error_dialog (window, _("Could not sync value. Error was:\n%s"), error);
+#endif
}
}
-
+#ifdef HAVE_POLICYKIT
if (can_use_pk) {
gconf_client_suggest_sync (gconfwindow->client, NULL);
gconf_pk_set_default_async (path,
@@ -693,21 +704,24 @@ gconf_editor_popup_window_set_as_default
(GFunc) gconf_editor_popup_policykit_callback,
g_object_ref (window), g_object_unref);
}
+#endif
}
static void
gconf_editor_popup_window_set_as_mandatory (GtkAction *action, GtkWidget *callback_data)
{
GConfEditorWindow *gconfwindow = GCONF_EDITOR_WINDOW (callback_data);
- GtkWindow *window = GTK_WINDOW (callback_data);
GtkTreeIter iter;
GConfValue *value;
char *path = NULL;
+#ifdef HAVE_POLICYKIT
+ /* QA Warning */
+ GtkWindow *window = GTK_WINDOW (callback_data);
gboolean can_use_pk;
can_use_pk = (gconfwindow->type == GCONF_EDITOR_WINDOW_TYPE_NORMAL);
-
+#endif
gtk_tree_selection_get_selected (gtk_tree_view_get_selection (GTK_TREE_VIEW (gconfwindow->list_view)),
NULL, &iter);
gtk_tree_model_get (gconfwindow->sorted_list_model, &iter,
@@ -728,12 +742,13 @@ gconf_editor_popup_window_set_as_mandato
if (!error)
return;
-
+#ifdef HAVE_POLICYKIT
if (!can_use_pk)
gconf_editor_window_popup_error_dialog (window, _("Could not sync value. Error was:\n%s"), error);
+#endif
}
}
-
+#ifdef HAVE_POLICYKIT
if (can_use_pk) {
gconf_client_suggest_sync (gconfwindow->client, NULL);
gconf_pk_set_mandatory_async (path,
@@ -741,6 +756,7 @@ gconf_editor_popup_window_set_as_mandato
(GFunc) gconf_editor_popup_policykit_callback,
g_object_ref (window), g_object_unref);
}
+#endif
}
static GtkActionEntry entries[] = {
@@ -934,10 +950,20 @@ list_view_button_press_event (GtkTreeVie
window->type != GCONF_EDITOR_WINDOW_TYPE_DEFAULTS);
gtk_widget_set_sensitive (gtk_ui_manager_get_widget (window->ui_manager, "/GConfKeyPopupMenu/DefaultKey"),
(gconf_util_can_edit_defaults () && window->type != GCONF_EDITOR_WINDOW_TYPE_DEFAULTS) ||
- (gconf_pk_can_set_default () && window->type == GCONF_EDITOR_WINDOW_TYPE_NORMAL));
+#ifdef HAVE_POLICYKIT
+ (gconf_pk_can_set_default () &&
+#else
+ (
+#endif
+ window->type == GCONF_EDITOR_WINDOW_TYPE_NORMAL));
gtk_widget_set_sensitive (gtk_ui_manager_get_widget (window->ui_manager, "/GConfKeyPopupMenu/MandatoryKey"),
(gconf_util_can_edit_mandatory () && window->type != GCONF_EDITOR_WINDOW_TYPE_MANDATORY) ||
- (gconf_pk_can_set_mandatory () && window->type == GCONF_EDITOR_WINDOW_TYPE_NORMAL));
+#ifdef HAVE_POLICYKIT
+ (gconf_pk_can_set_mandatory () &&
+#else
+ (
+#endif
+window->type == GCONF_EDITOR_WINDOW_TYPE_NORMAL));
gtk_tree_path_free (path);
}
@@ -1037,10 +1063,20 @@ gconf_editor_window_list_view_popup_menu
window->type != GCONF_EDITOR_WINDOW_TYPE_DEFAULTS);
gtk_widget_set_sensitive (gtk_ui_manager_get_widget (window->ui_manager, "/GConfKeyPopupMenu/DefaultKey"),
(gconf_util_can_edit_defaults () && window->type != GCONF_EDITOR_WINDOW_TYPE_DEFAULTS) ||
- (gconf_pk_can_set_default () && window->type == GCONF_EDITOR_WINDOW_TYPE_NORMAL));
+#ifdef HAVE_POLICYKIT
+ (gconf_pk_can_set_default () &&
+#else
+ (
+#endif
+window->type == GCONF_EDITOR_WINDOW_TYPE_NORMAL));
gtk_widget_set_sensitive (gtk_ui_manager_get_widget (window->ui_manager, "/GConfKeyPopupMenu/MandatoryKey"),
(gconf_util_can_edit_mandatory () && window->type != GCONF_EDITOR_WINDOW_TYPE_MANDATORY) ||
- (gconf_pk_can_set_mandatory () && window->type == GCONF_EDITOR_WINDOW_TYPE_NORMAL));
+#ifdef HAVE_POLICYKIT
+ (gconf_pk_can_set_mandatory () &&
+#else
+ (
+#endif
+window->type == GCONF_EDITOR_WINDOW_TYPE_NORMAL));
}
else {
|