Awn

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

Proposed by moonbeam
Status: Superseded
Proposed branch: lp:~awn-testing/awn/awn-rewrite-ua-support
Merge into: lp:~awn-core/awn/trunk-rewrite
Diff against target: None lines
To merge this branch: bzr merge lp:~awn-testing/awn/awn-rewrite-ua-support
Reviewer Review Type Date Requested Status
Awn-core Pending
Review via email: mp+8821@code.launchpad.net

This proposal has been superseded by a proposal from 2009-07-15.

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

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.

838. By moonbeam

* .bzrignore:
* INSTALL:
 Sync with files in Rewrite.
* src/awn-applet-manager.c:
 Removed some debugs.

839. By moonbeam

* src/awn-ua-alignment.c:
 Destroy the socket when ua/screenlet removed from the ua_acitive_list.

840. By Julien Lavergne

Fix tabs in awnClass.py (require by PEP8)

841. By Julien Lavergne

Fix also tabs in AwnDefs.py.in

842. By moonbeam

* applets/uawrapper/awn-ua-wrapper.h:
       Removed leftover file

843. By moonbeam

* libawn/awn-alignment.c:
       Sync file with rewrite.

844. By moonbeam

* src/awn-applet-manager.c:
* src/awn-applet-manager.h:
* src/awn-ua-alignment.c:
       Various whitespace fixes.
       Modified awn_ua_get_all_server_flags().
       Removed touch_quark set on UaAlignment() for UAAlignment.

845. By moonbeam

Merge rewrite.

846. By moonbeam

* applets/uawrapper/:
 Removed empty dir.

847. By moonbeam

Merged rewrite

848. By Michal Hruby

