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
=== modified file '.bzrignore'
--- .bzrignore 2009-07-09 07:12:27 +0000
+++ .bzrignore 2009-07-13 18:05:02 +0000
@@ -107,6 +107,12 @@
107src/stamp-awnmarshal.h107src/stamp-awnmarshal.h
108applets/taskmanager/taskmanager-marshal.c108applets/taskmanager/taskmanager-marshal.c
109applets/taskmanager/taskmanager-marshal.h109applets/taskmanager/taskmanager-marshal.h
110debian/patches/*.log
111debian/stamp*
112debian/libawn*/*
113debian/avant-*/*
114debian/python*/*
115debian/awn*/*
110doltcompile116doltcompile
111doltlibtool117doltlibtool
112m4/lt*.m4118m4/lt*.m4
113119
=== modified file 'INSTALL'
--- INSTALL 2009-05-22 09:16:20 +0000
+++ INSTALL 2009-06-25 04:55:53 +0000
@@ -2,15 +2,15 @@
2*************************2*************************
33
4Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005,4Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005,
52006, 2007, 2008 Free Software Foundation, Inc.52006, 2007 Free Software Foundation, Inc.
66
7 This file is free documentation; the Free Software Foundation gives7This file is free documentation; the Free Software Foundation gives
8unlimited permission to copy, distribute and modify it.8unlimited permission to copy, distribute and modify it.
99
10Basic Installation10Basic Installation
11==================11==================
1212
13 Briefly, the shell commands `./configure; make; make install' should13Briefly, the shell commands `./configure; make; make install' should
14configure, build, and install this package. The following14configure, build, and install this package. The following
15more-detailed instructions are generic; see the `README' file for15more-detailed instructions are generic; see the `README' file for
16instructions specific to this package.16instructions specific to this package.
@@ -73,9 +73,9 @@
73Compilers and Options73Compilers and Options
74=====================74=====================
7575
76 Some systems require unusual options for compilation or linking that76Some systems require unusual options for compilation or linking that the
77the `configure' script does not know about. Run `./configure --help'77`configure' script does not know about. Run `./configure --help' for
78for details on some of the pertinent environment variables.78details on some of the pertinent environment variables.
7979
80 You can give `configure' initial values for configuration parameters80 You can give `configure' initial values for configuration parameters
81by setting variables in the command line or in the environment. Here81by setting variables in the command line or in the environment. Here
@@ -88,7 +88,7 @@
88Compiling For Multiple Architectures88Compiling For Multiple Architectures
89====================================89====================================
9090
91 You can compile the package for more than one kind of computer at the91You can compile the package for more than one kind of computer at the
92same time, by placing the object files for each architecture in their92same time, by placing the object files for each architecture in their
93own directory. To do this, you can use GNU `make'. `cd' to the93own directory. To do this, you can use GNU `make'. `cd' to the
94directory where you want the object files and executables to go and run94directory where you want the object files and executables to go and run
@@ -100,24 +100,10 @@
100installed the package for one architecture, use `make distclean' before100installed the package for one architecture, use `make distclean' before
101reconfiguring for another architecture.101reconfiguring for another architecture.
102102
103 On MacOS X 10.5 and later systems, you can create libraries and
104executables that work on multiple system types--known as "fat" or
105"universal" binaries--by specifying multiple `-arch' options to the
106compiler but only a single `-arch' option to the preprocessor. Like
107this:
108
109 ./configure CC="gcc -arch i386 -arch x86_64 -arch ppc -arch ppc64" \
110 CXX="g++ -arch i386 -arch x86_64 -arch ppc -arch ppc64" \
111 CPP="gcc -E" CXXCPP="g++ -E"
112
113 This is not guaranteed to produce working output in all cases, you
114may have to build one architecture at a time and combine the results
115using the `lipo' tool if you have problems.
116
117Installation Names103Installation Names
118==================104==================
119105
120 By default, `make install' installs the package's commands under106By default, `make install' installs the package's commands under
121`/usr/local/bin', include files under `/usr/local/include', etc. You107`/usr/local/bin', include files under `/usr/local/include', etc. You
122can specify an installation prefix other than `/usr/local' by giving108can specify an installation prefix other than `/usr/local' by giving
123`configure' the option `--prefix=PREFIX'.109`configure' the option `--prefix=PREFIX'.
@@ -140,7 +126,7 @@
140Optional Features126Optional Features
141=================127=================
142128
143 Some packages pay attention to `--enable-FEATURE' options to129Some packages pay attention to `--enable-FEATURE' options to
144`configure', where FEATURE indicates an optional part of the package.130`configure', where FEATURE indicates an optional part of the package.
145They may also pay attention to `--with-PACKAGE' options, where PACKAGE131They may also pay attention to `--with-PACKAGE' options, where PACKAGE
146is something like `gnu-as' or `x' (for the X Window System). The132is something like `gnu-as' or `x' (for the X Window System). The
@@ -152,36 +138,14 @@
152you can use the `configure' options `--x-includes=DIR' and138you can use the `configure' options `--x-includes=DIR' and
153`--x-libraries=DIR' to specify their locations.139`--x-libraries=DIR' to specify their locations.
154140
155Particular systems
156==================
157
158 On HP-UX, the default C compiler is not ANSI C compatible. If GNU
159CC is not installed, it is recommended to use the following options in
160order to use an ANSI C compiler:
161
162 ./configure CC="cc -Ae"
163
164and if that doesn't work, install pre-built binaries of GCC for HP-UX.
165
166 On OSF/1 a.k.a. Tru64, some versions of the default C compiler cannot
167parse its `<wchar.h>' header file. The option `-nodtk' can be used as
168a workaround. If GNU CC is not installed, it is therefore recommended
169to try
170
171 ./configure CC="cc"
172
173and if that doesn't work, try
174
175 ./configure CC="cc -nodtk"
176
177Specifying the System Type141Specifying the System Type
178==========================142==========================
179143
180 There may be some features `configure' cannot figure out144There may be some features `configure' cannot figure out automatically,
181automatically, but needs to determine by the type of machine the package145but needs to determine by the type of machine the package will run on.
182will run on. Usually, assuming the package is built to be run on the146Usually, assuming the package is built to be run on the _same_
183_same_ architectures, `configure' can figure that out, but if it prints147architectures, `configure' can figure that out, but if it prints a
184a message saying it cannot guess the machine type, give it the148message saying it cannot guess the machine type, give it the
185`--build=TYPE' option. TYPE can either be a short name for the system149`--build=TYPE' option. TYPE can either be a short name for the system
186type, such as `sun4', or a canonical name which has the form:150type, such as `sun4', or a canonical name which has the form:
187151
@@ -207,9 +171,9 @@
207Sharing Defaults171Sharing Defaults
208================172================
209173
210 If you want to set default values for `configure' scripts to share,174If you want to set default values for `configure' scripts to share, you
211you can create a site shell script called `config.site' that gives175can create a site shell script called `config.site' that gives default
212default values for variables like `CC', `cache_file', and `prefix'.176values for variables like `CC', `cache_file', and `prefix'.
213`configure' looks for `PREFIX/share/config.site' if it exists, then177`configure' looks for `PREFIX/share/config.site' if it exists, then
214`PREFIX/etc/config.site' if it exists. Or, you can set the178`PREFIX/etc/config.site' if it exists. Or, you can set the
215`CONFIG_SITE' environment variable to the location of the site script.179`CONFIG_SITE' environment variable to the location of the site script.
@@ -218,7 +182,7 @@
218Defining Variables182Defining Variables
219==================183==================
220184
221 Variables not defined in a site shell script can be set in the185Variables not defined in a site shell script can be set in the
222environment passed to `configure'. However, some packages may run186environment passed to `configure'. However, some packages may run
223configure again during the build, and the customized values of these187configure again during the build, and the customized values of these
224variables may be lost. In order to avoid this problem, you should set188variables may be lost. In order to avoid this problem, you should set
@@ -237,19 +201,11 @@
237`configure' Invocation201`configure' Invocation
238======================202======================
239203
240 `configure' recognizes the following options to control how it204`configure' recognizes the following options to control how it operates.
241operates.
242205
243`--help'206`--help'
244`-h'207`-h'
245 Print a summary of all of the options to `configure', and exit.208 Print a summary of the options to `configure', and exit.
246
247`--help=short'
248`--help=recursive'
249 Print a summary of the options unique to this package's
250 `configure', and exit. The `short' variant lists options used
251 only in the top level, while the `recursive' variant lists options
252 also present in any nested packages.
253209
254`--version'210`--version'
255`-V'211`-V'
@@ -276,16 +232,6 @@
276 Look for the package's source code in directory DIR. Usually232 Look for the package's source code in directory DIR. Usually
277 `configure' can determine that directory automatically.233 `configure' can determine that directory automatically.
278234
279`--prefix=DIR'
280 Use DIR as the installation prefix. *Note Installation Names::
281 for more details, including other options available for fine-tuning
282 the installation locations.
283
284`--no-create'
285`-n'
286 Run the configure checks, but stop before creating any output
287 files.
288
289`configure' also accepts some other, not widely useful, options. Run235`configure' also accepts some other, not widely useful, options. Run
290`configure --help' for more details.236`configure --help' for more details.
291237
292238
=== added directory 'applets/uawrapper'
=== added file 'applets/uawrapper/awn-ua-wrapper.h'
--- applets/uawrapper/awn-ua-wrapper.h 1970-01-01 00:00:00 +0000
+++ applets/uawrapper/awn-ua-wrapper.h 2009-06-25 04:55:53 +0000
@@ -0,0 +1,42 @@
1/* awn-ua-wrapper.h */
2
3#ifndef _AWN_UA_WRAPPER
4#define _AWN_UA_WRAPPER
5
6#include <glib-object.h>
7#include <libawn/libawn.h>
8
9G_BEGIN_DECLS
10
11#define AWN_TYPE_UA_WRAPPER awn_ua_wrapper_get_type()
12
13#define AWN_UA_WRAPPER(obj) \
14 (G_TYPE_CHECK_INSTANCE_CAST ((obj), AWN_TYPE_UA_WRAPPER, AwnUAWrapper))
15
16#define AWN_UA_WRAPPER_CLASS(klass) \
17 (G_TYPE_CHECK_CLASS_CAST ((klass), AWN_TYPE_UA_WRAPPER, AwnUAWrapperClass))
18
19#define AWN_IS_UA_WRAPPER(obj) \
20 (G_TYPE_CHECK_INSTANCE_TYPE ((obj), AWN_TYPE_UA_WRAPPER))
21
22#define AWN_IS_UA_WRAPPER_CLASS(klass) \
23 (G_TYPE_CHECK_CLASS_TYPE ((klass), AWN_TYPE_UA_WRAPPER))
24
25#define AWN_UA_WRAPPER_GET_CLASS(obj) \
26 (G_TYPE_INSTANCE_GET_CLASS ((obj), AWN_TYPE_UA_WRAPPER, AwnUAWrapperClass))
27
28typedef struct {
29 AwnApplet parent;
30} AwnUAWrapper;
31
32typedef struct {
33 AwnAppletClass parent_class;
34} AwnUAWrapperClass;
35
36GType awn_ua_wrapper_get_type (void);
37
38AwnUAWrapper* awn_ua_wrapper_new (gchar* uid, gint panel_id);
39
40G_END_DECLS
41
42#endif /* _AWN_UA_WRAPPER */
043
=== modified file 'awn-settings/awnClass.py'
--- awn-settings/awnClass.py 2009-07-10 00:56:51 +0000
+++ awn-settings/awnClass.py 2009-07-14 17:57:18 +0000
@@ -1537,16 +1537,22 @@
1537 os.unlink(filename)1537 os.unlink(filename)
15381538
1539 def _apply (self):1539 def _apply (self):
1540 l = []1540 applets_list = []
1541 ua_list = []
1542
1541 it = self.active_model.get_iter_first ()1543 it = self.active_model.get_iter_first ()
1542 while (it):1544 while (it):
1543 path = self.active_model.get_value (it, 1)1545 path = self.active_model.get_value (it, 1)
1544 uid = self.active_model.get_value (it, 2)1546 uid = self.active_model.get_value (it, 2)
1545 s = "%s::%s" % (path, uid)1547 s = "%s::%s" % (path, uid)
1546 l.append (s)1548 if path.endswith(".desktop"):
1549 applets_list.append(s)
1550 else:
1551 ua_list.append(s)
1552
1547 it= self.active_model.iter_next (it)1553 it= self.active_model.iter_next (it)
15481554
1549 self.client.set_list(defs.PANEL, defs.APPLET_LIST, awn.CONFIG_LIST_STRING, l)1555 self.client.set_list(defs.PANEL, defs.APPLET_LIST, awn.CONFIG_LIST_STRING, applets_list)
15501556
1551 def up_clicked (self, button):1557 def up_clicked (self, button):
1552 select = self.treeview.get_selection()1558 select = self.treeview.get_selection()
@@ -1592,18 +1598,32 @@
15921598
1593 applets = self.client.get_list(defs.PANEL, defs.APPLET_LIST, awn.CONFIG_LIST_STRING)1599 applets = self.client.get_list(defs.PANEL, defs.APPLET_LIST, awn.CONFIG_LIST_STRING)
15941600
1601 ua_applets = self.client.get_list(defs.PANEL, defs.UA_LIST, awn.CONFIG_LIST_STRING)
1602
1603 for ua in ua_applets:
1604 tokens = ua.split("::")
1605 applets.insert(int(tokens[1]), ua)
1606
1595 self.refresh_icon_list (applets, self.active_model)1607 self.refresh_icon_list (applets, self.active_model)
15961608
1597 def refresh_icon_list (self, applets, model):1609 def refresh_icon_list (self, applets, model):
1598 for a in applets:1610 for a in applets:
1599 tokens = a.split("::")1611 tokens = a.split("::")
1600 path = tokens[0]1612 if tokens[0].endswith(".desktop"):
1601 uid = tokens[1]1613 path = tokens[0]
1602 icon, text, name = self.make_row(path)1614 uid = tokens[1]
1603 if len (text) < 2:1615 icon, text, name = self.make_row(path)
1604 continue;1616 if len (text) < 2:
1617 continue;
16051618
1606 model.append([icon, path, uid, text])1619 model.append([icon, path, uid, text])
1620 else:
1621 path = tokens[0]
1622 uid = tokens[1]
1623 theme = gtk.icon_theme_get_default ()
1624 icon = theme.load_icon ("screenlets", 32, 0)
1625 text = tokens[0]
1626 model.append([icon, path, uid, text])
16071627
1608 def load_applets (self):1628 def load_applets (self):
1609 applets = self.applets_by_categories()1629 applets = self.applets_by_categories()
@@ -1645,7 +1665,21 @@
1645 applets = l.values()1665 applets = l.values()
16461666
1647 if not None in applets and self.load_finished:1667 if not None in applets and self.load_finished:
1648 self.client.set_list(defs.PANEL, defs.APPLET_LIST, awn.CONFIG_LIST_STRING, applets)1668 applets_list = []
1669 ua_list = []
1670 for a in applets:
1671 tokens = a.split("::")
1672 path = tokens[0]
1673 if path.endswith(".desktop"):
1674 applets_list.append(a)
1675 else:
1676 position = applets.index(a)
1677 ua = tokens[0] + "::" + str(position)
1678 ua_list.append(ua)
1679
1680 self.client.set_list(defs.PANEL, defs.APPLET_LIST, awn.CONFIG_LIST_STRING, applets_list)
1681 self.client.set_list(defs.PANEL, defs.UA_LIST, awn.CONFIG_LIST_STRING, ua_list)
1682
16491683
1650 def callback_widget_filter_applets(self, data=None):1684 def callback_widget_filter_applets(self, data=None):
1651 model = self.choose_categorie.get_model()1685 model = self.choose_categorie.get_model()
16521686
=== modified file 'awn-settings/awnDefs.py.in'
--- awn-settings/awnDefs.py.in 2009-07-10 00:56:51 +0000
+++ awn-settings/awnDefs.py.in 2009-07-14 19:09:25 +0000
@@ -59,6 +59,7 @@
59EXPAND = "expand" #bool59EXPAND = "expand" #bool
60CLICKTHROUGH = "clickthrough" #int60CLICKTHROUGH = "clickthrough" #int
61BEHAVIOR = "behavior" #int61BEHAVIOR = "behavior" #int
62UA_LIST = "ua_active_list" #list-string
6263
63PANELS = "panels" #group64PANELS = "panels" #group
64PANEL_LIST = "panel_list" #int65PANEL_LIST = "panel_list" #int
6566
=== modified file 'data/awn.schema-ini.in'
--- data/awn.schema-ini.in 2009-07-06 22:12:25 +0000
+++ data/awn.schema-ini.in 2009-07-14 18:01:40 +0000
@@ -28,6 +28,16 @@
28default = @APPLETDATADIR@/taskmanager.desktop::128default = @APPLETDATADIR@/taskmanager.desktop::1
29description = The list of applets for this panel ordered from ltr or ttb.29description = The list of applets for this panel ordered from ltr or ttb.
3030
31[panel/ua_list]
32type = list-string
33default =
34description = The list of UA Screenlets that have been previous added in the form ScreeneletInstance::Position.
35
36[panel/ua_active_list]
37type = list-string
38default =
39description = The active list UA Screenlets for this panel.
40
31[panel/monitor_force]41[panel/monitor_force]
32type = bool42type = bool
33default = False43default = False
3444
=== modified file 'libawn/awn-alignment.c'
--- libawn/awn-alignment.c 2009-03-26 23:47:26 +0000
+++ libawn/awn-alignment.c 2009-06-25 18:26:59 +0000
@@ -192,6 +192,18 @@
192 return alignment;192 return alignment;
193}193}
194194
195GtkWidget*
196awn_alignment_new (void)
197{
198 GtkWidget *alignment;
199
200 alignment = g_object_new(AWN_TYPE_ALIGNMENT,
201 NULL);
202
203 return alignment;
204}
205
206
195static void207static void
196on_orient_changed (AwnAlignment *alignment, AwnOrientation orient)208on_orient_changed (AwnAlignment *alignment, AwnOrientation orient)
197{209{
198210
=== modified file 'libawn/awn-alignment.h'
--- libawn/awn-alignment.h 2009-03-22 23:12:16 +0000
+++ libawn/awn-alignment.h 2009-06-25 18:26:59 +0000
@@ -80,6 +80,8 @@
80void awn_alignment_set_offset_modifier (AwnAlignment *alignment, 80void awn_alignment_set_offset_modifier (AwnAlignment *alignment,
81 gint modifier);81 gint modifier);
8282
83GtkWidget* awn_alignment_new (void);
84
83G_END_DECLS85G_END_DECLS
8486
85#endif87#endif
8688
=== modified file 'src/Makefile.am'
--- src/Makefile.am 2009-06-21 13:23:05 +0000
+++ src/Makefile.am 2009-07-13 18:20:16 +0000
@@ -27,6 +27,7 @@
27 awn-app-glue.h \27 awn-app-glue.h \
28 awn-applet-manager.c \28 awn-applet-manager.c \
29 awn-applet-manager.h \29 awn-applet-manager.h \
30 awn-applet-manager-glue.h \
30 awn-applet-proxy.c \31 awn-applet-proxy.c \
31 awn-applet-proxy.h \32 awn-applet-proxy.h \
32 awn-background.c \33 awn-background.c \
@@ -51,6 +52,8 @@
51 awn-panel-glue.h \52 awn-panel-glue.h \
52 awn-throbber.c \53 awn-throbber.c \
53 awn-throbber.h \54 awn-throbber.h \
55 awn-ua-alignment.c \
56 awn-ua-alignment.h \
54 awn-x.h \57 awn-x.h \
55 awn-x.c \58 awn-x.c \
56 inlinepixbufs.h \59 inlinepixbufs.h \
@@ -65,9 +68,13 @@
65awn-panel-glue.h: awn-panel-dbus.xml Makefile68awn-panel-glue.h: awn-panel-dbus.xml Makefile
66 $(LIBTOOL) --mode=execute $(DBUS_GLIB_BIN)/dbus-binding-tool --prefix=awn_panel --mode=glib-server --output=$@ $<69 $(LIBTOOL) --mode=execute $(DBUS_GLIB_BIN)/dbus-binding-tool --prefix=awn_panel --mode=glib-server --output=$@ $<
6770
71awn-applet-manager-glue.h: awn-applet-manager-dbus.xml Makefile
72 $(LIBTOOL) --mode=execute $(DBUS_GLIB_BIN)/dbus-binding-tool --prefix=awn_ua --mode=glib-server --output=$@ $<
73
68BUILT_SOURCES = \74BUILT_SOURCES = \
69 awn-app-glue.h \75 awn-app-glue.h \
70 awn-panel-glue.h \76 awn-panel-glue.h \
77 awn-applet-manager-glue.h \
71 $(MARSHALFILES) \78 $(MARSHALFILES) \
72 $(NULL)79 $(NULL)
7380
@@ -76,6 +83,7 @@
76EXTRA_DIST = \83EXTRA_DIST = \
77 awn-app-dbus.xml \84 awn-app-dbus.xml \
78 awn-panel-dbus.xml \85 awn-panel-dbus.xml \
86 awn-applet-manager-dbus.xml \
79 $(NULL)87 $(NULL)
8088
81# vim: set ts=8 sts=8 sw=8 :89# vim: set ts=8 sts=8 sw=8 :
8290
=== added file 'src/awn-applet-manager-dbus.xml'
--- src/awn-applet-manager-dbus.xml 1970-01-01 00:00:00 +0000
+++ src/awn-applet-manager-dbus.xml 2009-06-02 22:11:19 +0000
@@ -0,0 +1,21 @@
1<?xml version="1.0"?>
2<node name="/org/awnproject/Awn/UA">
3 <interface name="org.awnproject.Awn.UA">
4 <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="awn_ua"/>
5
6 <!-- Methods -->
7 <method name="add_applet">
8 <arg name="name" type="s" direction="in" />
9 <arg name="uid" type="x" direction="in" />
10 <arg name="width" type="i" direction="in" />
11 <arg name="height" type="i" direction="in" />
12 <arg name="size_type" type="s" direction="in" />
13 </method>
14
15 <method name="get_all_server_flags">
16 <arg name="name" type="s" direction="in" />
17 <arg name="hash" type="a{ss}" direction="out" />
18 </method>
19
20 </interface>
21</node>
022
=== modified file 'src/awn-applet-manager.c'
--- src/awn-applet-manager.c 2009-07-09 07:12:27 +0000
+++ src/awn-applet-manager.c 2009-07-14 20:38:19 +0000
@@ -16,22 +16,26 @@
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
17 *17 *
18 * Author : Neil Jagdish Patel <njpatel@gmail.com>18 * Author : Neil Jagdish Patel <njpatel@gmail.com>
19 *19 *bind
20 */20 */
2121
22#include "config.h"22#include "config.h"
2323
24#include <libawn/awn-config-bridge.h>24#include <libawn/libawn.h>
25#include <dbus/dbus-glib.h>
26#include <dbus/dbus-glib-bindings.h>
25#include <libawn/awn-utils.h>27#include <libawn/awn-utils.h>
26#include <math.h>28#include <math.h>
2729
28#include "awn-defines.h"30#include "awn-defines.h"
29#include "awn-applet-manager.h"31#include "awn-applet-manager.h"
3032#include "awn-ua-alignment.h"
31#include "awn-applet-proxy.h"33#include "awn-applet-proxy.h"
32#include "awn-throbber.h"34#include "awn-throbber.h"
33#include "xutils.h"35#include "xutils.h"
3436
37#define MAX_UA_LIST_ENTRIES 50
38
35G_DEFINE_TYPE (AwnAppletManager, awn_applet_manager, GTK_TYPE_BOX) 39G_DEFINE_TYPE (AwnAppletManager, awn_applet_manager, GTK_TYPE_BOX)
3640
37#define AWN_APPLET_MANAGER_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE (obj, \41#define AWN_APPLET_MANAGER_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE (obj, \
@@ -44,8 +48,15 @@
44 AwnOrientation orient;48 AwnOrientation orient;
45 gint offset;49 gint offset;
46 gint size;50 gint size;
51
47 GSList *applet_list;52 GSList *applet_list;
4853
54 /*ua_list does not serve the same purpose as the applet_list
55 It's a list of unique UA names plus their position in the panel
56 */
57 GSList *ua_list;
58 GSList *ua_active_list;
59
49 gboolean docklet_mode;60 gboolean docklet_mode;
50 GtkWidget *docklet_widget;61 GtkWidget *docklet_widget;
5162
@@ -60,6 +71,7 @@
6071
61 /* Current box class */72 /* Current box class */
62 GtkWidgetClass *klass;73 GtkWidgetClass *klass;
74
63};75};
6476
65enum 77enum
@@ -71,6 +83,8 @@
71 PROP_OFFSET,83 PROP_OFFSET,
72 PROP_SIZE,84 PROP_SIZE,
73 PROP_APPLET_LIST,85 PROP_APPLET_LIST,
86 PROP_UA_LIST,
87 PROP_UA_ACTIVE_LIST,
74 PROP_EXPANDS88 PROP_EXPANDS
75};89};
7690
@@ -123,6 +137,20 @@
123 AWN_GROUP_PANEL, AWN_PANEL_APPLET_LIST,137 AWN_GROUP_PANEL, AWN_PANEL_APPLET_LIST,
124 AWN_CONFIG_CLIENT_LIST_TYPE_STRING,138 AWN_CONFIG_CLIENT_LIST_TYPE_STRING,
125 object, "applet_list");139 object, "applet_list");
140 awn_config_bridge_bind_list (bridge, priv->client,
141 AWN_GROUP_PANEL, AWN_PANEL_UA_LIST,
142 AWN_CONFIG_CLIENT_LIST_TYPE_STRING,
143 object, "ua_list");
144 awn_config_bridge_bind_list (bridge, priv->client,
145 AWN_GROUP_PANEL, AWN_PANEL_UA_ACTIVE_LIST,
146 AWN_CONFIG_CLIENT_LIST_TYPE_STRING,
147 object, "ua_active_list");
148 /*
149 ua_active_list should be empty when awn starts...
150 */
151 awn_config_client_set_list (priv->client,AWN_GROUP_PANEL, AWN_PANEL_UA_ACTIVE_LIST,
152 AWN_CONFIG_CLIENT_LIST_TYPE_STRING,
153 NULL, NULL);
126}154}
127155
128static void156static void
@@ -165,10 +193,15 @@
165 case PROP_SIZE:193 case PROP_SIZE:
166 g_value_set_int (value, priv->size);194 g_value_set_int (value, priv->size);
167 break;195 break;
168
169 case PROP_APPLET_LIST:196 case PROP_APPLET_LIST:
170 g_value_set_pointer (value, priv->applet_list);197 g_value_set_pointer (value, priv->applet_list);
171 break;198 break;
199 case PROP_UA_LIST:
200 g_value_set_pointer (value, priv->ua_list);
201 break;
202 case PROP_UA_ACTIVE_LIST:
203 g_value_set_pointer (value, priv->ua_active_list);
204 break;
172 case PROP_EXPANDS:205 case PROP_EXPANDS:
173 g_value_set_boolean (value, priv->expands);206 g_value_set_boolean (value, priv->expands);
174 break;207 break;
@@ -208,6 +241,16 @@
208 priv->applet_list = g_value_get_pointer (value);241 priv->applet_list = g_value_get_pointer (value);
209 awn_applet_manager_refresh_applets (manager);242 awn_applet_manager_refresh_applets (manager);
210 break;243 break;
244 case PROP_UA_LIST:
245 free_list (priv->ua_list);
246 priv->ua_list = g_value_get_pointer (value);
247 awn_applet_manager_refresh_applets (manager);
248 break;
249 case PROP_UA_ACTIVE_LIST:
250 free_list (priv->ua_active_list);
251 priv->ua_active_list = g_value_get_pointer (value);
252 awn_applet_manager_refresh_applets (manager);
253 break;
211 default:254 default:
212 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);255 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
213 }256 }
@@ -240,6 +283,8 @@
240 G_OBJECT_CLASS (awn_applet_manager_parent_class)->dispose (object);283 G_OBJECT_CLASS (awn_applet_manager_parent_class)->dispose (object);
241}284}
242285
286#include "awn-applet-manager-glue.h"
287
243static void288static void
244awn_applet_manager_class_init (AwnAppletManagerClass *klass)289awn_applet_manager_class_init (AwnAppletManagerClass *klass)
245{290{
@@ -294,6 +339,20 @@
294 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));339 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
295340
296 g_object_class_install_property (obj_class,341 g_object_class_install_property (obj_class,
342 PROP_UA_LIST,
343 g_param_spec_pointer ("ua_list",
344 "UA List",
345 "The rememebered screenlet positions for this panel",
346 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
347
348 g_object_class_install_property (obj_class,
349 PROP_UA_ACTIVE_LIST,
350 g_param_spec_pointer ("ua-active-list",
351 "UA Active List",
352 "The list of acitve screenlets for this panel",
353 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
354
355 g_object_class_install_property (obj_class,
297 PROP_EXPANDS,356 PROP_EXPANDS,
298 g_param_spec_boolean ("expands",357 g_param_spec_boolean ("expands",
299 "Expands",358 "Expands",
@@ -321,12 +380,18 @@
321 G_TYPE_NONE, 0);380 G_TYPE_NONE, 0);
322 381
323 g_type_class_add_private (obj_class, sizeof (AwnAppletManagerPrivate));382 g_type_class_add_private (obj_class, sizeof (AwnAppletManagerPrivate));
383
384 dbus_g_object_type_install_info (G_TYPE_FROM_CLASS (klass),
385 &dbus_glib_awn_ua_object_info);
386
324}387}
325388
326static void389static void
327awn_applet_manager_init (AwnAppletManager *manager)390awn_applet_manager_init (AwnAppletManager *manager)
328{391{
329 AwnAppletManagerPrivate *priv;392 AwnAppletManagerPrivate *priv;
393 DBusGConnection *connection;
394 GError *error = NULL;
330395
331 priv = manager->priv = AWN_APPLET_MANAGER_GET_PRIVATE (manager);396 priv = manager->priv = AWN_APPLET_MANAGER_GET_PRIVATE (manager);
332397
@@ -338,6 +403,21 @@
338 priv->extra_widgets = g_hash_table_new (g_direct_hash, g_direct_equal);403 priv->extra_widgets = g_hash_table_new (g_direct_hash, g_direct_equal);
339404
340 gtk_widget_show_all (GTK_WIDGET (manager));405 gtk_widget_show_all (GTK_WIDGET (manager));
406
407 /* Grab a connection to the bus */
408 connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
409 if (connection == NULL)
410 {
411 g_warning ("Unable to make connection to the D-Bus session bus: %s",
412 error->message);
413 g_error_free (error);
414 gtk_main_quit ();
415 }
416
417 dbus_g_connection_register_g_object (connection,
418 AWN_DBUS_MANAGER_PATH,
419 G_OBJECT (GTK_WIDGET (manager)));
420
341}421}
342422
343GtkWidget *423GtkWidget *
@@ -505,7 +585,7 @@
505 g_type_class_unref (priv->klass);585 g_type_class_unref (priv->klass);
506 priv->klass = NULL;586 priv->klass = NULL;
507 }587 }
508588// g_debug ("%s, orient = %d",__func__,priv->orient);
509 switch (priv->orient)589 switch (priv->orient)
510 {590 {
511 case AWN_ORIENTATION_TOP:591 case AWN_ORIENTATION_TOP:
@@ -547,7 +627,10 @@
547 {627 {
548 g_free (l->data);628 g_free (l->data);
549 }629 }
550 g_slist_free (list);630 if (list)
631 {
632 g_slist_free (list);
633 }
551}634}
552635
553/*636/*
@@ -647,6 +730,7 @@
647 gint i = 0;730 gint i = 0;
648 gint applet_num = 0;731 gint applet_num = 0;
649732
733 g_debug ("%s",__func__);
650 if (!GTK_WIDGET_REALIZED (manager))734 if (!GTK_WIDGET_REALIZED (manager))
651 return;735 return;
652736
@@ -684,12 +768,14 @@
684 continue;768 continue;
685 }769 }
686770
771// g_debug ("%s: %s, %s",__func__,tokens[0],tokens[1]);
687 /* See if the applet already exists */772 /* See if the applet already exists */
688 applet = g_hash_table_lookup (priv->applets, tokens[1]);773 applet = g_hash_table_lookup (priv->applets, tokens[1]);
689774
690 /* If not, create it */775 /* If not, create it */
691 if (applet == NULL)776 if (applet == NULL)
692 {777 {
778 g_debug ("applet does not exist");
693 applet = create_applet (manager, tokens[0], tokens[1]);779 applet = create_applet (manager, tokens[0], tokens[1]);
694 if (!applet)780 if (!applet)
695 {781 {
@@ -752,6 +838,7 @@
752 gtk_box_pack_start (GTK_BOX (manager), widget, FALSE, FALSE, 0);838 gtk_box_pack_start (GTK_BOX (manager), widget, FALSE, FALSE, 0);
753 /* caller is supposed to call gtk_widget_show! */839 /* caller is supposed to call gtk_widget_show! */
754 }840 }
841 g_print ("Gint : %i : ", pos);
755 g_hash_table_replace (priv->extra_widgets, widget, GINT_TO_POINTER (pos));842 g_hash_table_replace (priv->extra_widgets, widget, GINT_TO_POINTER (pos));
756843
757 awn_applet_manager_refresh_applets (manager);844 awn_applet_manager_refresh_applets (manager);
@@ -769,6 +856,159 @@
769 }856 }
770}857}
771858
859/*DBUS*/
860/*
861 Description of this dbus interface.
862
863 @action(IFACE)
864 def add_applet (self, id, plug_id, width, height, size_type):
865 """
866 Add an applet.
867
868 id: A unique string used to identify the applet.
869 plug_id: The applet's gtk.Plug's xid.
870 width: A recommended width. This will be interpreted according to size_type.
871 height A recommended height. This will be interpreted according to size_type.
872 size_type: Determines the meaning of width and height.
873 May be one of the following values:
874 "scalable"- The applet may be resized as long as the width/height ratio is kept.
875 "static"- The applet should be displayed at exactly the size requested.
876 "static-width"- The applet's width should remain static, and the server may change the height.
877 "static-height"- The applet's height should remain static, and the server may change the width.
878 "dynamic"- The applet may be resized to any size.
879 desktop_path: Path to the desktop file.
880 """
881 # NOTE: Melange currently ignores the size_type parameter.
882 container = ToplevelContainer(plug_id, id, self, width, height,
883 size_type, backend=self.backend)
884 self.containers.append(container)
885*/
886gboolean
887awn_ua_add_applet ( AwnAppletManager *manager,
888 gchar *name,
889 glong xid,
890 gint width,
891 gint height,
892 gchar *size_type,
893 GError **error)
894{
895 g_return_val_if_fail (AWN_IS_APPLET_MANAGER (manager),FALSE);
896 g_return_val_if_fail ( (g_strcmp0(size_type,"scalable")==0 ) ||
897 (g_strcmp0(size_type,"dynamic")==0 ), FALSE );
898
899 GdkWindow* plugwin;
900 AwnAppletManagerPrivate *priv = manager->priv;
901 gint pos = g_slist_length (priv->applet_list);
902 GdkNativeWindow native_window = (GdkNativeWindow) xid;
903 gchar * tmp = g_strdup_printf ("%s::%d",name,pos);
904 gchar * ua_list_entry = NULL;
905 GtkWidget *ua_alignment;
906 double ua_ratio;
907
908 /*
909 Is there an entry in ua_list for this particular screenlet instance(name).
910 The comparision function used ignores the position.
911 */
912 GSList * search = g_slist_find_custom (priv->ua_list,tmp,awn_ua_alignment_list_cmp);
913 if (search)
914 {
915 /* There's already an entry in ua_list so use that. */
916 GStrv tokens;
917 ua_list_entry = g_strdup (search->data) ;
918 g_free (tmp);
919 /* Get the position where the screenlet should be placed*/
920 tokens = g_strsplit (search->data,"::",2);
921 if (tokens && tokens[1])
922 {
923 pos = atoi (tokens[1]);
924 }
925 g_strfreev (tokens);
926 /* remove the link... that data will be appended at to the list*/
927 g_free (search->data);
928 priv->ua_list = g_slist_delete_link (priv->ua_list,search);
929 search = NULL;
930 }
931 else
932 {
933 /*
934 This screenlet instance is not recorded in ua_list. It will end up being
935 placed at the end of the bar
936 */
937 ua_list_entry = tmp;
938 }
939
940 /*
941 Calculated here and passed to the awn_ua_alignment_new(). AwnUAAlignment
942 could recalculate the ratio on bar resizes based on the, then current,
943 dimensions of the widget but over time the amount of error in the the
944 calcs would increase
945 */
946 ua_ratio = width / (double) height;
947 ua_alignment = awn_ua_alignment_new(manager,ua_list_entry,ua_ratio);
948
949 g_signal_connect_swapped (awn_ua_alignment_get_socket(AWN_UA_ALIGNMENT(ua_alignment)),
950 "plug-added",
951 G_CALLBACK (_applet_plug_added),
952 manager);
953
954 awn_applet_manager_add_widget(manager, GTK_WIDGET (ua_alignment), pos);
955 gtk_widget_show_all (ua_alignment);
956
957 plugwin = awn_ua_alignment_add_id (AWN_UA_ALIGNMENT(ua_alignment),native_window);
958
959 g_object_set_qdata (G_OBJECT (ua_alignment),
960 priv->touch_quark, GINT_TO_POINTER (0));
961
962 if (!plugwin)
963 {
964 g_warning ("UA Plug was not created within socket.");
965 gtk_widget_destroy (ua_alignment);
966 return FALSE;
967 }
968
969 /*
970 Either add the new entry into ua_list or move an existing entry to the
971 end of ua_list_entry
972 */
973 priv->ua_list = g_slist_append (priv->ua_list,g_strdup(ua_list_entry));
974
975 /* Keep the length of ua_list reasonable */
976 if (g_slist_length (priv->ua_list) > MAX_UA_LIST_ENTRIES)
977 {
978 GSList * iter;
979 int i = g_slist_length (priv->ua_list) - MAX_UA_LIST_ENTRIES;
980 for(iter = priv->ua_list; i && iter ; iter = priv->ua_list )
981 {
982 g_free (iter->data);
983 priv->ua_list = g_slist_delete_link (priv->ua_list,iter);
984 i--;
985 }
986 }
987 awn_config_client_set_list (priv->client,AWN_GROUP_PANEL, AWN_PANEL_UA_LIST,
988 AWN_CONFIG_CLIENT_LIST_TYPE_STRING,
989 priv->ua_list, NULL);
990 /*Add our newly active screenlet to thend of the active list */
991 priv->ua_active_list = g_slist_append (priv->ua_active_list,g_strdup(ua_list_entry));
992 awn_config_client_set_list (priv->client,AWN_GROUP_PANEL, AWN_PANEL_UA_ACTIVE_LIST,
993 AWN_CONFIG_CLIENT_LIST_TYPE_STRING,
994 priv->ua_active_list, NULL);
995
996 return TRUE;
997}
998
999gboolean
1000awn_ua_get_all_server_flags ( AwnAppletManager *manager,
1001 GHashTable *hash,
1002 gchar *name,
1003 GError **error)
1004{
1005/* Future function to return capability of the server
1006For now, it return nothing*/
1007return TRUE;
1008}
1009
1010
1011/*End DBUS*/
772void1012void
773awn_applet_manager_show_applets (AwnAppletManager *manager)1013awn_applet_manager_show_applets (AwnAppletManager *manager)
774{1014{
7751015
=== modified file 'src/awn-applet-manager.h'
--- src/awn-applet-manager.h 2009-07-08 20:38:35 +0000
+++ src/awn-applet-manager.h 2009-07-13 18:05:02 +0000
@@ -25,6 +25,7 @@
25#include <gtk/gtk.h>25#include <gtk/gtk.h>
2626
27#include <libawn/awn-config-client.h>27#include <libawn/awn-config-client.h>
28#include <libawn/awn-defines.h>
2829
29#include "awn-panel.h"30#include "awn-panel.h"
3031
@@ -82,9 +83,25 @@
8283
83gboolean awn_applet_manager_get_expands (AwnAppletManager *manager);84gboolean awn_applet_manager_get_expands (AwnAppletManager *manager);
8485
85void awn_applet_manager_set_applet_flags (AwnAppletManager *manager,86
86 const gchar *uid,87
87 AwnAppletFlags flags);88gboolean awn_ua_get_all_server_flags (AwnAppletManager *manager,
89 GHashTable *hash,
90 gchar *name,
91 GError **error);
92
93gboolean awn_ua_add_applet ( AwnAppletManager *manager,
94 gchar *name,
95 glong xid,
96 gint width,
97 gint height,
98 gchar *size_type,
99 GError **error);
100
101
102void awn_applet_manager_set_applet_flags (AwnAppletManager *manager,
103 const gchar *uid,
104 AwnAppletFlags flags);
88105
89void awn_applet_manager_show_applets (AwnAppletManager *manager);106void awn_applet_manager_show_applets (AwnAppletManager *manager);
90void awn_applet_manager_hide_applets (AwnAppletManager *manager);107void awn_applet_manager_hide_applets (AwnAppletManager *manager);
91108
=== modified file 'src/awn-applet-proxy.c'
--- src/awn-applet-proxy.c 2009-07-08 21:17:59 +0000
+++ src/awn-applet-proxy.c 2009-07-13 18:05:02 +0000
@@ -276,6 +276,7 @@
276 1, G_TYPE_INT);276 1, G_TYPE_INT);
277277
278 g_type_class_add_private (obj_class, sizeof (AwnAppletProxyPrivate));278 g_type_class_add_private (obj_class, sizeof (AwnAppletProxyPrivate));
279
279}280}
280281
281static gboolean282static gboolean
@@ -349,6 +350,8 @@
349 return proxy;350 return proxy;
350}351}
351352
353
354
352/*355/*
353 * GtkSocket callbacks356 * GtkSocket callbacks
354 */357 */
@@ -552,4 +555,3 @@
552 priv->idle_id = g_idle_add (awn_applet_proxy_idle_cb, proxy);555 priv->idle_id = g_idle_add (awn_applet_proxy_idle_cb, proxy);
553 }556 }
554}557}
555
556558
=== modified file 'src/awn-defines.h'
--- src/awn-defines.h 2009-04-18 00:36:20 +0000
+++ src/awn-defines.h 2009-07-14 18:01:40 +0000
@@ -28,6 +28,7 @@
2828
29#define AWN_DBUS_APP_PATH AWN_DBUS_PATH29#define AWN_DBUS_APP_PATH AWN_DBUS_PATH
30#define AWN_DBUS_PANEL_PATH AWN_DBUS_PATH"/Panel"30#define AWN_DBUS_PANEL_PATH AWN_DBUS_PATH"/Panel"
31#define AWN_DBUS_MANAGER_PATH AWN_DBUS_PATH"/UA"
3132
32/* FIXME: Move some of these out into libawn when we can */33/* FIXME: Move some of these out into libawn when we can */
33#define AWN_GROUP_PANEL "panel"34#define AWN_GROUP_PANEL "panel"
@@ -38,6 +39,8 @@
38#define AWN_PANEL_SIZE "size"39#define AWN_PANEL_SIZE "size"
39#define AWN_PANEL_AUTOHIDE "autohide"40#define AWN_PANEL_AUTOHIDE "autohide"
40#define AWN_PANEL_APPLET_LIST "applet_list"41#define AWN_PANEL_APPLET_LIST "applet_list"
42#define AWN_PANEL_UA_LIST "ua_list"
43#define AWN_PANEL_UA_ACTIVE_LIST "ua_active_list"
41#define AWN_PANEL_MONITOR_HEIGHT "monitor_height"44#define AWN_PANEL_MONITOR_HEIGHT "monitor_height"
42#define AWN_PANEL_MONITOR_WIDTH "monitor_width"45#define AWN_PANEL_MONITOR_WIDTH "monitor_width"
43#define AWN_PANEL_MONITOR_FORCE "monitor_force"46#define AWN_PANEL_MONITOR_FORCE "monitor_force"
4447
=== added file 'src/awn-ua-alignment.c'
--- src/awn-ua-alignment.c 1970-01-01 00:00:00 +0000
+++ src/awn-ua-alignment.c 2009-07-14 19:09:25 +0000
@@ -0,0 +1,469 @@
1/*
2 * Copyright (C) 2009 Rodney Cryderman <rcryderman@gmail.com>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
17 *
18 *
19 */
20
21/* awn-ua-alignment.c */
22#include <stdlib.h>
23#include "awn-ua-alignment.h"
24#include "awn-defines.h"
25
26G_DEFINE_TYPE (AwnUAAlignment, awn_ua_alignment, GTK_TYPE_ALIGNMENT)
27
28#define AWN_UA_ALIGNMENT_GET_PRIVATE(o) \
29 (G_TYPE_INSTANCE_GET_PRIVATE ((o), AWN_TYPE_UA_ALIGNMENT, AwnUAAlignmentPrivate))
30
31typedef struct _AwnUAAlignmentPrivate AwnUAAlignmentPrivate;
32
33struct _AwnUAAlignmentPrivate
34{
35 GtkWidget * socket;
36 GtkWidget * applet_manager;
37
38 gchar *ua_list_entry;
39 double ua_ratio;
40
41 guint notify_size_id;
42 guint notify_orient_id;
43 guint notify_offset_id;
44 guint notify_ua_list_id;
45};
46
47enum
48{
49 PROP_0,
50 PROP_APPLET_MANAGER,
51 PROP_UA_LIST_ENTRY,
52 PROP_UA_RATIO
53};
54
55
56static gboolean awn_ua_alignment_plug_removed (GtkWidget * socket,
57 AwnUAAlignment * self);
58static void awn_ua_alignment_list_change(GObject *object,
59 GParamSpec *param_spec,
60 gpointer user_data);
61static void awn_ua_alignment_orient_change(GObject *object,
62 GParamSpec *param_spec,
63 gpointer user_data);
64static void awn_ua_alignment_size_change(GObject *object,
65 GParamSpec *param_spec,
66 gpointer user_data);
67static void awn_ua_alignment_offset_change(GObject *object,
68 GParamSpec *param_spec,
69 gpointer user_data);
70
71
72static void
73awn_ua_alignment_get_property (GObject *object, guint property_id,
74 GValue *value, GParamSpec *pspec)
75{
76 AwnUAAlignmentPrivate * priv;
77
78 priv = AWN_UA_ALIGNMENT_GET_PRIVATE (object);
79
80 switch (property_id)
81 {
82 case PROP_APPLET_MANAGER:
83 g_value_set_object (value,priv->applet_manager);
84 break;
85 case PROP_UA_LIST_ENTRY:
86 g_value_set_string (value,priv->ua_list_entry);
87 break;
88 case PROP_UA_RATIO:
89 g_value_set_double (value,priv->ua_ratio);
90 break;
91 default:
92 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
93 }
94}
95
96static void
97awn_ua_alignment_set_property (GObject *object, guint property_id,
98 const GValue *value, GParamSpec *pspec)
99{
100 AwnUAAlignmentPrivate * priv;
101
102 priv = AWN_UA_ALIGNMENT_GET_PRIVATE (object);
103 switch (property_id)
104 {
105 case PROP_APPLET_MANAGER:
106 priv->applet_manager = g_value_get_object (value);
107 break;
108 case PROP_UA_LIST_ENTRY:
109 g_free (priv->ua_list_entry);
110 priv->ua_list_entry = g_value_dup_string (value);
111 break;
112 case PROP_UA_RATIO:
113 priv->ua_ratio = g_value_get_double (value);
114 break;
115 default:
116 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
117 }
118}
119
120static void
121awn_ua_alignment_dispose (GObject *object)
122{
123 G_OBJECT_CLASS (awn_ua_alignment_parent_class)->dispose (object);
124}
125
126static void
127awn_ua_alignment_finalize (GObject *object)
128{
129 AwnUAAlignmentPrivate * priv = AWN_UA_ALIGNMENT_GET_PRIVATE (object);
130 g_debug ("%s",__func__);
131 if (priv->ua_list_entry)
132 {
133 g_free (priv->ua_list_entry);
134 }
135 G_OBJECT_CLASS (awn_ua_alignment_parent_class)->finalize (object);
136}
137
138static void
139awn_ua_alignment_constructed (GObject *object)
140{
141 AwnUAAlignmentPrivate * priv = AWN_UA_ALIGNMENT_GET_PRIVATE (object);
142
143 if (G_OBJECT_CLASS (awn_ua_alignment_parent_class)->constructed)
144 {
145 G_OBJECT_CLASS (awn_ua_alignment_parent_class)->constructed (object);
146 }
147
148 gtk_container_add (GTK_CONTAINER(object),priv->socket);
149 awn_ua_alignment_orient_change (NULL,NULL,object);
150 priv->notify_offset_id = g_signal_connect (priv->applet_manager,
151 "notify::offset",
152 G_CALLBACK(awn_ua_alignment_offset_change),
153 object);
154 priv->notify_orient_id = g_signal_connect_after (priv->applet_manager,
155 "notify::orient",
156 G_CALLBACK(awn_ua_alignment_orient_change),
157 object);
158 priv->notify_size_id = g_signal_connect_after (priv->applet_manager,
159 "notify::size",
160 G_CALLBACK(awn_ua_alignment_size_change),
161 object);
162 priv->notify_ua_list_id = g_signal_connect_after (priv->applet_manager,
163 "notify::ua-active-list",
164 G_CALLBACK(awn_ua_alignment_list_change),
165 object);
166}
167
168static void
169awn_ua_alignment_class_init (AwnUAAlignmentClass *klass)
170{
171 GObjectClass *object_class = G_OBJECT_CLASS (klass);
172 GParamSpec *pspec;
173
174 object_class->get_property = awn_ua_alignment_get_property;
175 object_class->set_property = awn_ua_alignment_set_property;
176 object_class->dispose = awn_ua_alignment_dispose;
177 object_class->finalize = awn_ua_alignment_finalize;
178 object_class->constructed = awn_ua_alignment_constructed;
179
180 pspec = g_param_spec_object ("applet-manager",
181 "Awn Applet Manager",
182 "Awn Applet Manager",
183 AWN_TYPE_APPLET_MANAGER,
184 G_PARAM_READWRITE | G_PARAM_CONSTRUCT);
185 g_object_class_install_property (object_class, PROP_APPLET_MANAGER, pspec);
186
187 pspec = g_param_spec_string ("ua-list-entry",
188 "UA List entry",
189 "UA List entry",
190 NULL,
191 G_PARAM_READWRITE | G_PARAM_CONSTRUCT);
192 g_object_class_install_property (object_class, PROP_UA_LIST_ENTRY, pspec);
193
194 pspec = g_param_spec_double ("ua-ratio",
195 "UA Ratio",
196 "UA Ratio",
197 0.0,
198 100.0,
199 1.0,
200 G_PARAM_READWRITE | G_PARAM_CONSTRUCT);
201 g_object_class_install_property (object_class, PROP_UA_RATIO, pspec);
202
203 g_type_class_add_private (klass, sizeof (AwnUAAlignmentPrivate));
204}
205
206static void
207awn_ua_alignment_init (AwnUAAlignment *self)
208{
209 AwnUAAlignmentPrivate *priv;
210
211 priv = AWN_UA_ALIGNMENT_GET_PRIVATE (self);
212 priv->socket = gtk_socket_new ();
213}
214
215GtkWidget*
216awn_ua_alignment_new (AwnAppletManager *manager,gchar * ua_list_entry,double ua_ratio)
217{
218 return g_object_new (AWN_TYPE_UA_ALIGNMENT,
219 "applet-manager",manager,
220 "ua-list-entry",ua_list_entry,
221 "ua-ratio",ua_ratio,
222 NULL);
223}
224
225GtkWidget*
226awn_ua_alignment_get_socket (AwnUAAlignment *self)
227{
228 AwnUAAlignmentPrivate *priv;
229
230 priv = AWN_UA_ALIGNMENT_GET_PRIVATE (self);
231 return priv->socket;
232}
233
234
235GdkWindow *
236awn_ua_alignment_add_id (AwnUAAlignment *self,GdkNativeWindow native_window)
237{
238 GdkWindow * plugwin;
239 AwnUAAlignmentPrivate *priv;
240
241 priv = AWN_UA_ALIGNMENT_GET_PRIVATE (self);
242 gtk_socket_add_id (GTK_SOCKET(priv->socket), native_window);
243 plugwin = gtk_socket_get_plug_window (GTK_SOCKET(priv->socket));
244 g_signal_connect (priv->socket,"plug-removed",
245 G_CALLBACK(awn_ua_alignment_plug_removed),self);
246 gtk_widget_realize (priv->socket);
247 gtk_widget_show_all (priv->socket);
248 return plugwin;
249}
250
251
252static gboolean
253awn_ua_alignment_plug_removed (GtkWidget * socket,AwnUAAlignment * self)
254{
255
256 GSList * search;
257 GSList * ua_active_list;
258 GSList * orig_active_list;
259 GSList * iter;
260 AwnConfigClient *client;
261
262 AwnUAAlignmentPrivate *priv = AWN_UA_ALIGNMENT_GET_PRIVATE (self);
263
264 g_signal_handler_disconnect (priv->applet_manager,priv->notify_size_id);
265 g_signal_handler_disconnect (priv->applet_manager,priv->notify_orient_id);
266 g_signal_handler_disconnect (priv->applet_manager,priv->notify_offset_id);
267 g_signal_handler_disconnect (priv->applet_manager,priv->notify_ua_list_id);
268
269 g_object_get ( priv->applet_manager,
270 "ua_active_list",&orig_active_list,
271 "client",&client,
272 NULL);
273 ua_active_list = g_slist_copy (orig_active_list);
274 for (iter = ua_active_list;iter;iter = iter->next)
275 {
276 iter->data = g_strdup(iter->data);
277 }
278 search = g_slist_find_custom (ua_active_list,priv->ua_list_entry,
279 (GCompareFunc)g_strcmp0);
280 if (search)
281 {
282 ua_active_list = g_slist_delete_link (ua_active_list,search);
283 }
284 awn_config_client_set_list (client,AWN_GROUP_PANEL, AWN_PANEL_UA_ACTIVE_LIST,
285 AWN_CONFIG_CLIENT_LIST_TYPE_STRING,
286 ua_active_list, NULL);
287 g_object_set (priv->applet_manager,
288 "ua-active-list",ua_active_list,
289 NULL);
290 awn_applet_manager_remove_widget(AWN_APPLET_MANAGER(priv->applet_manager),
291 GTK_WIDGET (self));
292 return FALSE;
293}
294
295/*UA*/
296gint
297awn_ua_alignment_list_cmp (gconstpointer a, gconstpointer b)
298{
299 const gchar * str1 = a;
300 const gchar * str2 = b;
301 gchar * search = NULL;
302 GStrv tokens = g_strsplit (str1,"::",2);
303 g_return_val_if_fail (tokens,-1);
304
305 search = g_strstr_len (str2,-1,tokens[0]);
306 g_strfreev (tokens);
307
308 if (!search)
309 {
310 return -1;
311 };
312 return 0;
313}
314
315static void
316awn_ua_alignment_offset_change(GObject *object,GParamSpec *param_spec,gpointer user_data)
317{
318 AwnUAAlignment * self = user_data;
319 gint offset;
320 gint orient;
321 AwnUAAlignmentPrivate *priv = AWN_UA_ALIGNMENT_GET_PRIVATE (self);
322
323 g_object_get ( priv->applet_manager,
324 "offset",&offset,
325 "orient",&orient,
326 NULL);
327
328 switch (orient)
329 {
330 case AWN_ORIENTATION_TOP:
331 gtk_alignment_set_padding (GTK_ALIGNMENT(self), offset, 0, 0, 0);
332 break;
333 case AWN_ORIENTATION_BOTTOM:
334 gtk_alignment_set_padding (GTK_ALIGNMENT(self), 0, offset, 0, 0);
335 break;
336 case AWN_ORIENTATION_LEFT:
337 gtk_alignment_set_padding (GTK_ALIGNMENT(self), 0, 0, offset, 0);
338 break;
339 case AWN_ORIENTATION_RIGHT:
340 gtk_alignment_set_padding (GTK_ALIGNMENT(self), 0, 0, 0, offset);
341 break;
342 default:
343 g_warning ("%s: recieved invalid orient %d",__func__,orient);
344 }
345}
346
347static void
348awn_ua_alignment_size_change(GObject *object,GParamSpec *param_spec,gpointer user_data)
349{
350 AwnUAAlignment * self = user_data;
351 gint offset;
352 gint orient;
353 gint size;
354 AwnUAAlignmentPrivate *priv = AWN_UA_ALIGNMENT_GET_PRIVATE (self);
355
356 g_object_get ( priv->applet_manager,
357 "offset",&offset,
358 "orient",&orient,
359 "size",&size,
360 NULL);
361 GtkRequisition req;
362
363 req.width = req.height = size;
364 switch (orient)
365 {
366 case AWN_ORIENTATION_TOP:
367 case AWN_ORIENTATION_BOTTOM:
368 req.width = size * priv->ua_ratio;
369 req.height = size;
370 break;
371 case AWN_ORIENTATION_LEFT:
372 case AWN_ORIENTATION_RIGHT:
373 req.width = size;
374 req.height = size * 1.0 / priv->ua_ratio;
375 break;
376 default:
377 g_warning ("%s: recieved invalid orient %d",__func__,orient);
378 }
379 gtk_widget_set_size_request (GTK_WIDGET(self),req.width,req.height);
380}
381
382static void
383awn_ua_alignment_orient_change(GObject *object,GParamSpec *param_spec,gpointer user_data)
384{
385
386 AwnUAAlignment * self = user_data;
387 gint orient;
388 AwnUAAlignmentPrivate *priv = AWN_UA_ALIGNMENT_GET_PRIVATE (self);
389
390 g_object_get ( priv->applet_manager,
391 "orient",&orient,
392 NULL);
393 switch (orient)
394 {
395 case AWN_ORIENTATION_TOP:
396 gtk_alignment_set (GTK_ALIGNMENT(self), 0.0, 0.0, 1.0, 0.5);
397 break;
398 case AWN_ORIENTATION_BOTTOM:
399 gtk_alignment_set (GTK_ALIGNMENT(self), 0.0, 1.0, 1.0, 0.5);
400 break;
401 case AWN_ORIENTATION_LEFT:
402 gtk_alignment_set (GTK_ALIGNMENT(self), 0.0, 0.0, 0.5, 1.0);
403 break;
404 case AWN_ORIENTATION_RIGHT:
405 gtk_alignment_set (GTK_ALIGNMENT(self), 1.0, 0.0, 0.5, 1.0);
406 break;
407 default:
408 g_warning ("%s: recieved invalid orient %d",__func__,orient);
409 }
410 awn_ua_alignment_offset_change (object,param_spec,self);
411 awn_ua_alignment_size_change (object,param_spec,self);
412}
413
414static void
415awn_ua_alignment_list_change(GObject *object,GParamSpec *param_spec,gpointer user_data)
416{
417 AwnUAAlignment * self = user_data;
418 gint orient;
419 AwnUAAlignmentPrivate *priv = AWN_UA_ALIGNMENT_GET_PRIVATE (self);
420 GSList * ua_active_list;
421
422 g_object_get ( priv->applet_manager,
423 "orient",&orient,
424 "ua_active_list",&ua_active_list,
425 NULL);
426
427 GSList * search = g_slist_find_custom (ua_active_list,
428 priv->ua_list_entry,
429 (GCompareFunc)g_strcmp0);
430 if (search)
431 {
432 g_debug ("Found... do not need to update %s",priv->ua_list_entry);
433 }
434 else
435 {
436 search = g_slist_find_custom (ua_active_list,priv->ua_list_entry,awn_ua_alignment_list_cmp);
437 if (search)
438 {
439 g_debug ("Moving %s to %s",priv->ua_list_entry,(gchar*)search->data);
440 GStrv tokens;
441 gint pos = -1;
442 g_free (priv->ua_list_entry);
443 priv->ua_list_entry = g_strdup(search->data);
444 tokens = g_strsplit (search->data,"::",2);
445 if (tokens && tokens[1])
446 {
447 pos = atoi (tokens[1]);
448 }
449 g_strfreev (tokens);
450 if (pos != -1)
451 {
452 awn_applet_manager_add_widget(AWN_APPLET_MANAGER(priv->applet_manager),
453 GTK_WIDGET (self),
454 pos);
455 }
456 }
457 else
458 {
459 g_debug ("looks like %s was removed from panel/ua_list",priv->ua_list_entry);
460 /*
461 aantn as expected this does not kill the screenlet. What is the best way to
462 tell it that we want it to go away?
463 */
464 awn_applet_manager_remove_widget(AWN_APPLET_MANAGER(priv->applet_manager),
465 GTK_WIDGET (self));
466 gtk_widget_destroy (GTK_WIDGET(self));
467 }
468 }
469}
0470
=== added file 'src/awn-ua-alignment.h'
--- src/awn-ua-alignment.h 1970-01-01 00:00:00 +0000
+++ src/awn-ua-alignment.h 2009-07-14 02:56:28 +0000
@@ -0,0 +1,68 @@
1/*
2 * Copyright (C) 2009 Rodney Cryderman <rcryderman@gmail.com>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
17 *
18 *
19 */
20
21/* awn-ua-alignment.h */
22
23#ifndef _AWN_UA_ALIGNMENT
24#define _AWN_UA_ALIGNMENT
25
26#include <gtk/gtk.h>
27#include "awn-applet-manager.h"
28
29G_BEGIN_DECLS
30
31#define AWN_TYPE_UA_ALIGNMENT awn_ua_alignment_get_type()
32
33#define AWN_UA_ALIGNMENT(obj) \
34 (G_TYPE_CHECK_INSTANCE_CAST ((obj), AWN_TYPE_UA_ALIGNMENT, AwnUAAlignment))
35
36#define AWN_UA_ALIGNMENT_CLASS(klass) \
37 (G_TYPE_CHECK_CLASS_CAST ((klass), AWN_TYPE_UA_ALIGNMENT, AwnUAAlignmentClass))
38
39#define AWN_IS_UA_ALIGNMENT(obj) \
40 (G_TYPE_CHECK_INSTANCE_TYPE ((obj), AWN_TYPE_UA_ALIGNMENT))
41
42#define AWN_IS_UA_ALIGNMENT_CLASS(klass) \
43 (G_TYPE_CHECK_CLASS_TYPE ((klass), AWN_TYPE_UA_ALIGNMENT))
44
45#define AWN_UA_ALIGNMENT_GET_CLASS(obj) \
46 (G_TYPE_INSTANCE_GET_CLASS ((obj), AWN_TYPE_UA_ALIGNMENT, AwnUAAlignmentClass))
47
48typedef struct {
49 GtkAlignment parent;
50} AwnUAAlignment;
51
52typedef struct {
53 GtkAlignmentClass parent_class;
54} AwnUAAlignmentClass;
55
56GType awn_ua_alignment_get_type (void);
57
58GtkWidget* awn_ua_alignment_new (AwnAppletManager *manager,gchar * ua_list_entry,double ua_ratio);
59
60GtkWidget* awn_ua_alignment_get_socket (AwnUAAlignment *self);
61
62GdkWindow * awn_ua_alignment_add_id (AwnUAAlignment *self, GdkNativeWindow native_window);
63
64gint awn_ua_alignment_list_cmp (gconstpointer a, gconstpointer b);
65
66G_END_DECLS
67
68#endif /* _AWN_UA_ALIGNMENT */

Subscribers

People subscribed via source and target branches

to status/vote changes: