aboutsummaryrefslogtreecommitdiffstats
path: root/meta/recipes-connectivity/connman/connman-gnome/0001-Port-to-Gtk3.patch
blob: 279ca05d6f04f391dd859e222312f56a5304b57a (plain)
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
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
From 092fe0793b39c6feb6464bfbd568b050960d62c0 Mon Sep 17 00:00:00 2001
From: Jussi Kukkonen <jussi.kukkonen@intel.com>
Date: Wed, 2 Mar 2016 15:47:49 +0200
Subject: [PATCH] Port to Gtk3

Some unused (or not useful) code was removed, functionality should stay
the same, although applet now loads icons based on actual size available
to it.

Code still contains quite a few uses of deprecated API.

Upstream-Status: Submitted
Signed-off-by: Jussi Kukkonen <jussi.kukkonen@intel.com>
---
 applet/agent.c        |  3 +--
 applet/main.c         | 43 ------------------------------
 applet/status.c       | 74 +++++++++++++++++++++++++++++++++------------------
 configure.ac          |  3 +--
 properties/ethernet.c | 14 +++++-----
 properties/main.c     |  2 +-
 properties/wifi.c     | 12 ++++-----
 7 files changed, 64 insertions(+), 87 deletions(-)

diff --git a/applet/agent.c b/applet/agent.c
index 65bed08..04fe86a 100644
--- a/applet/agent.c
+++ b/applet/agent.c
@@ -126,7 +126,6 @@ static void request_input_dialog(GHashTable *request,
 	gtk_window_set_position(GTK_WINDOW(dialog), GTK_WIN_POS_CENTER);
 	gtk_window_set_keep_above(GTK_WINDOW(dialog), TRUE);
 	gtk_window_set_urgency_hint(GTK_WINDOW(dialog), TRUE);
-	gtk_dialog_set_has_separator(GTK_DIALOG(dialog), FALSE);
 	input->dialog = dialog;
 
 	gtk_dialog_add_button(GTK_DIALOG(dialog),
@@ -139,7 +138,7 @@ static void request_input_dialog(GHashTable *request,
 	gtk_table_set_row_spacings(GTK_TABLE(table), 4);
 	gtk_table_set_col_spacings(GTK_TABLE(table), 20);
 	gtk_container_set_border_width(GTK_CONTAINER(table), 12);
-	gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), table);
+	gtk_container_add(GTK_CONTAINER(gtk_dialog_get_content_area (GTK_DIALOG(dialog))), table);
 
 	label = gtk_label_new(_("Please provide some network information:"));
 	gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.0);
diff --git a/applet/main.c b/applet/main.c
index c7b3c7f..f2ce46b 100644
--- a/applet/main.c
+++ b/applet/main.c
@@ -157,46 +157,6 @@ static void name_owner_changed(DBusGProxy *proxy, const char *name,
 	}
 }
 
