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: | 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 |
Related bugs: |
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.
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.
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?).
Mark Lee (malept) : | # |
Preview Diff
1 | === modified file 'awn-settings/awnClass.py' | |||
2 | --- awn-settings/awnClass.py 2009-07-15 20:40:32 +0000 | |||
3 | +++ awn-settings/awnClass.py 2009-07-16 15:04:17 +0000 | |||
4 | @@ -1541,16 +1541,23 @@ | |||
5 | 1541 | os.unlink(filename) | 1541 | os.unlink(filename) |
6 | 1542 | 1542 | ||
7 | 1543 | def _apply (self): | 1543 | def _apply (self): |
9 | 1544 | l = [] | 1544 | applets_list = [] |
10 | 1545 | ua_list = [] | ||
11 | 1546 | |||
12 | 1545 | it = self.active_model.get_iter_first () | 1547 | it = self.active_model.get_iter_first () |
13 | 1546 | while (it): | 1548 | while (it): |
14 | 1547 | path = self.active_model.get_value (it, 1) | 1549 | path = self.active_model.get_value (it, 1) |
15 | 1548 | uid = self.active_model.get_value (it, 2) | 1550 | uid = self.active_model.get_value (it, 2) |
16 | 1549 | s = "%s::%s" % (path, uid) | 1551 | s = "%s::%s" % (path, uid) |
18 | 1550 | l.append (s) | 1552 | if path.endswith(".desktop"): |
19 | 1553 | applets_list.append(s) | ||
20 | 1554 | else: | ||
21 | 1555 | ua_list.append(s) | ||
22 | 1556 | |||
23 | 1551 | it= self.active_model.iter_next (it) | 1557 | it= self.active_model.iter_next (it) |
24 | 1552 | 1558 | ||
26 | 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) |
27 | 1560 | self.client.set_list(defs.PANEL, defs.UA_LIST, awn.CONFIG_LIST_STRING, ua_list) | ||
28 | 1554 | 1561 | ||
29 | 1555 | def up_clicked (self, button): | 1562 | def up_clicked (self, button): |
30 | 1556 | select = self.treeview.get_selection() | 1563 | select = self.treeview.get_selection() |
31 | @@ -1596,18 +1603,32 @@ | |||
32 | 1596 | 1603 | ||
33 | 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) |
34 | 1598 | 1605 | ||
35 | 1606 | ua_applets = self.client.get_list(defs.PANEL, defs.UA_LIST, awn.CONFIG_LIST_STRING) | ||
36 | 1607 | |||
37 | 1608 | for ua in ua_applets: | ||
38 | 1609 | tokens = ua.split("::") | ||
39 | 1610 | applets.insert(int(tokens[1]), ua) | ||
40 | 1611 | |||
41 | 1599 | self.refresh_icon_list (applets, self.active_model) | 1612 | self.refresh_icon_list (applets, self.active_model) |
42 | 1600 | 1613 | ||
43 | 1601 | def refresh_icon_list (self, applets, model): | 1614 | def refresh_icon_list (self, applets, model): |
44 | 1602 | for a in applets: | 1615 | for a in applets: |
45 | 1603 | tokens = a.split("::") | 1616 | tokens = a.split("::") |
51 | 1604 | path = tokens[0] | 1617 | if tokens[0].endswith(".desktop"): |
52 | 1605 | uid = tokens[1] | 1618 | path = tokens[0] |
53 | 1606 | icon, text, name = self.make_row(path) | 1619 | uid = tokens[1] |
54 | 1607 | if len (text) < 2: | 1620 | icon, text, name = self.make_row(path) |
55 | 1608 | continue; | 1621 | if len (text) < 2: |
56 | 1622 | continue; | ||
57 | 1609 | 1623 | ||
59 | 1610 | model.append([icon, path, uid, text]) | 1624 | model.append([icon, path, uid, text]) |
60 | 1625 | else: | ||
61 | 1626 | path = tokens[0] | ||
62 | 1627 | uid = tokens[1] | ||
63 | 1628 | theme = gtk.icon_theme_get_default () | ||
64 | 1629 | icon = theme.load_icon ("screenlets", 32, 0) | ||
65 | 1630 | text = tokens[0] | ||
66 | 1631 | model.append([icon, path, uid, text]) | ||
67 | 1611 | 1632 | ||
68 | 1612 | def load_applets (self): | 1633 | def load_applets (self): |
69 | 1613 | applets = self.applets_by_categories() | 1634 | applets = self.applets_by_categories() |
70 | @@ -1649,7 +1670,21 @@ | |||
71 | 1649 | applets = l.values() | 1670 | applets = l.values() |
72 | 1650 | 1671 | ||
73 | 1651 | if not None in applets and self.load_finished: | 1672 | if not None in applets and self.load_finished: |
75 | 1652 | self.client.set_list(defs.PANEL, defs.APPLET_LIST, awn.CONFIG_LIST_STRING, applets) | 1673 | applets_list = [] |
76 | 1674 | ua_list = [] | ||
77 | 1675 | for a in applets: | ||
78 | 1676 | tokens = a.split("::") | ||
79 | 1677 | path = tokens[0] | ||
80 | 1678 | if path.endswith(".desktop"): | ||
81 | 1679 | applets_list.append(a) | ||
82 | 1680 | else: | ||
83 | 1681 | position = applets.index(a) | ||
84 | 1682 | ua = tokens[0] + "::" + str(position) | ||
85 | 1683 | ua_list.append(ua) | ||
86 | 1684 | |||
87 | 1685 | self.client.set_list(defs.PANEL, defs.APPLET_LIST, awn.CONFIG_LIST_STRING, applets_list) | ||
88 | 1686 | self.client.set_list(defs.PANEL, defs.UA_LIST, awn.CONFIG_LIST_STRING, ua_list) | ||
89 | 1687 | |||
90 | 1653 | 1688 | ||
91 | 1654 | def callback_widget_filter_applets(self, data=None): | 1689 | def callback_widget_filter_applets(self, data=None): |
92 | 1655 | model = self.choose_categorie.get_model() | 1690 | model = self.choose_categorie.get_model() |
93 | 1656 | 1691 | ||
94 | === modified file 'awn-settings/awnDefs.py.in' | |||
95 | --- awn-settings/awnDefs.py.in 2009-07-10 00:56:51 +0000 | |||
96 | +++ awn-settings/awnDefs.py.in 2009-07-15 20:43:31 +0000 | |||
97 | @@ -59,6 +59,7 @@ | |||
98 | 59 | EXPAND = "expand" #bool | 59 | EXPAND = "expand" #bool |
99 | 60 | CLICKTHROUGH = "clickthrough" #int | 60 | CLICKTHROUGH = "clickthrough" #int |
100 | 61 | BEHAVIOR = "behavior" #int | 61 | BEHAVIOR = "behavior" #int |
101 | 62 | UA_LIST = "ua_active_list" #list-string | ||
102 | 62 | 63 | ||
103 | 63 | PANELS = "panels" #group | 64 | PANELS = "panels" #group |
104 | 64 | PANEL_LIST = "panel_list" #int | 65 | PANEL_LIST = "panel_list" #int |
105 | 65 | 66 | ||
106 | === modified file 'data/awn.schema-ini.in' | |||
107 | --- data/awn.schema-ini.in 2009-07-06 22:12:25 +0000 | |||
108 | +++ data/awn.schema-ini.in 2009-07-14 18:01:40 +0000 | |||
109 | @@ -28,6 +28,16 @@ | |||
110 | 28 | default = @APPLETDATADIR@/taskmanager.desktop::1 | 28 | default = @APPLETDATADIR@/taskmanager.desktop::1 |
111 | 29 | description = The list of applets for this panel ordered from ltr or ttb. | 29 | description = The list of applets for this panel ordered from ltr or ttb. |
112 | 30 | 30 | ||
113 | 31 | [panel/ua_list] | ||
114 | 32 | type = list-string | ||
115 | 33 | default = | ||
116 | 34 | description = The list of UA Screenlets that have been previous added in the form ScreeneletInstance::Position. | ||
117 | 35 | |||
118 | 36 | [panel/ua_active_list] | ||
119 | 37 | type = list-string | ||
120 | 38 | default = | ||
121 | 39 | description = The active list UA Screenlets for this panel. | ||
122 | 40 | |||
123 | 31 | [panel/monitor_force] | 41 | [panel/monitor_force] |
124 | 32 | type = bool | 42 | type = bool |
125 | 33 | default = False | 43 | default = False |
126 | 34 | 44 | ||
127 | === modified file 'src/Makefile.am' | |||
128 | --- src/Makefile.am 2009-06-21 13:23:05 +0000 | |||
129 | +++ src/Makefile.am 2009-07-17 22:02:30 +0000 | |||
130 | @@ -51,6 +51,8 @@ | |||
131 | 51 | awn-panel-glue.h \ | 51 | awn-panel-glue.h \ |
132 | 52 | awn-throbber.c \ | 52 | awn-throbber.c \ |
133 | 53 | awn-throbber.h \ | 53 | awn-throbber.h \ |
134 | 54 | awn-ua-alignment.c \ | ||
135 | 55 | awn-ua-alignment.h \ | ||
136 | 54 | awn-x.h \ | 56 | awn-x.h \ |
137 | 55 | awn-x.c \ | 57 | awn-x.c \ |
138 | 56 | inlinepixbufs.h \ | 58 | inlinepixbufs.h \ |
139 | 57 | 59 | ||
140 | === modified file 'src/awn-applet-manager.c' | |||
141 | --- src/awn-applet-manager.c 2009-07-09 07:12:27 +0000 | |||
142 | +++ src/awn-applet-manager.c 2009-07-17 22:13:45 +0000 | |||
143 | @@ -21,17 +21,19 @@ | |||
144 | 21 | 21 | ||
145 | 22 | #include "config.h" | 22 | #include "config.h" |
146 | 23 | 23 | ||
148 | 24 | #include <libawn/awn-config-bridge.h> | 24 | #include <libawn/libawn.h> |
149 | 25 | #include <libawn/awn-utils.h> | 25 | #include <libawn/awn-utils.h> |
150 | 26 | #include <math.h> | 26 | #include <math.h> |
151 | 27 | 27 | ||
152 | 28 | #include "awn-defines.h" | 28 | #include "awn-defines.h" |
153 | 29 | #include "awn-applet-manager.h" | 29 | #include "awn-applet-manager.h" |
155 | 30 | 30 | #include "awn-ua-alignment.h" | |
156 | 31 | #include "awn-applet-proxy.h" | 31 | #include "awn-applet-proxy.h" |
157 | 32 | #include "awn-throbber.h" | 32 | #include "awn-throbber.h" |
158 | 33 | #include "xutils.h" | 33 | #include "xutils.h" |
159 | 34 | 34 | ||
160 | 35 | #define MAX_UA_LIST_ENTRIES 50 | ||
161 | 36 | |||
162 | 35 | G_DEFINE_TYPE (AwnAppletManager, awn_applet_manager, GTK_TYPE_BOX) | 37 | G_DEFINE_TYPE (AwnAppletManager, awn_applet_manager, GTK_TYPE_BOX) |
163 | 36 | 38 | ||
164 | 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, \ |
165 | @@ -44,8 +46,15 @@ | |||
166 | 44 | AwnOrientation orient; | 46 | AwnOrientation orient; |
167 | 45 | gint offset; | 47 | gint offset; |
168 | 46 | gint size; | 48 | gint size; |
169 | 49 | |||
170 | 47 | GSList *applet_list; | 50 | GSList *applet_list; |
171 | 48 | 51 | ||
172 | 52 | /*ua_list does not serve the same purpose as the applet_list | ||
173 | 53 | It's a list of unique UA names plus their position in the panel | ||
174 | 54 | */ | ||
175 | 55 | GSList *ua_list; | ||
176 | 56 | GSList *ua_active_list; | ||
177 | 57 | |||
178 | 49 | gboolean docklet_mode; | 58 | gboolean docklet_mode; |
179 | 50 | GtkWidget *docklet_widget; | 59 | GtkWidget *docklet_widget; |
180 | 51 | 60 | ||
181 | @@ -60,6 +69,7 @@ | |||
182 | 60 | 69 | ||
183 | 61 | /* Current box class */ | 70 | /* Current box class */ |
184 | 62 | GtkWidgetClass *klass; | 71 | GtkWidgetClass *klass; |
185 | 72 | |||
186 | 63 | }; | 73 | }; |
187 | 64 | 74 | ||
188 | 65 | enum | 75 | enum |
189 | @@ -71,6 +81,8 @@ | |||
190 | 71 | PROP_OFFSET, | 81 | PROP_OFFSET, |
191 | 72 | PROP_SIZE, | 82 | PROP_SIZE, |
192 | 73 | PROP_APPLET_LIST, | 83 | PROP_APPLET_LIST, |
193 | 84 | PROP_UA_LIST, | ||
194 | 85 | PROP_UA_ACTIVE_LIST, | ||
195 | 74 | PROP_EXPANDS | 86 | PROP_EXPANDS |
196 | 75 | }; | 87 | }; |
197 | 76 | 88 | ||
198 | @@ -123,6 +135,20 @@ | |||
199 | 123 | AWN_GROUP_PANEL, AWN_PANEL_APPLET_LIST, | 135 | AWN_GROUP_PANEL, AWN_PANEL_APPLET_LIST, |
200 | 124 | AWN_CONFIG_CLIENT_LIST_TYPE_STRING, | 136 | AWN_CONFIG_CLIENT_LIST_TYPE_STRING, |
201 | 125 | object, "applet_list"); | 137 | object, "applet_list"); |
202 | 138 | awn_config_bridge_bind_list (bridge, priv->client, | ||
203 | 139 | AWN_GROUP_PANEL, AWN_PANEL_UA_LIST, | ||
204 | 140 | AWN_CONFIG_CLIENT_LIST_TYPE_STRING, | ||
205 | 141 | object, "ua_list"); | ||
206 | 142 | awn_config_bridge_bind_list (bridge, priv->client, | ||
207 | 143 | AWN_GROUP_PANEL, AWN_PANEL_UA_ACTIVE_LIST, | ||
208 | 144 | AWN_CONFIG_CLIENT_LIST_TYPE_STRING, | ||
209 | 145 | object, "ua_active_list"); | ||
210 | 146 | /* | ||
211 | 147 | ua_active_list should be empty when awn starts... | ||
212 | 148 | */ | ||
213 | 149 | awn_config_client_set_list (priv->client,AWN_GROUP_PANEL, AWN_PANEL_UA_ACTIVE_LIST, | ||
214 | 150 | AWN_CONFIG_CLIENT_LIST_TYPE_STRING, | ||
215 | 151 | NULL, NULL); | ||
216 | 126 | } | 152 | } |
217 | 127 | 153 | ||
218 | 128 | static void | 154 | static void |
219 | @@ -165,10 +191,15 @@ | |||
220 | 165 | case PROP_SIZE: | 191 | case PROP_SIZE: |
221 | 166 | g_value_set_int (value, priv->size); | 192 | g_value_set_int (value, priv->size); |
222 | 167 | break; | 193 | break; |
223 | 168 | |||
224 | 169 | case PROP_APPLET_LIST: | 194 | case PROP_APPLET_LIST: |
225 | 170 | g_value_set_pointer (value, priv->applet_list); | 195 | g_value_set_pointer (value, priv->applet_list); |
226 | 171 | break; | 196 | break; |
227 | 197 | case PROP_UA_LIST: | ||
228 | 198 | g_value_set_pointer (value, priv->ua_list); | ||
229 | 199 | break; | ||
230 | 200 | case PROP_UA_ACTIVE_LIST: | ||
231 | 201 | g_value_set_pointer (value, priv->ua_active_list); | ||
232 | 202 | break; | ||
233 | 172 | case PROP_EXPANDS: | 203 | case PROP_EXPANDS: |
234 | 173 | g_value_set_boolean (value, priv->expands); | 204 | g_value_set_boolean (value, priv->expands); |
235 | 174 | break; | 205 | break; |
236 | @@ -208,6 +239,16 @@ | |||
237 | 208 | priv->applet_list = g_value_get_pointer (value); | 239 | priv->applet_list = g_value_get_pointer (value); |
238 | 209 | awn_applet_manager_refresh_applets (manager); | 240 | awn_applet_manager_refresh_applets (manager); |
239 | 210 | break; | 241 | break; |
240 | 242 | case PROP_UA_LIST: | ||
241 | 243 | free_list (priv->ua_list); | ||
242 | 244 | priv->ua_list = g_value_get_pointer (value); | ||
243 | 245 | awn_applet_manager_refresh_applets (manager); | ||
244 | 246 | break; | ||
245 | 247 | case PROP_UA_ACTIVE_LIST: | ||
246 | 248 | free_list (priv->ua_active_list); | ||
247 | 249 | priv->ua_active_list = g_value_get_pointer (value); | ||
248 | 250 | awn_applet_manager_refresh_applets (manager); | ||
249 | 251 | break; | ||
250 | 211 | default: | 252 | default: |
251 | 212 | G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); | 253 | G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); |
252 | 213 | } | 254 | } |
253 | @@ -294,6 +335,20 @@ | |||
254 | 294 | G_PARAM_READWRITE | G_PARAM_CONSTRUCT)); | 335 | G_PARAM_READWRITE | G_PARAM_CONSTRUCT)); |
255 | 295 | 336 | ||
256 | 296 | g_object_class_install_property (obj_class, | 337 | g_object_class_install_property (obj_class, |
257 | 338 | PROP_UA_LIST, | ||
258 | 339 | g_param_spec_pointer ("ua_list", | ||
259 | 340 | "UA List", | ||
260 | 341 | "The rememebered screenlet positions for this panel", | ||
261 | 342 | G_PARAM_READWRITE | G_PARAM_CONSTRUCT)); | ||
262 | 343 | |||
263 | 344 | g_object_class_install_property (obj_class, | ||
264 | 345 | PROP_UA_ACTIVE_LIST, | ||
265 | 346 | g_param_spec_pointer ("ua-active-list", | ||
266 | 347 | "UA Active List", | ||
267 | 348 | "The list of acitve screenlets for this panel", | ||
268 | 349 | G_PARAM_READWRITE | G_PARAM_CONSTRUCT)); | ||
269 | 350 | |||
270 | 351 | g_object_class_install_property (obj_class, | ||
271 | 297 | PROP_EXPANDS, | 352 | PROP_EXPANDS, |
272 | 298 | g_param_spec_boolean ("expands", | 353 | g_param_spec_boolean ("expands", |
273 | 299 | "Expands", | 354 | "Expands", |
274 | @@ -505,7 +560,6 @@ | |||
275 | 505 | g_type_class_unref (priv->klass); | 560 | g_type_class_unref (priv->klass); |
276 | 506 | priv->klass = NULL; | 561 | priv->klass = NULL; |
277 | 507 | } | 562 | } |
278 | 508 | |||
279 | 509 | switch (priv->orient) | 563 | switch (priv->orient) |
280 | 510 | { | 564 | { |
281 | 511 | case AWN_ORIENTATION_TOP: | 565 | case AWN_ORIENTATION_TOP: |
282 | @@ -547,7 +601,10 @@ | |||
283 | 547 | { | 601 | { |
284 | 548 | g_free (l->data); | 602 | g_free (l->data); |
285 | 549 | } | 603 | } |
287 | 550 | g_slist_free (list); | 604 | if (list) |
288 | 605 | { | ||
289 | 606 | g_slist_free (list); | ||
290 | 607 | } | ||
291 | 551 | } | 608 | } |
292 | 552 | 609 | ||
293 | 553 | /* | 610 | /* |
294 | @@ -653,7 +710,7 @@ | |||
295 | 653 | if (priv->applet_list == NULL) | 710 | if (priv->applet_list == NULL) |
296 | 654 | { | 711 | { |
297 | 655 | g_debug ("No applets"); | 712 | g_debug ("No applets"); |
299 | 656 | return; | 713 | return; // FIXME: removing last applet doesn't work because of this |
300 | 657 | } | 714 | } |
301 | 658 | 715 | ||
302 | 659 | guint applet_count = g_slist_length (priv->applet_list); | 716 | guint applet_count = g_slist_length (priv->applet_list); |
303 | @@ -769,6 +826,155 @@ | |||
304 | 769 | } | 826 | } |
305 | 770 | } | 827 | } |
306 | 771 | 828 | ||
307 | 829 | /*DBUS*/ | ||
308 | 830 | /* | ||
309 | 831 | Description of this dbus interface. | ||
310 | 832 | |||
311 | 833 | @action(IFACE) | ||
312 | 834 | def add_applet (self, id, plug_id, width, height, size_type): | ||
313 | 835 | """ | ||
314 | 836 | Add an applet. | ||
315 | 837 | |||
316 | 838 | id: A unique string used to identify the applet. | ||
317 | 839 | plug_id: The applet's gtk.Plug's xid. | ||
318 | 840 | width: A recommended width. This will be interpreted according to size_type. | ||
319 | 841 | height A recommended height. This will be interpreted according to size_type. | ||
320 | 842 | size_type: Determines the meaning of width and height. | ||
321 | 843 | May be one of the following values: | ||
322 | 844 | "scalable"- The applet may be resized as long as the width/height ratio is kept. | ||
323 | 845 | "static"- The applet should be displayed at exactly the size requested. | ||
324 | 846 | "static-width"- The applet's width should remain static, and the server may change the height. | ||
325 | 847 | "static-height"- The applet's height should remain static, and the server may change the width. | ||
326 | 848 | "dynamic"- The applet may be resized to any size. | ||
327 | 849 | desktop_path: Path to the desktop file. | ||
328 | 850 | """ | ||
329 | 851 | # NOTE: Melange currently ignores the size_type parameter. | ||
330 | 852 | container = ToplevelContainer(plug_id, id, self, width, height, | ||
331 | 853 | size_type, backend=self.backend) | ||
332 | 854 | self.containers.append(container) | ||
333 | 855 | */ | ||
334 | 856 | gboolean | ||
335 | 857 | awn_ua_add_applet ( AwnAppletManager *manager, | ||
336 | 858 | gchar *name, glong xid, | ||
337 | 859 | gint width, gint height, | ||
338 | 860 | gchar *size_type, | ||
339 | 861 | GError **error) | ||
340 | 862 | { | ||
341 | 863 | g_return_val_if_fail (AWN_IS_APPLET_MANAGER (manager),FALSE); | ||
342 | 864 | g_return_val_if_fail ( (g_strcmp0(size_type,"scalable")==0 ) || | ||
343 | 865 | (g_strcmp0(size_type,"dynamic")==0 ), FALSE ); | ||
344 | 866 | |||
345 | 867 | GdkWindow* plugwin; | ||
346 | 868 | AwnAppletManagerPrivate *priv = manager->priv; | ||
347 | 869 | gint pos = g_slist_length (priv->applet_list); | ||
348 | 870 | GdkNativeWindow native_window = (GdkNativeWindow) xid; | ||
349 | 871 | gchar * tmp = g_strdup_printf ("%s::%d",name,pos); | ||
350 | 872 | gchar * ua_list_entry = NULL; | ||
351 | 873 | GtkWidget *ua_alignment; | ||
352 | 874 | double ua_ratio; | ||
353 | 875 | |||
354 | 876 | /* | ||
355 | 877 | Is there an entry in ua_list for this particular screenlet instance(name). | ||
356 | 878 | The comparision function used ignores the position. | ||
357 | 879 | */ | ||
358 | 880 | GSList * search = g_slist_find_custom (priv->ua_list,tmp,awn_ua_alignment_list_cmp); | ||
359 | 881 | if (search) | ||
360 | 882 | { | ||
361 | 883 | /* There's already an entry in ua_list so use that. */ | ||
362 | 884 | GStrv tokens; | ||
363 | 885 | ua_list_entry = g_strdup (search->data) ; | ||
364 | 886 | g_free (tmp); | ||
365 | 887 | /* Get the position where the screenlet should be placed*/ | ||
366 | 888 | tokens = g_strsplit (search->data,"::",2); | ||
367 | 889 | if (tokens && tokens[1]) | ||
368 | 890 | { | ||
369 | 891 | pos = atoi (tokens[1]); | ||
370 | 892 | } | ||
371 | 893 | g_strfreev (tokens); | ||
372 | 894 | /* remove the link... that data will be appended at to the list*/ | ||
373 | 895 | g_free (search->data); | ||
374 | 896 | priv->ua_list = g_slist_delete_link (priv->ua_list,search); | ||
375 | 897 | search = NULL; | ||
376 | 898 | } | ||
377 | 899 | else | ||
378 | 900 | { | ||
379 | 901 | /* | ||
380 | 902 | This screenlet instance is not recorded in ua_list. It will end up being | ||
381 | 903 | placed at the end of the bar | ||
382 | 904 | */ | ||
383 | 905 | ua_list_entry = tmp; | ||
384 | 906 | } | ||
385 | 907 | |||
386 | 908 | /* | ||
387 | 909 | Calculated here and passed to the awn_ua_alignment_new(). AwnUAAlignment | ||
388 | 910 | could recalculate the ratio on bar resizes based on the, then current, | ||
389 | 911 | dimensions of the widget but over time the amount of error in the the | ||
390 | 912 | calcs would increase | ||
391 | 913 | */ | ||
392 | 914 | ua_ratio = width / (double) height; | ||
393 | 915 | ua_alignment = awn_ua_alignment_new(manager,ua_list_entry,ua_ratio); | ||
394 | 916 | |||
395 | 917 | g_signal_connect_swapped (awn_ua_alignment_get_socket(AWN_UA_ALIGNMENT(ua_alignment)), | ||
396 | 918 | "plug-added", | ||
397 | 919 | G_CALLBACK (_applet_plug_added), | ||
398 | 920 | manager); | ||
399 | 921 | |||
400 | 922 | awn_applet_manager_add_widget(manager, GTK_WIDGET (ua_alignment), pos); | ||
401 | 923 | gtk_widget_show_all (ua_alignment); | ||
402 | 924 | |||
403 | 925 | plugwin = awn_ua_alignment_add_id (AWN_UA_ALIGNMENT(ua_alignment),native_window); | ||
404 | 926 | |||
405 | 927 | if (!plugwin) | ||
406 | 928 | { | ||
407 | 929 | g_warning ("UA Plug was not created within socket."); | ||
408 | 930 | gtk_widget_destroy (ua_alignment); | ||
409 | 931 | return FALSE; | ||
410 | 932 | } | ||
411 | 933 | |||
412 | 934 | /* | ||
413 | 935 | Either add the new entry into ua_list or move an existing entry to the | ||
414 | 936 | end of ua_list_entry | ||
415 | 937 | */ | ||
416 | 938 | priv->ua_list = g_slist_append (priv->ua_list,g_strdup(ua_list_entry)); | ||
417 | 939 | |||
418 | 940 | /* Keep the length of ua_list reasonable */ | ||
419 | 941 | if (g_slist_length (priv->ua_list) > MAX_UA_LIST_ENTRIES) | ||
420 | 942 | { | ||
421 | 943 | GSList * iter; | ||
422 | 944 | int i = g_slist_length (priv->ua_list) - MAX_UA_LIST_ENTRIES; | ||
423 | 945 | for(iter = priv->ua_list; i && iter ; iter = priv->ua_list ) | ||
424 | 946 | { | ||
425 | 947 | g_free (iter->data); | ||
426 | 948 | priv->ua_list = g_slist_delete_link (priv->ua_list,iter); | ||
427 | 949 | i--; | ||
428 | 950 | } | ||
429 | 951 | } | ||
430 | 952 | awn_config_client_set_list (priv->client,AWN_GROUP_PANEL, AWN_PANEL_UA_LIST, | ||
431 | 953 | AWN_CONFIG_CLIENT_LIST_TYPE_STRING, | ||
432 | 954 | priv->ua_list, NULL); | ||
433 | 955 | /*Add our newly active screenlet to thend of the active list */ | ||
434 | 956 | priv->ua_active_list = g_slist_append (priv->ua_active_list,g_strdup(ua_list_entry)); | ||
435 | 957 | awn_config_client_set_list (priv->client,AWN_GROUP_PANEL, AWN_PANEL_UA_ACTIVE_LIST, | ||
436 | 958 | AWN_CONFIG_CLIENT_LIST_TYPE_STRING, | ||
437 | 959 | priv->ua_active_list, NULL); | ||
438 | 960 | |||
439 | 961 | return TRUE; | ||
440 | 962 | } | ||
441 | 963 | |||
442 | 964 | gboolean | ||
443 | 965 | awn_ua_get_all_server_flags ( AwnAppletManager *manager, | ||
444 | 966 | GHashTable **hash, | ||
445 | 967 | gchar *name, | ||
446 | 968 | GError **error) | ||
447 | 969 | { | ||
448 | 970 | *hash = g_hash_table_new(g_str_hash,g_str_equal); | ||
449 | 971 | /* Future function to return capability of the server | ||
450 | 972 | For now, it return nothing*/ | ||
451 | 973 | return TRUE; | ||
452 | 974 | } | ||
453 | 975 | |||
454 | 976 | |||
455 | 977 | /*End DBUS*/ | ||
456 | 772 | void | 978 | void |
457 | 773 | awn_applet_manager_show_applets (AwnAppletManager *manager) | 979 | awn_applet_manager_show_applets (AwnAppletManager *manager) |
458 | 774 | { | 980 | { |
459 | 775 | 981 | ||
460 | === modified file 'src/awn-applet-manager.h' | |||
461 | --- src/awn-applet-manager.h 2009-07-08 20:38:35 +0000 | |||
462 | +++ src/awn-applet-manager.h 2009-07-17 22:02:30 +0000 | |||
463 | @@ -25,6 +25,7 @@ | |||
464 | 25 | #include <gtk/gtk.h> | 25 | #include <gtk/gtk.h> |
465 | 26 | 26 | ||
466 | 27 | #include <libawn/awn-config-client.h> | 27 | #include <libawn/awn-config-client.h> |
467 | 28 | #include <libawn/awn-defines.h> | ||
468 | 28 | 29 | ||
469 | 29 | #include "awn-panel.h" | 30 | #include "awn-panel.h" |
470 | 30 | 31 | ||
471 | @@ -96,6 +97,19 @@ | |||
472 | 96 | AwnPathType path_type, | 97 | AwnPathType path_type, |
473 | 97 | gfloat offset_modifier); | 98 | gfloat offset_modifier); |
474 | 98 | 99 | ||
475 | 100 | /* UA stuff */ | ||
476 | 101 | |||
477 | 102 | gboolean awn_ua_get_all_server_flags (AwnAppletManager *manager, | ||
478 | 103 | GHashTable **hash, | ||
479 | 104 | gchar *name, | ||
480 | 105 | GError **error); | ||
481 | 106 | |||
482 | 107 | gboolean awn_ua_add_applet (AwnAppletManager *manager, | ||
483 | 108 | gchar *name, glong xid, | ||
484 | 109 | gint width, gint height, | ||
485 | 110 | gchar *size_type, | ||
486 | 111 | GError **error); | ||
487 | 112 | |||
488 | 99 | G_END_DECLS | 113 | G_END_DECLS |
489 | 100 | 114 | ||
490 | 101 | #endif /* _AWN_APPLET_MANAGER_H */ | 115 | #endif /* _AWN_APPLET_MANAGER_H */ |
491 | 102 | 116 | ||
492 | === modified file 'src/awn-defines.h' | |||
493 | --- src/awn-defines.h 2009-04-18 00:36:20 +0000 | |||
494 | +++ src/awn-defines.h 2009-07-14 18:01:40 +0000 | |||
495 | @@ -28,6 +28,7 @@ | |||
496 | 28 | 28 | ||
497 | 29 | #define AWN_DBUS_APP_PATH AWN_DBUS_PATH | 29 | #define AWN_DBUS_APP_PATH AWN_DBUS_PATH |
498 | 30 | #define AWN_DBUS_PANEL_PATH AWN_DBUS_PATH"/Panel" | 30 | #define AWN_DBUS_PANEL_PATH AWN_DBUS_PATH"/Panel" |
499 | 31 | #define AWN_DBUS_MANAGER_PATH AWN_DBUS_PATH"/UA" | ||
500 | 31 | 32 | ||
501 | 32 | /* FIXME: Move some of these out into libawn when we can */ | 33 | /* FIXME: Move some of these out into libawn when we can */ |
502 | 33 | #define AWN_GROUP_PANEL "panel" | 34 | #define AWN_GROUP_PANEL "panel" |
503 | @@ -38,6 +39,8 @@ | |||
504 | 38 | #define AWN_PANEL_SIZE "size" | 39 | #define AWN_PANEL_SIZE "size" |
505 | 39 | #define AWN_PANEL_AUTOHIDE "autohide" | 40 | #define AWN_PANEL_AUTOHIDE "autohide" |
506 | 40 | #define AWN_PANEL_APPLET_LIST "applet_list" | 41 | #define AWN_PANEL_APPLET_LIST "applet_list" |
507 | 42 | #define AWN_PANEL_UA_LIST "ua_list" | ||
508 | 43 | #define AWN_PANEL_UA_ACTIVE_LIST "ua_active_list" | ||
509 | 41 | #define AWN_PANEL_MONITOR_HEIGHT "monitor_height" | 44 | #define AWN_PANEL_MONITOR_HEIGHT "monitor_height" |
510 | 42 | #define AWN_PANEL_MONITOR_WIDTH "monitor_width" | 45 | #define AWN_PANEL_MONITOR_WIDTH "monitor_width" |
511 | 43 | #define AWN_PANEL_MONITOR_FORCE "monitor_force" | 46 | #define AWN_PANEL_MONITOR_FORCE "monitor_force" |
512 | 44 | 47 | ||
513 | === modified file 'src/awn-panel-dbus.xml' | |||
514 | --- src/awn-panel-dbus.xml 2009-06-26 10:09:15 +0000 | |||
515 | +++ src/awn-panel-dbus.xml 2009-07-17 22:02:30 +0000 | |||
516 | @@ -69,4 +69,23 @@ | |||
517 | 69 | <property name="PanelXid" type="x" access="read" /> | 69 | <property name="PanelXid" type="x" access="read" /> |
518 | 70 | 70 | ||
519 | 71 | </interface> | 71 | </interface> |
520 | 72 | |||
521 | 73 | <interface name="org.awnproject.Awn.UA"> | ||
522 | 74 | <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="awn_panel"/> | ||
523 | 75 | |||
524 | 76 | <!-- Methods --> | ||
525 | 77 | <method name="add_applet"> | ||
526 | 78 | <arg name="name" type="s" direction="in" /> | ||
527 | 79 | <arg name="uid" type="x" direction="in" /> | ||
528 | 80 | <arg name="width" type="i" direction="in" /> | ||
529 | 81 | <arg name="height" type="i" direction="in" /> | ||
530 | 82 | <arg name="size_type" type="s" direction="in" /> | ||
531 | 83 | </method> | ||
532 | 84 | |||
533 | 85 | <method name="get_all_server_flags"> | ||
534 | 86 | <arg name="name" type="s" direction="in" /> | ||
535 | 87 | <arg name="hash" type="a{ss}" direction="out" /> | ||
536 | 88 | </method> | ||
537 | 89 | |||
538 | 90 | </interface> | ||
539 | 72 | </node> | 91 | </node> |
540 | 73 | 92 | ||
541 | === modified file 'src/awn-panel.c' | |||
542 | --- src/awn-panel.c 2009-07-12 01:04:30 +0000 | |||
543 | +++ src/awn-panel.c 2009-07-17 22:10:27 +0000 | |||
544 | @@ -316,6 +316,7 @@ | |||
545 | 316 | 316 | ||
546 | 317 | static gboolean awn_panel_set_drag_proxy (AwnPanel *panel, | 317 | static gboolean awn_panel_set_drag_proxy (AwnPanel *panel, |
547 | 318 | gboolean check_mouse_pos); | 318 | gboolean check_mouse_pos); |
548 | 319 | |||
549 | 319 | /* | 320 | /* |
550 | 320 | * GOBJECT CODE | 321 | * GOBJECT CODE |
551 | 321 | */ | 322 | */ |
552 | @@ -2891,3 +2892,33 @@ | |||
553 | 2891 | dbus_g_method_return (context, window_id); | 2892 | dbus_g_method_return (context, window_id); |
554 | 2892 | } | 2893 | } |
555 | 2893 | 2894 | ||
556 | 2895 | gboolean | ||
557 | 2896 | awn_panel_get_all_server_flags (AwnPanel *panel, | ||
558 | 2897 | GHashTable **hash, | ||
559 | 2898 | gchar *name, | ||
560 | 2899 | GError **error) | ||
561 | 2900 | { | ||
562 | 2901 | AwnPanelPrivate *priv; | ||
563 | 2902 | |||
564 | 2903 | g_return_val_if_fail (AWN_IS_PANEL (panel), FALSE); | ||
565 | 2904 | priv = panel->priv; | ||
566 | 2905 | |||
567 | 2906 | return awn_ua_get_all_server_flags (AWN_APPLET_MANAGER (priv->manager), | ||
568 | 2907 | hash, name, error); | ||
569 | 2908 | } | ||
570 | 2909 | |||
571 | 2910 | gboolean | ||
572 | 2911 | awn_panel_add_applet (AwnPanel *panel, gchar *name, glong xid, | ||
573 | 2912 | gint width, gint height, | ||
574 | 2913 | gchar *size_type, | ||
575 | 2914 | GError **error) | ||
576 | 2915 | { | ||
577 | 2916 | AwnPanelPrivate *priv; | ||
578 | 2917 | |||
579 | 2918 | g_return_val_if_fail (AWN_IS_PANEL (panel), FALSE); | ||
580 | 2919 | priv = panel->priv; | ||
581 | 2920 | |||
582 | 2921 | return awn_ua_add_applet (AWN_APPLET_MANAGER (priv->manager), name, xid, | ||
583 | 2922 | width, height, size_type, error); | ||
584 | 2923 | } | ||
585 | 2924 | |||
586 | 2894 | 2925 | ||
587 | === modified file 'src/awn-panel.h' | |||
588 | --- src/awn-panel.h 2009-06-26 10:09:15 +0000 | |||
589 | +++ src/awn-panel.h 2009-07-17 22:10:27 +0000 | |||
590 | @@ -107,6 +107,17 @@ | |||
591 | 107 | gboolean expand, | 107 | gboolean expand, |
592 | 108 | DBusGMethodInvocation *context); | 108 | DBusGMethodInvocation *context); |
593 | 109 | 109 | ||
594 | 110 | gboolean awn_panel_get_all_server_flags(AwnPanel *panel, | ||
595 | 111 | GHashTable **hash, | ||
596 | 112 | gchar *name, | ||
597 | 113 | GError **error); | ||
598 | 114 | |||
599 | 115 | gboolean awn_panel_add_applet (AwnPanel *panel, | ||
600 | 116 | gchar *name, glong xid, | ||
601 | 117 | gint width, gint height, | ||
602 | 118 | gchar *size_type, | ||
603 | 119 | GError **error); | ||
604 | 120 | |||
605 | 110 | G_END_DECLS | 121 | G_END_DECLS |
606 | 111 | 122 | ||
607 | 112 | 123 | ||
608 | 113 | 124 | ||
609 | === added file 'src/awn-ua-alignment.c' | |||
610 | --- src/awn-ua-alignment.c 1970-01-01 00:00:00 +0000 | |||
611 | +++ src/awn-ua-alignment.c 2009-07-16 15:03:52 +0000 | |||
612 | @@ -0,0 +1,469 @@ | |||
613 | 1 | /* | ||
614 | 2 | * Copyright (C) 2009 Rodney Cryderman <rcryderman@gmail.com> | ||
615 | 3 | * | ||
616 | 4 | * This program is free software; you can redistribute it and/or modify | ||
617 | 5 | * it under the terms of the GNU General Public License as published by | ||
618 | 6 | * the Free Software Foundation; either version 2 of the License, or | ||
619 | 7 | * (at your option) any later version. | ||
620 | 8 | * | ||
621 | 9 | * This program is distributed in the hope that it will be useful, | ||
622 | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
623 | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
624 | 12 | * GNU General Public License for more details. | ||
625 | 13 | * | ||
626 | 14 | * You should have received a copy of the GNU General Public License | ||
627 | 15 | * along with this program; if not, write to the Free Software | ||
628 | 16 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | ||
629 | 17 | * | ||
630 | 18 | * | ||
631 | 19 | */ | ||
632 | 20 | |||
633 | 21 | /* awn-ua-alignment.c */ | ||
634 | 22 | #include <stdlib.h> | ||
635 | 23 | #include "awn-ua-alignment.h" | ||
636 | 24 | #include "awn-defines.h" | ||
637 | 25 | |||
638 | 26 | G_DEFINE_TYPE (AwnUAAlignment, awn_ua_alignment, GTK_TYPE_ALIGNMENT) | ||
639 | 27 | |||
640 | 28 | #define AWN_UA_ALIGNMENT_GET_PRIVATE(o) \ | ||
641 | 29 | (G_TYPE_INSTANCE_GET_PRIVATE ((o), AWN_TYPE_UA_ALIGNMENT, AwnUAAlignmentPrivate)) | ||
642 | 30 | |||
643 | 31 | typedef struct _AwnUAAlignmentPrivate AwnUAAlignmentPrivate; | ||
644 | 32 | |||
645 | 33 | struct _AwnUAAlignmentPrivate | ||
646 | 34 | { | ||
647 | 35 | GtkWidget * socket; | ||
648 | 36 | GtkWidget * applet_manager; | ||
649 | 37 | |||
650 | 38 | gchar *ua_list_entry; | ||
651 | 39 | double ua_ratio; | ||
652 | 40 | |||
653 | 41 | guint notify_size_id; | ||
654 | 42 | guint notify_orient_id; | ||
655 | 43 | guint notify_offset_id; | ||
656 | 44 | guint notify_ua_list_id; | ||
657 | 45 | }; | ||
658 | 46 | |||
659 | 47 | enum | ||
660 | 48 | { | ||
661 | 49 | PROP_0, | ||
662 | 50 | PROP_APPLET_MANAGER, | ||
663 | 51 | PROP_UA_LIST_ENTRY, | ||
664 | 52 | PROP_UA_RATIO | ||
665 | 53 | }; | ||
666 | 54 | |||
667 | 55 | |||
668 | 56 | static gboolean awn_ua_alignment_plug_removed (GtkWidget * socket, | ||
669 | 57 | AwnUAAlignment * self); | ||
670 | 58 | static void awn_ua_alignment_list_change(GObject *object, | ||
671 | 59 | GParamSpec *param_spec, | ||
672 | 60 | gpointer user_data); | ||
673 | 61 | static void awn_ua_alignment_orient_change(GObject *object, | ||
674 | 62 | GParamSpec *param_spec, | ||
675 | 63 | gpointer user_data); | ||
676 | 64 | static void awn_ua_alignment_size_change(GObject *object, | ||
677 | 65 | GParamSpec *param_spec, | ||
678 | 66 | gpointer user_data); | ||
679 | 67 | static void awn_ua_alignment_offset_change(GObject *object, | ||
680 | 68 | GParamSpec *param_spec, | ||
681 | 69 | gpointer user_data); | ||
682 | 70 | |||
683 | 71 | |||
684 | 72 | static void | ||
685 | 73 | awn_ua_alignment_get_property (GObject *object, guint property_id, | ||
686 | 74 | GValue *value, GParamSpec *pspec) | ||
687 | 75 | { | ||
688 | 76 | AwnUAAlignmentPrivate * priv; | ||
689 | 77 | |||
690 | 78 | priv = AWN_UA_ALIGNMENT_GET_PRIVATE (object); | ||
691 | 79 | |||
692 | 80 | switch (property_id) | ||
693 | 81 | { | ||
694 | 82 | case PROP_APPLET_MANAGER: | ||
695 | 83 | g_value_set_object (value,priv->applet_manager); | ||
696 | 84 | break; | ||
697 | 85 | case PROP_UA_LIST_ENTRY: | ||
698 | 86 | g_value_set_string (value,priv->ua_list_entry); | ||
699 | 87 | break; | ||
700 | 88 | case PROP_UA_RATIO: | ||
701 | 89 | g_value_set_double (value,priv->ua_ratio); | ||
702 | 90 | break; | ||
703 | 91 | default: | ||
704 | 92 | G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); | ||
705 | 93 | } | ||
706 | 94 | } | ||
707 | 95 | |||
708 | 96 | static void | ||
709 | 97 | awn_ua_alignment_set_property (GObject *object, guint property_id, | ||
710 | 98 | const GValue *value, GParamSpec *pspec) | ||
711 | 99 | { | ||
712 | 100 | AwnUAAlignmentPrivate * priv; | ||
713 | 101 | |||
714 | 102 | priv = AWN_UA_ALIGNMENT_GET_PRIVATE (object); | ||
715 | 103 | switch (property_id) | ||
716 | 104 | { | ||
717 | 105 | case PROP_APPLET_MANAGER: | ||
718 | 106 | priv->applet_manager = g_value_get_object (value); | ||
719 | 107 | break; | ||
720 | 108 | case PROP_UA_LIST_ENTRY: | ||
721 | 109 | g_free (priv->ua_list_entry); | ||
722 | 110 | priv->ua_list_entry = g_value_dup_string (value); | ||
723 | 111 | break; | ||
724 | 112 | case PROP_UA_RATIO: | ||
725 | 113 | priv->ua_ratio = g_value_get_double (value); | ||
726 | 114 | break; | ||
727 | 115 | default: | ||
728 | 116 | G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); | ||
729 | 117 | } | ||
730 | 118 | } | ||
731 | 119 | |||
732 | 120 | static void | ||
733 | 121 | awn_ua_alignment_dispose (GObject *object) | ||
734 | 122 | { | ||
735 | 123 | G_OBJECT_CLASS (awn_ua_alignment_parent_class)->dispose (object); | ||
736 | 124 | } | ||
737 | 125 | |||
738 | 126 | static void | ||
739 | 127 | awn_ua_alignment_finalize (GObject *object) | ||
740 | 128 | { | ||
741 | 129 | AwnUAAlignmentPrivate * priv = AWN_UA_ALIGNMENT_GET_PRIVATE (object); | ||
742 | 130 | g_debug ("%s",__func__); | ||
743 | 131 | if (priv->ua_list_entry) | ||
744 | 132 | { | ||
745 | 133 | g_free (priv->ua_list_entry); | ||
746 | 134 | } | ||
747 | 135 | G_OBJECT_CLASS (awn_ua_alignment_parent_class)->finalize (object); | ||
748 | 136 | } | ||
749 | 137 | |||
750 | 138 | static void | ||
751 | 139 | awn_ua_alignment_constructed (GObject *object) | ||
752 | 140 | { | ||
753 | 141 | AwnUAAlignmentPrivate * priv = AWN_UA_ALIGNMENT_GET_PRIVATE (object); | ||
754 | 142 | |||
755 | 143 | if (G_OBJECT_CLASS (awn_ua_alignment_parent_class)->constructed) | ||
756 | 144 | { | ||
757 | 145 | G_OBJECT_CLASS (awn_ua_alignment_parent_class)->constructed (object); | ||
758 | 146 | } | ||
759 | 147 | |||
760 | 148 | gtk_container_add (GTK_CONTAINER(object),priv->socket); | ||
761 | 149 | awn_ua_alignment_orient_change (NULL,NULL,object); | ||
762 | 150 | priv->notify_offset_id = g_signal_connect (priv->applet_manager, | ||
763 | 151 | "notify::offset", | ||
764 | 152 | G_CALLBACK(awn_ua_alignment_offset_change), | ||
765 | 153 | object); | ||
766 | 154 | priv->notify_orient_id = g_signal_connect_after (priv->applet_manager, | ||
767 | 155 | "notify::orient", | ||
768 | 156 | G_CALLBACK(awn_ua_alignment_orient_change), | ||
769 | 157 | object); | ||
770 | 158 | priv->notify_size_id = g_signal_connect_after (priv->applet_manager, | ||
771 | 159 | "notify::size", | ||
772 | 160 | G_CALLBACK(awn_ua_alignment_size_change), | ||
773 | 161 | object); | ||
774 | 162 | priv->notify_ua_list_id = g_signal_connect_after (priv->applet_manager, | ||
775 | 163 | "notify::ua-active-list", | ||
776 | 164 | G_CALLBACK(awn_ua_alignment_list_change), | ||
777 | 165 | object); | ||
778 | 166 | } | ||
779 | 167 | |||
780 | 168 | static void | ||
781 | 169 | awn_ua_alignment_class_init (AwnUAAlignmentClass *klass) | ||
782 | 170 | { | ||
783 | 171 | GObjectClass *object_class = G_OBJECT_CLASS (klass); | ||
784 | 172 | GParamSpec *pspec; | ||
785 | 173 | |||
786 | 174 | object_class->get_property = awn_ua_alignment_get_property; | ||
787 | 175 | object_class->set_property = awn_ua_alignment_set_property; | ||
788 | 176 | object_class->dispose = awn_ua_alignment_dispose; | ||
789 | 177 | object_class->finalize = awn_ua_alignment_finalize; | ||
790 | 178 | object_class->constructed = awn_ua_alignment_constructed; | ||
791 | 179 | |||
792 | 180 | pspec = g_param_spec_object ("applet-manager", | ||
793 | 181 | "Awn Applet Manager", | ||
794 | 182 | "Awn Applet Manager", | ||
795 | 183 | AWN_TYPE_APPLET_MANAGER, | ||
796 | 184 | G_PARAM_READWRITE | G_PARAM_CONSTRUCT); | ||
797 | 185 | g_object_class_install_property (object_class, PROP_APPLET_MANAGER, pspec); | ||
798 | 186 | |||
799 | 187 | pspec = g_param_spec_string ("ua-list-entry", | ||
800 | 188 | "UA List entry", | ||
801 | 189 | "UA List entry", | ||
802 | 190 | NULL, | ||
803 | 191 | G_PARAM_READWRITE | G_PARAM_CONSTRUCT); | ||
804 | 192 | g_object_class_install_property (object_class, PROP_UA_LIST_ENTRY, pspec); | ||
805 | 193 | |||
806 | 194 | pspec = g_param_spec_double ("ua-ratio", | ||
807 | 195 | "UA Ratio", | ||
808 | 196 | "UA Ratio", | ||
809 | 197 | 0.0, | ||
810 | 198 | 100.0, | ||
811 | 199 | 1.0, | ||
812 | 200 | G_PARAM_READWRITE | G_PARAM_CONSTRUCT); | ||
813 | 201 | g_object_class_install_property (object_class, PROP_UA_RATIO, pspec); | ||
814 | 202 | |||
815 | 203 | g_type_class_add_private (klass, sizeof (AwnUAAlignmentPrivate)); | ||
816 | 204 | } | ||
817 | 205 | |||
818 | 206 | static void | ||
819 | 207 | awn_ua_alignment_init (AwnUAAlignment *self) | ||
820 | 208 | { | ||
821 | 209 | AwnUAAlignmentPrivate *priv; | ||
822 | 210 | |||
823 | 211 | priv = AWN_UA_ALIGNMENT_GET_PRIVATE (self); | ||
824 | 212 | priv->socket = gtk_socket_new (); | ||
825 | 213 | } | ||
826 | 214 | |||
827 | 215 | GtkWidget* | ||
828 | 216 | awn_ua_alignment_new (AwnAppletManager *manager,gchar * ua_list_entry,double ua_ratio) | ||
829 | 217 | { | ||
830 | 218 | return g_object_new (AWN_TYPE_UA_ALIGNMENT, | ||
831 | 219 | "applet-manager",manager, | ||
832 | 220 | "ua-list-entry",ua_list_entry, | ||
833 | 221 | "ua-ratio",ua_ratio, | ||
834 | 222 | NULL); | ||
835 | 223 | } | ||
836 | 224 | |||
837 | 225 | GtkWidget* | ||
838 | 226 | awn_ua_alignment_get_socket (AwnUAAlignment *self) | ||
839 | 227 | { | ||
840 | 228 | AwnUAAlignmentPrivate *priv; | ||
841 | 229 | |||
842 | 230 | priv = AWN_UA_ALIGNMENT_GET_PRIVATE (self); | ||
843 | 231 | return priv->socket; | ||
844 | 232 | } | ||
845 | 233 | |||
846 | 234 | |||
847 | 235 | GdkWindow * | ||
848 | 236 | awn_ua_alignment_add_id (AwnUAAlignment *self,GdkNativeWindow native_window) | ||
849 | 237 | { | ||
850 | 238 | GdkWindow * plugwin; | ||
851 | 239 | AwnUAAlignmentPrivate *priv; | ||
852 | 240 | |||
853 | 241 | priv = AWN_UA_ALIGNMENT_GET_PRIVATE (self); | ||
854 | 242 | gtk_socket_add_id (GTK_SOCKET(priv->socket), native_window); | ||
855 | 243 | plugwin = gtk_socket_get_plug_window (GTK_SOCKET(priv->socket)); | ||
856 | 244 | g_signal_connect (priv->socket,"plug-removed", | ||
857 | 245 | G_CALLBACK(awn_ua_alignment_plug_removed),self); | ||
858 | 246 | gtk_widget_realize (priv->socket); | ||
859 | 247 | gtk_widget_show_all (priv->socket); | ||
860 | 248 | return plugwin; | ||
861 | 249 | } | ||
862 | 250 | |||
863 | 251 | |||
864 | 252 | static gboolean | ||
865 | 253 | awn_ua_alignment_plug_removed (GtkWidget * socket,AwnUAAlignment * self) | ||
866 | 254 | { | ||
867 | 255 | |||
868 | 256 | GSList * search; | ||
869 | 257 | GSList * ua_active_list; | ||
870 | 258 | GSList * orig_active_list; | ||
871 | 259 | GSList * iter; | ||
872 | 260 | AwnConfigClient *client; | ||
873 | 261 | |||
874 | 262 | AwnUAAlignmentPrivate *priv = AWN_UA_ALIGNMENT_GET_PRIVATE (self); | ||
875 | 263 | |||
876 | 264 | g_signal_handler_disconnect (priv->applet_manager,priv->notify_size_id); | ||
877 | 265 | g_signal_handler_disconnect (priv->applet_manager,priv->notify_orient_id); | ||
878 | 266 | g_signal_handler_disconnect (priv->applet_manager,priv->notify_offset_id); | ||
879 | 267 | g_signal_handler_disconnect (priv->applet_manager,priv->notify_ua_list_id); | ||
880 | 268 | |||
881 | 269 | g_object_get ( priv->applet_manager, | ||
882 | 270 | "ua_active_list",&orig_active_list, | ||
883 | 271 | "client",&client, | ||
884 | 272 | NULL); | ||
885 | 273 | ua_active_list = g_slist_copy (orig_active_list); | ||
886 | 274 | for (iter = ua_active_list;iter;iter = iter->next) | ||
887 | 275 | { | ||
888 | 276 | iter->data = g_strdup(iter->data); | ||
889 | 277 | } | ||
890 | 278 | search = g_slist_find_custom (ua_active_list,priv->ua_list_entry, | ||
891 | 279 | (GCompareFunc)g_strcmp0); | ||
892 | 280 | if (search) | ||
893 | 281 | { | ||
894 | 282 | ua_active_list = g_slist_delete_link (ua_active_list,search); | ||
895 | 283 | } | ||
896 | 284 | awn_config_client_set_list (client,AWN_GROUP_PANEL, AWN_PANEL_UA_ACTIVE_LIST, | ||
897 | 285 | AWN_CONFIG_CLIENT_LIST_TYPE_STRING, | ||
898 | 286 | ua_active_list, NULL); | ||
899 | 287 | g_object_set (priv->applet_manager, | ||
900 | 288 | "ua-active-list",ua_active_list, | ||
901 | 289 | NULL); | ||
902 | 290 | awn_applet_manager_remove_widget(AWN_APPLET_MANAGER(priv->applet_manager), | ||
903 | 291 | GTK_WIDGET (self)); | ||
904 | 292 | return FALSE; | ||
905 | 293 | } | ||
906 | 294 | |||
907 | 295 | /*UA*/ | ||
908 | 296 | gint | ||
909 | 297 | awn_ua_alignment_list_cmp (gconstpointer a, gconstpointer b) | ||
910 | 298 | { | ||
911 | 299 | const gchar * str1 = a; | ||
912 | 300 | const gchar * str2 = b; | ||
913 | 301 | gchar * search = NULL; | ||
914 | 302 | GStrv tokens = g_strsplit (str1,"::",2); | ||
915 | 303 | g_return_val_if_fail (tokens,-1); | ||
916 | 304 | |||
917 | 305 | search = g_strstr_len (str2,-1,tokens[0]); | ||
918 | 306 | g_strfreev (tokens); | ||
919 | 307 | |||
920 | 308 | if (!search) | ||
921 | 309 | { | ||
922 | 310 | return -1; | ||
923 | 311 | }; | ||
924 | 312 | return 0; | ||
925 | 313 | } | ||
926 | 314 | |||
927 | 315 | static void | ||
928 | 316 | awn_ua_alignment_offset_change(GObject *object,GParamSpec *param_spec,gpointer user_data) | ||
929 | 317 | { | ||
930 | 318 | AwnUAAlignment * self = user_data; | ||
931 | 319 | gint offset; | ||
932 | 320 | gint orient; | ||
933 | 321 | AwnUAAlignmentPrivate *priv = AWN_UA_ALIGNMENT_GET_PRIVATE (self); | ||
934 | 322 | |||
935 | 323 | g_object_get ( priv->applet_manager, | ||
936 | 324 | "offset",&offset, | ||
937 | 325 | "orient",&orient, | ||
938 | 326 | NULL); | ||
939 | 327 | |||
940 | 328 | switch (orient) | ||
941 | 329 | { | ||
942 | 330 | case AWN_ORIENTATION_TOP: | ||
943 | 331 | gtk_alignment_set_padding (GTK_ALIGNMENT(self), offset, 0, 0, 0); | ||
944 | 332 | break; | ||
945 | 333 | case AWN_ORIENTATION_BOTTOM: | ||
946 | 334 | gtk_alignment_set_padding (GTK_ALIGNMENT(self), 0, offset, 0, 0); | ||
947 | 335 | break; | ||
948 | 336 | case AWN_ORIENTATION_LEFT: | ||
949 | 337 | gtk_alignment_set_padding (GTK_ALIGNMENT(self), 0, 0, offset, 0); | ||
950 | 338 | break; | ||
951 | 339 | case AWN_ORIENTATION_RIGHT: | ||
952 | 340 | gtk_alignment_set_padding (GTK_ALIGNMENT(self), 0, 0, 0, offset); | ||
953 | 341 | break; | ||
954 | 342 | default: | ||
955 | 343 | g_warning ("%s: recieved invalid orient %d",__func__,orient); | ||
956 | 344 | } | ||
957 | 345 | } | ||
958 | 346 | |||
959 | 347 | static void | ||
960 | 348 | awn_ua_alignment_size_change(GObject *object,GParamSpec *param_spec,gpointer user_data) | ||
961 | 349 | { | ||
962 | 350 | AwnUAAlignment * self = user_data; | ||
963 | 351 | gint offset; | ||
964 | 352 | gint orient; | ||
965 | 353 | gint size; | ||
966 | 354 | AwnUAAlignmentPrivate *priv = AWN_UA_ALIGNMENT_GET_PRIVATE (self); | ||
967 | 355 | |||
968 | 356 | g_object_get ( priv->applet_manager, | ||
969 | 357 | "offset",&offset, | ||
970 | 358 | "orient",&orient, | ||
971 | 359 | "size",&size, | ||
972 | 360 | NULL); | ||
973 | 361 | GtkRequisition req; | ||
974 | 362 | |||
975 | 363 | req.width = req.height = size; | ||
976 | 364 | switch (orient) | ||
977 | 365 | { | ||
978 | 366 | case AWN_ORIENTATION_TOP: | ||
979 | 367 | case AWN_ORIENTATION_BOTTOM: | ||
980 | 368 | req.width = size * priv->ua_ratio; | ||
981 | 369 | req.height = size; | ||
982 | 370 | break; | ||
983 | 371 | case AWN_ORIENTATION_LEFT: | ||
984 | 372 | case AWN_ORIENTATION_RIGHT: | ||
985 | 373 | req.width = size; | ||
986 | 374 | req.height = size * 1.0 / priv->ua_ratio; | ||
987 | 375 | break; | ||
988 | 376 | default: | ||
989 | 377 | g_warning ("%s: received invalid orient %d",__func__,orient); | ||
990 | 378 | } | ||
991 | 379 | gtk_widget_set_size_request (GTK_WIDGET(self),req.width,req.height); | ||
992 | 380 | } | ||
993 | 381 | |||
994 | 382 | static void | ||
995 | 383 | awn_ua_alignment_orient_change(GObject *object,GParamSpec *param_spec,gpointer user_data) | ||
996 | 384 | { | ||
997 | 385 | |||
998 | 386 | AwnUAAlignment * self = user_data; | ||
999 | 387 | gint orient; | ||
1000 | 388 | AwnUAAlignmentPrivate *priv = AWN_UA_ALIGNMENT_GET_PRIVATE (self); | ||
1001 | 389 | |||
1002 | 390 | g_object_get ( priv->applet_manager, | ||
1003 | 391 | "orient",&orient, | ||
1004 | 392 | NULL); | ||
1005 | 393 | switch (orient) | ||
1006 | 394 | { | ||
1007 | 395 | case AWN_ORIENTATION_TOP: | ||
1008 | 396 | gtk_alignment_set (GTK_ALIGNMENT(self), 0.0, 0.0, 1.0, 0.5); | ||
1009 | 397 | break; | ||
1010 | 398 | case AWN_ORIENTATION_BOTTOM: | ||
1011 | 399 | gtk_alignment_set (GTK_ALIGNMENT(self), 0.0, 1.0, 1.0, 0.5); | ||
1012 | 400 | break; | ||
1013 | 401 | case AWN_ORIENTATION_LEFT: | ||
1014 | 402 | gtk_alignment_set (GTK_ALIGNMENT(self), 0.0, 0.0, 0.5, 1.0); | ||
1015 | 403 | break; | ||
1016 | 404 | case AWN_ORIENTATION_RIGHT: | ||
1017 | 405 | gtk_alignment_set (GTK_ALIGNMENT(self), 1.0, 0.0, 0.5, 1.0); | ||
1018 | 406 | break; | ||
1019 | 407 | default: | ||
1020 | 408 | g_warning ("%s: received invalid orient %d",__func__,orient); | ||
1021 | 409 | } | ||
1022 | 410 | awn_ua_alignment_offset_change (object,param_spec,self); | ||
1023 | 411 | awn_ua_alignment_size_change (object,param_spec,self); | ||
1024 | 412 | } | ||
1025 | 413 | |||
1026 | 414 | static void | ||
1027 | 415 | awn_ua_alignment_list_change(GObject *object,GParamSpec *param_spec,gpointer user_data) | ||
1028 | 416 | { | ||
1029 | 417 | AwnUAAlignment * self = user_data; | ||
1030 | 418 | gint orient; | ||
1031 | 419 | AwnUAAlignmentPrivate *priv = AWN_UA_ALIGNMENT_GET_PRIVATE (self); | ||
1032 | 420 | GSList * ua_active_list; | ||
1033 | 421 | |||
1034 | 422 | g_object_get ( priv->applet_manager, | ||
1035 | 423 | "orient",&orient, | ||
1036 | 424 | "ua_active_list",&ua_active_list, | ||
1037 | 425 | NULL); | ||
1038 | 426 | |||
1039 | 427 | GSList * search = g_slist_find_custom (ua_active_list, | ||
1040 | 428 | priv->ua_list_entry, | ||
1041 | 429 | (GCompareFunc)g_strcmp0); | ||
1042 | 430 | if (search) | ||
1043 | 431 | { | ||
1044 | 432 | g_debug ("Found... do not need to update %s",priv->ua_list_entry); | ||
1045 | 433 | } | ||
1046 | 434 | else | ||
1047 | 435 | { | ||
1048 | 436 | search = g_slist_find_custom (ua_active_list,priv->ua_list_entry,awn_ua_alignment_list_cmp); | ||
1049 | 437 | if (search) | ||
1050 | 438 | { | ||
1051 | 439 | g_debug ("Moving %s to %s",priv->ua_list_entry,(gchar*)search->data); | ||
1052 | 440 | GStrv tokens; | ||
1053 | 441 | gint pos = -1; | ||
1054 | 442 | g_free (priv->ua_list_entry); | ||
1055 | 443 | priv->ua_list_entry = g_strdup(search->data); | ||
1056 | 444 | tokens = g_strsplit (search->data,"::",2); | ||
1057 | 445 | if (tokens && tokens[1]) | ||
1058 | 446 | { | ||
1059 | 447 | pos = atoi (tokens[1]); | ||
1060 | 448 | } | ||
1061 | 449 | g_strfreev (tokens); | ||
1062 | 450 | if (pos != -1) | ||
1063 | 451 | { | ||
1064 | 452 | awn_applet_manager_add_widget(AWN_APPLET_MANAGER(priv->applet_manager), | ||
1065 | 453 | GTK_WIDGET (self), | ||
1066 | 454 | pos); | ||
1067 | 455 | } | ||
1068 | 456 | } | ||
1069 | 457 | else | ||
1070 | 458 | { | ||
1071 | 459 | g_debug ("looks like %s was removed from panel/ua_list",priv->ua_list_entry); | ||
1072 | 460 | /* | ||
1073 | 461 | aantn as expected this does not kill the screenlet. What is the best way to | ||
1074 | 462 | tell it that we want it to go away? | ||
1075 | 463 | */ | ||
1076 | 464 | awn_applet_manager_remove_widget(AWN_APPLET_MANAGER(priv->applet_manager), | ||
1077 | 465 | GTK_WIDGET (self)); | ||
1078 | 466 | gtk_widget_destroy (priv->socket); | ||
1079 | 467 | } | ||
1080 | 468 | } | ||
1081 | 469 | } | ||
1082 | 0 | 470 | ||
1083 | === added file 'src/awn-ua-alignment.h' | |||
1084 | --- src/awn-ua-alignment.h 1970-01-01 00:00:00 +0000 | |||
1085 | +++ src/awn-ua-alignment.h 2009-07-14 02:56:28 +0000 | |||
1086 | @@ -0,0 +1,68 @@ | |||
1087 | 1 | /* | ||
1088 | 2 | * Copyright (C) 2009 Rodney Cryderman <rcryderman@gmail.com> | ||
1089 | 3 | * | ||
1090 | 4 | * This program is free software; you can redistribute it and/or modify | ||
1091 | 5 | * it under the terms of the GNU General Public License as published by | ||
1092 | 6 | * the Free Software Foundation; either version 2 of the License, or | ||
1093 | 7 | * (at your option) any later version. | ||
1094 | 8 | * | ||
1095 | 9 | * This program is distributed in the hope that it will be useful, | ||
1096 | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1097 | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1098 | 12 | * GNU General Public License for more details. | ||
1099 | 13 | * | ||
1100 | 14 | * You should have received a copy of the GNU General Public License | ||
1101 | 15 | * along with this program; if not, write to the Free Software | ||
1102 | 16 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | ||
1103 | 17 | * | ||
1104 | 18 | * | ||
1105 | 19 | */ | ||
1106 | 20 | |||
1107 | 21 | /* awn-ua-alignment.h */ | ||
1108 | 22 | |||
1109 | 23 | #ifndef _AWN_UA_ALIGNMENT | ||
1110 | 24 | #define _AWN_UA_ALIGNMENT | ||
1111 | 25 | |||
1112 | 26 | #include <gtk/gtk.h> | ||
1113 | 27 | #include "awn-applet-manager.h" | ||
1114 | 28 | |||
1115 | 29 | G_BEGIN_DECLS | ||
1116 | 30 | |||
1117 | 31 | #define AWN_TYPE_UA_ALIGNMENT awn_ua_alignment_get_type() | ||
1118 | 32 | |||
1119 | 33 | #define AWN_UA_ALIGNMENT(obj) \ | ||
1120 | 34 | (G_TYPE_CHECK_INSTANCE_CAST ((obj), AWN_TYPE_UA_ALIGNMENT, AwnUAAlignment)) | ||
1121 | 35 | |||
1122 | 36 | #define AWN_UA_ALIGNMENT_CLASS(klass) \ | ||
1123 | 37 | (G_TYPE_CHECK_CLASS_CAST ((klass), AWN_TYPE_UA_ALIGNMENT, AwnUAAlignmentClass)) | ||
1124 | 38 | |||
1125 | 39 | #define AWN_IS_UA_ALIGNMENT(obj) \ | ||
1126 | 40 | (G_TYPE_CHECK_INSTANCE_TYPE ((obj), AWN_TYPE_UA_ALIGNMENT)) | ||
1127 | 41 | |||
1128 | 42 | #define AWN_IS_UA_ALIGNMENT_CLASS(klass) \ | ||
1129 | 43 | (G_TYPE_CHECK_CLASS_TYPE ((klass), AWN_TYPE_UA_ALIGNMENT)) | ||
1130 | 44 | |||
1131 | 45 | #define AWN_UA_ALIGNMENT_GET_CLASS(obj) \ | ||
1132 | 46 | (G_TYPE_INSTANCE_GET_CLASS ((obj), AWN_TYPE_UA_ALIGNMENT, AwnUAAlignmentClass)) | ||
1133 | 47 | |||
1134 | 48 | typedef struct { | ||
1135 | 49 | GtkAlignment parent; | ||
1136 | 50 | } AwnUAAlignment; | ||
1137 | 51 | |||
1138 | 52 | typedef struct { | ||
1139 | 53 | GtkAlignmentClass parent_class; | ||
1140 | 54 | } AwnUAAlignmentClass; | ||
1141 | 55 | |||
1142 | 56 | GType awn_ua_alignment_get_type (void); | ||
1143 | 57 | |||
1144 | 58 | GtkWidget* awn_ua_alignment_new (AwnAppletManager *manager,gchar * ua_list_entry,double ua_ratio); | ||
1145 | 59 | |||
1146 | 60 | GtkWidget* awn_ua_alignment_get_socket (AwnUAAlignment *self); | ||
1147 | 61 | |||
1148 | 62 | GdkWindow * awn_ua_alignment_add_id (AwnUAAlignment *self, GdkNativeWindow native_window); | ||
1149 | 63 | |||
1150 | 64 | gint awn_ua_alignment_list_cmp (gconstpointer a, gconstpointer b); | ||
1151 | 65 | |||
1152 | 66 | G_END_DECLS | ||
1153 | 67 | |||
1154 | 68 | #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.