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