Changes to the DBus interface

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file '.bzrignore'
2--- .bzrignore 2009-07-09 07:12:27 +0000
3+++ .bzrignore 2009-07-13 18:05:02 +0000
4@@ -107,6 +107,12 @@
5 src/stamp-awnmarshal.h
6 applets/taskmanager/taskmanager-marshal.c
7 applets/taskmanager/taskmanager-marshal.h
8+debian/patches/*.log
9+debian/stamp*
10+debian/libawn*/*
11+debian/avant-*/*
12+debian/python*/*
13+debian/awn*/*
14 doltcompile
15 doltlibtool
16 m4/lt*.m4
17
18=== modified file 'INSTALL'
19--- INSTALL 2009-05-22 09:16:20 +0000
20+++ INSTALL 2009-06-25 04:55:53 +0000
21@@ -2,15 +2,15 @@
22 *************************
23
24 Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005,
25-2006, 2007, 2008 Free Software Foundation, Inc.
26+2006, 2007 Free Software Foundation, Inc.
27
28- This file is free documentation; the Free Software Foundation gives
29+This file is free documentation; the Free Software Foundation gives
30 unlimited permission to copy, distribute and modify it.
31
32 Basic Installation
33 ==================
34
35- Briefly, the shell commands `./configure; make; make install' should
36+Briefly, the shell commands `./configure; make; make install' should
37 configure, build, and install this package. The following
38 more-detailed instructions are generic; see the `README' file for
39 instructions specific to this package.
40@@ -73,9 +73,9 @@
41 Compilers and Options
42 =====================
43
44- Some systems require unusual options for compilation or linking that
45-the `configure' script does not know about. Run `./configure --help'
46-for details on some of the pertinent environment variables.
47+Some systems require unusual options for compilation or linking that the
48+`configure' script does not know about. Run `./configure --help' for
49+details on some of the pertinent environment variables.
50
51 You can give `configure' initial values for configuration parameters
52 by setting variables in the command line or in the environment. Here
53@@ -88,7 +88,7 @@
54 Compiling For Multiple Architectures
55 ====================================
56
57- You can compile the package for more than one kind of computer at the
58+You can compile the package for more than one kind of computer at the
59 same time, by placing the object files for each architecture in their
60 own directory. To do this, you can use GNU `make'. `cd' to the
61 directory where you want the object files and executables to go and run
62@@ -100,24 +100,10 @@
63 installed the package for one architecture, use `make distclean' before
64 reconfiguring for another architecture.
65
66- On MacOS X 10.5 and later systems, you can create libraries and
67-executables that work on multiple system types--known as "fat" or
68-"universal" binaries--by specifying multiple `-arch' options to the
69-compiler but only a single `-arch' option to the preprocessor. Like
70-this:
71-
72- ./configure CC="gcc -arch i386 -arch x86_64 -arch ppc -arch ppc64" \
73- CXX="g++ -arch i386 -arch x86_64 -arch ppc -arch ppc64" \
74- CPP="gcc -E" CXXCPP="g++ -E"
75-
76- This is not guaranteed to produce working output in all cases, you
77-may have to build one architecture at a time and combine the results
78-using the `lipo' tool if you have problems.
79-
80 Installation Names
81 ==================
82
83- By default, `make install' installs the package's commands under
84+By default, `make install' installs the package's commands under
85 `/usr/local/bin', include files under `/usr/local/include', etc. You
86 can specify an installation prefix other than `/usr/local' by giving
87 `configure' the option `--prefix=PREFIX'.
88@@ -140,7 +126,7 @@
89 Optional Features
90 =================
91
92- Some packages pay attention to `--enable-FEATURE' options to
93+Some packages pay attention to `--enable-FEATURE' options to
94 `configure', where FEATURE indicates an optional part of the package.
95 They may also pay attention to `--with-PACKAGE' options, where PACKAGE
96 is something like `gnu-as' or `x' (for the X Window System). The
97@@ -152,36 +138,14 @@
98 you can use the `configure' options `--x-includes=DIR' and
99 `--x-libraries=DIR' to specify their locations.
100
101-Particular systems
102-==================
103-
104- On HP-UX, the default C compiler is not ANSI C compatible. If GNU
105-CC is not installed, it is recommended to use the following options in
106-order to use an ANSI C compiler:
107-
108- ./configure CC="cc -Ae"
109-
110-and if that doesn't work, install pre-built binaries of GCC for HP-UX.
111-
112- On OSF/1 a.k.a. Tru64, some versions of the default C compiler cannot
113-parse its `<wchar.h>' header file. The option `-nodtk' can be used as
114-a workaround. If GNU CC is not installed, it is therefore recommended
115-to try
116-
117- ./configure CC="cc"
118-
119-and if that doesn't work, try
120-
121- ./configure CC="cc -nodtk"
122-
123 Specifying the System Type
124 ==========================
125
126- There may be some features `configure' cannot figure out
127-automatically, but needs to determine by the type of machine the package
128-will run on. Usually, assuming the package is built to be run on the
129-_same_ architectures, `configure' can figure that out, but if it prints
130-a message saying it cannot guess the machine type, give it the
131+There may be some features `configure' cannot figure out automatically,
132+but needs to determine by the type of machine the package will run on.
133+Usually, assuming the package is built to be run on the _same_
134+architectures, `configure' can figure that out, but if it prints a
135+message saying it cannot guess the machine type, give it the
136 `--build=TYPE' option. TYPE can either be a short name for the system
137 type, such as `sun4', or a canonical name which has the form:
138
139@@ -207,9 +171,9 @@
140 Sharing Defaults
141 ================
142
143- If you want to set default values for `configure' scripts to share,
144-you can create a site shell script called `config.site' that gives
145-default values for variables like `CC', `cache_file', and `prefix'.
146+If you want to set default values for `configure' scripts to share, you
147+can create a site shell script called `config.site' that gives default
148+values for variables like `CC', `cache_file', and `prefix'.
149 `configure' looks for `PREFIX/share/config.site' if it exists, then
150 `PREFIX/etc/config.site' if it exists. Or, you can set the
151 `CONFIG_SITE' environment variable to the location of the site script.
152@@ -218,7 +182,7 @@
153 Defining Variables
154 ==================
155
156- Variables not defined in a site shell script can be set in the
157+Variables not defined in a site shell script can be set in the
158 environment passed to `configure'. However, some packages may run
159 configure again during the build, and the customized values of these
160 variables may be lost. In order to avoid this problem, you should set
161@@ -237,19 +201,11 @@
162 `configure' Invocation
163 ======================
164
165- `configure' recognizes the following options to control how it
166-operates.
167+`configure' recognizes the following options to control how it operates.
168
169 `--help'
170 `-h'
171- Print a summary of all of the options to `configure', and exit.
172-
173-`--help=short'
174-`--help=recursive'
175- Print a summary of the options unique to this package's
176- `configure', and exit. The `short' variant lists options used
177- only in the top level, while the `recursive' variant lists options
178- also present in any nested packages.
179+ Print a summary of the options to `configure', and exit.
180
181 `--version'
182 `-V'
183@@ -276,16 +232,6 @@
184 Look for the package's source code in directory DIR. Usually
185 `configure' can determine that directory automatically.
186
187-`--prefix=DIR'
188- Use DIR as the installation prefix. *Note Installation Names::
189- for more details, including other options available for fine-tuning
190- the installation locations.
191-
192-`--no-create'
193-`-n'
194- Run the configure checks, but stop before creating any output
195- files.
196-
197 `configure' also accepts some other, not widely useful, options. Run
198 `configure --help' for more details.
199
200
201=== added directory 'applets/uawrapper'
202=== added file 'applets/uawrapper/awn-ua-wrapper.h'
203--- applets/uawrapper/awn-ua-wrapper.h 1970-01-01 00:00:00 +0000
204+++ applets/uawrapper/awn-ua-wrapper.h 2009-06-25 04:55:53 +0000
205@@ -0,0 +1,42 @@
206+/* awn-ua-wrapper.h */
207+
208+#ifndef _AWN_UA_WRAPPER
209+#define _AWN_UA_WRAPPER
210+
211+#include <glib-object.h>
212+#include <libawn/libawn.h>
213+
214+G_BEGIN_DECLS
215+
216+#define AWN_TYPE_UA_WRAPPER awn_ua_wrapper_get_type()
217+
218+#define AWN_UA_WRAPPER(obj) \
219+ (G_TYPE_CHECK_INSTANCE_CAST ((obj), AWN_TYPE_UA_WRAPPER, AwnUAWrapper))
220+
221+#define AWN_UA_WRAPPER_CLASS(klass) \
222+ (G_TYPE_CHECK_CLASS_CAST ((klass), AWN_TYPE_UA_WRAPPER, AwnUAWrapperClass))
223+
224+#define AWN_IS_UA_WRAPPER(obj) \
225+ (G_TYPE_CHECK_INSTANCE_TYPE ((obj), AWN_TYPE_UA_WRAPPER))
226+
227+#define AWN_IS_UA_WRAPPER_CLASS(klass) \
228+ (G_TYPE_CHECK_CLASS_TYPE ((klass), AWN_TYPE_UA_WRAPPER))
229+
230+#define AWN_UA_WRAPPER_GET_CLASS(obj) \
231+ (G_TYPE_INSTANCE_GET_CLASS ((obj), AWN_TYPE_UA_WRAPPER, AwnUAWrapperClass))
232+
233+typedef struct {
234+ AwnApplet parent;
235+} AwnUAWrapper;
236+
237+typedef struct {
238+ AwnAppletClass parent_class;
239+} AwnUAWrapperClass;
240+
241+GType awn_ua_wrapper_get_type (void);
242+
243+AwnUAWrapper* awn_ua_wrapper_new (gchar* uid, gint panel_id);
244+
245+G_END_DECLS
246+
247+#endif /* _AWN_UA_WRAPPER */
248
249=== modified file 'awn-settings/awnClass.py'
250--- awn-settings/awnClass.py 2009-07-10 00:56:51 +0000
251+++ awn-settings/awnClass.py 2009-07-14 17:57:18 +0000
252@@ -1537,16 +1537,22 @@
253 os.unlink(filename)
254
255 def _apply (self):
256- l = []
257+ applets_list = []
258+ ua_list = []
259+
260 it = self.active_model.get_iter_first ()
261 while (it):
262 path = self.active_model.get_value (it, 1)
263 uid = self.active_model.get_value (it, 2)
264 s = "%s::%s" % (path, uid)
265- l.append (s)
266+ if path.endswith(".desktop"):
267+ applets_list.append(s)
268+ else:
269+ ua_list.append(s)
270+
271 it= self.active_model.iter_next (it)
272
273- self.client.set_list(defs.PANEL, defs.APPLET_LIST, awn.CONFIG_LIST_STRING, l)
274+ self.client.set_list(defs.PANEL, defs.APPLET_LIST, awn.CONFIG_LIST_STRING, applets_list)
275
276 def up_clicked (self, button):
277 select = self.treeview.get_selection()
278@@ -1592,18 +1598,32 @@
279
280 applets = self.client.get_list(defs.PANEL, defs.APPLET_LIST, awn.CONFIG_LIST_STRING)
281
282+ ua_applets = self.client.get_list(defs.PANEL, defs.UA_LIST, awn.CONFIG_LIST_STRING)
283+
284+ for ua in ua_applets:
285+ tokens = ua.split("::")
286+ applets.insert(int(tokens[1]), ua)
287+
288 self.refresh_icon_list (applets, self.active_model)
289
290 def refresh_icon_list (self, applets, model):
291- for a in applets:
292- tokens = a.split("::")
293- path = tokens[0]
294- uid = tokens[1]
295- icon, text, name = self.make_row(path)
296- if len (text) < 2:
297- continue;
298+ for a in applets:
299+ tokens = a.split("::")
300+ if tokens[0].endswith(".desktop"):
301+ path = tokens[0]
302+ uid = tokens[1]
303+ icon, text, name = self.make_row(path)
304+ if len (text) < 2:
305+ continue;
306
307- model.append([icon, path, uid, text])
308+ model.append([icon, path, uid, text])
309+ else:
310+ path = tokens[0]
311+ uid = tokens[1]
312+ theme = gtk.icon_theme_get_default ()
313+ icon = theme.load_icon ("screenlets", 32, 0)
314+ text = tokens[0]
315+ model.append([icon, path, uid, text])
316
317 def load_applets (self):
318 applets = self.applets_by_categories()
319@@ -1645,7 +1665,21 @@
320 applets = l.values()
321
322 if not None in applets and self.load_finished:
323- self.client.set_list(defs.PANEL, defs.APPLET_LIST, awn.CONFIG_LIST_STRING, applets)
324+ applets_list = []
325+ ua_list = []
326+ for a in applets:
327+ tokens = a.split("::")
328+ path = tokens[0]
329+ if path.endswith(".desktop"):
330+ applets_list.append(a)
331+ else:
332+ position = applets.index(a)
333+ ua = tokens[0] + "::" + str(position)
334+ ua_list.append(ua)
335+
336+ self.client.set_list(defs.PANEL, defs.APPLET_LIST, awn.CONFIG_LIST_STRING, applets_list)
337+ self.client.set_list(defs.PANEL, defs.UA_LIST, awn.CONFIG_LIST_STRING, ua_list)
338+
339
340 def callback_widget_filter_applets(self, data=None):
341 model = self.choose_categorie.get_model()
342
343=== modified file 'awn-settings/awnDefs.py.in'
344--- awn-settings/awnDefs.py.in 2009-07-10 00:56:51 +0000
345+++ awn-settings/awnDefs.py.in 2009-07-14 19:09:25 +0000
346@@ -59,6 +59,7 @@
347 EXPAND = "expand" #bool
348 CLICKTHROUGH = "clickthrough" #int
349 BEHAVIOR = "behavior" #int
350+UA_LIST = "ua_active_list" #list-string
351
352 PANELS = "panels" #group
353 PANEL_LIST = "panel_list" #int
354
355=== modified file 'data/awn.schema-ini.in'
356--- data/awn.schema-ini.in 2009-07-06 22:12:25 +0000
357+++ data/awn.schema-ini.in 2009-07-14 18:01:40 +0000
358@@ -28,6 +28,16 @@
359 default = @APPLETDATADIR@/taskmanager.desktop::1
360 description = The list of applets for this panel ordered from ltr or ttb.
361
362+[panel/ua_list]
363+type = list-string
364+default =
365+description = The list of UA Screenlets that have been previous added in the form ScreeneletInstance::Position.
366+
367+[panel/ua_active_list]
368+type = list-string
369+default =
370+description = The active list UA Screenlets for this panel.
371+
372 [panel/monitor_force]
373 type = bool
374 default = False
375
376=== modified file 'libawn/awn-alignment.c'
377--- libawn/awn-alignment.c 2009-03-26 23:47:26 +0000
378+++ libawn/awn-alignment.c 2009-06-25 18:26:59 +0000
379@@ -192,6 +192,18 @@
380 return alignment;
381 }
382
383+GtkWidget*
384+awn_alignment_new (void)
385+{
386+ GtkWidget *alignment;
387+
388+ alignment = g_object_new(AWN_TYPE_ALIGNMENT,
389+ NULL);
390+
391+ return alignment;
392+}
393+
394+
395 static void
396 on_orient_changed (AwnAlignment *alignment, AwnOrientation orient)
397 {
398
399=== modified file 'libawn/awn-alignment.h'
400--- libawn/awn-alignment.h 2009-03-22 23:12:16 +0000
401+++ libawn/awn-alignment.h 2009-06-25 18:26:59 +0000
402@@ -80,6 +80,8 @@
403 void awn_alignment_set_offset_modifier (AwnAlignment *alignment,
404 gint modifier);
405
406+GtkWidget* awn_alignment_new (void);
407+
408 G_END_DECLS
409
410 #endif
411
412=== modified file 'src/Makefile.am'
413--- src/Makefile.am 2009-06-21 13:23:05 +0000
414+++ src/Makefile.am 2009-07-13 18:20:16 +0000
415@@ -27,6 +27,7 @@
416 awn-app-glue.h \
417 awn-applet-manager.c \
418 awn-applet-manager.h \
419+ awn-applet-manager-glue.h \
420 awn-applet-proxy.c \
421 awn-applet-proxy.h \
422 awn-background.c \
423@@ -51,6 +52,8 @@
424 awn-panel-glue.h \
425 awn-throbber.c \
426 awn-throbber.h \
427+ awn-ua-alignment.c \
428+ awn-ua-alignment.h \
429 awn-x.h \
430 awn-x.c \
431 inlinepixbufs.h \
432@@ -65,9 +68,13 @@
433 awn-panel-glue.h: awn-panel-dbus.xml Makefile
434 $(LIBTOOL) --mode=execute $(DBUS_GLIB_BIN)/dbus-binding-tool --prefix=awn_panel --mode=glib-server --output=$@ $<
435
436+awn-applet-manager-glue.h: awn-applet-manager-dbus.xml Makefile
437+ $(LIBTOOL) --mode=execute $(DBUS_GLIB_BIN)/dbus-binding-tool --prefix=awn_ua --mode=glib-server --output=$@ $<
438+
439 BUILT_SOURCES = \
440 awn-app-glue.h \
441 awn-panel-glue.h \
442+ awn-applet-manager-glue.h \
443 $(MARSHALFILES) \
444 $(NULL)
445
446@@ -76,6 +83,7 @@
447 EXTRA_DIST = \
448 awn-app-dbus.xml \
449 awn-panel-dbus.xml \
450+ awn-applet-manager-dbus.xml \
451 $(NULL)
452
453 # vim: set ts=8 sts=8 sw=8 :
454
455=== added file 'src/awn-applet-manager-dbus.xml'
456--- src/awn-applet-manager-dbus.xml 1970-01-01 00:00:00 +0000
457+++ src/awn-applet-manager-dbus.xml 2009-06-02 22:11:19 +0000
458@@ -0,0 +1,21 @@
459+<?xml version="1.0"?>
460+<node name="/org/awnproject/Awn/UA">
461+ <interface name="org.awnproject.Awn.UA">
462+ <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="awn_ua"/>
463+
464+ <!-- Methods -->
465+ <method name="add_applet">
466+ <arg name="name" type="s" direction="in" />
467+ <arg name="uid" type="x" direction="in" />
468+ <arg name="width" type="i" direction="in" />
469+ <arg name="height" type="i" direction="in" />
470+ <arg name="size_type" type="s" direction="in" />
471+ </method>
472+
473+ <method name="get_all_server_flags">
474+ <arg name="name" type="s" direction="in" />
475+ <arg name="hash" type="a{ss}" direction="out" />
476+ </method>
477+
478+ </interface>
479+</node>
480
481=== modified file 'src/awn-applet-manager.c'
482--- src/awn-applet-manager.c 2009-07-09 07:12:27 +0000
483+++ src/awn-applet-manager.c 2009-07-14 20:38:19 +0000
484@@ -16,22 +16,26 @@
485 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
486 *
487 * Author : Neil Jagdish Patel <njpatel@gmail.com>
488- *
489+ *bind
490 */
491
492 #include "config.h"
493
494-#include <libawn/awn-config-bridge.h>
495+#include <libawn/libawn.h>
496+#include <dbus/dbus-glib.h>
497+#include <dbus/dbus-glib-bindings.h>
498 #include <libawn/awn-utils.h>
499 #include <math.h>
500
501 #include "awn-defines.h"
502 #include "awn-applet-manager.h"
503-
504+#include "awn-ua-alignment.h"
505 #include "awn-applet-proxy.h"
506 #include "awn-throbber.h"
507 #include "xutils.h"
508
509+#define MAX_UA_LIST_ENTRIES 50
510+
511 G_DEFINE_TYPE (AwnAppletManager, awn_applet_manager, GTK_TYPE_BOX)
512
513 #define AWN_APPLET_MANAGER_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE (obj, \
514@@ -44,8 +48,15 @@
515 AwnOrientation orient;
516 gint offset;
517 gint size;
518+
519 GSList *applet_list;
520
521+ /*ua_list does not serve the same purpose as the applet_list
522+ It's a list of unique UA names plus their position in the panel
523+ */
524+ GSList *ua_list;
525+ GSList *ua_active_list;
526+
527 gboolean docklet_mode;
528 GtkWidget *docklet_widget;
529
530@@ -60,6 +71,7 @@
531
532 /* Current box class */
533 GtkWidgetClass *klass;
534+
535 };
536
537 enum
538@@ -71,6 +83,8 @@
539 PROP_OFFSET,
540 PROP_SIZE,
541 PROP_APPLET_LIST,
542+ PROP_UA_LIST,
543+ PROP_UA_ACTIVE_LIST,
544 PROP_EXPANDS
545 };
546
547@@ -123,6 +137,20 @@
548 AWN_GROUP_PANEL, AWN_PANEL_APPLET_LIST,
549 AWN_CONFIG_CLIENT_LIST_TYPE_STRING,
550 object, "applet_list");
551+ awn_config_bridge_bind_list (bridge, priv->client,
552+ AWN_GROUP_PANEL, AWN_PANEL_UA_LIST,
553+ AWN_CONFIG_CLIENT_LIST_TYPE_STRING,
554+ object, "ua_list");
555+ awn_config_bridge_bind_list (bridge, priv->client,
556+ AWN_GROUP_PANEL, AWN_PANEL_UA_ACTIVE_LIST,
557+ AWN_CONFIG_CLIENT_LIST_TYPE_STRING,
558+ object, "ua_active_list");
559+ /*
560+ ua_active_list should be empty when awn starts...
561+ */
562+ awn_config_client_set_list (priv->client,AWN_GROUP_PANEL, AWN_PANEL_UA_ACTIVE_LIST,
563+ AWN_CONFIG_CLIENT_LIST_TYPE_STRING,
564+ NULL, NULL);
565 }
566
567 static void
568@@ -165,10 +193,15 @@
569 case PROP_SIZE:
570 g_value_set_int (value, priv->size);
571 break;
572-
573 case PROP_APPLET_LIST:
574 g_value_set_pointer (value, priv->applet_list);
575 break;
576+ case PROP_UA_LIST:
577+ g_value_set_pointer (value, priv->ua_list);
578+ break;
579+ case PROP_UA_ACTIVE_LIST:
580+ g_value_set_pointer (value, priv->ua_active_list);
581+ break;
582 case PROP_EXPANDS:
583 g_value_set_boolean (value, priv->expands);
584 break;
585@@ -208,6 +241,16 @@
586 priv->applet_list = g_value_get_pointer (value);
587 awn_applet_manager_refresh_applets (manager);
588 break;
589+ case PROP_UA_LIST:
590+ free_list (priv->ua_list);
591+ priv->ua_list = g_value_get_pointer (value);
592+ awn_applet_manager_refresh_applets (manager);
593+ break;
594+ case PROP_UA_ACTIVE_LIST:
595+ free_list (priv->ua_active_list);
596+ priv->ua_active_list = g_value_get_pointer (value);
597+ awn_applet_manager_refresh_applets (manager);
598+ break;
599 default:
600 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
601 }
602@@ -240,6 +283,8 @@
603 G_OBJECT_CLASS (awn_applet_manager_parent_class)->dispose (object);
604 }
605
606+#include "awn-applet-manager-glue.h"
607+
608 static void
609 awn_applet_manager_class_init (AwnAppletManagerClass *klass)
610 {
611@@ -294,6 +339,20 @@
612 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
613
614 g_object_class_install_property (obj_class,
615+ PROP_UA_LIST,
616+ g_param_spec_pointer ("ua_list",
617+ "UA List",
618+ "The rememebered screenlet positions for this panel",
619+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
620+
621+ g_object_class_install_property (obj_class,
622+ PROP_UA_ACTIVE_LIST,
623+ g_param_spec_pointer ("ua-active-list",
624+ "UA Active List",
625+ "The list of acitve screenlets for this panel",
626+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
627+
628+ g_object_class_install_property (obj_class,
629 PROP_EXPANDS,
630 g_param_spec_boolean ("expands",
631 "Expands",
632@@ -321,12 +380,18 @@
633 G_TYPE_NONE, 0);
634
635 g_type_class_add_private (obj_class, sizeof (AwnAppletManagerPrivate));
636+
637+ dbus_g_object_type_install_info (G_TYPE_FROM_CLASS (klass),
638+ &dbus_glib_awn_ua_object_info);
639+
640 }
641
642 static void
643 awn_applet_manager_init (AwnAppletManager *manager)
644 {
645 AwnAppletManagerPrivate *priv;
646+ DBusGConnection *connection;
647+ GError *error = NULL;
648
649 priv = manager->priv = AWN_APPLET_MANAGER_GET_PRIVATE (manager);
650
651@@ -338,6 +403,21 @@
652 priv->extra_widgets = g_hash_table_new (g_direct_hash, g_direct_equal);
653
654 gtk_widget_show_all (GTK_WIDGET (manager));
655+
656+ /* Grab a connection to the bus */
657+ connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
658+ if (connection == NULL)
659+ {
660+ g_warning ("Unable to make connection to the D-Bus session bus: %s",
661+ error->message);
662+ g_error_free (error);
663+ gtk_main_quit ();
664+ }
665+
666+ dbus_g_connection_register_g_object (connection,
667+ AWN_DBUS_MANAGER_PATH,
668+ G_OBJECT (GTK_WIDGET (manager)));
669+
670 }
671
672 GtkWidget *
673@@ -505,7 +585,7 @@
674 g_type_class_unref (priv->klass);
675 priv->klass = NULL;
676 }
677-
678+// g_debug ("%s, orient = %d",__func__,priv->orient);
679 switch (priv->orient)
680 {
681 case AWN_ORIENTATION_TOP:
682@@ -547,7 +627,10 @@
683 {
684 g_free (l->data);
685 }
686- g_slist_free (list);
687+ if (list)
688+ {
689+ g_slist_free (list);
690+ }
691 }
692
693 /*
694@@ -647,6 +730,7 @@
695 gint i = 0;
696 gint applet_num = 0;
697
698+ g_debug ("%s",__func__);
699 if (!GTK_WIDGET_REALIZED (manager))
700 return;
701
702@@ -684,12 +768,14 @@
703 continue;
704 }
705
706+// g_debug ("%s: %s, %s",__func__,tokens[0],tokens[1]);
707 /* See if the applet already exists */
708 applet = g_hash_table_lookup (priv->applets, tokens[1]);
709
710 /* If not, create it */
711 if (applet == NULL)
712 {
713+ g_debug ("applet does not exist");
714 applet = create_applet (manager, tokens[0], tokens[1]);
715 if (!applet)
716 {
717@@ -752,6 +838,7 @@
718 gtk_box_pack_start (GTK_BOX (manager), widget, FALSE, FALSE, 0);
719 /* caller is supposed to call gtk_widget_show! */
720 }
721+ g_print ("Gint : %i : ", pos);
722 g_hash_table_replace (priv->extra_widgets, widget, GINT_TO_POINTER (pos));
723
724 awn_applet_manager_refresh_applets (manager);
725@@ -769,6 +856,159 @@
726 }
727 }
728
729+/*DBUS*/
730+/*
731+ Description of this dbus interface.
732+
733+ @action(IFACE)
734+ def add_applet (self, id, plug_id, width, height, size_type):
735+ """
736+ Add an applet.
737+
738+ id: A unique string used to identify the applet.
739+ plug_id: The applet's gtk.Plug's xid.
740+ width: A recommended width. This will be interpreted according to size_type.
741+ height A recommended height. This will be interpreted according to size_type.
742+ size_type: Determines the meaning of width and height.
743+ May be one of the following values:
744+ "scalable"- The applet may be resized as long as the width/height ratio is kept.
745+ "static"- The applet should be displayed at exactly the size requested.
746+ "static-width"- The applet's width should remain static, and the server may change the height.
747+ "static-height"- The applet's height should remain static, and the server may change the width.
748+ "dynamic"- The applet may be resized to any size.
749+ desktop_path: Path to the desktop file.
750+ """
751+ # NOTE: Melange currently ignores the size_type parameter.
752+ container = ToplevelContainer(plug_id, id, self, width, height,
753+ size_type, backend=self.backend)
754+ self.containers.append(container)
755+*/
756+gboolean
757+awn_ua_add_applet ( AwnAppletManager *manager,
758+ gchar *name,
759+ glong xid,
760+ gint width,
761+ gint height,
762+ gchar *size_type,
763+ GError **error)
764+{
765+ g_return_val_if_fail (AWN_IS_APPLET_MANAGER (manager),FALSE);
766+ g_return_val_if_fail ( (g_strcmp0(size_type,"scalable")==0 ) ||
767+ (g_strcmp0(size_type,"dynamic")==0 ), FALSE );
768+
769+ GdkWindow* plugwin;
770+ AwnAppletManagerPrivate *priv = manager->priv;
771+ gint pos = g_slist_length (priv->applet_list);
772+ GdkNativeWindow native_window = (GdkNativeWindow) xid;
773+ gchar * tmp = g_strdup_printf ("%s::%d",name,pos);
774+ gchar * ua_list_entry = NULL;
775+ GtkWidget *ua_alignment;
776+ double ua_ratio;
777+
778+ /*
779+ Is there an entry in ua_list for this particular screenlet instance(name).
780+ The comparision function used ignores the position.
781+ */
782+ GSList * search = g_slist_find_custom (priv->ua_list,tmp,awn_ua_alignment_list_cmp);
783+ if (search)
784+ {
785+ /* There's already an entry in ua_list so use that. */
786+ GStrv tokens;
787+ ua_list_entry = g_strdup (search->data) ;
788+ g_free (tmp);
789+ /* Get the position where the screenlet should be placed*/
790+ tokens = g_strsplit (search->data,"::",2);
791+ if (tokens && tokens[1])
792+ {
793+ pos = atoi (tokens[1]);
794+ }
795+ g_strfreev (tokens);
796+ /* remove the link... that data will be appended at to the list*/
797+ g_free (search->data);
798+ priv->ua_list = g_slist_delete_link (priv->ua_list,search);
799+ search = NULL;
800+ }
801+ else
802+ {
803+ /*
804+ This screenlet instance is not recorded in ua_list. It will end up being
805+ placed at the end of the bar
806+ */
807+ ua_list_entry = tmp;
808+ }
809+
810+ /*
811+ Calculated here and passed to the awn_ua_alignment_new(). AwnUAAlignment
812+ could recalculate the ratio on bar resizes based on the, then current,
813+ dimensions of the widget but over time the amount of error in the the
814+ calcs would increase
815+ */
816+ ua_ratio = width / (double) height;
817+ ua_alignment = awn_ua_alignment_new(manager,ua_list_entry,ua_ratio);
818+
819+ g_signal_connect_swapped (awn_ua_alignment_get_socket(AWN_UA_ALIGNMENT(ua_alignment)),
820+ "plug-added",
821+ G_CALLBACK (_applet_plug_added),
822+ manager);
823+
824+ awn_applet_manager_add_widget(manager, GTK_WIDGET (ua_alignment), pos);
825+ gtk_widget_show_all (ua_alignment);
826+
827+ plugwin = awn_ua_alignment_add_id (AWN_UA_ALIGNMENT(ua_alignment),native_window);
828+
829+ g_object_set_qdata (G_OBJECT (ua_alignment),
830+ priv->touch_quark, GINT_TO_POINTER (0));
831+
832+ if (!plugwin)
833+ {
834+ g_warning ("UA Plug was not created within socket.");
835+ gtk_widget_destroy (ua_alignment);
836+ return FALSE;
837+ }
838+
839+ /*
840+ Either add the new entry into ua_list or move an existing entry to the
841+ end of ua_list_entry
842+ */
843+ priv->ua_list = g_slist_append (priv->ua_list,g_strdup(ua_list_entry));
844+
845+ /* Keep the length of ua_list reasonable */
846+ if (g_slist_length (priv->ua_list) > MAX_UA_LIST_ENTRIES)
847+ {
848+ GSList * iter;
849+ int i = g_slist_length (priv->ua_list) - MAX_UA_LIST_ENTRIES;
850+ for(iter = priv->ua_list; i && iter ; iter = priv->ua_list )
851+ {
852+ g_free (iter->data);
853+ priv->ua_list = g_slist_delete_link (priv->ua_list,iter);
854+ i--;
855+ }
856+ }
857+ awn_config_client_set_list (priv->client,AWN_GROUP_PANEL, AWN_PANEL_UA_LIST,
858+ AWN_CONFIG_CLIENT_LIST_TYPE_STRING,
859+ priv->ua_list, NULL);
860+ /*Add our newly active screenlet to thend of the active list */
861+ priv->ua_active_list = g_slist_append (priv->ua_active_list,g_strdup(ua_list_entry));
862+ awn_config_client_set_list (priv->client,AWN_GROUP_PANEL, AWN_PANEL_UA_ACTIVE_LIST,
863+ AWN_CONFIG_CLIENT_LIST_TYPE_STRING,
864+ priv->ua_active_list, NULL);
865+
866+ return TRUE;
867+}
868+
869+gboolean
870+awn_ua_get_all_server_flags ( AwnAppletManager *manager,
871+ GHashTable *hash,
872+ gchar *name,
873+ GError **error)
874+{
875+/* Future function to return capability of the server
876+For now, it return nothing*/
877+return TRUE;
878+}
879+
880+
881+/*End DBUS*/
882 void
883 awn_applet_manager_show_applets (AwnAppletManager *manager)
884 {
885
886=== modified file 'src/awn-applet-manager.h'
887--- src/awn-applet-manager.h 2009-07-08 20:38:35 +0000
888+++ src/awn-applet-manager.h 2009-07-13 18:05:02 +0000
889@@ -25,6 +25,7 @@
890 #include <gtk/gtk.h>
891
892 #include <libawn/awn-config-client.h>
893+#include <libawn/awn-defines.h>
894
895 #include "awn-panel.h"
896
897@@ -82,9 +83,25 @@
898
899 gboolean awn_applet_manager_get_expands (AwnAppletManager *manager);
900
901-void awn_applet_manager_set_applet_flags (AwnAppletManager *manager,
902- const gchar *uid,
903- AwnAppletFlags flags);
904+
905+
906+gboolean awn_ua_get_all_server_flags (AwnAppletManager *manager,
907+ GHashTable *hash,
908+ gchar *name,
909+ GError **error);
910+
911+gboolean awn_ua_add_applet ( AwnAppletManager *manager,
912+ gchar *name,
913+ glong xid,
914+ gint width,
915+ gint height,
916+ gchar *size_type,
917+ GError **error);
918+
919+
920+void awn_applet_manager_set_applet_flags (AwnAppletManager *manager,
921+ const gchar *uid,
922+ AwnAppletFlags flags);
923
924 void awn_applet_manager_show_applets (AwnAppletManager *manager);
925 void awn_applet_manager_hide_applets (AwnAppletManager *manager);
926
927=== modified file 'src/awn-applet-proxy.c'
928--- src/awn-applet-proxy.c 2009-07-08 21:17:59 +0000
929+++ src/awn-applet-proxy.c 2009-07-13 18:05:02 +0000
930@@ -276,6 +276,7 @@
931 1, G_TYPE_INT);
932
933 g_type_class_add_private (obj_class, sizeof (AwnAppletProxyPrivate));
934+
935 }
936
937 static gboolean
938@@ -349,6 +350,8 @@
939 return proxy;
940 }
941
942+
943+
944 /*
945 * GtkSocket callbacks
946 */
947@@ -552,4 +555,3 @@
948 priv->idle_id = g_idle_add (awn_applet_proxy_idle_cb, proxy);
949 }
950 }
951-
952
953=== modified file 'src/awn-defines.h'
954--- src/awn-defines.h 2009-04-18 00:36:20 +0000
955+++ src/awn-defines.h 2009-07-14 18:01:40 +0000
956@@ -28,6 +28,7 @@
957
958 #define AWN_DBUS_APP_PATH AWN_DBUS_PATH
959 #define AWN_DBUS_PANEL_PATH AWN_DBUS_PATH"/Panel"
960+#define AWN_DBUS_MANAGER_PATH AWN_DBUS_PATH"/UA"
961
962 /* FIXME: Move some of these out into libawn when we can */
963 #define AWN_GROUP_PANEL "panel"
964@@ -38,6 +39,8 @@
965 #define AWN_PANEL_SIZE "size"
966 #define AWN_PANEL_AUTOHIDE "autohide"
967 #define AWN_PANEL_APPLET_LIST "applet_list"
968+#define AWN_PANEL_UA_LIST "ua_list"
969+#define AWN_PANEL_UA_ACTIVE_LIST "ua_active_list"
970 #define AWN_PANEL_MONITOR_HEIGHT "monitor_height"
971 #define AWN_PANEL_MONITOR_WIDTH "monitor_width"
972 #define AWN_PANEL_MONITOR_FORCE "monitor_force"
973
974=== added file 'src/awn-ua-alignment.c'
975--- src/awn-ua-alignment.c 1970-01-01 00:00:00 +0000
976+++ src/awn-ua-alignment.c 2009-07-14 19:09:25 +0000
977@@ -0,0 +1,469 @@
978+/*
979+ * Copyright (C) 2009 Rodney Cryderman <rcryderman@gmail.com>
980+ *
981+ * This program is free software; you can redistribute it and/or modify
982+ * it under the terms of the GNU General Public License as published by
983+ * the Free Software Foundation; either version 2 of the License, or
984+ * (at your option) any later version.
985+ *
986+ * This program is distributed in the hope that it will be useful,
987+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
988+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
989+ * GNU General Public License for more details.
990+ *
991+ * You should have received a copy of the GNU General Public License
992+ * along with this program; if not, write to the Free Software
993+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
994+ *
995+ *
996+ */
997+
998+/* awn-ua-alignment.c */
999+#include <stdlib.h>
1000+#include "awn-ua-alignment.h"
1001+#include "awn-defines.h"
1002+
1003+G_DEFINE_TYPE (AwnUAAlignment, awn_ua_alignment, GTK_TYPE_ALIGNMENT)
1004+
1005+#define AWN_UA_ALIGNMENT_GET_PRIVATE(o) \
1006+ (G_TYPE_INSTANCE_GET_PRIVATE ((o), AWN_TYPE_UA_ALIGNMENT, AwnUAAlignmentPrivate))
1007+
1008+typedef struct _AwnUAAlignmentPrivate AwnUAAlignmentPrivate;
1009+
1010+struct _AwnUAAlignmentPrivate
1011+{
1012+ GtkWidget * socket;
1013+ GtkWidget * applet_manager;
1014+
1015+ gchar *ua_list_entry;
1016+ double ua_ratio;
1017+
1018+ guint notify_size_id;
1019+ guint notify_orient_id;
1020+ guint notify_offset_id;
1021+ guint notify_ua_list_id;
1022+};
1023+
1024+enum
1025+{
1026+ PROP_0,
1027+ PROP_APPLET_MANAGER,
1028+ PROP_UA_LIST_ENTRY,
1029+ PROP_UA_RATIO
1030+};
1031+
1032+
1033+static gboolean awn_ua_alignment_plug_removed (GtkWidget * socket,
1034+ AwnUAAlignment * self);
1035+static void awn_ua_alignment_list_change(GObject *object,
1036+ GParamSpec *param_spec,
1037+ gpointer user_data);
1038+static void awn_ua_alignment_orient_change(GObject *object,
1039+ GParamSpec *param_spec,
1040+ gpointer user_data);
1041+static void awn_ua_alignment_size_change(GObject *object,
1042+ GParamSpec *param_spec,
1043+ gpointer user_data);
1044+static void awn_ua_alignment_offset_change(GObject *object,
1045+ GParamSpec *param_spec,
1046+ gpointer user_data);
1047+
1048+
1049+static void
1050+awn_ua_alignment_get_property (GObject *object, guint property_id,
1051+ GValue *value, GParamSpec *pspec)
1052+{
1053+ AwnUAAlignmentPrivate * priv;
1054+
1055+ priv = AWN_UA_ALIGNMENT_GET_PRIVATE (object);
1056+
1057+ switch (property_id)
1058+ {
1059+ case PROP_APPLET_MANAGER:
1060+ g_value_set_object (value,priv->applet_manager);
1061+ break;
1062+ case PROP_UA_LIST_ENTRY:
1063+ g_value_set_string (value,priv->ua_list_entry);
1064+ break;
1065+ case PROP_UA_RATIO:
1066+ g_value_set_double (value,priv->ua_ratio);
1067+ break;
1068+ default:
1069+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
1070+ }
1071+}
1072+
1073+static void
1074+awn_ua_alignment_set_property (GObject *object, guint property_id,
1075+ const GValue *value, GParamSpec *pspec)
1076+{
1077+ AwnUAAlignmentPrivate * priv;
1078+
1079+ priv = AWN_UA_ALIGNMENT_GET_PRIVATE (object);
1080+ switch (property_id)
1081+ {
1082+ case PROP_APPLET_MANAGER:
1083+ priv->applet_manager = g_value_get_object (value);
1084+ break;
1085+ case PROP_UA_LIST_ENTRY:
1086+ g_free (priv->ua_list_entry);
1087+ priv->ua_list_entry = g_value_dup_string (value);
1088+ break;
1089+ case PROP_UA_RATIO:
1090+ priv->ua_ratio = g_value_get_double (value);
1091+ break;
1092+ default:
1093+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
1094+ }
1095+}
1096+
1097+static void
1098+awn_ua_alignment_dispose (GObject *object)
1099+{
1100+ G_OBJECT_CLASS (awn_ua_alignment_parent_class)->dispose (object);
1101+}
1102+
1103+static void
1104+awn_ua_alignment_finalize (GObject *object)
1105+{
1106+ AwnUAAlignmentPrivate * priv = AWN_UA_ALIGNMENT_GET_PRIVATE (object);
1107+ g_debug ("%s",__func__);
1108+ if (priv->ua_list_entry)
1109+ {
1110+ g_free (priv->ua_list_entry);
1111+ }
1112+ G_OBJECT_CLASS (awn_ua_alignment_parent_class)->finalize (object);
1113+}
1114+
1115+static void
1116+awn_ua_alignment_constructed (GObject *object)
1117+{
1118+ AwnUAAlignmentPrivate * priv = AWN_UA_ALIGNMENT_GET_PRIVATE (object);
1119+
1120+ if (G_OBJECT_CLASS (awn_ua_alignment_parent_class)->constructed)
1121+ {
1122+ G_OBJECT_CLASS (awn_ua_alignment_parent_class)->constructed (object);
1123+ }
1124+
1125+ gtk_container_add (GTK_CONTAINER(object),priv->socket);
1126+ awn_ua_alignment_orient_change (NULL,NULL,object);
1127+ priv->notify_offset_id = g_signal_connect (priv->applet_manager,
1128+ "notify::offset",
1129+ G_CALLBACK(awn_ua_alignment_offset_change),
1130+ object);
1131+ priv->notify_orient_id = g_signal_connect_after (priv->applet_manager,
1132+ "notify::orient",
1133+ G_CALLBACK(awn_ua_alignment_orient_change),
1134+ object);
1135+ priv->notify_size_id = g_signal_connect_after (priv->applet_manager,
1136+ "notify::size",
1137+ G_CALLBACK(awn_ua_alignment_size_change),
1138+ object);
1139+ priv->notify_ua_list_id = g_signal_connect_after (priv->applet_manager,
1140+ "notify::ua-active-list",
1141+ G_CALLBACK(awn_ua_alignment_list_change),
1142+ object);
1143+}
1144+
1145+static void
1146+awn_ua_alignment_class_init (AwnUAAlignmentClass *klass)
1147+{
1148+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
1149+ GParamSpec *pspec;
1150+
1151+ object_class->get_property = awn_ua_alignment_get_property;
1152+ object_class->set_property = awn_ua_alignment_set_property;
1153+ object_class->dispose = awn_ua_alignment_dispose;
1154+ object_class->finalize = awn_ua_alignment_finalize;
1155+ object_class->constructed = awn_ua_alignment_constructed;
1156+
1157+ pspec = g_param_spec_object ("applet-manager",
1158+ "Awn Applet Manager",
1159+ "Awn Applet Manager",
1160+ AWN_TYPE_APPLET_MANAGER,
1161+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT);
1162+ g_object_class_install_property (object_class, PROP_APPLET_MANAGER, pspec);
1163+
1164+ pspec = g_param_spec_string ("ua-list-entry",
1165+ "UA List entry",
1166+ "UA List entry",
1167+ NULL,
1168+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT);
1169+ g_object_class_install_property (object_class, PROP_UA_LIST_ENTRY, pspec);
1170+
1171+ pspec = g_param_spec_double ("ua-ratio",
1172+ "UA Ratio",
1173+ "UA Ratio",
1174+ 0.0,
1175+ 100.0,
1176+ 1.0,
1177+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT);
1178+ g_object_class_install_property (object_class, PROP_UA_RATIO, pspec);
1179+
1180+ g_type_class_add_private (klass, sizeof (AwnUAAlignmentPrivate));
1181+}
1182+
1183+static void
1184+awn_ua_alignment_init (AwnUAAlignment *self)
1185+{
1186+ AwnUAAlignmentPrivate *priv;
1187+
1188+ priv = AWN_UA_ALIGNMENT_GET_PRIVATE (self);
1189+ priv->socket = gtk_socket_new ();
1190+}
1191+
1192+GtkWidget*
1193+awn_ua_alignment_new (AwnAppletManager *manager,gchar * ua_list_entry,double ua_ratio)
1194+{
1195+ return g_object_new (AWN_TYPE_UA_ALIGNMENT,
1196+ "applet-manager",manager,
1197+ "ua-list-entry",ua_list_entry,
1198+ "ua-ratio",ua_ratio,
1199+ NULL);
1200+}
1201+
1202+GtkWidget*
1203+awn_ua_alignment_get_socket (AwnUAAlignment *self)
1204+{
1205+ AwnUAAlignmentPrivate *priv;
1206+
1207+ priv = AWN_UA_ALIGNMENT_GET_PRIVATE (self);
1208+ return priv->socket;
1209+}
1210+
1211+
1212+GdkWindow *
1213+awn_ua_alignment_add_id (AwnUAAlignment *self,GdkNativeWindow native_window)
1214+{
1215+ GdkWindow * plugwin;
1216+ AwnUAAlignmentPrivate *priv;
1217+
1218+ priv = AWN_UA_ALIGNMENT_GET_PRIVATE (self);
1219+ gtk_socket_add_id (GTK_SOCKET(priv->socket), native_window);
1220+ plugwin = gtk_socket_get_plug_window (GTK_SOCKET(priv->socket));
1221+ g_signal_connect (priv->socket,"plug-removed",
1222+ G_CALLBACK(awn_ua_alignment_plug_removed),self);
1223+ gtk_widget_realize (priv->socket);
1224+ gtk_widget_show_all (priv->socket);
1225+ return plugwin;
1226+}
1227+
1228+
1229+static gboolean
1230+awn_ua_alignment_plug_removed (GtkWidget * socket,AwnUAAlignment * self)
1231+{
1232+
1233+ GSList * search;
1234+ GSList * ua_active_list;
1235+ GSList * orig_active_list;
1236+ GSList * iter;
1237+ AwnConfigClient *client;
1238+
1239+ AwnUAAlignmentPrivate *priv = AWN_UA_ALIGNMENT_GET_PRIVATE (self);
1240+
1241+ g_signal_handler_disconnect (priv->applet_manager,priv->notify_size_id);
1242+ g_signal_handler_disconnect (priv->applet_manager,priv->notify_orient_id);
1243+ g_signal_handler_disconnect (priv->applet_manager,priv->notify_offset_id);
1244+ g_signal_handler_disconnect (priv->applet_manager,priv->notify_ua_list_id);
1245+
1246+ g_object_get ( priv->applet_manager,
1247+ "ua_active_list",&orig_active_list,
1248+ "client",&client,
1249+ NULL);
1250+ ua_active_list = g_slist_copy (orig_active_list);
1251+ for (iter = ua_active_list;iter;iter = iter->next)
1252+ {
1253+ iter->data = g_strdup(iter->data);
1254+ }
1255+ search = g_slist_find_custom (ua_active_list,priv->ua_list_entry,
1256+ (GCompareFunc)g_strcmp0);
1257+ if (search)
1258+ {
1259+ ua_active_list = g_slist_delete_link (ua_active_list,search);
1260+ }
1261+ awn_config_client_set_list (client,AWN_GROUP_PANEL, AWN_PANEL_UA_ACTIVE_LIST,
1262+ AWN_CONFIG_CLIENT_LIST_TYPE_STRING,
1263+ ua_active_list, NULL);
1264+ g_object_set (priv->applet_manager,
1265+ "ua-active-list",ua_active_list,
1266+ NULL);
1267+ awn_applet_manager_remove_widget(AWN_APPLET_MANAGER(priv->applet_manager),
1268+ GTK_WIDGET (self));
1269+ return FALSE;
1270+}
1271+
1272+/*UA*/
1273+gint
1274+awn_ua_alignment_list_cmp (gconstpointer a, gconstpointer b)
1275+{
1276+ const gchar * str1 = a;
1277+ const gchar * str2 = b;
1278+ gchar * search = NULL;
1279+ GStrv tokens = g_strsplit (str1,"::",2);
1280+ g_return_val_if_fail (tokens,-1);
1281+
1282+ search = g_strstr_len (str2,-1,tokens[0]);
1283+ g_strfreev (tokens);
1284+
1285+ if (!search)
1286+ {
1287+ return -1;
1288+ };
1289+ return 0;
1290+}
1291+
1292+static void
1293+awn_ua_alignment_offset_change(GObject *object,GParamSpec *param_spec,gpointer user_data)
1294+{
1295+ AwnUAAlignment * self = user_data;
1296+ gint offset;
1297+ gint orient;
1298+ AwnUAAlignmentPrivate *priv = AWN_UA_ALIGNMENT_GET_PRIVATE (self);
1299+
1300+ g_object_get ( priv->applet_manager,
1301+ "offset",&offset,
1302+ "orient",&orient,
1303+ NULL);
1304+
1305+ switch (orient)
1306+ {
1307+ case AWN_ORIENTATION_TOP:
1308+ gtk_alignment_set_padding (GTK_ALIGNMENT(self), offset, 0, 0, 0);
1309+ break;
1310+ case AWN_ORIENTATION_BOTTOM:
1311+ gtk_alignment_set_padding (GTK_ALIGNMENT(self), 0, offset, 0, 0);
1312+ break;
1313+ case AWN_ORIENTATION_LEFT:
1314+ gtk_alignment_set_padding (GTK_ALIGNMENT(self), 0, 0, offset, 0);
1315+ break;
1316+ case AWN_ORIENTATION_RIGHT:
1317+ gtk_alignment_set_padding (GTK_ALIGNMENT(self), 0, 0, 0, offset);
1318+ break;
1319+ default:
1320+ g_warning ("%s: recieved invalid orient %d",__func__,orient);
1321+ }
1322+}
1323+
1324+static void
1325+awn_ua_alignment_size_change(GObject *object,GParamSpec *param_spec,gpointer user_data)
1326+{
1327+ AwnUAAlignment * self = user_data;
1328+ gint offset;
1329+ gint orient;
1330+ gint size;
1331+ AwnUAAlignmentPrivate *priv = AWN_UA_ALIGNMENT_GET_PRIVATE (self);
1332+
1333+ g_object_get ( priv->applet_manager,
1334+ "offset",&offset,
1335+ "orient",&orient,
1336+ "size",&size,
1337+ NULL);
1338+ GtkRequisition req;
1339+
1340+ req.width = req.height = size;
1341+ switch (orient)
1342+ {
1343+ case AWN_ORIENTATION_TOP:
1344+ case AWN_ORIENTATION_BOTTOM:
1345+ req.width = size * priv->ua_ratio;
1346+ req.height = size;
1347+ break;
1348+ case AWN_ORIENTATION_LEFT:
1349+ case AWN_ORIENTATION_RIGHT:
1350+ req.width = size;
1351+ req.height = size * 1.0 / priv->ua_ratio;
1352+ break;
1353+ default:
1354+ g_warning ("%s: recieved invalid orient %d",__func__,orient);
1355+ }
1356+ gtk_widget_set_size_request (GTK_WIDGET(self),req.width,req.height);
1357+}
1358+
1359+static void
1360+awn_ua_alignment_orient_change(GObject *object,GParamSpec *param_spec,gpointer user_data)
1361+{
1362+
1363+ AwnUAAlignment * self = user_data;
1364+ gint orient;
1365+ AwnUAAlignmentPrivate *priv = AWN_UA_ALIGNMENT_GET_PRIVATE (self);
1366+
1367+ g_object_get ( priv->applet_manager,
1368+ "orient",&orient,
1369+ NULL);
1370+ switch (orient)
1371+ {
1372+ case AWN_ORIENTATION_TOP:
1373+ gtk_alignment_set (GTK_ALIGNMENT(self), 0.0, 0.0, 1.0, 0.5);
1374+ break;
1375+ case AWN_ORIENTATION_BOTTOM:
1376+ gtk_alignment_set (GTK_ALIGNMENT(self), 0.0, 1.0, 1.0, 0.5);
1377+ break;
1378+ case AWN_ORIENTATION_LEFT:
1379+ gtk_alignment_set (GTK_ALIGNMENT(self), 0.0, 0.0, 0.5, 1.0);
1380+ break;
1381+ case AWN_ORIENTATION_RIGHT:
1382+ gtk_alignment_set (GTK_ALIGNMENT(self), 1.0, 0.0, 0.5, 1.0);
1383+ break;
1384+ default:
1385+ g_warning ("%s: recieved invalid orient %d",__func__,orient);
1386+ }
1387+ awn_ua_alignment_offset_change (object,param_spec,self);
1388+ awn_ua_alignment_size_change (object,param_spec,self);
1389+}
1390+
1391+static void
1392+awn_ua_alignment_list_change(GObject *object,GParamSpec *param_spec,gpointer user_data)
1393+{
1394+ AwnUAAlignment * self = user_data;
1395+ gint orient;
1396+ AwnUAAlignmentPrivate *priv = AWN_UA_ALIGNMENT_GET_PRIVATE (self);
1397+ GSList * ua_active_list;
1398+
1399+ g_object_get ( priv->applet_manager,
1400+ "orient",&orient,
1401+ "ua_active_list",&ua_active_list,
1402+ NULL);
1403+
1404+ GSList * search = g_slist_find_custom (ua_active_list,
1405+ priv->ua_list_entry,
1406+ (GCompareFunc)g_strcmp0);
1407+ if (search)
1408+ {
1409+ g_debug ("Found... do not need to update %s",priv->ua_list_entry);
1410+ }
1411+ else
1412+ {
1413+ search = g_slist_find_custom (ua_active_list,priv->ua_list_entry,awn_ua_alignment_list_cmp);
1414+ if (search)
1415+ {
1416+ g_debug ("Moving %s to %s",priv->ua_list_entry,(gchar*)search->data);
1417+ GStrv tokens;
1418+ gint pos = -1;
1419+ g_free (priv->ua_list_entry);
1420+ priv->ua_list_entry = g_strdup(search->data);
1421+ tokens = g_strsplit (search->data,"::",2);
1422+ if (tokens && tokens[1])
1423+ {
1424+ pos = atoi (tokens[1]);
1425+ }
1426+ g_strfreev (tokens);
1427+ if (pos != -1)
1428+ {
1429+ awn_applet_manager_add_widget(AWN_APPLET_MANAGER(priv->applet_manager),
1430+ GTK_WIDGET (self),
1431+ pos);
1432+ }
1433+ }
1434+ else
1435+ {
1436+ g_debug ("looks like %s was removed from panel/ua_list",priv->ua_list_entry);
1437+ /*
1438+ aantn as expected this does not kill the screenlet. What is the best way to
1439+ tell it that we want it to go away?
1440+ */
1441+ awn_applet_manager_remove_widget(AWN_APPLET_MANAGER(priv->applet_manager),
1442+ GTK_WIDGET (self));
1443+ gtk_widget_destroy (GTK_WIDGET(self));
1444+ }
1445+ }
1446+}
1447
1448=== added file 'src/awn-ua-alignment.h'
1449--- src/awn-ua-alignment.h 1970-01-01 00:00:00 +0000
1450+++ src/awn-ua-alignment.h 2009-07-14 02:56:28 +0000
1451@@ -0,0 +1,68 @@
1452+/*
1453+ * Copyright (C) 2009 Rodney Cryderman <rcryderman@gmail.com>
1454+ *
1455+ * This program is free software; you can redistribute it and/or modify
1456+ * it under the terms of the GNU General Public License as published by
1457+ * the Free Software Foundation; either version 2 of the License, or
1458+ * (at your option) any later version.
1459+ *
1460+ * This program is distributed in the hope that it will be useful,
1461+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1462+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1463+ * GNU General Public License for more details.
1464+ *
1465+ * You should have received a copy of the GNU General Public License
1466+ * along with this program; if not, write to the Free Software
1467+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
1468+ *
1469+ *
1470+ */
1471+
1472+/* awn-ua-alignment.h */
1473+
1474+#ifndef _AWN_UA_ALIGNMENT
1475+#define _AWN_UA_ALIGNMENT
1476+
1477+#include <gtk/gtk.h>
1478+#include "awn-applet-manager.h"
1479+
1480+G_BEGIN_DECLS
1481+
1482+#define AWN_TYPE_UA_ALIGNMENT awn_ua_alignment_get_type()
1483+
1484+#define AWN_UA_ALIGNMENT(obj) \
1485+ (G_TYPE_CHECK_INSTANCE_CAST ((obj), AWN_TYPE_UA_ALIGNMENT, AwnUAAlignment))
1486+
1487+#define AWN_UA_ALIGNMENT_CLASS(klass) \
1488+ (G_TYPE_CHECK_CLASS_CAST ((klass), AWN_TYPE_UA_ALIGNMENT, AwnUAAlignmentClass))
1489+
1490+#define AWN_IS_UA_ALIGNMENT(obj) \
1491+ (G_TYPE_CHECK_INSTANCE_TYPE ((obj), AWN_TYPE_UA_ALIGNMENT))
1492+
1493+#define AWN_IS_UA_ALIGNMENT_CLASS(klass) \
1494+ (G_TYPE_CHECK_CLASS_TYPE ((klass), AWN_TYPE_UA_ALIGNMENT))
1495+
1496+#define AWN_UA_ALIGNMENT_GET_CLASS(obj) \
1497+ (G_TYPE_INSTANCE_GET_CLASS ((obj), AWN_TYPE_UA_ALIGNMENT, AwnUAAlignmentClass))
1498+
1499+typedef struct {
1500+ GtkAlignment parent;
1501+} AwnUAAlignment;
1502+
1503+typedef struct {
1504+ GtkAlignmentClass parent_class;
1505+} AwnUAAlignmentClass;
1506+
1507+GType awn_ua_alignment_get_type (void);
1508+
1509+GtkWidget* awn_ua_alignment_new (AwnAppletManager *manager,gchar * ua_list_entry,double ua_ratio);
1510+
1511+GtkWidget* awn_ua_alignment_get_socket (AwnUAAlignment *self);
1512+
1513+GdkWindow * awn_ua_alignment_add_id (AwnUAAlignment *self, GdkNativeWindow native_window);
1514+
1515+gint awn_ua_alignment_list_cmp (gconstpointer a, gconstpointer b);
1516+
1517+G_END_DECLS
1518+
1519+#endif /* _AWN_UA_ALIGNMENT */

Subscribers

People subscribed via source and target branches

to status/vote changes: