Merge lp:~awn-testing/awn/awn-rewrite-ua-support into lp:~awn-core/awn/trunk-rewrite
- awn-rewrite-ua-support
- Merge into trunk-rewrite
Proposed by
Julien Lavergne
Status: | Superseded |
---|---|
Proposed branch: | lp:~awn-testing/awn/awn-rewrite-ua-support |
Merge into: | lp:~awn-core/awn/trunk-rewrite |
Diff against target: | None lines |
To merge this branch: | bzr merge lp:~awn-testing/awn/awn-rewrite-ua-support |
Related bugs: |
This proposal supersedes a proposal from 2009-07-15.
This proposal has been superseded by a proposal from 2009-07-15.
Commit message
Description of the change
To post a comment you must log in.
Revision history for this message
moonbeam (rcryderman) wrote : Posted in a previous version of this proposal | # |
- 841. By Julien Lavergne
-
Fix also tabs in AwnDefs.py.in
- 842. By moonbeam
-
* applets/
uawrapper/ awn-ua- wrapper. h:
Removed leftover file - 843. By moonbeam
-
* libawn/
awn-alignment. c:
Sync file with rewrite. - 844. By moonbeam
-
* src/awn-
applet- manager. c:
* src/awn-applet- manager. h:
* src/awn-ua-alignment. c:
Various whitespace fixes.
Modified awn_ua_get_all_ server_ flags() .
Removed touch_quark set on UaAlignment() for UAAlignment. - 845. By moonbeam
-
Merge rewrite.
- 846. By moonbeam
-
* applets/uawrapper/:
Removed empty dir. - 847. By moonbeam
-
Merged rewrite
- 848. By Michal Hruby
-
Changes to the DBus interface
Unmerged revisions
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === added directory 'applets/uawrapper' |
2 | === added file 'applets/uawrapper/awn-ua-wrapper.h' |
3 | --- applets/uawrapper/awn-ua-wrapper.h 1970-01-01 00:00:00 +0000 |
4 | +++ applets/uawrapper/awn-ua-wrapper.h 2009-06-25 04:55:53 +0000 |
5 | @@ -0,0 +1,42 @@ |
6 | +/* awn-ua-wrapper.h */ |
7 | + |
8 | +#ifndef _AWN_UA_WRAPPER |
9 | +#define _AWN_UA_WRAPPER |
10 | + |
11 | +#include <glib-object.h> |
12 | +#include <libawn/libawn.h> |
13 | + |
14 | +G_BEGIN_DECLS |
15 | + |
16 | +#define AWN_TYPE_UA_WRAPPER awn_ua_wrapper_get_type() |
17 | + |
18 | +#define AWN_UA_WRAPPER(obj) \ |
19 | + (G_TYPE_CHECK_INSTANCE_CAST ((obj), AWN_TYPE_UA_WRAPPER, AwnUAWrapper)) |
20 | + |
21 | +#define AWN_UA_WRAPPER_CLASS(klass) \ |
22 | + (G_TYPE_CHECK_CLASS_CAST ((klass), AWN_TYPE_UA_WRAPPER, AwnUAWrapperClass)) |
23 | + |
24 | +#define AWN_IS_UA_WRAPPER(obj) \ |
25 | + (G_TYPE_CHECK_INSTANCE_TYPE ((obj), AWN_TYPE_UA_WRAPPER)) |
26 | + |
27 | +#define AWN_IS_UA_WRAPPER_CLASS(klass) \ |
28 | + (G_TYPE_CHECK_CLASS_TYPE ((klass), AWN_TYPE_UA_WRAPPER)) |
29 | + |
30 | +#define AWN_UA_WRAPPER_GET_CLASS(obj) \ |
31 | + (G_TYPE_INSTANCE_GET_CLASS ((obj), AWN_TYPE_UA_WRAPPER, AwnUAWrapperClass)) |
32 | + |
33 | +typedef struct { |
34 | + AwnApplet parent; |
35 | +} AwnUAWrapper; |
36 | + |
37 | +typedef struct { |
38 | + AwnAppletClass parent_class; |
39 | +} AwnUAWrapperClass; |
40 | + |
41 | +GType awn_ua_wrapper_get_type (void); |
42 | + |
43 | +AwnUAWrapper* awn_ua_wrapper_new (gchar* uid, gint panel_id); |
44 | + |
45 | +G_END_DECLS |
46 | + |
47 | +#endif /* _AWN_UA_WRAPPER */ |
48 | |
49 | === modified file 'awn-settings/awnClass.py' |
50 | --- awn-settings/awnClass.py 2009-07-10 00:56:51 +0000 |
51 | +++ awn-settings/awnClass.py 2009-07-15 20:12:48 +0000 |
52 | @@ -1537,16 +1537,23 @@ |
53 | os.unlink(filename) |
54 | |
55 | def _apply (self): |
56 | - l = [] |
57 | + applets_list = [] |
58 | + ua_list = [] |
59 | + |
60 | it = self.active_model.get_iter_first () |
61 | while (it): |
62 | path = self.active_model.get_value (it, 1) |
63 | uid = self.active_model.get_value (it, 2) |
64 | s = "%s::%s" % (path, uid) |
65 | - l.append (s) |
66 | + if path.endswith(".desktop"): |
67 | + applets_list.append(s) |
68 | + else: |
69 | + ua_list.append(s) |
70 | + |
71 | it= self.active_model.iter_next (it) |
72 | |
73 | - self.client.set_list(defs.PANEL, defs.APPLET_LIST, awn.CONFIG_LIST_STRING, l) |
74 | + self.client.set_list(defs.PANEL, defs.APPLET_LIST, awn.CONFIG_LIST_STRING, applets_list) |
75 | + self.client.set_list(defs.PANEL, defs.UA_LIST, awn.CONFIG_LIST_STRING, ua_list) |
76 | |
77 | def up_clicked (self, button): |
78 | select = self.treeview.get_selection() |
79 | @@ -1592,18 +1599,32 @@ |
80 | |
81 | applets = self.client.get_list(defs.PANEL, defs.APPLET_LIST, awn.CONFIG_LIST_STRING) |
82 | |
83 | + ua_applets = self.client.get_list(defs.PANEL, defs.UA_LIST, awn.CONFIG_LIST_STRING) |
84 | + |
85 | + for ua in ua_applets: |
86 | + tokens = ua.split("::") |
87 | + applets.insert(int(tokens[1]), ua) |
88 | + |
89 | self.refresh_icon_list (applets, self.active_model) |
90 | |
91 | def refresh_icon_list (self, applets, model): |
92 | for a in applets: |
93 | tokens = a.split("::") |
94 | - path = tokens[0] |
95 | - uid = tokens[1] |
96 | - icon, text, name = self.make_row(path) |
97 | - if len (text) < 2: |
98 | - continue; |
99 | + if tokens[0].endswith(".desktop"): |
100 | + path = tokens[0] |
101 | + uid = tokens[1] |
102 | + icon, text, name = self.make_row(path) |
103 | + if len (text) < 2: |
104 | + continue; |
105 | |
106 | - model.append([icon, path, uid, text]) |
107 | + model.append([icon, path, uid, text]) |
108 | + else: |
109 | + path = tokens[0] |
110 | + uid = tokens[1] |
111 | + theme = gtk.icon_theme_get_default () |
112 | + icon = theme.load_icon ("screenlets", 32, 0) |
113 | + text = tokens[0] |
114 | + model.append([icon, path, uid, text]) |
115 | |
116 | def load_applets (self): |
117 | applets = self.applets_by_categories() |
118 | @@ -1645,7 +1666,21 @@ |
119 | applets = l.values() |
120 | |
121 | if not None in applets and self.load_finished: |
122 | - self.client.set_list(defs.PANEL, defs.APPLET_LIST, awn.CONFIG_LIST_STRING, applets) |
123 | + applets_list = [] |
124 | + ua_list = [] |
125 | + for a in applets: |
126 | + tokens = a.split("::") |
127 | + path = tokens[0] |
128 | + if path.endswith(".desktop"): |
129 | + applets_list.append(a) |
130 | + else: |
131 | + position = applets.index(a) |
132 | + ua = tokens[0] + "::" + str(position) |
133 | + ua_list.append(ua) |
134 | + |
135 | + self.client.set_list(defs.PANEL, defs.APPLET_LIST, awn.CONFIG_LIST_STRING, applets_list) |
136 | + self.client.set_list(defs.PANEL, defs.UA_LIST, awn.CONFIG_LIST_STRING, ua_list) |
137 | + |
138 | |
139 | def callback_widget_filter_applets(self, data=None): |
140 | model = self.choose_categorie.get_model() |
141 | |
142 | === modified file 'awn-settings/awnDefs.py.in' |
143 | --- awn-settings/awnDefs.py.in 2009-07-10 00:56:51 +0000 |
144 | +++ awn-settings/awnDefs.py.in 2009-07-14 19:09:25 +0000 |
145 | @@ -59,6 +59,7 @@ |
146 | EXPAND = "expand" #bool |
147 | CLICKTHROUGH = "clickthrough" #int |
148 | BEHAVIOR = "behavior" #int |
149 | +UA_LIST = "ua_active_list" #list-string |
150 | |
151 | PANELS = "panels" #group |
152 | PANEL_LIST = "panel_list" #int |
153 | |
154 | === modified file 'data/awn.schema-ini.in' |
155 | --- data/awn.schema-ini.in 2009-07-06 22:12:25 +0000 |
156 | +++ data/awn.schema-ini.in 2009-07-14 18:01:40 +0000 |
157 | @@ -28,6 +28,16 @@ |
158 | default = @APPLETDATADIR@/taskmanager.desktop::1 |
159 | description = The list of applets for this panel ordered from ltr or ttb. |
160 | |
161 | +[panel/ua_list] |
162 | +type = list-string |
163 | +default = |
164 | +description = The list of UA Screenlets that have been previous added in the form ScreeneletInstance::Position. |
165 | + |
166 | +[panel/ua_active_list] |
167 | +type = list-string |
168 | +default = |
169 | +description = The active list UA Screenlets for this panel. |
170 | + |
171 | [panel/monitor_force] |
172 | type = bool |
173 | default = False |
174 | |
175 | === modified file 'libawn/awn-alignment.c' |
176 | --- libawn/awn-alignment.c 2009-03-26 23:47:26 +0000 |
177 | +++ libawn/awn-alignment.c 2009-06-25 18:26:59 +0000 |
178 | @@ -192,6 +192,18 @@ |
179 | return alignment; |
180 | } |
181 | |
182 | +GtkWidget* |
183 | +awn_alignment_new (void) |
184 | +{ |
185 | + GtkWidget *alignment; |
186 | + |
187 | + alignment = g_object_new(AWN_TYPE_ALIGNMENT, |
188 | + NULL); |
189 | + |
190 | + return alignment; |
191 | +} |
192 | + |
193 | + |
194 | static void |
195 | on_orient_changed (AwnAlignment *alignment, AwnOrientation orient) |
196 | { |
197 | |
198 | === modified file 'libawn/awn-alignment.h' |
199 | --- libawn/awn-alignment.h 2009-03-22 23:12:16 +0000 |
200 | +++ libawn/awn-alignment.h 2009-06-25 18:26:59 +0000 |
201 | @@ -80,6 +80,8 @@ |
202 | void awn_alignment_set_offset_modifier (AwnAlignment *alignment, |
203 | gint modifier); |
204 | |
205 | +GtkWidget* awn_alignment_new (void); |
206 | + |
207 | G_END_DECLS |
208 | |
209 | #endif |
210 | |
211 | === modified file 'src/Makefile.am' |
212 | --- src/Makefile.am 2009-06-21 13:23:05 +0000 |
213 | +++ src/Makefile.am 2009-07-13 18:20:16 +0000 |
214 | @@ -27,6 +27,7 @@ |
215 | awn-app-glue.h \ |
216 | awn-applet-manager.c \ |
217 | awn-applet-manager.h \ |
218 | + awn-applet-manager-glue.h \ |
219 | awn-applet-proxy.c \ |
220 | awn-applet-proxy.h \ |
221 | awn-background.c \ |
222 | @@ -51,6 +52,8 @@ |
223 | awn-panel-glue.h \ |
224 | awn-throbber.c \ |
225 | awn-throbber.h \ |
226 | + awn-ua-alignment.c \ |
227 | + awn-ua-alignment.h \ |
228 | awn-x.h \ |
229 | awn-x.c \ |
230 | inlinepixbufs.h \ |
231 | @@ -65,9 +68,13 @@ |
232 | awn-panel-glue.h: awn-panel-dbus.xml Makefile |
233 | $(LIBTOOL) --mode=execute $(DBUS_GLIB_BIN)/dbus-binding-tool --prefix=awn_panel --mode=glib-server --output=$@ $< |
234 | |
235 | +awn-applet-manager-glue.h: awn-applet-manager-dbus.xml Makefile |
236 | + $(LIBTOOL) --mode=execute $(DBUS_GLIB_BIN)/dbus-binding-tool --prefix=awn_ua --mode=glib-server --output=$@ $< |
237 | + |
238 | BUILT_SOURCES = \ |
239 | awn-app-glue.h \ |
240 | awn-panel-glue.h \ |
241 | + awn-applet-manager-glue.h \ |
242 | $(MARSHALFILES) \ |
243 | $(NULL) |
244 | |
245 | @@ -76,6 +83,7 @@ |
246 | EXTRA_DIST = \ |
247 | awn-app-dbus.xml \ |
248 | awn-panel-dbus.xml \ |
249 | + awn-applet-manager-dbus.xml \ |
250 | $(NULL) |
251 | |
252 | # vim: set ts=8 sts=8 sw=8 : |
253 | |
254 | === added file 'src/awn-applet-manager-dbus.xml' |
255 | --- src/awn-applet-manager-dbus.xml 1970-01-01 00:00:00 +0000 |
256 | +++ src/awn-applet-manager-dbus.xml 2009-06-02 22:11:19 +0000 |
257 | @@ -0,0 +1,21 @@ |
258 | +<?xml version="1.0"?> |
259 | +<node name="/org/awnproject/Awn/UA"> |
260 | + <interface name="org.awnproject.Awn.UA"> |
261 | + <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="awn_ua"/> |
262 | + |
263 | + <!-- Methods --> |
264 | + <method name="add_applet"> |
265 | + <arg name="name" type="s" direction="in" /> |
266 | + <arg name="uid" type="x" direction="in" /> |
267 | + <arg name="width" type="i" direction="in" /> |
268 | + <arg name="height" type="i" direction="in" /> |
269 | + <arg name="size_type" type="s" direction="in" /> |
270 | + </method> |
271 | + |
272 | + <method name="get_all_server_flags"> |
273 | + <arg name="name" type="s" direction="in" /> |
274 | + <arg name="hash" type="a{ss}" direction="out" /> |
275 | + </method> |
276 | + |
277 | + </interface> |
278 | +</node> |
279 | |
280 | === modified file 'src/awn-applet-manager.c' |
281 | --- src/awn-applet-manager.c 2009-07-09 07:12:27 +0000 |
282 | +++ src/awn-applet-manager.c 2009-07-15 17:12:11 +0000 |
283 | @@ -21,17 +21,21 @@ |
284 | |
285 | #include "config.h" |
286 | |
287 | -#include <libawn/awn-config-bridge.h> |
288 | +#include <libawn/libawn.h> |
289 | +#include <dbus/dbus-glib.h> |
290 | +#include <dbus/dbus-glib-bindings.h> |
291 | #include <libawn/awn-utils.h> |
292 | #include <math.h> |
293 | |
294 | #include "awn-defines.h" |
295 | #include "awn-applet-manager.h" |
296 | - |
297 | +#include "awn-ua-alignment.h" |
298 | #include "awn-applet-proxy.h" |
299 | #include "awn-throbber.h" |
300 | #include "xutils.h" |
301 | |
302 | +#define MAX_UA_LIST_ENTRIES 50 |
303 | + |
304 | G_DEFINE_TYPE (AwnAppletManager, awn_applet_manager, GTK_TYPE_BOX) |
305 | |
306 | #define AWN_APPLET_MANAGER_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE (obj, \ |
307 | @@ -44,8 +48,15 @@ |
308 | AwnOrientation orient; |
309 | gint offset; |
310 | gint size; |
311 | + |
312 | GSList *applet_list; |
313 | |
314 | + /*ua_list does not serve the same purpose as the applet_list |
315 | + It's a list of unique UA names plus their position in the panel |
316 | + */ |
317 | + GSList *ua_list; |
318 | + GSList *ua_active_list; |
319 | + |
320 | gboolean docklet_mode; |
321 | GtkWidget *docklet_widget; |
322 | |
323 | @@ -60,6 +71,7 @@ |
324 | |
325 | /* Current box class */ |
326 | GtkWidgetClass *klass; |
327 | + |
328 | }; |
329 | |
330 | enum |
331 | @@ -71,6 +83,8 @@ |
332 | PROP_OFFSET, |
333 | PROP_SIZE, |
334 | PROP_APPLET_LIST, |
335 | + PROP_UA_LIST, |
336 | + PROP_UA_ACTIVE_LIST, |
337 | PROP_EXPANDS |
338 | }; |
339 | |
340 | @@ -123,6 +137,20 @@ |
341 | AWN_GROUP_PANEL, AWN_PANEL_APPLET_LIST, |
342 | AWN_CONFIG_CLIENT_LIST_TYPE_STRING, |
343 | object, "applet_list"); |
344 | + awn_config_bridge_bind_list (bridge, priv->client, |
345 | + AWN_GROUP_PANEL, AWN_PANEL_UA_LIST, |
346 | + AWN_CONFIG_CLIENT_LIST_TYPE_STRING, |
347 | + object, "ua_list"); |
348 | + awn_config_bridge_bind_list (bridge, priv->client, |
349 | + AWN_GROUP_PANEL, AWN_PANEL_UA_ACTIVE_LIST, |
350 | + AWN_CONFIG_CLIENT_LIST_TYPE_STRING, |
351 | + object, "ua_active_list"); |
352 | + /* |
353 | + ua_active_list should be empty when awn starts... |
354 | + */ |
355 | + awn_config_client_set_list (priv->client,AWN_GROUP_PANEL, AWN_PANEL_UA_ACTIVE_LIST, |
356 | + AWN_CONFIG_CLIENT_LIST_TYPE_STRING, |
357 | + NULL, NULL); |
358 | } |
359 | |
360 | static void |
361 | @@ -165,10 +193,15 @@ |
362 | case PROP_SIZE: |
363 | g_value_set_int (value, priv->size); |
364 | break; |
365 | - |
366 | case PROP_APPLET_LIST: |
367 | g_value_set_pointer (value, priv->applet_list); |
368 | break; |
369 | + case PROP_UA_LIST: |
370 | + g_value_set_pointer (value, priv->ua_list); |
371 | + break; |
372 | + case PROP_UA_ACTIVE_LIST: |
373 | + g_value_set_pointer (value, priv->ua_active_list); |
374 | + break; |
375 | case PROP_EXPANDS: |
376 | g_value_set_boolean (value, priv->expands); |
377 | break; |
378 | @@ -208,6 +241,16 @@ |
379 | priv->applet_list = g_value_get_pointer (value); |
380 | awn_applet_manager_refresh_applets (manager); |
381 | break; |
382 | + case PROP_UA_LIST: |
383 | + free_list (priv->ua_list); |
384 | + priv->ua_list = g_value_get_pointer (value); |
385 | + awn_applet_manager_refresh_applets (manager); |
386 | + break; |
387 | + case PROP_UA_ACTIVE_LIST: |
388 | + free_list (priv->ua_active_list); |
389 | + priv->ua_active_list = g_value_get_pointer (value); |
390 | + awn_applet_manager_refresh_applets (manager); |
391 | + break; |
392 | default: |
393 | G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); |
394 | } |
395 | @@ -240,6 +283,8 @@ |
396 | G_OBJECT_CLASS (awn_applet_manager_parent_class)->dispose (object); |
397 | } |
398 | |
399 | +#include "awn-applet-manager-glue.h" |
400 | + |
401 | static void |
402 | awn_applet_manager_class_init (AwnAppletManagerClass *klass) |
403 | { |
404 | @@ -294,6 +339,20 @@ |
405 | G_PARAM_READWRITE | G_PARAM_CONSTRUCT)); |
406 | |
407 | g_object_class_install_property (obj_class, |
408 | + PROP_UA_LIST, |
409 | + g_param_spec_pointer ("ua_list", |
410 | + "UA List", |
411 | + "The rememebered screenlet positions for this panel", |
412 | + G_PARAM_READWRITE | G_PARAM_CONSTRUCT)); |
413 | + |
414 | + g_object_class_install_property (obj_class, |
415 | + PROP_UA_ACTIVE_LIST, |
416 | + g_param_spec_pointer ("ua-active-list", |
417 | + "UA Active List", |
418 | + "The list of acitve screenlets for this panel", |
419 | + G_PARAM_READWRITE | G_PARAM_CONSTRUCT)); |
420 | + |
421 | + g_object_class_install_property (obj_class, |
422 | PROP_EXPANDS, |
423 | g_param_spec_boolean ("expands", |
424 | "Expands", |
425 | @@ -321,12 +380,18 @@ |
426 | G_TYPE_NONE, 0); |
427 | |
428 | g_type_class_add_private (obj_class, sizeof (AwnAppletManagerPrivate)); |
429 | + |
430 | + dbus_g_object_type_install_info (G_TYPE_FROM_CLASS (klass), |
431 | + &dbus_glib_awn_ua_object_info); |
432 | + |
433 | } |
434 | |
435 | static void |
436 | awn_applet_manager_init (AwnAppletManager *manager) |
437 | { |
438 | AwnAppletManagerPrivate *priv; |
439 | + DBusGConnection *connection; |
440 | + GError *error = NULL; |
441 | |
442 | priv = manager->priv = AWN_APPLET_MANAGER_GET_PRIVATE (manager); |
443 | |
444 | @@ -338,6 +403,21 @@ |
445 | priv->extra_widgets = g_hash_table_new (g_direct_hash, g_direct_equal); |
446 | |
447 | gtk_widget_show_all (GTK_WIDGET (manager)); |
448 | + |
449 | + /* Grab a connection to the bus */ |
450 | + connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error); |
451 | + if (connection == NULL) |
452 | + { |
453 | + g_warning ("Unable to make connection to the D-Bus session bus: %s", |
454 | + error->message); |
455 | + g_error_free (error); |
456 | + gtk_main_quit (); |
457 | + } |
458 | + |
459 | + dbus_g_connection_register_g_object (connection, |
460 | + AWN_DBUS_MANAGER_PATH, |
461 | + G_OBJECT (GTK_WIDGET (manager))); |
462 | + |
463 | } |
464 | |
465 | GtkWidget * |
466 | @@ -505,7 +585,6 @@ |
467 | g_type_class_unref (priv->klass); |
468 | priv->klass = NULL; |
469 | } |
470 | - |
471 | switch (priv->orient) |
472 | { |
473 | case AWN_ORIENTATION_TOP: |
474 | @@ -547,7 +626,10 @@ |
475 | { |
476 | g_free (l->data); |
477 | } |
478 | - g_slist_free (list); |
479 | + if (list) |
480 | + { |
481 | + g_slist_free (list); |
482 | + } |
483 | } |
484 | |
485 | /* |
486 | @@ -752,6 +834,7 @@ |
487 | gtk_box_pack_start (GTK_BOX (manager), widget, FALSE, FALSE, 0); |
488 | /* caller is supposed to call gtk_widget_show! */ |
489 | } |
490 | + g_print ("Gint : %i : ", pos); |
491 | g_hash_table_replace (priv->extra_widgets, widget, GINT_TO_POINTER (pos)); |
492 | |
493 | awn_applet_manager_refresh_applets (manager); |
494 | @@ -769,6 +852,159 @@ |
495 | } |
496 | } |
497 | |
498 | +/*DBUS*/ |
499 | +/* |
500 | + Description of this dbus interface. |
501 | + |
502 | + @action(IFACE) |
503 | + def add_applet (self, id, plug_id, width, height, size_type): |
504 | + """ |
505 | + Add an applet. |
506 | + |
507 | + id: A unique string used to identify the applet. |
508 | + plug_id: The applet's gtk.Plug's xid. |
509 | + width: A recommended width. This will be interpreted according to size_type. |
510 | + height A recommended height. This will be interpreted according to size_type. |
511 | + size_type: Determines the meaning of width and height. |
512 | + May be one of the following values: |
513 | + "scalable"- The applet may be resized as long as the width/height ratio is kept. |
514 | + "static"- The applet should be displayed at exactly the size requested. |
515 | + "static-width"- The applet's width should remain static, and the server may change the height. |
516 | + "static-height"- The applet's height should remain static, and the server may change the width. |
517 | + "dynamic"- The applet may be resized to any size. |
518 | + desktop_path: Path to the desktop file. |
519 | + """ |
520 | + # NOTE: Melange currently ignores the size_type parameter. |
521 | + container = ToplevelContainer(plug_id, id, self, width, height, |
522 | + size_type, backend=self.backend) |
523 | + self.containers.append(container) |
524 | +*/ |
525 | +gboolean |
526 | +awn_ua_add_applet ( AwnAppletManager *manager, |
527 | + gchar *name, |
528 | + glong xid, |
529 | + gint width, |
530 | + gint height, |
531 | + gchar *size_type, |
532 | + GError **error) |
533 | +{ |
534 | + g_return_val_if_fail (AWN_IS_APPLET_MANAGER (manager),FALSE); |
535 | + g_return_val_if_fail ( (g_strcmp0(size_type,"scalable")==0 ) || |
536 | + (g_strcmp0(size_type,"dynamic")==0 ), FALSE ); |
537 | + |
538 | + GdkWindow* plugwin; |
539 | + AwnAppletManagerPrivate *priv = manager->priv; |
540 | + gint pos = g_slist_length (priv->applet_list); |
541 | + GdkNativeWindow native_window = (GdkNativeWindow) xid; |
542 | + gchar * tmp = g_strdup_printf ("%s::%d",name,pos); |
543 | + gchar * ua_list_entry = NULL; |
544 | + GtkWidget *ua_alignment; |
545 | + double ua_ratio; |
546 | + |
547 | + /* |
548 | + Is there an entry in ua_list for this particular screenlet instance(name). |
549 | + The comparision function used ignores the position. |
550 | + */ |
551 | + GSList * search = g_slist_find_custom (priv->ua_list,tmp,awn_ua_alignment_list_cmp); |
552 | + if (search) |
553 | + { |
554 | + /* There's already an entry in ua_list so use that. */ |
555 | + GStrv tokens; |
556 | + ua_list_entry = g_strdup (search->data) ; |
557 | + g_free (tmp); |
558 | + /* Get the position where the screenlet should be placed*/ |
559 | + tokens = g_strsplit (search->data,"::",2); |
560 | + if (tokens && tokens[1]) |
561 | + { |
562 | + pos = atoi (tokens[1]); |
563 | + } |
564 | + g_strfreev (tokens); |
565 | + /* remove the link... that data will be appended at to the list*/ |
566 | + g_free (search->data); |
567 | + priv->ua_list = g_slist_delete_link (priv->ua_list,search); |
568 | + search = NULL; |
569 | + } |
570 | + else |
571 | + { |
572 | + /* |
573 | + This screenlet instance is not recorded in ua_list. It will end up being |
574 | + placed at the end of the bar |
575 | + */ |
576 | + ua_list_entry = tmp; |
577 | + } |
578 | + |
579 | + /* |
580 | + Calculated here and passed to the awn_ua_alignment_new(). AwnUAAlignment |
581 | + could recalculate the ratio on bar resizes based on the, then current, |
582 | + dimensions of the widget but over time the amount of error in the the |
583 | + calcs would increase |
584 | + */ |
585 | + ua_ratio = width / (double) height; |
586 | + ua_alignment = awn_ua_alignment_new(manager,ua_list_entry,ua_ratio); |
587 | + |
588 | + g_signal_connect_swapped (awn_ua_alignment_get_socket(AWN_UA_ALIGNMENT(ua_alignment)), |
589 | + "plug-added", |
590 | + G_CALLBACK (_applet_plug_added), |
591 | + manager); |
592 | + |
593 | + awn_applet_manager_add_widget(manager, GTK_WIDGET (ua_alignment), pos); |
594 | + gtk_widget_show_all (ua_alignment); |
595 | + |
596 | + plugwin = awn_ua_alignment_add_id (AWN_UA_ALIGNMENT(ua_alignment),native_window); |
597 | + |
598 | + g_object_set_qdata (G_OBJECT (ua_alignment), |
599 | + priv->touch_quark, GINT_TO_POINTER (0)); |
600 | + |
601 | + if (!plugwin) |
602 | + { |
603 | + g_warning ("UA Plug was not created within socket."); |
604 | + gtk_widget_destroy (ua_alignment); |
605 | + return FALSE; |
606 | + } |
607 | + |
608 | + /* |
609 | + Either add the new entry into ua_list or move an existing entry to the |
610 | + end of ua_list_entry |
611 | + */ |
612 | + priv->ua_list = g_slist_append (priv->ua_list,g_strdup(ua_list_entry)); |
613 | + |
614 | + /* Keep the length of ua_list reasonable */ |
615 | + if (g_slist_length (priv->ua_list) > MAX_UA_LIST_ENTRIES) |
616 | + { |
617 | + GSList * iter; |
618 | + int i = g_slist_length (priv->ua_list) - MAX_UA_LIST_ENTRIES; |
619 | + for(iter = priv->ua_list; i && iter ; iter = priv->ua_list ) |
620 | + { |
621 | + g_free (iter->data); |
622 | + priv->ua_list = g_slist_delete_link (priv->ua_list,iter); |
623 | + i--; |
624 | + } |
625 | + } |
626 | + awn_config_client_set_list (priv->client,AWN_GROUP_PANEL, AWN_PANEL_UA_LIST, |
627 | + AWN_CONFIG_CLIENT_LIST_TYPE_STRING, |
628 | + priv->ua_list, NULL); |
629 | + /*Add our newly active screenlet to thend of the active list */ |
630 | + priv->ua_active_list = g_slist_append (priv->ua_active_list,g_strdup(ua_list_entry)); |
631 | + awn_config_client_set_list (priv->client,AWN_GROUP_PANEL, AWN_PANEL_UA_ACTIVE_LIST, |
632 | + AWN_CONFIG_CLIENT_LIST_TYPE_STRING, |
633 | + priv->ua_active_list, NULL); |
634 | + |
635 | + return TRUE; |
636 | +} |
637 | + |
638 | +gboolean |
639 | +awn_ua_get_all_server_flags ( AwnAppletManager *manager, |
640 | + GHashTable *hash, |
641 | + gchar *name, |
642 | + GError **error) |
643 | +{ |
644 | +/* Future function to return capability of the server |
645 | +For now, it return nothing*/ |
646 | +return TRUE; |
647 | +} |
648 | + |
649 | + |
650 | +/*End DBUS*/ |
651 | void |
652 | awn_applet_manager_show_applets (AwnAppletManager *manager) |
653 | { |
654 | |
655 | === modified file 'src/awn-applet-manager.h' |
656 | --- src/awn-applet-manager.h 2009-07-08 20:38:35 +0000 |
657 | +++ src/awn-applet-manager.h 2009-07-13 18:05:02 +0000 |
658 | @@ -25,6 +25,7 @@ |
659 | #include <gtk/gtk.h> |
660 | |
661 | #include <libawn/awn-config-client.h> |
662 | +#include <libawn/awn-defines.h> |
663 | |
664 | #include "awn-panel.h" |
665 | |
666 | @@ -82,9 +83,25 @@ |
667 | |
668 | gboolean awn_applet_manager_get_expands (AwnAppletManager *manager); |
669 | |
670 | -void awn_applet_manager_set_applet_flags (AwnAppletManager *manager, |
671 | - const gchar *uid, |
672 | - AwnAppletFlags flags); |
673 | + |
674 | + |
675 | +gboolean awn_ua_get_all_server_flags (AwnAppletManager *manager, |
676 | + GHashTable *hash, |
677 | + gchar *name, |
678 | + GError **error); |
679 | + |
680 | +gboolean awn_ua_add_applet ( AwnAppletManager *manager, |
681 | + gchar *name, |
682 | + glong xid, |
683 | + gint width, |
684 | + gint height, |
685 | + gchar *size_type, |
686 | + GError **error); |
687 | + |
688 | + |
689 | +void awn_applet_manager_set_applet_flags (AwnAppletManager *manager, |
690 | + const gchar *uid, |
691 | + AwnAppletFlags flags); |
692 | |
693 | void awn_applet_manager_show_applets (AwnAppletManager *manager); |
694 | void awn_applet_manager_hide_applets (AwnAppletManager *manager); |
695 | |
696 | === modified file 'src/awn-applet-proxy.c' |
697 | --- src/awn-applet-proxy.c 2009-07-08 21:17:59 +0000 |
698 | +++ src/awn-applet-proxy.c 2009-07-13 18:05:02 +0000 |
699 | @@ -276,6 +276,7 @@ |
700 | 1, G_TYPE_INT); |
701 | |
702 | g_type_class_add_private (obj_class, sizeof (AwnAppletProxyPrivate)); |
703 | + |
704 | } |
705 | |
706 | static gboolean |
707 | @@ -349,6 +350,8 @@ |
708 | return proxy; |
709 | } |
710 | |
711 | + |
712 | + |
713 | /* |
714 | * GtkSocket callbacks |
715 | */ |
716 | @@ -552,4 +555,3 @@ |
717 | priv->idle_id = g_idle_add (awn_applet_proxy_idle_cb, proxy); |
718 | } |
719 | } |
720 | - |
721 | |
722 | === modified file 'src/awn-defines.h' |
723 | --- src/awn-defines.h 2009-04-18 00:36:20 +0000 |
724 | +++ src/awn-defines.h 2009-07-14 18:01:40 +0000 |
725 | @@ -28,6 +28,7 @@ |
726 | |
727 | #define AWN_DBUS_APP_PATH AWN_DBUS_PATH |
728 | #define AWN_DBUS_PANEL_PATH AWN_DBUS_PATH"/Panel" |
729 | +#define AWN_DBUS_MANAGER_PATH AWN_DBUS_PATH"/UA" |
730 | |
731 | /* FIXME: Move some of these out into libawn when we can */ |
732 | #define AWN_GROUP_PANEL "panel" |
733 | @@ -38,6 +39,8 @@ |
734 | #define AWN_PANEL_SIZE "size" |
735 | #define AWN_PANEL_AUTOHIDE "autohide" |
736 | #define AWN_PANEL_APPLET_LIST "applet_list" |
737 | +#define AWN_PANEL_UA_LIST "ua_list" |
738 | +#define AWN_PANEL_UA_ACTIVE_LIST "ua_active_list" |
739 | #define AWN_PANEL_MONITOR_HEIGHT "monitor_height" |
740 | #define AWN_PANEL_MONITOR_WIDTH "monitor_width" |
741 | #define AWN_PANEL_MONITOR_FORCE "monitor_force" |
742 | |
743 | === added file 'src/awn-ua-alignment.c' |
744 | --- src/awn-ua-alignment.c 1970-01-01 00:00:00 +0000 |
745 | +++ src/awn-ua-alignment.c 2009-07-15 18:28:34 +0000 |
746 | @@ -0,0 +1,469 @@ |
747 | +/* |
748 | + * Copyright (C) 2009 Rodney Cryderman <rcryderman@gmail.com> |
749 | + * |
750 | + * This program is free software; you can redistribute it and/or modify |
751 | + * it under the terms of the GNU General Public License as published by |
752 | + * the Free Software Foundation; either version 2 of the License, or |
753 | + * (at your option) any later version. |
754 | + * |
755 | + * This program is distributed in the hope that it will be useful, |
756 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
757 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
758 | + * GNU General Public License for more details. |
759 | + * |
760 | + * You should have received a copy of the GNU General Public License |
761 | + * along with this program; if not, write to the Free Software |
762 | + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
763 | + * |
764 | + * |
765 | + */ |
766 | + |
767 | +/* awn-ua-alignment.c */ |
768 | +#include <stdlib.h> |
769 | +#include "awn-ua-alignment.h" |
770 | +#include "awn-defines.h" |
771 | + |
772 | +G_DEFINE_TYPE (AwnUAAlignment, awn_ua_alignment, GTK_TYPE_ALIGNMENT) |
773 | + |
774 | +#define AWN_UA_ALIGNMENT_GET_PRIVATE(o) \ |
775 | + (G_TYPE_INSTANCE_GET_PRIVATE ((o), AWN_TYPE_UA_ALIGNMENT, AwnUAAlignmentPrivate)) |
776 | + |
777 | +typedef struct _AwnUAAlignmentPrivate AwnUAAlignmentPrivate; |
778 | + |
779 | +struct _AwnUAAlignmentPrivate |
780 | +{ |
781 | + GtkWidget * socket; |
782 | + GtkWidget * applet_manager; |
783 | + |
784 | + gchar *ua_list_entry; |
785 | + double ua_ratio; |
786 | + |
787 | + guint notify_size_id; |
788 | + guint notify_orient_id; |
789 | + guint notify_offset_id; |
790 | + guint notify_ua_list_id; |
791 | +}; |
792 | + |
793 | +enum |
794 | +{ |
795 | + PROP_0, |
796 | + PROP_APPLET_MANAGER, |
797 | + PROP_UA_LIST_ENTRY, |
798 | + PROP_UA_RATIO |
799 | +}; |
800 | + |
801 | + |
802 | +static gboolean awn_ua_alignment_plug_removed (GtkWidget * socket, |
803 | + AwnUAAlignment * self); |
804 | +static void awn_ua_alignment_list_change(GObject *object, |
805 | + GParamSpec *param_spec, |
806 | + gpointer user_data); |
807 | +static void awn_ua_alignment_orient_change(GObject *object, |
808 | + GParamSpec *param_spec, |
809 | + gpointer user_data); |
810 | +static void awn_ua_alignment_size_change(GObject *object, |
811 | + GParamSpec *param_spec, |
812 | + gpointer user_data); |
813 | +static void awn_ua_alignment_offset_change(GObject *object, |
814 | + GParamSpec *param_spec, |
815 | + gpointer user_data); |
816 | + |
817 | + |
818 | +static void |
819 | +awn_ua_alignment_get_property (GObject *object, guint property_id, |
820 | + GValue *value, GParamSpec *pspec) |
821 | +{ |
822 | + AwnUAAlignmentPrivate * priv; |
823 | + |
824 | + priv = AWN_UA_ALIGNMENT_GET_PRIVATE (object); |
825 | + |
826 | + switch (property_id) |
827 | + { |
828 | + case PROP_APPLET_MANAGER: |
829 | + g_value_set_object (value,priv->applet_manager); |
830 | + break; |
831 | + case PROP_UA_LIST_ENTRY: |
832 | + g_value_set_string (value,priv->ua_list_entry); |
833 | + break; |
834 | + case PROP_UA_RATIO: |
835 | + g_value_set_double (value,priv->ua_ratio); |
836 | + break; |
837 | + default: |
838 | + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); |
839 | + } |
840 | +} |
841 | + |
842 | +static void |
843 | +awn_ua_alignment_set_property (GObject *object, guint property_id, |
844 | + const GValue *value, GParamSpec *pspec) |
845 | +{ |
846 | + AwnUAAlignmentPrivate * priv; |
847 | + |
848 | + priv = AWN_UA_ALIGNMENT_GET_PRIVATE (object); |
849 | + switch (property_id) |
850 | + { |
851 | + case PROP_APPLET_MANAGER: |
852 | + priv->applet_manager = g_value_get_object (value); |
853 | + break; |
854 | + case PROP_UA_LIST_ENTRY: |
855 | + g_free (priv->ua_list_entry); |
856 | + priv->ua_list_entry = g_value_dup_string (value); |
857 | + break; |
858 | + case PROP_UA_RATIO: |
859 | + priv->ua_ratio = g_value_get_double (value); |
860 | + break; |
861 | + default: |
862 | + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); |
863 | + } |
864 | +} |
865 | + |
866 | +static void |
867 | +awn_ua_alignment_dispose (GObject *object) |
868 | +{ |
869 | + G_OBJECT_CLASS (awn_ua_alignment_parent_class)->dispose (object); |
870 | +} |
871 | + |
872 | +static void |
873 | +awn_ua_alignment_finalize (GObject *object) |
874 | +{ |
875 | + AwnUAAlignmentPrivate * priv = AWN_UA_ALIGNMENT_GET_PRIVATE (object); |
876 | + g_debug ("%s",__func__); |
877 | + if (priv->ua_list_entry) |
878 | + { |
879 | + g_free (priv->ua_list_entry); |
880 | + } |
881 | + G_OBJECT_CLASS (awn_ua_alignment_parent_class)->finalize (object); |
882 | +} |
883 | + |
884 | +static void |
885 | +awn_ua_alignment_constructed (GObject *object) |
886 | +{ |
887 | + AwnUAAlignmentPrivate * priv = AWN_UA_ALIGNMENT_GET_PRIVATE (object); |
888 | + |
889 | + if (G_OBJECT_CLASS (awn_ua_alignment_parent_class)->constructed) |
890 | + { |
891 | + G_OBJECT_CLASS (awn_ua_alignment_parent_class)->constructed (object); |
892 | + } |
893 | + |
894 | + gtk_container_add (GTK_CONTAINER(object),priv->socket); |
895 | + awn_ua_alignment_orient_change (NULL,NULL,object); |
896 | + priv->notify_offset_id = g_signal_connect (priv->applet_manager, |
897 | + "notify::offset", |
898 | + G_CALLBACK(awn_ua_alignment_offset_change), |
899 | + object); |
900 | + priv->notify_orient_id = g_signal_connect_after (priv->applet_manager, |
901 | + "notify::orient", |
902 | + G_CALLBACK(awn_ua_alignment_orient_change), |
903 | + object); |
904 | + priv->notify_size_id = g_signal_connect_after (priv->applet_manager, |
905 | + "notify::size", |
906 | + G_CALLBACK(awn_ua_alignment_size_change), |
907 | + object); |
908 | + priv->notify_ua_list_id = g_signal_connect_after (priv->applet_manager, |
909 | + "notify::ua-active-list", |
910 | + G_CALLBACK(awn_ua_alignment_list_change), |
911 | + object); |
912 | +} |
913 | + |
914 | +static void |
915 | +awn_ua_alignment_class_init (AwnUAAlignmentClass *klass) |
916 | +{ |
917 | + GObjectClass *object_class = G_OBJECT_CLASS (klass); |
918 | + GParamSpec *pspec; |
919 | + |
920 | + object_class->get_property = awn_ua_alignment_get_property; |
921 | + object_class->set_property = awn_ua_alignment_set_property; |
922 | + object_class->dispose = awn_ua_alignment_dispose; |
923 | + object_class->finalize = awn_ua_alignment_finalize; |
924 | + object_class->constructed = awn_ua_alignment_constructed; |
925 | + |
926 | + pspec = g_param_spec_object ("applet-manager", |
927 | + "Awn Applet Manager", |
928 | + "Awn Applet Manager", |
929 | + AWN_TYPE_APPLET_MANAGER, |
930 | + G_PARAM_READWRITE | G_PARAM_CONSTRUCT); |
931 | + g_object_class_install_property (object_class, PROP_APPLET_MANAGER, pspec); |
932 | + |
933 | + pspec = g_param_spec_string ("ua-list-entry", |
934 | + "UA List entry", |
935 | + "UA List entry", |
936 | + NULL, |
937 | + G_PARAM_READWRITE | G_PARAM_CONSTRUCT); |
938 | + g_object_class_install_property (object_class, PROP_UA_LIST_ENTRY, pspec); |
939 | + |
940 | + pspec = g_param_spec_double ("ua-ratio", |
941 | + "UA Ratio", |
942 | + "UA Ratio", |
943 | + 0.0, |
944 | + 100.0, |
945 | + 1.0, |
946 | + G_PARAM_READWRITE | G_PARAM_CONSTRUCT); |
947 | + g_object_class_install_property (object_class, PROP_UA_RATIO, pspec); |
948 | + |
949 | + g_type_class_add_private (klass, sizeof (AwnUAAlignmentPrivate)); |
950 | +} |
951 | + |
952 | +static void |
953 | +awn_ua_alignment_init (AwnUAAlignment *self) |
954 | +{ |
955 | + AwnUAAlignmentPrivate *priv; |
956 | + |
957 | + priv = AWN_UA_ALIGNMENT_GET_PRIVATE (self); |
958 | + priv->socket = gtk_socket_new (); |
959 | +} |
960 | + |
961 | +GtkWidget* |
962 | +awn_ua_alignment_new (AwnAppletManager *manager,gchar * ua_list_entry,double ua_ratio) |
963 | +{ |
964 | + return g_object_new (AWN_TYPE_UA_ALIGNMENT, |
965 | + "applet-manager",manager, |
966 | + "ua-list-entry",ua_list_entry, |
967 | + "ua-ratio",ua_ratio, |
968 | + NULL); |
969 | +} |
970 | + |
971 | +GtkWidget* |
972 | +awn_ua_alignment_get_socket (AwnUAAlignment *self) |
973 | +{ |
974 | + AwnUAAlignmentPrivate *priv; |
975 | + |
976 | + priv = AWN_UA_ALIGNMENT_GET_PRIVATE (self); |
977 | + return priv->socket; |
978 | +} |
979 | + |
980 | + |
981 | +GdkWindow * |
982 | +awn_ua_alignment_add_id (AwnUAAlignment *self,GdkNativeWindow native_window) |
983 | +{ |
984 | + GdkWindow * plugwin; |
985 | + AwnUAAlignmentPrivate *priv; |
986 | + |
987 | + priv = AWN_UA_ALIGNMENT_GET_PRIVATE (self); |
988 | + gtk_socket_add_id (GTK_SOCKET(priv->socket), native_window); |
989 | + plugwin = gtk_socket_get_plug_window (GTK_SOCKET(priv->socket)); |
990 | + g_signal_connect (priv->socket,"plug-removed", |
991 | + G_CALLBACK(awn_ua_alignment_plug_removed),self); |
992 | + gtk_widget_realize (priv->socket); |
993 | + gtk_widget_show_all (priv->socket); |
994 | + return plugwin; |
995 | +} |
996 | + |
997 | + |
998 | +static gboolean |
999 | +awn_ua_alignment_plug_removed (GtkWidget * socket,AwnUAAlignment * self) |
1000 | +{ |
1001 | + |
1002 | + GSList * search; |
1003 | + GSList * ua_active_list; |
1004 | + GSList * orig_active_list; |
1005 | + GSList * iter; |
1006 | + AwnConfigClient *client; |
1007 | + |
1008 | + AwnUAAlignmentPrivate *priv = AWN_UA_ALIGNMENT_GET_PRIVATE (self); |
1009 | + |
1010 | + g_signal_handler_disconnect (priv->applet_manager,priv->notify_size_id); |
1011 | + g_signal_handler_disconnect (priv->applet_manager,priv->notify_orient_id); |
1012 | + g_signal_handler_disconnect (priv->applet_manager,priv->notify_offset_id); |
1013 | + g_signal_handler_disconnect (priv->applet_manager,priv->notify_ua_list_id); |
1014 | + |
1015 | + g_object_get ( priv->applet_manager, |
1016 | + "ua_active_list",&orig_active_list, |
1017 | + "client",&client, |
1018 | + NULL); |
1019 | + ua_active_list = g_slist_copy (orig_active_list); |
1020 | + for (iter = ua_active_list;iter;iter = iter->next) |
1021 | + { |
1022 | + iter->data = g_strdup(iter->data); |
1023 | + } |
1024 | + search = g_slist_find_custom (ua_active_list,priv->ua_list_entry, |
1025 | + (GCompareFunc)g_strcmp0); |
1026 | + if (search) |
1027 | + { |
1028 | + ua_active_list = g_slist_delete_link (ua_active_list,search); |
1029 | + } |
1030 | + awn_config_client_set_list (client,AWN_GROUP_PANEL, AWN_PANEL_UA_ACTIVE_LIST, |
1031 | + AWN_CONFIG_CLIENT_LIST_TYPE_STRING, |
1032 | + ua_active_list, NULL); |
1033 | + g_object_set (priv->applet_manager, |
1034 | + "ua-active-list",ua_active_list, |
1035 | + NULL); |
1036 | + awn_applet_manager_remove_widget(AWN_APPLET_MANAGER(priv->applet_manager), |
1037 | + GTK_WIDGET (self)); |
1038 | + return FALSE; |
1039 | +} |
1040 | + |
1041 | +/*UA*/ |
1042 | +gint |
1043 | +awn_ua_alignment_list_cmp (gconstpointer a, gconstpointer b) |
1044 | +{ |
1045 | + const gchar * str1 = a; |
1046 | + const gchar * str2 = b; |
1047 | + gchar * search = NULL; |
1048 | + GStrv tokens = g_strsplit (str1,"::",2); |
1049 | + g_return_val_if_fail (tokens,-1); |
1050 | + |
1051 | + search = g_strstr_len (str2,-1,tokens[0]); |
1052 | + g_strfreev (tokens); |
1053 | + |
1054 | + if (!search) |
1055 | + { |
1056 | + return -1; |
1057 | + }; |
1058 | + return 0; |
1059 | +} |
1060 | + |
1061 | +static void |
1062 | +awn_ua_alignment_offset_change(GObject *object,GParamSpec *param_spec,gpointer user_data) |
1063 | +{ |
1064 | + AwnUAAlignment * self = user_data; |
1065 | + gint offset; |
1066 | + gint orient; |
1067 | + AwnUAAlignmentPrivate *priv = AWN_UA_ALIGNMENT_GET_PRIVATE (self); |
1068 | + |
1069 | + g_object_get ( priv->applet_manager, |
1070 | + "offset",&offset, |
1071 | + "orient",&orient, |
1072 | + NULL); |
1073 | + |
1074 | + switch (orient) |
1075 | + { |
1076 | + case AWN_ORIENTATION_TOP: |
1077 | + gtk_alignment_set_padding (GTK_ALIGNMENT(self), offset, 0, 0, 0); |
1078 | + break; |
1079 | + case AWN_ORIENTATION_BOTTOM: |
1080 | + gtk_alignment_set_padding (GTK_ALIGNMENT(self), 0, offset, 0, 0); |
1081 | + break; |
1082 | + case AWN_ORIENTATION_LEFT: |
1083 | + gtk_alignment_set_padding (GTK_ALIGNMENT(self), 0, 0, offset, 0); |
1084 | + break; |
1085 | + case AWN_ORIENTATION_RIGHT: |
1086 | + gtk_alignment_set_padding (GTK_ALIGNMENT(self), 0, 0, 0, offset); |
1087 | + break; |
1088 | + default: |
1089 | + g_warning ("%s: recieved invalid orient %d",__func__,orient); |
1090 | + } |
1091 | +} |
1092 | + |
1093 | +static void |
1094 | +awn_ua_alignment_size_change(GObject *object,GParamSpec *param_spec,gpointer user_data) |
1095 | +{ |
1096 | + AwnUAAlignment * self = user_data; |
1097 | + gint offset; |
1098 | + gint orient; |
1099 | + gint size; |
1100 | + AwnUAAlignmentPrivate *priv = AWN_UA_ALIGNMENT_GET_PRIVATE (self); |
1101 | + |
1102 | + g_object_get ( priv->applet_manager, |
1103 | + "offset",&offset, |
1104 | + "orient",&orient, |
1105 | + "size",&size, |
1106 | + NULL); |
1107 | + GtkRequisition req; |
1108 | + |
1109 | + req.width = req.height = size; |
1110 | + switch (orient) |
1111 | + { |
1112 | + case AWN_ORIENTATION_TOP: |
1113 | + case AWN_ORIENTATION_BOTTOM: |
1114 | + req.width = size * priv->ua_ratio; |
1115 | + req.height = size; |
1116 | + break; |
1117 | + case AWN_ORIENTATION_LEFT: |
1118 | + case AWN_ORIENTATION_RIGHT: |
1119 | + req.width = size; |
1120 | + req.height = size * 1.0 / priv->ua_ratio; |
1121 | + break; |
1122 | + default: |
1123 | + g_warning ("%s: recieved invalid orient %d",__func__,orient); |
1124 | + } |
1125 | + gtk_widget_set_size_request (GTK_WIDGET(self),req.width,req.height); |
1126 | +} |
1127 | + |
1128 | +static void |
1129 | +awn_ua_alignment_orient_change(GObject *object,GParamSpec *param_spec,gpointer user_data) |
1130 | +{ |
1131 | + |
1132 | + AwnUAAlignment * self = user_data; |
1133 | + gint orient; |
1134 | + AwnUAAlignmentPrivate *priv = AWN_UA_ALIGNMENT_GET_PRIVATE (self); |
1135 | + |
1136 | + g_object_get ( priv->applet_manager, |
1137 | + "orient",&orient, |
1138 | + NULL); |
1139 | + switch (orient) |
1140 | + { |
1141 | + case AWN_ORIENTATION_TOP: |
1142 | + gtk_alignment_set (GTK_ALIGNMENT(self), 0.0, 0.0, 1.0, 0.5); |
1143 | + break; |
1144 | + case AWN_ORIENTATION_BOTTOM: |
1145 | + gtk_alignment_set (GTK_ALIGNMENT(self), 0.0, 1.0, 1.0, 0.5); |
1146 | + break; |
1147 | + case AWN_ORIENTATION_LEFT: |
1148 | + gtk_alignment_set (GTK_ALIGNMENT(self), 0.0, 0.0, 0.5, 1.0); |
1149 | + break; |
1150 | + case AWN_ORIENTATION_RIGHT: |
1151 | + gtk_alignment_set (GTK_ALIGNMENT(self), 1.0, 0.0, 0.5, 1.0); |
1152 | + break; |
1153 | + default: |
1154 | + g_warning ("%s: recieved invalid orient %d",__func__,orient); |
1155 | + } |
1156 | + awn_ua_alignment_offset_change (object,param_spec,self); |
1157 | + awn_ua_alignment_size_change (object,param_spec,self); |
1158 | +} |
1159 | + |
1160 | +static void |
1161 | +awn_ua_alignment_list_change(GObject *object,GParamSpec *param_spec,gpointer user_data) |
1162 | +{ |
1163 | + AwnUAAlignment * self = user_data; |
1164 | + gint orient; |
1165 | + AwnUAAlignmentPrivate *priv = AWN_UA_ALIGNMENT_GET_PRIVATE (self); |
1166 | + GSList * ua_active_list; |
1167 | + |
1168 | + g_object_get ( priv->applet_manager, |
1169 | + "orient",&orient, |
1170 | + "ua_active_list",&ua_active_list, |
1171 | + NULL); |
1172 | + |
1173 | + GSList * search = g_slist_find_custom (ua_active_list, |
1174 | + priv->ua_list_entry, |
1175 | + (GCompareFunc)g_strcmp0); |
1176 | + if (search) |
1177 | + { |
1178 | + g_debug ("Found... do not need to update %s",priv->ua_list_entry); |
1179 | + } |
1180 | + else |
1181 | + { |
1182 | + search = g_slist_find_custom (ua_active_list,priv->ua_list_entry,awn_ua_alignment_list_cmp); |
1183 | + if (search) |
1184 | + { |
1185 | + g_debug ("Moving %s to %s",priv->ua_list_entry,(gchar*)search->data); |
1186 | + GStrv tokens; |
1187 | + gint pos = -1; |
1188 | + g_free (priv->ua_list_entry); |
1189 | + priv->ua_list_entry = g_strdup(search->data); |
1190 | + tokens = g_strsplit (search->data,"::",2); |
1191 | + if (tokens && tokens[1]) |
1192 | + { |
1193 | + pos = atoi (tokens[1]); |
1194 | + } |
1195 | + g_strfreev (tokens); |
1196 | + if (pos != -1) |
1197 | + { |
1198 | + awn_applet_manager_add_widget(AWN_APPLET_MANAGER(priv->applet_manager), |
1199 | + GTK_WIDGET (self), |
1200 | + pos); |
1201 | + } |
1202 | + } |
1203 | + else |
1204 | + { |
1205 | + g_debug ("looks like %s was removed from panel/ua_list",priv->ua_list_entry); |
1206 | + /* |
1207 | + aantn as expected this does not kill the screenlet. What is the best way to |
1208 | + tell it that we want it to go away? |
1209 | + */ |
1210 | + awn_applet_manager_remove_widget(AWN_APPLET_MANAGER(priv->applet_manager), |
1211 | + GTK_WIDGET (self)); |
1212 | + gtk_widget_destroy (priv->socket); |
1213 | + } |
1214 | + } |
1215 | +} |
1216 | |
1217 | === added file 'src/awn-ua-alignment.h' |
1218 | --- src/awn-ua-alignment.h 1970-01-01 00:00:00 +0000 |
1219 | +++ src/awn-ua-alignment.h 2009-07-14 02:56:28 +0000 |
1220 | @@ -0,0 +1,68 @@ |
1221 | +/* |
1222 | + * Copyright (C) 2009 Rodney Cryderman <rcryderman@gmail.com> |
1223 | + * |
1224 | + * This program is free software; you can redistribute it and/or modify |
1225 | + * it under the terms of the GNU General Public License as published by |
1226 | + * the Free Software Foundation; either version 2 of the License, or |
1227 | + * (at your option) any later version. |
1228 | + * |
1229 | + * This program is distributed in the hope that it will be useful, |
1230 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1231 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1232 | + * GNU General Public License for more details. |
1233 | + * |
1234 | + * You should have received a copy of the GNU General Public License |
1235 | + * along with this program; if not, write to the Free Software |
1236 | + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
1237 | + * |
1238 | + * |
1239 | + */ |
1240 | + |
1241 | +/* awn-ua-alignment.h */ |
1242 | + |
1243 | +#ifndef _AWN_UA_ALIGNMENT |
1244 | +#define _AWN_UA_ALIGNMENT |
1245 | + |
1246 | +#include <gtk/gtk.h> |
1247 | +#include "awn-applet-manager.h" |
1248 | + |
1249 | +G_BEGIN_DECLS |
1250 | + |
1251 | +#define AWN_TYPE_UA_ALIGNMENT awn_ua_alignment_get_type() |
1252 | + |
1253 | +#define AWN_UA_ALIGNMENT(obj) \ |
1254 | + (G_TYPE_CHECK_INSTANCE_CAST ((obj), AWN_TYPE_UA_ALIGNMENT, AwnUAAlignment)) |
1255 | + |
1256 | +#define AWN_UA_ALIGNMENT_CLASS(klass) \ |
1257 | + (G_TYPE_CHECK_CLASS_CAST ((klass), AWN_TYPE_UA_ALIGNMENT, AwnUAAlignmentClass)) |
1258 | + |
1259 | +#define AWN_IS_UA_ALIGNMENT(obj) \ |
1260 | + (G_TYPE_CHECK_INSTANCE_TYPE ((obj), AWN_TYPE_UA_ALIGNMENT)) |
1261 | + |
1262 | +#define AWN_IS_UA_ALIGNMENT_CLASS(klass) \ |
1263 | + (G_TYPE_CHECK_CLASS_TYPE ((klass), AWN_TYPE_UA_ALIGNMENT)) |
1264 | + |
1265 | +#define AWN_UA_ALIGNMENT_GET_CLASS(obj) \ |
1266 | + (G_TYPE_INSTANCE_GET_CLASS ((obj), AWN_TYPE_UA_ALIGNMENT, AwnUAAlignmentClass)) |
1267 | + |
1268 | +typedef struct { |
1269 | + GtkAlignment parent; |
1270 | +} AwnUAAlignment; |
1271 | + |
1272 | +typedef struct { |
1273 | + GtkAlignmentClass parent_class; |
1274 | +} AwnUAAlignmentClass; |
1275 | + |
1276 | +GType awn_ua_alignment_get_type (void); |
1277 | + |
1278 | +GtkWidget* awn_ua_alignment_new (AwnAppletManager *manager,gchar * ua_list_entry,double ua_ratio); |
1279 | + |
1280 | +GtkWidget* awn_ua_alignment_get_socket (AwnUAAlignment *self); |
1281 | + |
1282 | +GdkWindow * awn_ua_alignment_add_id (AwnUAAlignment *self, GdkNativeWindow native_window); |
1283 | + |
1284 | +gint awn_ua_alignment_list_cmp (gconstpointer a, gconstpointer b); |
1285 | + |
1286 | +G_END_DECLS |
1287 | + |
1288 | +#endif /* _AWN_UA_ALIGNMENT */ |
It may not perfect, but I think it's good enough for a merge at this point. There's some design ugliness due to the alignment being outside of the socket. But most of the ua specific code is in its own object. And if UA/screenlets are not being used then there is close to zero impact on the code paths used by awn.