-static void open_uri(GtkWindow *parent, const char *uri)
-{
-	GtkWidget *dialog;
-	GdkScreen *screen;
-	GError *error = NULL;
-	gchar *cmdline;
-
-	screen = gtk_window_get_screen(parent);
-
-	cmdline = g_strconcat("xdg-open ", uri, NULL);
-
-	if (gdk_spawn_command_line_on_screen(screen,
-				cmdline, &error) == FALSE) {
-		dialog = gtk_message_dialog_new(parent,
-				GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_ERROR,
-				GTK_BUTTONS_CLOSE, "%s", error->message);
-		gtk_dialog_run(GTK_DIALOG(dialog));
-		gtk_widget_destroy(dialog);
-		g_error_free(error);
-	}
-
-	g_free(cmdline);
-}
-
-static void about_url_hook(GtkAboutDialog *dialog,
-				const gchar *url, gpointer data)
-{
-	open_uri(GTK_WINDOW(dialog), url);
-}
-
-static void about_email_hook(GtkAboutDialog *dialog,
-				const gchar *email, gpointer data)
-{
-	gchar *uri;
-
-	uri = g_strconcat("mailto:", email, NULL);
-	open_uri(GTK_WINDOW(dialog), uri);
-	g_free(uri);
-}
-
 static void about_callback(GtkWidget *item, gpointer user_data)
 {
 	const gchar *authors[] = {
@@ -204,9 +164,6 @@ static void about_callback(GtkWidget *item, gpointer user_data)
 		NULL
 	};
 
-	gtk_about_dialog_set_url_hook(about_url_hook, NULL, NULL);
-	gtk_about_dialog_set_email_hook(about_email_hook, NULL, NULL);
-
 	gtk_show_about_dialog(NULL, "version", VERSION,
 			"copyright", "Copyright \xc2\xa9 2008 Intel Corporation",
 			"comments", _("A connection manager for the GNOME desktop"),
diff --git a/applet/status.c b/applet/status.c
index aed6f1e..6ecbf3a 100644
--- a/applet/status.c
+++ b/applet/status.c
@@ -30,13 +30,14 @@
 static gboolean available = FALSE;
 
 static GtkStatusIcon *statusicon = NULL;
+static gint icon_size = 0;
 
 static GdkPixbuf *pixbuf_load(GtkIconTheme *icontheme, const gchar *name)
 {
 	GdkPixbuf *pixbuf;
 	GError *error = NULL;
 
-	pixbuf = gtk_icon_theme_load_icon(icontheme, name, 22, 0, &error);
+	pixbuf = gtk_icon_theme_load_icon(icontheme, name, icon_size, 0, &error);
 
 	if (pixbuf == NULL) {
 		g_warning("Missing icon %s: %s", name, error->message);
@@ -102,8 +103,6 @@ static void icon_animation_start(IconAnimation *animation,
 {
 	available = TRUE;
 
-	gtk_status_icon_set_tooltip(statusicon, NULL);
-
 	animation->start = start;
 	animation->end = (end == 0) ? animation->count - 1 : end;
 
@@ -120,8 +119,6 @@ static void icon_animation_stop(IconAnimation *animation)
 {
 	available = TRUE;
 
-	gtk_status_icon_set_tooltip(statusicon, NULL);
-
 	if (animation->id > 0)
 		g_source_remove(animation->id);
 
@@ -190,6 +187,42 @@ static GdkPixbuf *pixbuf_none;
 static GdkPixbuf *pixbuf_wired;
 static GdkPixbuf *pixbuf_signal[5];
 
+static void
+load_icons (gint size)
+{
+        // educated guess to preload correct size
+        if (size == 0)
+                size = 34;
+
+        if (icon_size == size)
+                return;
+
+        icon_size = size;
+
+        if(pixbuf_none)
+                status_cleanup();
+
+        g_debug ("Loading icons at size %d", icon_size);
+        animation = icon_animation_load(icontheme, "connman-connecting", 33);
+        pixbuf_signal[0] = pixbuf_load(icontheme, "connman-signal-01");
+        pixbuf_signal[1] = pixbuf_load(icontheme, "connman-signal-02");
+        pixbuf_signal[2] = pixbuf_load(icontheme, "connman-signal-03");
+        pixbuf_signal[3] = pixbuf_load(icontheme, "connman-signal-04");
+        pixbuf_signal[4] = pixbuf_load(icontheme, "connman-signal-05");
+
+        pixbuf_none = pixbuf_load(icontheme, "connman-type-none");
+        pixbuf_wired = pixbuf_load(icontheme, "connman-type-wired");
+        pixbuf_notifier = pixbuf_load(icontheme, "connman-notifier-unavailable");
+}
+
+static gboolean
+size_changed_cb (GtkStatusIcon *statusicon,
+                 gint           size,
+                 gpointer       user_data)
+{
+        load_icons (size);
+}
+
 int status_init(StatusCallback activate, GtkWidget *popup)
 {
 	GdkScreen *screen;
@@ -204,17 +237,9 @@ int status_init(StatusCallback activate, GtkWidget *popup)
 
 	gtk_icon_theme_append_search_path(icontheme, ICONDIR);
 
-	animation = icon_animation_load(icontheme, "connman-connecting", 33);
-
-	pixbuf_signal[0] = pixbuf_load(icontheme, "connman-signal-01");
-	pixbuf_signal[1] = pixbuf_load(icontheme, "connman-signal-02");
-	pixbuf_signal[2] = pixbuf_load(icontheme, "connman-signal-03");
-	pixbuf_signal[3] = pixbuf_load(icontheme, "connman-signal-04");
-	pixbuf_signal[4] = pixbuf_load(icontheme, "connman-signal-05");
-
-	pixbuf_none = pixbuf_load(icontheme, "connman-type-none");
-	pixbuf_wired = pixbuf_load(icontheme, "connman-type-wired");
-	pixbuf_notifier = pixbuf_load(icontheme, "connman-notifier-unavailable");
+	g_signal_connect (statusicon, "size-changed",
+			  G_CALLBACK(size_changed_cb), NULL);
+	load_icons (gtk_status_icon_get_size (statusicon));
 
 	if (activate != NULL)
 		g_signal_connect(statusicon, "activate",
@@ -231,17 +256,18 @@ void status_cleanup(void)
 	int i;
 
 	icon_animation_free(animation);
+	animation = NULL;
 
 	for (i = 0; i < 5; i++)
-		g_object_unref(pixbuf_signal[i]);
+		g_clear_object(&pixbuf_signal[i]);
 
-	g_object_unref(pixbuf_none);
-	g_object_unref(pixbuf_wired);
-	g_object_unref(pixbuf_notifier);
+	g_clear_object(&pixbuf_none);
+	g_clear_object(&pixbuf_wired);
+	g_clear_object(&pixbuf_notifier);
 
-	g_object_unref(icontheme);
+	g_clear_object(&icontheme);
 
-	g_object_unref(statusicon);
+	g_clear_object(&statusicon);
 }
 
 void status_unavailable(void)
@@ -251,8 +277,6 @@ void status_unavailable(void)
 	available = FALSE;
 
 	gtk_status_icon_set_from_pixbuf(statusicon, pixbuf_notifier);
-	gtk_status_icon_set_tooltip(statusicon,
-				"Connection Manager daemon is not running");
 
 	gtk_status_icon_set_visible(statusicon, TRUE);
 }
@@ -299,7 +323,6 @@ static void set_ready(gint signal)
 
 	if (signal < 0) {
 		gtk_status_icon_set_from_pixbuf(statusicon, pixbuf_wired);
-		gtk_status_icon_set_tooltip(statusicon, NULL);
 		return;
 	}
 
@@ -311,7 +334,6 @@ static void set_ready(gint signal)
 		index = 4;
 
 	gtk_status_icon_set_from_pixbuf(statusicon, pixbuf_signal[index]);
-	gtk_status_icon_set_tooltip(statusicon, NULL);
 }
 
 struct timeout_data {
diff --git a/configure.ac b/configure.ac
index b972e07..a4dad5d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -55,8 +55,7 @@ AC_SUBST(DBUS_LIBS)
 DBUS_BINDING_TOOL="dbus-binding-tool"
 AC_SUBST(DBUS_BINDING_TOOL)
 
-PKG_CHECK_MODULES(GTK, gtk+-2.0 >= 2.8, dummy=yes,
-				AC_MSG_ERROR(gtk+ >= 2.8 is required))
+PKG_CHECK_MODULES(GTK, gtk+-3.0)
 AC_SUBST(GTK_CFLAGS)
 AC_SUBST(GTK_LIBS)
 
diff --git a/properties/ethernet.c b/properties/ethernet.c
index 31db7a0..0b6b423 100644
--- a/properties/ethernet.c
+++ b/properties/ethernet.c
@@ -82,7 +82,7 @@ void add_ethernet_switch_button(GtkWidget *mainbox, GtkTreeIter *iter,
 	gtk_container_set_border_width(GTK_CONTAINER(vbox), 24);
 	gtk_box_pack_start(GTK_BOX(mainbox), vbox, FALSE, FALSE, 0);
 
-	table = gtk_table_new(1, 1, TRUE);
+	table = gtk_table_new(1, 1, FALSE);
 	gtk_table_set_row_spacings(GTK_TABLE(table), 10);
 	gtk_table_set_col_spacings(GTK_TABLE(table), 10);
 	gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 0);
@@ -136,7 +136,7 @@ void add_ethernet_service(GtkWidget *mainbox, GtkTreeIter *iter, struct config_d
 	gtk_container_set_border_width(GTK_CONTAINER(vbox), 24);
 	gtk_box_pack_start(GTK_BOX(mainbox), vbox, FALSE, FALSE, 0);
 
-	table = gtk_table_new(5, 5, TRUE);
+	table = gtk_table_new(5, 5, FALSE);
 	gtk_table_set_row_spacings(GTK_TABLE(table), 10);
 	gtk_table_set_col_spacings(GTK_TABLE(table), 10);
 	gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 0);
@@ -144,9 +144,9 @@ void add_ethernet_service(GtkWidget *mainbox, GtkTreeIter *iter, struct config_d
 	label = gtk_label_new(_("Configuration:"));
 	gtk_table_attach_defaults(GTK_TABLE(table), label, 1, 2, 0, 1);
 
-	combo = gtk_combo_box_new_text();
-	gtk_combo_box_append_text(GTK_COMBO_BOX(combo), "DHCP");
-	gtk_combo_box_append_text(GTK_COMBO_BOX(combo), "MANUAL");
+	combo = gtk_combo_box_text_new();
+	gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(combo), "DHCP");
+	gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(combo), "MANUAL");
 	gtk_combo_box_set_row_separator_func(GTK_COMBO_BOX(combo),
 					separator_function, NULL, NULL);
 	gtk_table_attach_defaults(GTK_TABLE(table), combo, 2, 4, 0, 1);
@@ -219,7 +219,7 @@ void update_ethernet_ipv4(struct config_data *data, guint policy)
 	case CONNMAN_POLICY_DHCP:
 		gtk_combo_box_set_active(GTK_COMBO_BOX(combo), 0);
 		for (i = 0; i < 3; i++) {
-			gtk_entry_set_editable(GTK_ENTRY(entry[i]), 0);
+			gtk_editable_set_editable(GTK_EDITABLE(entry[i]), 0);
 			gtk_widget_set_sensitive(entry[i], 0);
 			gtk_entry_set_text(GTK_ENTRY(entry[i]), _(""));
 		}
@@ -227,7 +227,7 @@ void update_ethernet_ipv4(struct config_data *data, guint policy)
 	case CONNMAN_POLICY_MANUAL:
 		gtk_combo_box_set_active(GTK_COMBO_BOX(combo), 1);
 		for (i = 0; i < 3; i++) {
-			gtk_entry_set_editable(GTK_ENTRY(entry[i]), 1);
+			gtk_editable_set_editable(GTK_EDITABLE(entry[i]), 1);
 			gtk_widget_set_sensitive(entry[i], 1);
 		}
 		break;
diff --git a/properties/main.c b/properties/main.c
index c05f443..6f76361 100644
--- a/properties/main.c
+++ b/properties/main.c
@@ -429,7 +429,7 @@ static GtkWidget *create_interfaces(GtkWidget *window)
 
 	scrolled = gtk_scrolled_window_new(NULL, NULL);
 	gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled),
-				GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+				GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
 	gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolled),
 							GTK_SHADOW_OUT);
 	gtk_box_pack_start(GTK_BOX(hbox), scrolled, FALSE, TRUE, 0);
diff --git a/properties/wifi.c b/properties/wifi.c
index bd325ef..a5827e0 100644
--- a/properties/wifi.c
+++ b/properties/wifi.c
@@ -125,7 +125,7 @@ void add_wifi_switch_button(GtkWidget *mainbox, GtkTreeIter *iter,
 	gtk_container_set_border_width(GTK_CONTAINER(vbox), 24);
 	gtk_box_pack_start(GTK_BOX(mainbox), vbox, FALSE, FALSE, 0);
 
-	table = gtk_table_new(1, 1, TRUE);
+	table = gtk_table_new(1, 1, FALSE);
 	gtk_table_set_row_spacings(GTK_TABLE(table), 10);
 	gtk_table_set_col_spacings(GTK_TABLE(table), 10);
 	gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 0);
@@ -185,9 +185,9 @@ static void wifi_ipconfig(GtkWidget *table, struct config_data *data, GtkTreeIte
 	gtk_table_attach_defaults(GTK_TABLE(table), label, 1, 2, 3, 4);
 	data->ipv4.label[0] = label;
 
-	combo = gtk_combo_box_new_text();
-	gtk_combo_box_append_text(GTK_COMBO_BOX(combo), "DHCP");
-	gtk_combo_box_append_text(GTK_COMBO_BOX(combo), "Manual");
+	combo = gtk_combo_box_text_new();
+	gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(combo), "DHCP");
+	gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(combo), "Manual");
 
 	gtk_combo_box_set_row_separator_func(GTK_COMBO_BOX(combo),
 			separator_function, NULL, NULL);
@@ -335,14 +335,14 @@ void update_wifi_ipv4(struct config_data *data, guint policy)
 	case CONNMAN_POLICY_DHCP:
 		gtk_combo_box_set_active(GTK_COMBO_BOX(combo), 0);
 		for (i = 0; i < 3; i++) {
-			gtk_entry_set_editable(GTK_ENTRY(entry[i]), 0);
+			gtk_editable_set_editable(GTK_EDITABLE(entry[i]), 0);
 			gtk_widget_set_sensitive(entry[i], 0);
 		}
 		break;
 	case CONNMAN_POLICY_MANUAL:
 		gtk_combo_box_set_active(GTK_COMBO_BOX(combo), 1);
 		for (i = 0; i < 3; i++) {
-			gtk_entry_set_editable(GTK_ENTRY(entry[i]), 1);
+			gtk_editable_set_editable(GTK_EDITABLE(entry[i]), 1);
 			gtk_widget_set_sensitive(entry[i], 1);
 		}
 		break;
-- 
2.1.4