Awn

Merge lp:~awn-testing/awn/awn-rewrite-ua-support into lp:~awn-core/awn/trunk-rewrite

Proposed by Michal Hruby
Status: Merged
Approved by: moonbeam
Approved revision: 848
Merged at revision: not available
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
Reviewer Review Type Date Requested Status
Mark Lee superreview Approve
Michal Hruby (community) Approve
Review via email: mp+8972@code.launchpad.net

This proposal supersedes a proposal from 2009-07-16.

To post a comment you must log in.
Revision history for this message
moonbeam (rcryderman) wrote : Posted in a previous version of this proposal

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.

Revision history for this message
Mark Lee (malept) : Posted in a previous version of this proposal
review: Approve (superreview)
Revision history for this message
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-unfriendly. This would also remove the need to add dbus-specifics to AppletManager (*-glue.h and changes to Makefile.am)
6) get_all_server_flags method looks suspicious - hash table is not allocated, but TRUE is returned. (line 639)
7) There are mixed tabs/spaces in awn-applet-manager.h
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)?

review: Needs Fixing (detailed)
Revision history for this message
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-unfriendly. This would also remove the need to add dbus-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_server_flags method looks suspicious - hash table is not allocated,
> but TRUE is returned. (line 639)
Changed to return FALSE.

> 7) There are mixed tabs/spaces in awn-applet-manager.h

> 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.

Revision history for this message
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.

Revision history for this message
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-unfriendly. This would also remove the need to add dbus-
>> 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_server_flags method looks suspicious - hash table is not
>> allocated,
>> but TRUE is returned. (line 639)
> Changed to return FALSE.
>
>> 7) There are mixed tabs/spaces in awn-applet-manager.h
>
>> 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://code.launchpad.net/~awn-testing/awn/awn-rewrite-ua-support/+merge/8851
> You proposed lp:~awn-testing/awn/awn-rewrite-ua-support for merging.

Revision history for this message
Michal Hruby (mhr3) wrote :

From my point of view it's good to go, but someone please test with the actual UA before merging, since there were changes to the DBus interface (btw shouldn't there be a standardized name for the UA interface?).

review: Approve
Revision history for this message
Mark Lee (malept) :
review: Approve (superreview)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'awn-settings/awnClass.py'
--- awn-settings/awnClass.py 2009-07-15 20:40:32 +0000
+++ awn-settings/awnClass.py 2009-07-16 15:04:17 +0000
@@ -1541,16 +1541,23 @@
1541 os.unlink(filename)1541 os.unlink(filename)
15421542
1543 def _apply (self):1543 def _apply (self):
1544 l = []1544 applets_list = []
1545 ua_list = []
1546
1545 it = self.active_model.get_iter_first ()1547 it = self.active_model.get_iter_first ()
1546 while (it):1548 while (it):
1547 path = self.active_model.get_value (it, 1)1549 path = self.active_model.get_value (it, 1)
1548 uid = self.active_model.get_value (it, 2)1550 uid = self.active_model.get_value (it, 2)
1549 s = "%s::%s" % (path, uid)1551 s = "%s::%s" % (path, uid)
1550 l.append (s)1552 if path.endswith(".desktop"):
1553 applets_list.append(s)
1554 else:
1555 ua_list.append(s)
1556
1551 it= self.active_model.iter_next (it)1557 it= self.active_model.iter_next (it)
15521558
1553 self.client.set_list(defs.PANEL, defs.APPLET_LIST, awn.CONFIG_LIST_STRING, l)1559 self.client.set_list(defs.PANEL, defs.APPLET_LIST, awn.CONFIG_LIST_STRING, applets_list)
1560 self.client.set_list(defs.PANEL, defs.UA_LIST, awn.CONFIG_LIST_STRING, ua_list)
15541561
1555 def up_clicked (self, button):1562 def up_clicked (self, button):
1556 select = self.treeview.get_selection()1563 select = self.treeview.get_selection()
@@ -1596,18 +1603,32 @@
15961603
1597 applets = self.client.get_list(defs.PANEL, defs.APPLET_LIST, awn.CONFIG_LIST_STRING)1604 applets = self.client.get_list(defs.PANEL, defs.APPLET_LIST, awn.CONFIG_LIST_STRING)
15981605
1606 ua_applets = self.client.get_list(defs.PANEL, defs.UA_LIST, awn.CONFIG_LIST_STRING)
1607
1608 for ua in ua_applets:
1609 tokens = ua.split("::")
1610 applets.insert(int(tokens[1]), ua)
1611
1599 self.refresh_icon_list (applets, self.active_model)1612 self.refresh_icon_list (applets, self.active_model)
16001613
1601 def refresh_icon_list (self, applets, model):1614 def refresh_icon_list (self, applets, model):
1602 for a in applets:1615 for a in applets:
1603 tokens = a.split("::")1616 tokens = a.split("::")
1604 path = tokens[0]1617 if tokens[0].endswith(".desktop"):
1605 uid = tokens[1]1618 path = tokens[0]
1606 icon, text, name = self.make_row(path)1619 uid = tokens[1]
1607 if len (text) < 2:1620 icon, text, name = self.make_row(path)
1608 continue;1621 if len (text) < 2:
1622 continue;
16091623
1610 model.append([icon, path, uid, text])1624 model.append([icon, path, uid, text])
1625 else:
1626 path = tokens[0]
1627 uid = tokens[1]
1628 theme = gtk.icon_theme_get_default ()
1629 icon = theme.load_icon ("screenlets", 32, 0)
1630 text = tokens[0]
1631 model.append([icon, path, uid, text])
16111632
1612 def load_applets (self):1633 def load_applets (self):
1613 applets = self.applets_by_categories()1634 applets = self.applets_by_categories()
@@ -1649,7 +1670,21 @@
1649 applets = l.values()1670 applets = l.values()
16501671
1651 if not None in applets and self.load_finished:1672 if not None in applets and self.load_finished:
1652 self.client.set_list(defs.PANEL, defs.APPLET_LIST, awn.CONFIG_LIST_STRING, applets)1673 applets_list = []
1674 ua_list = []
1675 for a in applets:
1676 tokens = a.split("::")
1677 path = tokens[0]
1678 if path.endswith(".desktop"):
1679 applets_list.append(a)
1680 else:
1681 position = applets.index(a)
1682 ua = tokens[0] + "::" + str(position)
1683 ua_list.append(ua)
1684
1685 self.client.set_list(defs.PANEL, defs.APPLET_LIST, awn.CONFIG_LIST_STRING, applets_list)
1686 self.client.set_list(defs.PANEL, defs.UA_LIST, awn.CONFIG_LIST_STRING, ua_list)
1687
16531688
1654 def callback_widget_filter_applets(self, data=None):1689 def callback_widget_filter_applets(self, data=None):
1655 model = self.choose_categorie.get_model()1690 model = self.choose_categorie.get_model()
16561691
=== modified file 'awn-settings/awnDefs.py.in'
--- awn-settings/awnDefs.py.in 2009-07-10 00:56:51 +0000
+++ awn-settings/awnDefs.py.in 2009-07-15 20:43:31 +0000
@@ -59,6 +59,7 @@
59EXPAND = "expand" #bool59EXPAND = "expand" #bool
60CLICKTHROUGH = "clickthrough" #int60CLICKTHROUGH = "clickthrough" #int
61BEHAVIOR = "behavior" #int61BEHAVIOR = "behavior" #int
62UA_LIST = "ua_active_list" #list-string
6263
63PANELS = "panels" #group64PANELS = "panels" #group
64PANEL_LIST = "panel_list" #int65PANEL_LIST = "panel_list" #int
6566
=== modified file 'data/awn.schema-ini.in'
--- data/awn.schema-ini.in 2009-07-06 22:12:25 +0000
+++ data/awn.schema-ini.in 2009-07-14 18:01:40 +0000
@@ -28,6 +28,16 @@
28default = @APPLETDATADIR@/taskmanager.desktop::128default = @APPLETDATADIR@/taskmanager.desktop::1
29description = The list of applets for this panel ordered from ltr or ttb.29description = The list of applets for this panel ordered from ltr or ttb.
3030
31[panel/ua_list]
32type = list-string
33default =
34description = The list of UA Screenlets that have been previous added in the form ScreeneletInstance::Position.
35
36[panel/ua_active_list]
37type = list-string
38default =
39description = The active list UA Screenlets for this panel.
40
31[panel/monitor_force]41[panel/monitor_force]
32type = bool42type = bool
33default = False43default = False
3444
=== modified file 'src/Makefile.am'
--- src/Makefile.am 2009-06-21 13:23:05 +0000
+++ src/Makefile.am 2009-07-17 22:02:30 +0000
@@ -51,6 +51,8 @@
51 awn-panel-glue.h \51 awn-panel-glue.h \
52 awn-throbber.c \52 awn-throbber.c \
53 awn-throbber.h \53 awn-throbber.h \
54 awn-ua-alignment.c \
55 awn-ua-alignment.h \
54 awn-x.h \56 awn-x.h \
55 awn-x.c \57 awn-x.c \
56 inlinepixbufs.h \58 inlinepixbufs.h \
5759
=== modified file 'src/awn-applet-manager.c'
--- src/awn-applet-manager.c 2009-07-09 07:12:27 +0000
+++ src/awn-applet-manager.c 2009-07-17 22:13:45 +0000
@@ -21,17 +21,19 @@
2121
22#include "config.h"22#include "config.h"
2323
24#include <libawn/awn-config-bridge.h>24#include <libawn/libawn.h>
25#include <libawn/awn-utils.h>25#include <libawn/awn-utils.h>
26#include <math.h>26#include <math.h>
2727
28#include "awn-defines.h"28#include "awn-defines.h"
29#include "awn-applet-manager.h"29#include "awn-applet-manager.h"
3030#include "awn-ua-alignment.h"
31#include "awn-applet-proxy.h"31#include "awn-applet-proxy.h"
32#include "awn-throbber.h"32#include "awn-throbber.h"
33#include "xutils.h"33#include "xutils.h"
3434
35#define MAX_UA_LIST_ENTRIES 50
36
35G_DEFINE_TYPE (AwnAppletManager, awn_applet_manager, GTK_TYPE_BOX) 37G_DEFINE_TYPE (AwnAppletManager, awn_applet_manager, GTK_TYPE_BOX)
3638
37#define AWN_APPLET_MANAGER_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE (obj, \39#define AWN_APPLET_MANAGER_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE (obj, \
@@ -44,8 +46,15 @@
44 AwnOrientation orient;46 AwnOrientation orient;
45 gint offset;47 gint offset;
46 gint size;48 gint size;
49
47 GSList *applet_list;50 GSList *applet_list;
4851
52 /*ua_list does not serve the same purpose as the applet_list
53 It's a list of unique UA names plus their position in the panel
54 */
55 GSList *ua_list;
56 GSList *ua_active_list;
57
49 gboolean docklet_mode;58 gboolean docklet_mode;
50 GtkWidget *docklet_widget;59 GtkWidget *docklet_widget;
5160
@@ -60,6 +69,7 @@
6069
61 /* Current box class */70 /* Current box class */
62 GtkWidgetClass *klass;71 GtkWidgetClass *klass;
72
63};73};
6474
65enum 75enum
@@ -71,6 +81,8 @@
71 PROP_OFFSET,81 PROP_OFFSET,
72 PROP_SIZE,82 PROP_SIZE,
73 PROP_APPLET_LIST,83 PROP_APPLET_LIST,
84 PROP_UA_LIST,
85 PROP_UA_ACTIVE_LIST,
74 PROP_EXPANDS86 PROP_EXPANDS
75};87};
7688
@@ -123,6 +135,20 @@
123 AWN_GROUP_PANEL, AWN_PANEL_APPLET_LIST,135 AWN_GROUP_PANEL, AWN_PANEL_APPLET_LIST,
124 AWN_CONFIG_CLIENT_LIST_TYPE_STRING,136 AWN_CONFIG_CLIENT_LIST_TYPE_STRING,
125 object, "applet_list");137 object, "applet_list");
138 awn_config_bridge_bind_list (bridge, priv->client,
139 AWN_GROUP_PANEL, AWN_PANEL_UA_LIST,
140 AWN_CONFIG_CLIENT_LIST_TYPE_STRING,
141 object, "ua_list");
142 awn_config_bridge_bind_list (bridge, priv->client,
143 AWN_GROUP_PANEL, AWN_PANEL_UA_ACTIVE_LIST,
144 AWN_CONFIG_CLIENT_LIST_TYPE_STRING,
145 object, "ua_active_list");
146 /*
147 ua_active_list should be empty when awn starts...
148 */
149 awn_config_client_set_list (priv->client,AWN_GROUP_PANEL, AWN_PANEL_UA_ACTIVE_LIST,
150 AWN_CONFIG_CLIENT_LIST_TYPE_STRING,
151 NULL, NULL);
126}152}
127153
128static void154static void
@@ -165,10 +191,15 @@
165 case PROP_SIZE:191 case PROP_SIZE:
166 g_value_set_int (value, priv->size);192 g_value_set_int (value, priv->size);
167 break;193 break;
168
169 case PROP_APPLET_LIST:194 case PROP_APPLET_LIST:
170 g_value_set_pointer (value, priv->applet_list);195 g_value_set_pointer (value, priv->applet_list);
171 break;196 break;
197 case PROP_UA_LIST:
198 g_value_set_pointer (value, priv->ua_list);
199 break;
200 case PROP_UA_ACTIVE_LIST:
201 g_value_set_pointer (value, priv->ua_active_list);
202 break;
172 case PROP_EXPANDS:203 case PROP_EXPANDS:
173 g_value_set_boolean (value, priv->expands);204 g_value_set_boolean (value, priv->expands);
174 break;205 break;
@@ -208,6 +239,16 @@
208 priv->applet_list = g_value_get_pointer (value);239 priv->applet_list = g_value_get_pointer (value);
209 awn_applet_manager_refresh_applets (manager);240 awn_applet_manager_refresh_applets (manager);
210 break;241 break;
242 case PROP_UA_LIST:
243 free_list (priv->ua_list);
244 priv->ua_list = g_value_get_pointer (value);
245 awn_applet_manager_refresh_applets (manager);
246 break;
247 case PROP_UA_ACTIVE_LIST:
248 free_list (priv->ua_active_list);
249 priv->ua_active_list = g_value_get_pointer (value);
250 awn_applet_manager_refresh_applets (manager);
251 break;
211 default:252 default:
212 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);253 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
213 }254 }
@@ -294,6 +335,20 @@
294 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));335 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
295336
296 g_object_class_install_property (obj_class,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,
297 PROP_EXPANDS,352 PROP_EXPANDS,
298 g_param_spec_boolean ("expands",353 g_param_spec_boolean ("expands",
299 "Expands",354 "Expands",
@@ -505,7 +560,6 @@
505 g_type_class_unref (priv->klass);560 g_type_class_unref (priv->klass);
506 priv->klass = NULL;561 priv->klass = NULL;
507 }562 }
508
509 switch (priv->orient)563 switch (priv->orient)
510 {564 {
511 case AWN_ORIENTATION_TOP:565 case AWN_ORIENTATION_TOP:
@@ -547,7 +601,10 @@
547 {601 {
548 g_free (l->data);602 g_free (l->data);
549 }603 }
550 g_slist_free (list);604 if (list)
605 {
606 g_slist_free (list);
607 }
551}608}
552609
553/*610/*
@@ -653,7 +710,7 @@
653 if (priv->applet_list == NULL)710 if (priv->applet_list == NULL)
654 {711 {
655 g_debug ("No applets");712 g_debug ("No applets");
656 return;713 return; // FIXME: removing last applet doesn't work because of this
657 }714 }
658715
659 guint applet_count = g_slist_length (priv->applet_list);716 guint applet_count = g_slist_length (priv->applet_list);
@@ -769,6 +826,155 @@
769 }826 }
770}827}
771828
829/*DBUS*/
830/*
831 Description of this dbus interface.
832
833 @action(IFACE)
834 def add_applet (self, id, plug_id, width, height, size_type):
835 """
836 Add an applet.
837
838 id: A unique string used to identify the applet.
839 plug_id: The applet's gtk.Plug's xid.
840 width: A recommended width. This will be interpreted according to size_type.
841 height A recommended height. This will be interpreted according to size_type.
842 size_type: Determines the meaning of width and height.
843 May be one of the following values:
844 "scalable"- The applet may be resized as long as the width/height ratio is kept.
845 "static"- The applet should be displayed at exactly the size requested.
846 "static-width"- The applet's width should remain static, and the server may change the height.
847 "static-height"- The applet's height should remain static, and the server may change the width.
848 "dynamic"- The applet may be resized to any size.
849 desktop_path: Path to the desktop file.
850 """
851 # NOTE: Melange currently ignores the size_type parameter.
852 container = ToplevelContainer(plug_id, id, self, width, height,
853 size_type, backend=self.backend)
854 self.containers.append(container)
855*/
856gboolean
857awn_ua_add_applet ( AwnAppletManager *manager,
858 gchar *name, glong xid,
859 gint width, gint height,
860 gchar *size_type,
861 GError **error)
862{
863 g_return_val_if_fail (AWN_IS_APPLET_MANAGER (manager),FALSE);
864 g_return_val_if_fail ( (g_strcmp0(size_type,"scalable")==0 ) ||
865 (g_strcmp0(size_type,"dynamic")==0 ), FALSE );
866
867 GdkWindow* plugwin;
868 AwnAppletManagerPrivate *priv = manager->priv;
869 gint pos = g_slist_length (priv->applet_list);
870 GdkNativeWindow native_window = (GdkNativeWindow) xid;
871 gchar * tmp = g_strdup_printf ("%s::%d",name,pos);
872 gchar * ua_list_entry = NULL;
873 GtkWidget *ua_alignment;
874 double ua_ratio;
875
876 /*
877 Is there an entry in ua_list for this particular screenlet instance(name).
878 The comparision function used ignores the position.
879 */
880 GSList * search = g_slist_find_custom (priv->ua_list,tmp,awn_ua_alignment_list_cmp);
881 if (search)
882 {
883 /* There's already an entry in ua_list so use that. */
884 GStrv tokens;
885 ua_list_entry = g_strdup (search->data) ;
886 g_free (tmp);
887 /* Get the position where the screenlet should be placed*/
888 tokens = g_strsplit (search->data,"::",2);
889 if (tokens && tokens[1])
890 {
891 pos = atoi (tokens[1]);
892 }
893 g_strfreev (tokens);
894 /* remove the link... that data will be appended at to the list*/
895 g_free (search->data);
896 priv->ua_list = g_slist_delete_link (priv->ua_list,search);
897 search = NULL;
898 }
899 else
900 {
901 /*
902 This screenlet instance is not recorded in ua_list. It will end up being
903 placed at the end of the bar
904 */
905 ua_list_entry = tmp;
906 }
907
908 /*
909 Calculated here and passed to the awn_ua_alignment_new(). AwnUAAlignment
910 could recalculate the ratio on bar resizes based on the, then current,
911 dimensions of the widget but over time the amount of error in the the
912 calcs would increase
913 */
914 ua_ratio = width / (double) height;
915 ua_alignment = awn_ua_alignment_new(manager,ua_list_entry,ua_ratio);
916
917 g_signal_connect_swapped (awn_ua_alignment_get_socket(AWN_UA_ALIGNMENT(ua_alignment)),
918 "plug-added",
919 G_CALLBACK (_applet_plug_added),
920 manager);
921
922 awn_applet_manager_add_widget(manager, GTK_WIDGET (ua_alignment), pos);
923 gtk_widget_show_all (ua_alignment);
924
925 plugwin = awn_ua_alignment_add_id (AWN_UA_ALIGNMENT(ua_alignment),native_window);
926
927 if (!plugwin)
928 {
929 g_warning ("UA Plug was not created within socket.");
930 gtk_widget_destroy (ua_alignment);
931 return FALSE;
932 }
933
934 /*
935 Either add the new entry into ua_list or move an existing entry to the
936 end of ua_list_entry
937 */
938 priv->ua_list = g_slist_append (priv->ua_list,g_strdup(ua_list_entry));
939
940 /* Keep the length of ua_list reasonable */
941 if (g_slist_length (priv->ua_list) > MAX_UA_LIST_ENTRIES)
942 {
943 GSList * iter;
944 int i = g_slist_length (priv->ua_list) - MAX_UA_LIST_ENTRIES;
945 for(iter = priv->ua_list; i && iter ; iter = priv->ua_list )
946 {
947 g_free (iter->data);
948 priv->ua_list = g_slist_delete_link (priv->ua_list,iter);
949 i--;
950 }
951 }
952 awn_config_client_set_list (priv->client,AWN_GROUP_PANEL, AWN_PANEL_UA_LIST,
953 AWN_CONFIG_CLIENT_LIST_TYPE_STRING,
954 priv->ua_list, NULL);
955 /*Add our newly active screenlet to thend of the active list */
956 priv->ua_active_list = g_slist_append (priv->ua_active_list,g_strdup(ua_list_entry));
957 awn_config_client_set_list (priv->client,AWN_GROUP_PANEL, AWN_PANEL_UA_ACTIVE_LIST,
958 AWN_CONFIG_CLIENT_LIST_TYPE_STRING,
959 priv->ua_active_list, NULL);
960
961 return TRUE;
962}
963
964gboolean
965awn_ua_get_all_server_flags ( AwnAppletManager *manager,
966 GHashTable **hash,
967 gchar *name,
968 GError **error)
969{
970 *hash = g_hash_table_new(g_str_hash,g_str_equal);
971/* Future function to return capability of the server
972For now, it return nothing*/
973 return TRUE;
974}
975
976
977/*End DBUS*/
772void978void
773awn_applet_manager_show_applets (AwnAppletManager *manager)979awn_applet_manager_show_applets (AwnAppletManager *manager)
774{980{
775981
=== modified file 'src/awn-applet-manager.h'
--- src/awn-applet-manager.h 2009-07-08 20:38:35 +0000
+++ src/awn-applet-manager.h 2009-07-17 22:02:30 +0000
@@ -25,6 +25,7 @@
25#include <gtk/gtk.h>25#include <gtk/gtk.h>
2626
27#include <libawn/awn-config-client.h>27#include <libawn/awn-config-client.h>
28#include <libawn/awn-defines.h>
2829
29#include "awn-panel.h"30#include "awn-panel.h"
3031
@@ -96,6 +97,19 @@
96 AwnPathType path_type,97 AwnPathType path_type,
97 gfloat offset_modifier);98 gfloat offset_modifier);
9899
100/* UA stuff */
101
102gboolean awn_ua_get_all_server_flags (AwnAppletManager *manager,
103 GHashTable **hash,
104 gchar *name,
105 GError **error);
106
107gboolean awn_ua_add_applet (AwnAppletManager *manager,
108 gchar *name, glong xid,
109 gint width, gint height,
110 gchar *size_type,
111 GError **error);
112
99G_END_DECLS113G_END_DECLS
100114
101#endif /* _AWN_APPLET_MANAGER_H */115#endif /* _AWN_APPLET_MANAGER_H */
102116
=== modified file 'src/awn-defines.h'
--- src/awn-defines.h 2009-04-18 00:36:20 +0000
+++ src/awn-defines.h 2009-07-14 18:01:40 +0000
@@ -28,6 +28,7 @@
2828
29#define AWN_DBUS_APP_PATH AWN_DBUS_PATH29#define AWN_DBUS_APP_PATH AWN_DBUS_PATH
30#define AWN_DBUS_PANEL_PATH AWN_DBUS_PATH"/Panel"30#define AWN_DBUS_PANEL_PATH AWN_DBUS_PATH"/Panel"
31#define AWN_DBUS_MANAGER_PATH AWN_DBUS_PATH"/UA"
3132
32/* FIXME: Move some of these out into libawn when we can */33/* FIXME: Move some of these out into libawn when we can */
33#define AWN_GROUP_PANEL "panel"34#define AWN_GROUP_PANEL "panel"
@@ -38,6 +39,8 @@
38#define AWN_PANEL_SIZE "size"39#define AWN_PANEL_SIZE "size"
39#define AWN_PANEL_AUTOHIDE "autohide"40#define AWN_PANEL_AUTOHIDE "autohide"
40#define AWN_PANEL_APPLET_LIST "applet_list"41#define AWN_PANEL_APPLET_LIST "applet_list"
42#define AWN_PANEL_UA_LIST "ua_list"
43#define AWN_PANEL_UA_ACTIVE_LIST "ua_active_list"
41#define AWN_PANEL_MONITOR_HEIGHT "monitor_height"44#define AWN_PANEL_MONITOR_HEIGHT "monitor_height"
42#define AWN_PANEL_MONITOR_WIDTH "monitor_width"45#define AWN_PANEL_MONITOR_WIDTH "monitor_width"
43#define AWN_PANEL_MONITOR_FORCE "monitor_force"46#define AWN_PANEL_MONITOR_FORCE "monitor_force"
4447
=== modified file 'src/awn-panel-dbus.xml'
--- src/awn-panel-dbus.xml 2009-06-26 10:09:15 +0000
+++ src/awn-panel-dbus.xml 2009-07-17 22:02:30 +0000
@@ -69,4 +69,23 @@
69 <property name="PanelXid" type="x" access="read" />69 <property name="PanelXid" type="x" access="read" />
7070
71 </interface>71 </interface>
72
73 <interface name="org.awnproject.Awn.UA">
74 <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="awn_panel"/>
75
76 <!-- Methods -->
77 <method name="add_applet">
78 <arg name="name" type="s" direction="in" />
79 <arg name="uid" type="x" direction="in" />
80 <arg name="width" type="i" direction="in" />
81 <arg name="height" type="i" direction="in" />
82 <arg name="size_type" type="s" direction="in" />
83 </method>
84
85 <method name="get_all_server_flags">
86 <arg name="name" type="s" direction="in" />
87 <arg name="hash" type="a{ss}" direction="out" />
88 </method>
89
90 </interface>
72</node>91</node>
7392
=== modified file 'src/awn-panel.c'
--- src/awn-panel.c 2009-07-12 01:04:30 +0000
+++ src/awn-panel.c 2009-07-17 22:10:27 +0000
@@ -316,6 +316,7 @@
316316
317static gboolean awn_panel_set_drag_proxy (AwnPanel *panel,317static gboolean awn_panel_set_drag_proxy (AwnPanel *panel,
318 gboolean check_mouse_pos);318 gboolean check_mouse_pos);
319
319/*320/*
320 * GOBJECT CODE 321 * GOBJECT CODE
321 */322 */
@@ -2891,3 +2892,33 @@
2891 dbus_g_method_return (context, window_id);2892 dbus_g_method_return (context, window_id);
2892}2893}
28932894
2895gboolean
2896awn_panel_get_all_server_flags (AwnPanel *panel,
2897 GHashTable **hash,
2898 gchar *name,
2899 GError **error)
2900{
2901 AwnPanelPrivate *priv;
2902
2903 g_return_val_if_fail (AWN_IS_PANEL (panel), FALSE);
2904 priv = panel->priv;
2905
2906 return awn_ua_get_all_server_flags (AWN_APPLET_MANAGER (priv->manager),
2907 hash, name, error);
2908}
2909
2910gboolean
2911awn_panel_add_applet (AwnPanel *panel, gchar *name, glong xid,
2912 gint width, gint height,
2913 gchar *size_type,
2914 GError **error)
2915{
2916 AwnPanelPrivate *priv;
2917
2918 g_return_val_if_fail (AWN_IS_PANEL (panel), FALSE);
2919 priv = panel->priv;
2920
2921 return awn_ua_add_applet (AWN_APPLET_MANAGER (priv->manager), name, xid,
2922 width, height, size_type, error);
2923}
2924
28942925
=== modified file 'src/awn-panel.h'
--- src/awn-panel.h 2009-06-26 10:09:15 +0000
+++ src/awn-panel.h 2009-07-17 22:10:27 +0000
@@ -107,6 +107,17 @@
107 gboolean expand,107 gboolean expand,
108 DBusGMethodInvocation *context);108 DBusGMethodInvocation *context);
109109
110gboolean awn_panel_get_all_server_flags(AwnPanel *panel,
111 GHashTable **hash,
112 gchar *name,
113 GError **error);
114
115gboolean awn_panel_add_applet (AwnPanel *panel,
116 gchar *name, glong xid,
117 gint width, gint height,
118 gchar *size_type,
119 GError **error);
120
110G_END_DECLS121G_END_DECLS
111122
112123
113124
=== added file 'src/awn-ua-alignment.c'
--- src/awn-ua-alignment.c 1970-01-01 00:00:00 +0000
+++ src/awn-ua-alignment.c 2009-07-16 15:03:52 +0000
@@ -0,0 +1,469 @@
1/*
2 * Copyright (C) 2009 Rodney Cryderman <rcryderman@gmail.com>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
17 *
18 *
19 */
20
21/* awn-ua-alignment.c */
22#include <stdlib.h>
23#include "awn-ua-alignment.h"
24#include "awn-defines.h"
25
26G_DEFINE_TYPE (AwnUAAlignment, awn_ua_alignment, GTK_TYPE_ALIGNMENT)
27
28#define AWN_UA_ALIGNMENT_GET_PRIVATE(o) \
29 (G_TYPE_INSTANCE_GET_PRIVATE ((o), AWN_TYPE_UA_ALIGNMENT, AwnUAAlignmentPrivate))
30
31typedef struct _AwnUAAlignmentPrivate AwnUAAlignmentPrivate;
32
33struct _AwnUAAlignmentPrivate
34{
35 GtkWidget * socket;
36 GtkWidget * applet_manager;
37
38 gchar *ua_list_entry;
39 double ua_ratio;
40
41 guint notify_size_id;
42 guint notify_orient_id;
43 guint notify_offset_id;
44 guint notify_ua_list_id;
45};
46
47enum
48{
49 PROP_0,
50 PROP_APPLET_MANAGER,
51 PROP_UA_LIST_ENTRY,
52 PROP_UA_RATIO
53};
54
55
56static gboolean awn_ua_alignment_plug_removed (GtkWidget * socket,
57 AwnUAAlignment * self);
58static void awn_ua_alignment_list_change(GObject *object,
59 GParamSpec *param_spec,
60 gpointer user_data);
61static void awn_ua_alignment_orient_change(GObject *object,
62 GParamSpec *param_spec,
63 gpointer user_data);
64static void awn_ua_alignment_size_change(GObject *object,
65 GParamSpec *param_spec,
66 gpointer user_data);
67static void awn_ua_alignment_offset_change(GObject *object,
68 GParamSpec *param_spec,
69 gpointer user_data);
70
71
72static void
73awn_ua_alignment_get_property (GObject *object, guint property_id,
74 GValue *value, GParamSpec *pspec)
75{
76 AwnUAAlignmentPrivate * priv;
77
78 priv = AWN_UA_ALIGNMENT_GET_PRIVATE (object);
79
80 switch (property_id)
81 {
82 case PROP_APPLET_MANAGER:
83 g_value_set_object (value,priv->applet_manager);
84 break;
85 case PROP_UA_LIST_ENTRY:
86 g_value_set_string (value,priv->ua_list_entry);
87 break;
88 case PROP_UA_RATIO:
89 g_value_set_double (value,priv->ua_ratio);
90 break;
91 default:
92 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
93 }
94}
95
96static void
97awn_ua_alignment_set_property (GObject *object, guint property_id,
98 const GValue *value, GParamSpec *pspec)
99{
100 AwnUAAlignmentPrivate * priv;
101
102 priv = AWN_UA_ALIGNMENT_GET_PRIVATE (object);
103 switch (property_id)
104 {
105 case PROP_APPLET_MANAGER:
106 priv->applet_manager = g_value_get_object (value);
107 break;
108 case PROP_UA_LIST_ENTRY:
109 g_free (priv->ua_list_entry);
110 priv->ua_list_entry = g_value_dup_string (value);
111 break;
112 case PROP_UA_RATIO:
113 priv->ua_ratio = g_value_get_double (value);
114 break;
115 default:
116 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
117 }
118}
119
120static void
121awn_ua_alignment_dispose (GObject *object)
122{
123 G_OBJECT_CLASS (awn_ua_alignment_parent_class)->dispose (object);
124}
125
126static void
127awn_ua_alignment_finalize (GObject *object)
128{
129 AwnUAAlignmentPrivate * priv = AWN_UA_ALIGNMENT_GET_PRIVATE (object);
130 g_debug ("%s",__func__);
131 if (priv->ua_list_entry)
132 {
133 g_free (priv->ua_list_entry);
134 }
135 G_OBJECT_CLASS (awn_ua_alignment_parent_class)->finalize (object);
136}
137
138static void
139awn_ua_alignment_constructed (GObject *object)
140{
141 AwnUAAlignmentPrivate * priv = AWN_UA_ALIGNMENT_GET_PRIVATE (object);
142
143 if (G_OBJECT_CLASS (awn_ua_alignment_parent_class)->constructed)
144 {
145 G_OBJECT_CLASS (awn_ua_alignment_parent_class)->constructed (object);
146 }
147
148 gtk_container_add (GTK_CONTAINER(object),priv->socket);
149 awn_ua_alignment_orient_change (NULL,NULL,object);
150 priv->notify_offset_id = g_signal_connect (priv->applet_manager,
151 "notify::offset",
152 G_CALLBACK(awn_ua_alignment_offset_change),
153 object);
154 priv->notify_orient_id = g_signal_connect_after (priv->applet_manager,
155 "notify::orient",
156 G_CALLBACK(awn_ua_alignment_orient_change),
157 object);
158 priv->notify_size_id = g_signal_connect_after (priv->applet_manager,
159 "notify::size",
160 G_CALLBACK(awn_ua_alignment_size_change),
161 object);
162 priv->notify_ua_list_id = g_signal_connect_after (priv->applet_manager,
163 "notify::ua-active-list",
164 G_CALLBACK(awn_ua_alignment_list_change),
165 object);
166}
167
168static void
169awn_ua_alignment_class_init (AwnUAAlignmentClass *klass)
170{
171 GObjectClass *object_class = G_OBJECT_CLASS (klass);
172 GParamSpec *pspec;
173
174 object_class->get_property = awn_ua_alignment_get_property;
175 object_class->set_property = awn_ua_alignment_set_property;
176 object_class->dispose = awn_ua_alignment_dispose;
177 object_class->finalize = awn_ua_alignment_finalize;
178 object_class->constructed = awn_ua_alignment_constructed;
179
180 pspec = g_param_spec_object ("applet-manager",
181 "Awn Applet Manager",
182 "Awn Applet Manager",
183 AWN_TYPE_APPLET_MANAGER,
184 G_PARAM_READWRITE | G_PARAM_CONSTRUCT);
185 g_object_class_install_property (object_class, PROP_APPLET_MANAGER, pspec);
186
187 pspec = g_param_spec_string ("ua-list-entry",
188 "UA List entry",
189 "UA List entry",
190 NULL,
191 G_PARAM_READWRITE | G_PARAM_CONSTRUCT);
192 g_object_class_install_property (object_class, PROP_UA_LIST_ENTRY, pspec);
193
194 pspec = g_param_spec_double ("ua-ratio",
195 "UA Ratio",
196 "UA Ratio",
197 0.0,
198 100.0,
199 1.0,
200 G_PARAM_READWRITE | G_PARAM_CONSTRUCT);
201 g_object_class_install_property (object_class, PROP_UA_RATIO, pspec);
202
203 g_type_class_add_private (klass, sizeof (AwnUAAlignmentPrivate));
204}
205
206static void
207awn_ua_alignment_init (AwnUAAlignment *self)
208{
209 AwnUAAlignmentPrivate *priv;
210
211 priv = AWN_UA_ALIGNMENT_GET_PRIVATE (self);
212 priv->socket = gtk_socket_new ();
213}
214
215GtkWidget*
216awn_ua_alignment_new (AwnAppletManager *manager,gchar * ua_list_entry,double ua_ratio)
217{
218 return g_object_new (AWN_TYPE_UA_ALIGNMENT,
219 "applet-manager",manager,
220 "ua-list-entry",ua_list_entry,
221 "ua-ratio",ua_ratio,
222 NULL);
223}
224
225GtkWidget*
226awn_ua_alignment_get_socket (AwnUAAlignment *self)
227{
228 AwnUAAlignmentPrivate *priv;
229
230 priv = AWN_UA_ALIGNMENT_GET_PRIVATE (self);
231 return priv->socket;
232}
233
234
235GdkWindow *
236awn_ua_alignment_add_id (AwnUAAlignment *self,GdkNativeWindow native_window)
237{
238 GdkWindow * plugwin;
239 AwnUAAlignmentPrivate *priv;
240
241 priv = AWN_UA_ALIGNMENT_GET_PRIVATE (self);
242 gtk_socket_add_id (GTK_SOCKET(priv->socket), native_window);
243 plugwin = gtk_socket_get_plug_window (GTK_SOCKET(priv->socket));
244 g_signal_connect (priv->socket,"plug-removed",
245 G_CALLBACK(awn_ua_alignment_plug_removed),self);
246 gtk_widget_realize (priv->socket);
247 gtk_widget_show_all (priv->socket);
248 return plugwin;
249}
250
251
252static gboolean
253awn_ua_alignment_plug_removed (GtkWidget * socket,AwnUAAlignment * self)
254{
255
256 GSList * search;
257 GSList * ua_active_list;
258 GSList * orig_active_list;
259 GSList * iter;
260 AwnConfigClient *client;
261
262 AwnUAAlignmentPrivate *priv = AWN_UA_ALIGNMENT_GET_PRIVATE (self);
263
264 g_signal_handler_disconnect (priv->applet_manager,priv->notify_size_id);
265 g_signal_handler_disconnect (priv->applet_manager,priv->notify_orient_id);
266 g_signal_handler_disconnect (priv->applet_manager,priv->notify_offset_id);
267 g_signal_handler_disconnect (priv->applet_manager,priv->notify_ua_list_id);
268
269 g_object_get ( priv->applet_manager,
270 "ua_active_list",&orig_active_list,
271 "client",&client,
272 NULL);
273 ua_active_list = g_slist_copy (orig_active_list);
274 for (iter = ua_active_list;iter;iter = iter->next)
275 {
276 iter->data = g_strdup(iter->data);
277 }
278 search = g_slist_find_custom (ua_active_list,priv->ua_list_entry,
279 (GCompareFunc)g_strcmp0);
280 if (search)
281 {
282 ua_active_list = g_slist_delete_link (ua_active_list,search);
283 }
284 awn_config_client_set_list (client,AWN_GROUP_PANEL, AWN_PANEL_UA_ACTIVE_LIST,
285 AWN_CONFIG_CLIENT_LIST_TYPE_STRING,
286 ua_active_list, NULL);
287 g_object_set (priv->applet_manager,
288 "ua-active-list",ua_active_list,
289 NULL);
290 awn_applet_manager_remove_widget(AWN_APPLET_MANAGER(priv->applet_manager),
291 GTK_WIDGET (self));
292 return FALSE;
293}
294
295/*UA*/
296gint
297awn_ua_alignment_list_cmp (gconstpointer a, gconstpointer b)
298{
299 const gchar * str1 = a;
300 const gchar * str2 = b;
301 gchar * search = NULL;
302 GStrv tokens = g_strsplit (str1,"::",2);
303 g_return_val_if_fail (tokens,-1);
304
305 search = g_strstr_len (str2,-1,tokens[0]);
306 g_strfreev (tokens);
307
308 if (!search)
309 {
310 return -1;
311 };
312 return 0;
313}
314
315static void
316awn_ua_alignment_offset_change(GObject *object,GParamSpec *param_spec,gpointer user_data)
317{
318 AwnUAAlignment * self = user_data;
319 gint offset;
320 gint orient;
321 AwnUAAlignmentPrivate *priv = AWN_UA_ALIGNMENT_GET_PRIVATE (self);
322
323 g_object_get ( priv->applet_manager,
324 "offset",&offset,
325 "orient",&orient,
326 NULL);
327
328 switch (orient)
329 {
330 case AWN_ORIENTATION_TOP:
331 gtk_alignment_set_padding (GTK_ALIGNMENT(self), offset, 0, 0, 0);
332 break;
333 case AWN_ORIENTATION_BOTTOM:
334 gtk_alignment_set_padding (GTK_ALIGNMENT(self), 0, offset, 0, 0);
335 break;
336 case AWN_ORIENTATION_LEFT:
337 gtk_alignment_set_padding (GTK_ALIGNMENT(self), 0, 0, offset, 0);
338 break;
339 case AWN_ORIENTATION_RIGHT:
340 gtk_alignment_set_padding (GTK_ALIGNMENT(self), 0, 0, 0, offset);
341 break;
342 default:
343 g_warning ("%s: recieved invalid orient %d",__func__,orient);
344 }
345}
346
347static void
348awn_ua_alignment_size_change(GObject *object,GParamSpec *param_spec,gpointer user_data)
349{
350 AwnUAAlignment * self = user_data;
351 gint offset;
352 gint orient;
353 gint size;
354 AwnUAAlignmentPrivate *priv = AWN_UA_ALIGNMENT_GET_PRIVATE (self);
355
356 g_object_get ( priv->applet_manager,
357 "offset",&offset,
358 "orient",&orient,
359 "size",&size,
360 NULL);
361 GtkRequisition req;
362
363 req.width = req.height = size;
364 switch (orient)
365 {
366 case AWN_ORIENTATION_TOP:
367 case AWN_ORIENTATION_BOTTOM:
368 req.width = size * priv->ua_ratio;
369 req.height = size;
370 break;
371 case AWN_ORIENTATION_LEFT:
372 case AWN_ORIENTATION_RIGHT:
373 req.width = size;
374 req.height = size * 1.0 / priv->ua_ratio;
375 break;
376 default:
377 g_warning ("%s: received invalid orient %d",__func__,orient);
378 }
379 gtk_widget_set_size_request (GTK_WIDGET(self),req.width,req.height);
380}
381
382static void
383awn_ua_alignment_orient_change(GObject *object,GParamSpec *param_spec,gpointer user_data)
384{
385
386 AwnUAAlignment * self = user_data;
387 gint orient;
388 AwnUAAlignmentPrivate *priv = AWN_UA_ALIGNMENT_GET_PRIVATE (self);
389
390 g_object_get ( priv->applet_manager,
391 "orient",&orient,
392 NULL);
393 switch (orient)
394 {
395 case AWN_ORIENTATION_TOP:
396 gtk_alignment_set (GTK_ALIGNMENT(self), 0.0, 0.0, 1.0, 0.5);
397 break;
398 case AWN_ORIENTATION_BOTTOM:
399 gtk_alignment_set (GTK_ALIGNMENT(self), 0.0, 1.0, 1.0, 0.5);
400 break;
401 case AWN_ORIENTATION_LEFT:
402 gtk_alignment_set (GTK_ALIGNMENT(self), 0.0, 0.0, 0.5, 1.0);
403 break;
404 case AWN_ORIENTATION_RIGHT:
405 gtk_alignment_set (GTK_ALIGNMENT(self), 1.0, 0.0, 0.5, 1.0);
406 break;
407 default:
408 g_warning ("%s: received invalid orient %d",__func__,orient);
409 }
410 awn_ua_alignment_offset_change (object,param_spec,self);
411 awn_ua_alignment_size_change (object,param_spec,self);
412}
413
414static void
415awn_ua_alignment_list_change(GObject *object,GParamSpec *param_spec,gpointer user_data)
416{
417 AwnUAAlignment * self = user_data;
418 gint orient;
419 AwnUAAlignmentPrivate *priv = AWN_UA_ALIGNMENT_GET_PRIVATE (self);
420 GSList * ua_active_list;
421
422 g_object_get ( priv->applet_manager,
423 "orient",&orient,
424 "ua_active_list",&ua_active_list,
425 NULL);
426
427 GSList * search = g_slist_find_custom (ua_active_list,
428 priv->ua_list_entry,
429 (GCompareFunc)g_strcmp0);
430 if (search)
431 {
432 g_debug ("Found... do not need to update %s",priv->ua_list_entry);
433 }
434 else
435 {
436 search = g_slist_find_custom (ua_active_list,priv->ua_list_entry,awn_ua_alignment_list_cmp);
437 if (search)
438 {
439 g_debug ("Moving %s to %s",priv->ua_list_entry,(gchar*)search->data);
440 GStrv tokens;
441 gint pos = -1;
442 g_free (priv->ua_list_entry);
443 priv->ua_list_entry = g_strdup(search->data);
444 tokens = g_strsplit (search->data,"::",2);
445 if (tokens && tokens[1])
446 {
447 pos = atoi (tokens[1]);
448 }
449 g_strfreev (tokens);
450 if (pos != -1)
451 {
452 awn_applet_manager_add_widget(AWN_APPLET_MANAGER(priv->applet_manager),
453 GTK_WIDGET (self),
454 pos);
455 }
456 }
457 else
458 {
459 g_debug ("looks like %s was removed from panel/ua_list",priv->ua_list_entry);
460 /*
461 aantn as expected this does not kill the screenlet. What is the best way to
462 tell it that we want it to go away?
463 */
464 awn_applet_manager_remove_widget(AWN_APPLET_MANAGER(priv->applet_manager),
465 GTK_WIDGET (self));
466 gtk_widget_destroy (priv->socket);
467 }
468 }
469}
0470
=== added file 'src/awn-ua-alignment.h'
--- src/awn-ua-alignment.h 1970-01-01 00:00:00 +0000
+++ src/awn-ua-alignment.h 2009-07-14 02:56:28 +0000
@@ -0,0 +1,68 @@
1/*
2 * Copyright (C) 2009 Rodney Cryderman <rcryderman@gmail.com>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
17 *
18 *
19 */
20
21/* awn-ua-alignment.h */
22
23#ifndef _AWN_UA_ALIGNMENT
24#define _AWN_UA_ALIGNMENT
25
26#include <gtk/gtk.h>
27#include "awn-applet-manager.h"
28
29G_BEGIN_DECLS
30
31#define AWN_TYPE_UA_ALIGNMENT awn_ua_alignment_get_type()
32
33#define AWN_UA_ALIGNMENT(obj) \
34 (G_TYPE_CHECK_INSTANCE_CAST ((obj), AWN_TYPE_UA_ALIGNMENT, AwnUAAlignment))
35
36#define AWN_UA_ALIGNMENT_CLASS(klass) \
37 (G_TYPE_CHECK_CLASS_CAST ((klass), AWN_TYPE_UA_ALIGNMENT, AwnUAAlignmentClass))
38
39#define AWN_IS_UA_ALIGNMENT(obj) \
40 (G_TYPE_CHECK_INSTANCE_TYPE ((obj), AWN_TYPE_UA_ALIGNMENT))
41
42#define AWN_IS_UA_ALIGNMENT_CLASS(klass) \
43 (G_TYPE_CHECK_CLASS_TYPE ((klass), AWN_TYPE_UA_ALIGNMENT))
44
45#define AWN_UA_ALIGNMENT_GET_CLASS(obj) \
46 (G_TYPE_INSTANCE_GET_CLASS ((obj), AWN_TYPE_UA_ALIGNMENT, AwnUAAlignmentClass))
47
48typedef struct {
49 GtkAlignment parent;
50} AwnUAAlignment;
51
52typedef struct {
53 GtkAlignmentClass parent_class;
54} AwnUAAlignmentClass;
55
56GType awn_ua_alignment_get_type (void);
57
58GtkWidget* awn_ua_alignment_new (AwnAppletManager *manager,gchar * ua_list_entry,double ua_ratio);
59
60GtkWidget* awn_ua_alignment_get_socket (AwnUAAlignment *self);
61
62GdkWindow * awn_ua_alignment_add_id (AwnUAAlignment *self, GdkNativeWindow native_window);
63
64gint awn_ua_alignment_list_cmp (gconstpointer a, gconstpointer b);
65
66G_END_DECLS
67
68#endif /* _AWN_UA_ALIGNMENT */

Subscribers

People subscribed via source and target branches

to status/vote changes: