Merge lp:~muktupavels/indicator-applet/port-to-libgnome-panel into lp:indicator-applet

Proposed by Alberts Muktupāvels
Status: Merged
Approved by: Dmitry Shachnev
Approved revision: 443
Merged at revision: 443
Proposed branch: lp:~muktupavels/indicator-applet/port-to-libgnome-panel
Merge into: lp:indicator-applet
Diff against target: 1661 lines (+842/-427)
16 files modified
configure.ac (+7/-6)
data/Makefile.am (+1/-29)
debian/control (+22/-38)
debian/indicator-applet.install (+1/-2)
po/POTFILES.in (+5/-5)
po/POTFILES.skip (+0/-4)
src/Makefile.am (+41/-44)
src/indicator-applet-appmenu.c (+90/-0)
src/indicator-applet-appmenu.h (+31/-0)
src/indicator-applet-complete.c (+96/-0)
src/indicator-applet-complete.h (+31/-0)
src/indicator-applet-session.c (+93/-0)
src/indicator-applet-session.h (+31/-0)
src/indicator-applet.c (+241/-299)
src/indicator-applet.h (+46/-0)
src/indicator-module.c (+106/-0)
To merge this branch: bzr merge lp:~muktupavels/indicator-applet/port-to-libgnome-panel
Reviewer Review Type Date Requested Status
Dmitry Shachnev Pending
Review via email: mp+381003@code.launchpad.net

Commit message

Port applet to libgnome-panel library.

To post a comment you must log in.
443. By Alberts Muktupāvels

Port applet to libgnome-panel library.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'configure.ac'
2--- configure.ac 2020-03-21 22:10:27 +0000
3+++ configure.ac 2020-03-22 12:39:21 +0000
4@@ -3,7 +3,7 @@
5 AC_INIT([indicator-applet], [12.10.1])
6 AC_CONFIG_HEADERS([config.h])
7 AC_CONFIG_MACRO_DIR([m4])
8-AC_CONFIG_SRCDIR([src/applet-main.c])
9+AC_CONFIG_SRCDIR([src/indicator-applet.c])
10
11 AM_INIT_AUTOMAKE
12 AM_MAINTAINER_MODE
13@@ -24,13 +24,14 @@
14
15 GTK_REQUIRED_VERSION=3.1
16 INDICATOR_REQUIRED_VERSION=0.3.92
17-APPLET_PKG=libpanel-applet
18+LIBGNOME_PANEL_REQUIRED=3.36.0
19+APPLET_PKG=libgnome-panel
20 INDICATOR_PKG=indicator3-0.4
21
22 PKG_CHECK_MODULES(APPLET, gtk+-3.0 >= $GTK_REQUIRED_VERSION
23 x11
24 libido3-0.1
25- $APPLET_PKG
26+ $APPLET_PKG >= $LIBGNOME_PANEL_REQUIRED
27 $INDICATOR_PKG >= $INDICATOR_REQUIRED_VERSION)
28 AC_SUBST(APPLET_CFLAGS)
29 AC_SUBST(APPLET_LIBS)
30@@ -47,16 +48,16 @@
31 ###########################
32
33 if test "x$with_localinstall" = "xyes"; then
34- APPLETDIR="${datadir}/gnome-panel/applets/"
35+ MODULESDIR="${libdir}/gnome-panel/modules/"
36 INDICATORDIR="${libdir}/indicators/2/"
37 INDICATORICONSDIR="${datadir}/indicator-applet/icons/"
38 else
39- APPLETDIR=`$PKG_CONFIG --variable=libpanel_applet_dir $APPLET_PKG`
40+ MODULESDIR=`$PKG_CONFIG --variable=modulesdir $APPLET_PKG`
41 INDICATORDIR=`$PKG_CONFIG --variable=indicatordir $INDICATOR_PKG`
42 INDICATORICONSDIR=`$PKG_CONFIG --variable=iconsdir $INDICATOR_PKG`
43 fi
44
45-AC_SUBST(APPLETDIR)
46+AC_SUBST(MODULESDIR)
47 AC_SUBST(INDICATORDIR)
48 AC_SUBST(INDICATORICONSDIR)
49
50
51=== modified file 'data/Makefile.am'
52--- data/Makefile.am 2016-11-13 21:35:44 +0000
53+++ data/Makefile.am 2020-03-22 12:39:21 +0000
54@@ -1,26 +1,6 @@
55 # This file will be processed with automake to create Makefile.in
56
57 ##############################
58-# Applets
59-##############################
60-
61-appletdir = $(APPLETDIR)
62-applet_in_files = \
63- org.ayatana.panel.IndicatorApplet.panel-applet.in \
64- org.ayatana.panel.IndicatorAppletComplete.panel-applet.in \
65- org.ayatana.panel.IndicatorAppletAppmenu.panel-applet.in \
66- org.ayatana.panel.FastUserSwitchApplet.panel-applet.in
67-applet_DATA = $(applet_in_files:.panel-applet.in=.panel-applet)
68-
69-%.panel-applet.in: %.panel-applet.in.in Makefile
70- $(AM_V_GEN)sed \
71- -e "s|\@PKGLIBDIR\@|$(pkglibdir)|" \
72- $< > $@
73-
74-%.panel-applet: %.panel-applet.in $(INTLTOOL_MERGE) $(wildcard $(top_srcdir)/po/*po) ; $(AM_V_GEN) LC_ALL=C $(INTLTOOL_MERGE) $(top_srcdir)/po $< $@ -d -u -c $(top_builddir)/po/.intltool-merge-cache
75-
76-
77-##############################
78 # Icons
79 ##############################
80
81@@ -46,16 +26,8 @@
82 # Autojunk
83 ##############################
84
85-CLEANFILES = \
86- $(applet_in_files) \
87- $(applet_DATA) \
88- *.bak
89-
90 EXTRA_DIST = \
91- $(icons_DATA) \
92- $(applet_in_files:.in=.in.in)
93+ $(icons_DATA)
94
95 MAINTAINERCLEANFILES = \
96 Makefile.in
97-
98-
99
100=== removed file 'data/org.ayatana.panel.FastUserSwitchApplet.panel-applet.in.in'
101=== removed file 'data/org.ayatana.panel.IndicatorApplet.panel-applet.in.in'
102=== removed file 'data/org.ayatana.panel.IndicatorAppletAppmenu.panel-applet.in.in'
103=== removed file 'data/org.ayatana.panel.IndicatorAppletComplete.panel-applet.in.in'
104=== modified file 'debian/control'
105--- debian/control 2020-03-21 23:50:41 +0000
106+++ debian/control 2020-03-22 12:39:21 +0000
107@@ -7,8 +7,8 @@
108 dh-autoreconf,
109 libtool,
110 intltool,
111+ libgnome-panel-dev,
112 libgtk-3-dev,
113- libpanel-applet-dev,
114 libxml2-dev,
115 libindicator3-dev,
116 libido3-0.1-dev (>= 13.10.0),
117@@ -26,9 +26,16 @@
118 Depends: ${shlibs:Depends},
119 ${misc:Depends},
120 python3-xdg,
121-Recommends: indicator-messages,
122+Recommends: indicator-application,
123+ indicator-appmenu,
124+ indicator-bluetooth,
125+ indicator-datetime,
126+ indicator-keyboard,
127+ indicator-messages,
128+ indicator-power,
129+ indicator-printers,
130+ indicator-session,
131 indicator-sound,
132- indicator-application,
133 Provides: indicator-renderer,
134 Description: GNOME panel indicator applet
135 indicator-applet is an applet to display information from
136@@ -39,47 +46,24 @@
137
138 Package: indicator-applet-session
139 Architecture: any
140-Depends: ${shlibs:Depends},
141+Depends: indicator-applet,
142 ${misc:Depends},
143- indicator-applet (= ${binary:Version}),
144-Recommends: indicator-session,
145-Description: Clone of the GNOME panel indicator applet
146- Indicator-applet is an applet to display information from
147- various applications consistently in the GNOME panel.
148- .
149- This instance will only load the session menu which provides
150- status changing, user choosing and session management.
151+Section: oldlibs
152+Description: transitional package
153+ This is a transitional package. It can safely be removed.
154
155 Package: indicator-applet-complete
156 Architecture: any
157-Depends: ${shlibs:Depends},
158+Depends: indicator-applet,
159 ${misc:Depends},
160-Recommends: indicator-application,
161- indicator-bluetooth,
162- indicator-datetime,
163- indicator-keyboard,
164- indicator-messages,
165- indicator-power,
166- indicator-printers,
167- indicator-session,
168- indicator-sound,
169-Provides: indicator-renderer,
170-Description: Clone of the GNOME panel indicator applet
171- Indicator-applet is an applet to display information from
172- various applications consistently in the GNOME panel.
173- .
174- This instance will load all indicators in a single panel
175- applet.
176+Section: oldlibs
177+Description: transitional package
178+ This is a transitional package. It can safely be removed.
179
180 Package: indicator-applet-appmenu
181 Architecture: any
182-Depends: ${shlibs:Depends},
183+Depends: indicator-applet,
184 ${misc:Depends},
185-Recommends: indicator-appmenu,
186-Provides: indicator-renderer,
187-Description: Clone of the GNOME panel indicator applet
188- Indicator-applet is an applet to display information from
189- various applications consistently in the GNOME panel.
190- .
191- This instance will load the appmenu indicator.
192-
193+Section: oldlibs
194+Description: transitional package
195+ This is a transitional package. It can safely be removed.
196
197=== removed file 'debian/indicator-applet-appmenu.install'
198=== removed file 'debian/indicator-applet-complete.install'
199=== removed file 'debian/indicator-applet-session.install'
200=== modified file 'debian/indicator-applet.install'
201--- debian/indicator-applet.install 2016-12-02 11:33:34 +0000
202+++ debian/indicator-applet.install 2020-03-22 12:39:21 +0000
203@@ -1,5 +1,4 @@
204-usr/lib/*/indicator-applet/libindicator-applet.so
205-usr/share/gnome-panel/applets/org.ayatana.panel.IndicatorApplet.panel-applet
206+usr/lib/gnome-panel/modules/org.ayatana.indicator-applet.so
207 usr/share/icons
208 usr/share/locale
209 debian/indicator-applet-crashdb.conf /etc/apport/crashdb.conf.d/
210
211=== modified file 'po/POTFILES.in'
212--- po/POTFILES.in 2010-11-10 18:28:18 +0000
213+++ po/POTFILES.in 2020-03-22 12:39:21 +0000
214@@ -1,6 +1,6 @@
215 [encoding: UTF-8]
216-[type: gettext/keys]data/org.ayatana.panel.IndicatorApplet.panel-applet.in.in
217-[type: gettext/keys]data/org.ayatana.panel.IndicatorAppletComplete.panel-applet.in.in
218-[type: gettext/keys]data/org.ayatana.panel.IndicatorAppletAppmenu.panel-applet.in.in
219-[type: gettext/keys]data/org.ayatana.panel.FastUserSwitchApplet.panel-applet.in.in
220-src/applet-main.c
221+src/indicator-applet.c
222+src/indicator-applet-appmenu.c
223+src/indicator-applet-complete.c
224+src/indicator-applet-session.c
225+src/indicator-module.c
226
227=== modified file 'po/POTFILES.skip'
228--- po/POTFILES.skip 2010-11-10 18:28:18 +0000
229+++ po/POTFILES.skip 2020-03-22 12:39:21 +0000
230@@ -1,4 +0,0 @@
231-data/org.ayatana.panel.IndicatorApplet.panel-applet.in
232-data/org.ayatana.panel.IndicatorAppletComplete.panel-applet.in
233-data/org.ayatana.panel.IndicatorAppletAppmenu.panel-applet.in
234-data/org.ayatana.panel.FastUserSwitchApplet.panel-applet.in
235
236=== modified file 'src/Makefile.am'
237--- src/Makefile.am 2020-03-21 22:10:27 +0000
238+++ src/Makefile.am 2020-03-22 12:39:21 +0000
239@@ -1,47 +1,44 @@
240-indicator_applet_libdir = ${pkglibdir}
241-indicator_applet_lib_LTLIBRARIES = \
242- libindicator-applet.la \
243- libindicator-applet-appmenu.la \
244- libindicator-applet-session.la \
245- libindicator-applet-complete.la
246-
247-APPLET_SOURCES = \
248- applet-main.c \
249+NULL =
250+
251+org_ayatana_indicator_applet_libdir = $(MODULESDIR)
252+org_ayatana_indicator_applet_lib_LTLIBRARIES = org.ayatana.indicator-applet.la
253+
254+org_ayatana_indicator_applet_la_CPPFLAGS = \
255+ -DG_LOG_DOMAIN=\""indicator-applet"\" \
256+ -DG_LOG_USE_STRUCTURED=1 \
257+ -DGDK_DISABLE_DEPRECATED \
258+ -DINDICATOR_DIR=\""$(INDICATORDIR)"\" \
259+ -DINDICATOR_ICONS_DIR=\""$(INDICATORICONSDIR)"\" \
260+ -DLOCALE_DIR=\"$(localedir)\" \
261+ $(AM_CPPFLAGS) \
262+ $(NULL)
263+
264+org_ayatana_indicator_applet_la_CFLAGS = \
265+ $(APPLET_CFLAGS) \
266+ $(AM_CFLAGS) \
267+ $(NULL)
268+
269+org_ayatana_indicator_applet_la_SOURCES = \
270 eggaccelerators.c \
271 eggaccelerators.h \
272+ indicator-applet.c \
273+ indicator-applet.h \
274+ indicator-applet-appmenu.c \
275+ indicator-applet-appmenu.h \
276+ indicator-applet-complete.c \
277+ indicator-applet-complete.h \
278+ indicator-applet-session.c \
279+ indicator-applet-session.h \
280+ indicator-module.c \
281 tomboykeybinder.c \
282- tomboykeybinder.h
283-
284-APPLET_CPPFLAGS = \
285- -DGNOMELOCALEDIR=\""$(localedir)"\" \
286- -DINDICATOR_DIR=\""$(INDICATORDIR)"\" \
287- -DINDICATOR_ICONS_DIR=\""$(INDICATORICONSDIR)"\" \
288- -DGDK_DISABLE_DEPRECATED \
289- -I$(srcdir)/..
290-
291-AM_CFLAGS = $(APPLET_CFLAGS)
292-AM_LDFLAGS = -module -avoid-version
293-
294-libindicator_applet_la_SOURCES = $(APPLET_SOURCES)
295-libindicator_applet_la_CPPFLAGS = $(APPLET_CPPFLAGS) \
296- -DG_LOG_DOMAIN=\""Indicator-Applet"\" \
297- -DINDICATOR_APPLET
298-libindicator_applet_la_LIBADD = $(APPLET_LIBS)
299-
300-libindicator_applet_appmenu_la_SOURCES = $(APPLET_SOURCES)
301-libindicator_applet_appmenu_la_CPPFLAGS = $(APPLET_CPPFLAGS) \
302- -DG_LOG_DOMAIN=\""Indicator-Applet-Appmenu"\" \
303- -DINDICATOR_APPLET_APPMENU
304-libindicator_applet_appmenu_la_LIBADD = $(APPLET_LIBS)
305-
306-libindicator_applet_session_la_SOURCES = $(APPLET_SOURCES)
307-libindicator_applet_session_la_CPPFLAGS = $(APPLET_CPPFLAGS) \
308- -DG_LOG_DOMAIN=\""Indicator-Applet-Session"\" \
309- -DINDICATOR_APPLET_SESSION
310-libindicator_applet_session_la_LIBADD = $(APPLET_LIBS)
311-
312-libindicator_applet_complete_la_SOURCES = $(APPLET_SOURCES)
313-libindicator_applet_complete_la_CPPFLAGS = $(APPLET_CPPFLAGS) \
314- -DG_LOG_DOMAIN=\""Indicator-Applet-Complete"\" \
315- -DINDICATOR_APPLET_COMPLETE
316-libindicator_applet_complete_la_LIBADD = $(APPLET_LIBS)
317+ tomboykeybinder.h \
318+ $(NULL)
319+
320+org_ayatana_indicator_applet_la_LIBADD = \
321+ $(APPLET_LIBS) \
322+ $(NULL)
323+
324+org_ayatana_indicator_applet_la_LDFLAGS = \
325+ -module -avoid-version \
326+ $(AM_LDFLAGS) \
327+ $(NULL)
328
329=== added file 'src/indicator-applet-appmenu.c'
330--- src/indicator-applet-appmenu.c 1970-01-01 00:00:00 +0000
331+++ src/indicator-applet-appmenu.c 2020-03-22 12:39:21 +0000
332@@ -0,0 +1,90 @@
333+/*
334+ * Copyright (C) 2020 Alberts Muktupāvels
335+ *
336+ * This program is free software: you can redistribute it and/or modify
337+ * it under the terms of the GNU General Public License as published by
338+ * the Free Software Foundation, either version 3 of the License, or
339+ * (at your option) any later version.
340+ *
341+ * This program is distributed in the hope that it will be useful,
342+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
343+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
344+ * GNU General Public License for more details.
345+ *
346+ * You should have received a copy of the GNU General Public License
347+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
348+ */
349+
350+#include "config.h"
351+#include "indicator-applet-appmenu.h"
352+
353+#include <glib/gi18n-lib.h>
354+
355+struct _IndicatorAppletAppmenu
356+{
357+ IndicatorApplet parent;
358+};
359+
360+G_DEFINE_TYPE (IndicatorAppletAppmenu,
361+ indicator_applet_appmenu,
362+ INDICATOR_TYPE_APPLET)
363+
364+static const char *
365+indicator_applet_appmenu_get_name (void)
366+{
367+ return _("Indicator Applet Application Menu");
368+}
369+
370+static const char *
371+indicator_applet_appmenu_get_description (void)
372+{
373+ return _("An applet to hold your application menus.");
374+}
375+
376+static const char *
377+indicator_applet_appmenu_get_indicator_env (void)
378+{
379+ return "indicator-applet-appmenu";
380+}
381+
382+static gboolean
383+indicator_applet_appmenu_load_module (const char *name)
384+{
385+ return g_strcmp0 (name, "libappmenu.so") == 0;
386+}
387+
388+static gboolean
389+indicator_applet_appmenu_load_indicator (const char *name)
390+{
391+ return g_strcmp0 (name, "com.canonical.indicator.appmenu") == 0;
392+}
393+
394+static const char *
395+indicator_applet_appmenu_get_hotkey_keycode (void)
396+{
397+ return "<Super>F1";
398+}
399+
400+static void
401+indicator_applet_appmenu_class_init (IndicatorAppletAppmenuClass *self_class)
402+{
403+ IndicatorAppletClass *applet_class;
404+
405+ applet_class = INDICATOR_APPLET_CLASS (self_class);
406+
407+ applet_class->get_name = indicator_applet_appmenu_get_name;
408+ applet_class->get_description = indicator_applet_appmenu_get_description;
409+ applet_class->get_indicator_env = indicator_applet_appmenu_get_indicator_env;
410+ applet_class->load_module = indicator_applet_appmenu_load_module;
411+ applet_class->load_indicator = indicator_applet_appmenu_load_indicator;
412+ applet_class->get_hotkey_keycode = indicator_applet_appmenu_get_hotkey_keycode;
413+}
414+
415+static void
416+indicator_applet_appmenu_init (IndicatorAppletAppmenu *self)
417+{
418+ AtkObject *atk_object;
419+
420+ atk_object = gtk_widget_get_accessible (GTK_WIDGET (self));
421+ atk_object_set_name (atk_object, "indicator-applet-appmenu");
422+}
423
424=== added file 'src/indicator-applet-appmenu.h'
425--- src/indicator-applet-appmenu.h 1970-01-01 00:00:00 +0000
426+++ src/indicator-applet-appmenu.h 2020-03-22 12:39:21 +0000
427@@ -0,0 +1,31 @@
428+/*
429+ * Copyright (C) 2020 Alberts Muktupāvels
430+ *
431+ * This program is free software: you can redistribute it and/or modify
432+ * it under the terms of the GNU General Public License as published by
433+ * the Free Software Foundation, either version 3 of the License, or
434+ * (at your option) any later version.
435+ *
436+ * This program is distributed in the hope that it will be useful,
437+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
438+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
439+ * GNU General Public License for more details.
440+ *
441+ * You should have received a copy of the GNU General Public License
442+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
443+ */
444+
445+#ifndef INDICATOR_APPLET_APPMENU_H
446+#define INDICATOR_APPLET_APPMENU_H
447+
448+#include "indicator-applet.h"
449+
450+G_BEGIN_DECLS
451+
452+#define INDICATOR_TYPE_APPLET_APPMENU (indicator_applet_appmenu_get_type ())
453+G_DECLARE_FINAL_TYPE (IndicatorAppletAppmenu, indicator_applet_appmenu,
454+ INDICATOR, APPLET_APPMENU, IndicatorApplet)
455+
456+G_END_DECLS
457+
458+#endif
459
460=== added file 'src/indicator-applet-complete.c'
461--- src/indicator-applet-complete.c 1970-01-01 00:00:00 +0000
462+++ src/indicator-applet-complete.c 2020-03-22 12:39:21 +0000
463@@ -0,0 +1,96 @@
464+/*
465+ * Copyright (C) 2020 Alberts Muktupāvels
466+ *
467+ * This program is free software: you can redistribute it and/or modify
468+ * it under the terms of the GNU General Public License as published by
469+ * the Free Software Foundation, either version 3 of the License, or
470+ * (at your option) any later version.
471+ *
472+ * This program is distributed in the hope that it will be useful,
473+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
474+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
475+ * GNU General Public License for more details.
476+ *
477+ * You should have received a copy of the GNU General Public License
478+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
479+ */
480+
481+#include "config.h"
482+#include "indicator-applet-complete.h"
483+
484+#include <glib/gi18n-lib.h>
485+
486+struct _IndicatorAppletComplete
487+{
488+ IndicatorApplet parent;
489+};
490+
491+G_DEFINE_TYPE (IndicatorAppletComplete,
492+ indicator_applet_complete,
493+ INDICATOR_TYPE_APPLET)
494+
495+static const char *
496+indicator_applet_complete_get_name (void)
497+{
498+ return _("Indicator Applet Complete");
499+}
500+
501+static const char *
502+indicator_applet_complete_get_description (void)
503+{
504+ return _("An applet to hold all of the system indicators.");
505+}
506+
507+static const char *
508+indicator_applet_complete_get_indicator_env (void)
509+{
510+ return "indicator-applet-complete";
511+}
512+
513+static gboolean
514+indicator_applet_complete_load_module (const char *name)
515+{
516+ if (g_strcmp0 (name, "libappmenu.so") == 0)
517+ return FALSE;
518+
519+ return TRUE;
520+}
521+
522+static gboolean
523+indicator_applet_complete_load_indicator (const char *name)
524+{
525+ if (g_strcmp0 (name, "com.canonical.indicator.appmenu") == 0)
526+ return FALSE;
527+
528+ return TRUE;
529+}
530+
531+static const char *
532+indicator_applet_complete_get_hotkey_keycode (void)
533+{
534+ return "<Super>S";
535+}
536+
537+static void
538+indicator_applet_complete_class_init (IndicatorAppletCompleteClass *self_class)
539+{
540+ IndicatorAppletClass *applet_class;
541+
542+ applet_class = INDICATOR_APPLET_CLASS (self_class);
543+
544+ applet_class->get_name = indicator_applet_complete_get_name;
545+ applet_class->get_description = indicator_applet_complete_get_description;
546+ applet_class->get_indicator_env = indicator_applet_complete_get_indicator_env;
547+ applet_class->load_module = indicator_applet_complete_load_module;
548+ applet_class->load_indicator = indicator_applet_complete_load_indicator;
549+ applet_class->get_hotkey_keycode = indicator_applet_complete_get_hotkey_keycode;
550+}
551+
552+static void
553+indicator_applet_complete_init (IndicatorAppletComplete *self)
554+{
555+ AtkObject *atk_object;
556+
557+ atk_object = gtk_widget_get_accessible (GTK_WIDGET (self));
558+ atk_object_set_name (atk_object, "indicator-applet-complete");
559+}
560
561=== added file 'src/indicator-applet-complete.h'
562--- src/indicator-applet-complete.h 1970-01-01 00:00:00 +0000
563+++ src/indicator-applet-complete.h 2020-03-22 12:39:21 +0000
564@@ -0,0 +1,31 @@
565+/*
566+ * Copyright (C) 2020 Alberts Muktupāvels
567+ *
568+ * This program is free software: you can redistribute it and/or modify
569+ * it under the terms of the GNU General Public License as published by
570+ * the Free Software Foundation, either version 3 of the License, or
571+ * (at your option) any later version.
572+ *
573+ * This program is distributed in the hope that it will be useful,
574+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
575+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
576+ * GNU General Public License for more details.
577+ *
578+ * You should have received a copy of the GNU General Public License
579+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
580+ */
581+
582+#ifndef INDICATOR_APPLET_COMPLETE_H
583+#define INDICATOR_APPLET_COMPLETE_H
584+
585+#include "indicator-applet.h"
586+
587+G_BEGIN_DECLS
588+
589+#define INDICATOR_TYPE_APPLET_COMPLETE (indicator_applet_complete_get_type ())
590+G_DECLARE_FINAL_TYPE (IndicatorAppletComplete, indicator_applet_complete,
591+ INDICATOR, APPLET_COMPLETE, IndicatorApplet)
592+
593+G_END_DECLS
594+
595+#endif
596
597=== added file 'src/indicator-applet-session.c'
598--- src/indicator-applet-session.c 1970-01-01 00:00:00 +0000
599+++ src/indicator-applet-session.c 2020-03-22 12:39:21 +0000
600@@ -0,0 +1,93 @@
601+/*
602+ * Copyright (C) 2020 Alberts Muktupāvels
603+ *
604+ * This program is free software: you can redistribute it and/or modify
605+ * it under the terms of the GNU General Public License as published by
606+ * the Free Software Foundation, either version 3 of the License, or
607+ * (at your option) any later version.
608+ *
609+ * This program is distributed in the hope that it will be useful,
610+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
611+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
612+ * GNU General Public License for more details.
613+ *
614+ * You should have received a copy of the GNU General Public License
615+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
616+ */
617+
618+#include "config.h"
619+#include "indicator-applet-session.h"
620+
621+#include <glib/gi18n-lib.h>
622+
623+struct _IndicatorAppletSession
624+{
625+ IndicatorApplet parent;
626+};
627+
628+G_DEFINE_TYPE (IndicatorAppletSession,
629+ indicator_applet_session,
630+ INDICATOR_TYPE_APPLET)
631+
632+static const char *
633+indicator_applet_session_get_name (void)
634+{
635+ return _("Indicator Applet Session");
636+}
637+
638+static const char *
639+indicator_applet_session_get_description (void)
640+{
641+ return _("A place to adjust your status, change users or exit your session.");
642+}
643+
644+static const char *
645+indicator_applet_session_get_indicator_env (void)
646+{
647+ return "indicator-applet-session";
648+}
649+
650+static gboolean
651+indicator_applet_session_load_module (const char *name)
652+{
653+ return g_strcmp0 (name, "libsession.so") == 0 ||
654+ g_strcmp0 (name, "libme.so") == 0;
655+}
656+
657+static gboolean
658+indicator_applet_session_load_indicator (const char *name)
659+{
660+ return g_strcmp0 (name, "com.canonical.indicator.session") == 0 ||
661+ g_strcmp0 (name, "com.canonical.indicator.me") == 0;
662+}
663+
664+static const char *
665+indicator_applet_session_get_hotkey_keycode (void)
666+{
667+ return "<Super>S";
668+}
669+
670+static void
671+indicator_applet_session_class_init (IndicatorAppletSessionClass *self_class)
672+{
673+ IndicatorAppletClass *applet_class;
674+
675+ applet_class = INDICATOR_APPLET_CLASS (self_class);
676+
677+ applet_class->get_name = indicator_applet_session_get_name;
678+ applet_class->get_description = indicator_applet_session_get_description;
679+ applet_class->get_indicator_env = indicator_applet_session_get_indicator_env;
680+ applet_class->load_module = indicator_applet_session_load_module;
681+ applet_class->load_indicator = indicator_applet_session_load_indicator;
682+
683+ applet_class->get_hotkey_keycode = indicator_applet_session_get_hotkey_keycode;
684+}
685+
686+static void
687+indicator_applet_session_init (IndicatorAppletSession *self)
688+{
689+ AtkObject *atk_object;
690+
691+ atk_object = gtk_widget_get_accessible (GTK_WIDGET (self));
692+ atk_object_set_name (atk_object, "indicator-applet-session");
693+}
694
695=== added file 'src/indicator-applet-session.h'
696--- src/indicator-applet-session.h 1970-01-01 00:00:00 +0000
697+++ src/indicator-applet-session.h 2020-03-22 12:39:21 +0000
698@@ -0,0 +1,31 @@
699+/*
700+ * Copyright (C) 2020 Alberts Muktupāvels
701+ *
702+ * This program is free software: you can redistribute it and/or modify
703+ * it under the terms of the GNU General Public License as published by
704+ * the Free Software Foundation, either version 3 of the License, or
705+ * (at your option) any later version.
706+ *
707+ * This program is distributed in the hope that it will be useful,
708+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
709+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
710+ * GNU General Public License for more details.
711+ *
712+ * You should have received a copy of the GNU General Public License
713+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
714+ */
715+
716+#ifndef INDICATOR_APPLET_SESSION_H
717+#define INDICATOR_APPLET_SESSION_H
718+
719+#include "indicator-applet.h"
720+
721+G_BEGIN_DECLS
722+
723+#define INDICATOR_TYPE_APPLET_SESSION (indicator_applet_session_get_type ())
724+G_DECLARE_FINAL_TYPE (IndicatorAppletSession, indicator_applet_session,
725+ INDICATOR, APPLET_SESSION, IndicatorApplet)
726+
727+G_END_DECLS
728+
729+#endif
730
731=== renamed file 'src/applet-main.c' => 'src/indicator-applet.c'
732--- src/applet-main.c 2020-03-21 13:45:56 +0000
733+++ src/indicator-applet.c 2020-03-22 12:39:21 +0000
734@@ -20,11 +20,13 @@
735 with this program. If not, see <http://www.gnu.org/licenses/>.
736 */
737
738+#include "config.h"
739+#include "indicator-applet.h"
740+
741 #include <stdlib.h>
742 #include <string.h>
743 #include <config.h>
744 #include <glib/gi18n.h>
745-#include <panel-applet.h>
746 #include <gdk/gdkkeysyms.h>
747
748 #include <libido/libido.h>
749@@ -46,9 +48,6 @@
750 {NULL, NULL}
751 };
752
753-static GtkPackDirection packdirection;
754-static PanelAppletOrient orient;
755-
756 #define MENU_DATA_BOX "box"
757 #define MENU_DATA_INDICATOR_OBJECT "indicator-object"
758 #define MENU_DATA_INDICATOR_ENTRY "indicator-entry"
759@@ -59,89 +58,14 @@
760 #define IO_DATA_ORDER_NUMBER "indicator-order-number"
761 #define IO_DATA_MENUITEM_LOOKUP "indicator-menuitem-lookup"
762
763-static gboolean applet_fill_cb (PanelApplet * applet, const gchar * iid, gpointer data);
764-
765 static void update_accessible_desc (IndicatorObjectEntry * entry, GtkWidget * menuitem);
766
767-/*************
768- * main
769- * ***********/
770-
771-#ifdef INDICATOR_APPLET
772-PANEL_APPLET_IN_PROCESS_FACTORY ("IndicatorAppletFactory",
773- PANEL_TYPE_APPLET,
774- applet_fill_cb, NULL);
775-#endif
776-#ifdef INDICATOR_APPLET_SESSION
777-PANEL_APPLET_IN_PROCESS_FACTORY ("FastUserSwitchAppletFactory",
778- PANEL_TYPE_APPLET,
779- applet_fill_cb, NULL);
780-#endif
781-#ifdef INDICATOR_APPLET_COMPLETE
782-PANEL_APPLET_IN_PROCESS_FACTORY ("IndicatorAppletCompleteFactory",
783- PANEL_TYPE_APPLET,
784- applet_fill_cb, NULL);
785-#endif
786-#ifdef INDICATOR_APPLET_APPMENU
787-PANEL_APPLET_IN_PROCESS_FACTORY ("IndicatorAppletAppmenuFactory",
788- PANEL_TYPE_APPLET,
789- applet_fill_cb, NULL);
790-#endif
791-
792-/*************
793- * log files
794- * ***********/
795-#ifdef INDICATOR_APPLET
796-#define LOG_FILE_NAME "indicator-applet.log"
797-#endif
798-#ifdef INDICATOR_APPLET_SESSION
799-#define LOG_FILE_NAME "indicator-applet-session.log"
800-#endif
801-#ifdef INDICATOR_APPLET_COMPLETE
802-#define LOG_FILE_NAME "indicator-applet-complete.log"
803-#endif
804-#ifdef INDICATOR_APPLET_APPMENU
805-#define LOG_FILE_NAME "indicator-applet-appmenu.log"
806-#endif
807-static FILE *log_file = NULL;
808-
809-/*****************
810- * Hotkey support
811- * **************/
812-#ifdef INDICATOR_APPLET
813-gchar * hotkey_keycode = "<Super>M";
814-#endif
815-#ifdef INDICATOR_APPLET_SESSION
816-gchar * hotkey_keycode = "<Super>S";
817-#endif
818-#ifdef INDICATOR_APPLET_COMPLETE
819-gchar * hotkey_keycode = "<Super>S";
820-#endif
821-#ifdef INDICATOR_APPLET_APPMENU
822-gchar * hotkey_keycode = "<Super>F1";
823-#endif
824-
825-/********************
826- * Environment Names
827- * *******************/
828-#ifdef INDICATOR_APPLET
829-#define INDICATOR_SPECIFIC_ENV "indicator-applet-original"
830-#endif
831-#ifdef INDICATOR_APPLET_SESSION
832-#define INDICATOR_SPECIFIC_ENV "indicator-applet-session"
833-#endif
834-#ifdef INDICATOR_APPLET_COMPLETE
835-#define INDICATOR_SPECIFIC_ENV "indicator-applet-complete"
836-#endif
837-#ifdef INDICATOR_APPLET_APPMENU
838-#define INDICATOR_SPECIFIC_ENV "indicator-applet-appmenu"
839-#endif
840-
841-static const gchar * indicator_env[] = {
842- "indicator-applet",
843- INDICATOR_SPECIFIC_ENV,
844- NULL
845-};
846+typedef struct
847+{
848+ GtkWidget *menubar;
849+} IndicatorAppletPrivate;
850+
851+G_DEFINE_TYPE_WITH_PRIVATE (IndicatorApplet, indicator_applet, GP_TYPE_APPLET)
852
853 static gint
854 name2order (const gchar * name, const gchar * hint) {
855@@ -364,16 +288,34 @@
856 return;
857 }
858
859+static float
860+get_label_angle (IndicatorApplet *self)
861+{
862+ GtkPositionType position;
863+
864+ position = gp_applet_get_position (GP_APPLET (self));
865+
866+ if (position == GTK_POS_RIGHT)
867+ return 270.0;
868+ else if (position == GTK_POS_LEFT)
869+ return 90.0;
870+
871+ return 0.0;
872+}
873+
874 static GtkWidget*
875-create_menuitem (IndicatorObject * io, IndicatorObjectEntry * entry, GtkWidget * menubar)
876+create_menuitem (IndicatorObject *io,
877+ IndicatorObjectEntry *entry,
878+ IndicatorApplet *self)
879 {
880+ IndicatorAppletPrivate *priv;
881 GtkWidget * box;
882 GtkWidget * menuitem;
883
884+ priv = indicator_applet_get_instance_private (self);
885+
886 menuitem = gtk_menu_item_new();
887- box = (packdirection == GTK_PACK_DIRECTION_LTR)
888- ? gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 3)
889- : gtk_box_new (GTK_ORIENTATION_VERTICAL, 3);
890+ box = gtk_box_new (gp_applet_get_orientation (GP_APPLET (self)), 3);
891
892 gtk_widget_add_events(GTK_WIDGET(menuitem), GDK_SCROLL_MASK);
893
894@@ -392,18 +334,8 @@
895 gtk_box_pack_start(GTK_BOX(box), GTK_WIDGET(entry->image), FALSE, FALSE, 1);
896 }
897 if (entry->label != NULL) {
898- switch(packdirection) {
899- case GTK_PACK_DIRECTION_LTR:
900- gtk_label_set_angle(GTK_LABEL(entry->label), 0.0);
901- break;
902- case GTK_PACK_DIRECTION_TTB:
903- gtk_label_set_angle(GTK_LABEL(entry->label),
904- (orient == PANEL_APPLET_ORIENT_LEFT) ?
905- 270.0 : 90.0);
906- break;
907- default:
908- break;
909- }
910+ gtk_label_set_angle (GTK_LABEL (entry->label), get_label_angle (self));
911+
912 /* gtk_box_pack requires that the widget has no parent */
913 gtk_widget_unparent(GTK_WIDGET(entry->label));
914 gtk_box_pack_start(GTK_BOX(box), GTK_WIDGET(entry->label), FALSE, FALSE, 1);
915@@ -415,13 +347,15 @@
916 gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), GTK_WIDGET(entry->menu));
917 }
918
919- place_in_menu(menubar, menuitem, io, entry);
920+ place_in_menu (priv->menubar, menuitem, io, entry);
921
922 return menuitem;
923 }
924
925 static void
926-entry_added (IndicatorObject * io, IndicatorObjectEntry * entry, GtkWidget * menubar)
927+entry_added (IndicatorObject *io,
928+ IndicatorObjectEntry *entry,
929+ IndicatorApplet *self)
930 {
931 const gchar * name;
932 GtkWidget * menuitem;
933@@ -437,7 +371,7 @@
934 g_return_if_fail (menuitem_lookup != NULL);
935 menuitem = g_hash_table_lookup (menuitem_lookup, entry);
936 if (menuitem == NULL) {
937- menuitem = create_menuitem (io, entry, menubar);
938+ menuitem = create_menuitem (io, entry, self);
939 g_hash_table_insert (menuitem_lookup, entry, menuitem);
940 }
941
942@@ -606,12 +540,23 @@
943 return;
944 }
945
946-static void load_indicator(GtkWidget * menubar, IndicatorObject *object, const gchar *name) {
947+static void
948+load_indicator (IndicatorApplet *self,
949+ IndicatorObject *object,
950+ const char *name)
951+{
952+ IndicatorAppletPrivate *priv;
953 GObject * o;
954 GList *entries, *entry;
955
956+ priv = indicator_applet_get_instance_private (self);
957+
958 /* Set the environment it's in */
959- indicator_object_set_environment(object, (GStrv)indicator_env);
960+ indicator_object_set_environment (object, (GStrv) (const char * const[]) {
961+ "indicator-applet",
962+ INDICATOR_APPLET_GET_CLASS (self)->get_indicator_env (),
963+ NULL
964+ });
965
966 /* Attach the 'name' to the object */
967 o = G_OBJECT (object);
968@@ -626,25 +571,26 @@
969 g_object_set_data(o, IO_DATA_ORDER_NUMBER, GINT_TO_POINTER(pos));
970
971 /* Connect to its signals */
972- g_signal_connect(o, INDICATOR_OBJECT_SIGNAL_ENTRY_ADDED, G_CALLBACK(entry_added), menubar);
973- g_signal_connect(o, INDICATOR_OBJECT_SIGNAL_ENTRY_REMOVED, G_CALLBACK(entry_removed), menubar);
974- g_signal_connect(o, INDICATOR_OBJECT_SIGNAL_ENTRY_MOVED, G_CALLBACK(entry_moved), menubar);
975- g_signal_connect(o, INDICATOR_OBJECT_SIGNAL_MENU_SHOW, G_CALLBACK(menu_show), menubar);
976- g_signal_connect(o, INDICATOR_OBJECT_SIGNAL_ACCESSIBLE_DESC_UPDATE, G_CALLBACK(accessible_desc_update), menubar);
977+ g_signal_connect (o, INDICATOR_OBJECT_SIGNAL_ENTRY_ADDED, G_CALLBACK (entry_added), self);
978+ g_signal_connect (o, INDICATOR_OBJECT_SIGNAL_ENTRY_REMOVED, G_CALLBACK (entry_removed), priv->menubar);
979+ g_signal_connect (o, INDICATOR_OBJECT_SIGNAL_ENTRY_MOVED, G_CALLBACK (entry_moved), priv->menubar);
980+ g_signal_connect (o, INDICATOR_OBJECT_SIGNAL_MENU_SHOW, G_CALLBACK (menu_show), priv->menubar);
981+ g_signal_connect (o, INDICATOR_OBJECT_SIGNAL_ACCESSIBLE_DESC_UPDATE, G_CALLBACK (accessible_desc_update), priv->menubar);
982
983 /* Work on the entries */
984 entries = indicator_object_get_entries(object);
985
986 for (entry = entries; entry != NULL; entry = g_list_next(entry)) {
987 IndicatorObjectEntry * entrydata = (IndicatorObjectEntry *) entry->data;
988- entry_added(object, entrydata, menubar);
989+ entry_added (object, entrydata, self);
990 }
991
992 g_list_free(entries);
993 }
994
995 static gboolean
996-load_module (const gchar * name, GtkWidget * menubar)
997+load_module (const char *name,
998+ IndicatorApplet *self)
999 {
1000
1001 g_debug("Looking at Module: %s", name);
1002@@ -661,48 +607,25 @@
1003 IndicatorObject * io = indicator_object_new_from_file(fullpath);
1004 g_free(fullpath);
1005
1006- load_indicator(menubar, io, name);
1007+ load_indicator (self, io, name);
1008
1009 return TRUE;
1010 }
1011
1012-static void load_modules(GtkWidget *menubar, gint *indicators_loaded) {
1013+static void
1014+load_modules (IndicatorApplet *self,
1015+ int *indicators_loaded)
1016+{
1017 if (g_file_test(INDICATOR_DIR, (G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR))) {
1018 GDir * dir = g_dir_open(INDICATOR_DIR, 0, NULL);
1019
1020 const gchar * name;
1021 gint count = 0;
1022 while ((name = g_dir_read_name(dir)) != NULL) {
1023-
1024- #ifdef INDICATOR_APPLET_APPMENU
1025- if (g_strcmp0(name, "libappmenu.so")) {
1026- continue;
1027- }
1028- #else
1029- if (!g_strcmp0(name, "libappmenu.so")) {
1030- continue;
1031- }
1032- #endif
1033-
1034- #ifdef INDICATOR_APPLET
1035- if (!g_strcmp0(name, "libsession.so")) {
1036- continue;
1037- }
1038- if (!g_strcmp0(name, "libme.so")) {
1039- continue;
1040- }
1041- if (!g_strcmp0(name, "libdatetime.so")) {
1042- continue;
1043- }
1044- #endif
1045-
1046- #ifdef INDICATOR_APPLET_SESSION
1047- if (g_strcmp0(name, "libsession.so") && g_strcmp0(name, "libme.so")) {
1048- continue;
1049- }
1050- #endif
1051+ if (!INDICATOR_APPLET_GET_CLASS (self)->load_module (name))
1052+ continue;
1053
1054- if (load_module(name, menubar)) {
1055+ if (load_module (name, self)) {
1056 count++;
1057 }
1058 }
1059@@ -715,7 +638,10 @@
1060
1061 #define INDICATOR_SERVICE_DIR "/usr/share/unity/indicators"
1062
1063-static void load_indicators_from_indicator_files(GtkWidget *menubar, gint *indicators_loaded) {
1064+static void
1065+load_indicators_from_indicator_files (IndicatorApplet *self,
1066+ int *indicators_loaded)
1067+{
1068 GDir *dir;
1069 const gchar *name;
1070 GError *error = NULL;
1071@@ -738,37 +664,12 @@
1072 indicator = indicator_ng_new_for_profile (filename, "desktop", &error);
1073 g_free (filename);
1074
1075- #ifdef INDICATOR_APPLET_APPMENU
1076- if (g_strcmp0(name, "com.canonical.indicator.appmenu")) {
1077- continue;
1078- }
1079- #else
1080- if (!g_strcmp0(name, "com.canonical.indicator.appmenu")) {
1081- continue;
1082- }
1083- #endif
1084-
1085- #ifdef INDICATOR_APPLET
1086- if (!g_strcmp0(name, "com.canonical.indicator.session")) {
1087- continue;
1088- }
1089- if (!g_strcmp0(name, "com.canonical.indicator.me")) {
1090- continue;
1091- }
1092- if (!g_strcmp0(name, "com.canonical.indicator.datetime")) {
1093- continue;
1094- }
1095- #endif
1096-
1097- #ifdef INDICATOR_APPLET_SESSION
1098- if (g_strcmp0(name, "com.canonical.indicator.session") && g_strcmp0(name, "com.canonical.indicator.me")) {
1099- continue;
1100- }
1101- #endif
1102+ if (!INDICATOR_APPLET_GET_CLASS (self)->load_indicator (name))
1103+ continue;
1104
1105 if (indicator) {
1106 g_debug ("loading indicator: %s", name);
1107- load_indicator(menubar,INDICATOR_OBJECT (indicator), name);
1108+ load_indicator (self, INDICATOR_OBJECT (indicator), name);
1109 count++;
1110 }else{
1111 g_warning ("unable to load '%s': %s", name, error->message);
1112@@ -815,8 +716,9 @@
1113 static void
1114 about_cb (GSimpleAction *action G_GNUC_UNUSED,
1115 GVariant *parameter G_GNUC_UNUSED,
1116- gpointer data G_GNUC_UNUSED)
1117+ gpointer data)
1118 {
1119+ IndicatorApplet *self;
1120 static const gchar *authors[] = {
1121 "Ted Gould <ted@canonical.com>",
1122 NULL
1123@@ -836,31 +738,15 @@
1124 };
1125 gchar *license_i18n;
1126
1127+ self = INDICATOR_APPLET (data);
1128+
1129 license_i18n = g_strconcat (_(license[0]), "\n\n", _(license[1]), "\n\n", _(license[2]), NULL);
1130
1131 gtk_show_about_dialog(NULL,
1132-#ifdef INDICATOR_APPLET
1133- "program-name", _("Indicator Applet"),
1134-#endif
1135-#ifdef INDICATOR_APPLET_SESSION
1136- "program-name", _("Indicator Applet Session"),
1137-#endif
1138-#ifdef INDICATOR_APPLET_COMPLETE
1139- "program-name", _("Indicator Applet Complete"),
1140-#endif
1141-#ifdef INDICATOR_APPLET_APPMENU
1142- "program-name", _("Indicator Applet Application Menu"),
1143-#endif
1144+ "program-name", INDICATOR_APPLET_GET_CLASS (self)->get_name (),
1145 "version", VERSION,
1146 "copyright", "Copyright \xc2\xa9 2009-2010 Canonical, Ltd.",
1147-#ifdef INDICATOR_APPLET_SESSION
1148- "comments", _("A place to adjust your status, change users or exit your session."),
1149-#else
1150-#ifdef INDICATOR_APPLET_APPMENU
1151- "comments", _("An applet to hold your application menus."),
1152-#endif
1153- "comments", _("An applet to hold all of the system indicators."),
1154-#endif
1155+ "comments", INDICATOR_APPLET_GET_CLASS (self)->get_description (),
1156 "authors", authors,
1157 "license", license_i18n,
1158 "wrap-license", TRUE,
1159@@ -877,70 +763,62 @@
1160 return;
1161 }
1162
1163-static gboolean
1164+typedef struct
1165+{
1166+ GtkWidget *from;
1167+ IndicatorApplet *self;
1168+} SwapData;
1169+
1170+static void
1171 swap_orient_cb (GtkWidget *item, gpointer data)
1172 {
1173- GtkWidget *from = (GtkWidget *) data;
1174+ SwapData *swap_data = data;
1175+ GtkWidget *from = swap_data->from;
1176 GtkWidget *to = (GtkWidget *) g_object_get_data(G_OBJECT(from), "to");
1177 g_object_ref(G_OBJECT(item));
1178 gtk_container_remove(GTK_CONTAINER(from), item);
1179 if (GTK_IS_LABEL(item)) {
1180- switch(packdirection) {
1181- case GTK_PACK_DIRECTION_LTR:
1182- gtk_label_set_angle(GTK_LABEL(item), 0.0);
1183- break;
1184- case GTK_PACK_DIRECTION_TTB:
1185- gtk_label_set_angle(GTK_LABEL(item),
1186- (orient == PANEL_APPLET_ORIENT_LEFT) ?
1187- 270.0 : 90.0);
1188- break;
1189- default:
1190- break;
1191- }
1192+ gtk_label_set_angle(GTK_LABEL(item), get_label_angle (swap_data->self));
1193 }
1194 gtk_box_pack_start(GTK_BOX(to), item, FALSE, FALSE, 0);
1195- return TRUE;
1196 }
1197
1198-static gboolean
1199+static void
1200 reorient_box_cb (GtkWidget *menuitem, gpointer data)
1201 {
1202+ SwapData swap_data;
1203 GtkWidget *from = g_object_get_data(G_OBJECT(menuitem), MENU_DATA_BOX);
1204- GtkWidget *to = (packdirection == GTK_PACK_DIRECTION_LTR) ?
1205- gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0) : gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
1206+ GtkWidget *to = gtk_box_new (gp_applet_get_orientation (GP_APPLET (data)), 0);
1207 g_object_set_data(G_OBJECT(from), "to", to);
1208+
1209+ swap_data.from = from;
1210+ swap_data.self = data;
1211+
1212 gtk_container_foreach(GTK_CONTAINER(from), (GtkCallback)swap_orient_cb,
1213- from);
1214+ &swap_data);
1215+
1216 gtk_container_remove(GTK_CONTAINER(menuitem), from);
1217 gtk_container_add(GTK_CONTAINER(menuitem), to);
1218 g_object_set_data(G_OBJECT(menuitem), MENU_DATA_BOX, to);
1219 gtk_widget_show_all(menuitem);
1220- return TRUE;
1221 }
1222
1223-static gboolean
1224-panelapplet_reorient_cb (GtkWidget *applet, PanelAppletOrient neworient,
1225- gpointer data)
1226+static void
1227+placement_changed_cb (GpApplet *applet,
1228+ GtkOrientation orientation,
1229+ GtkPositionType position,
1230+ IndicatorApplet *self)
1231 {
1232- GtkWidget *menubar = (GtkWidget *)data;
1233- if ((((neworient == PANEL_APPLET_ORIENT_UP) ||
1234- (neworient == PANEL_APPLET_ORIENT_DOWN)) &&
1235- ((orient == PANEL_APPLET_ORIENT_LEFT) ||
1236- (orient == PANEL_APPLET_ORIENT_RIGHT))) ||
1237- (((neworient == PANEL_APPLET_ORIENT_LEFT) ||
1238- (neworient == PANEL_APPLET_ORIENT_RIGHT)) &&
1239- ((orient == PANEL_APPLET_ORIENT_UP) ||
1240- (orient == PANEL_APPLET_ORIENT_DOWN)))) {
1241- packdirection = (packdirection == GTK_PACK_DIRECTION_LTR) ?
1242- GTK_PACK_DIRECTION_TTB : GTK_PACK_DIRECTION_LTR;
1243- gtk_menu_bar_set_pack_direction(GTK_MENU_BAR(menubar),
1244- packdirection);
1245- orient = neworient;
1246- gtk_container_foreach(GTK_CONTAINER(menubar),
1247- (GtkCallback)reorient_box_cb, NULL);
1248- }
1249- orient = neworient;
1250- return FALSE;
1251+ IndicatorAppletPrivate *priv;
1252+ GtkPackDirection packdirection;
1253+
1254+ priv = indicator_applet_get_instance_private (self);
1255+
1256+ packdirection = (orientation == GTK_ORIENTATION_VERTICAL) ?
1257+ GTK_PACK_DIRECTION_TTB : GTK_PACK_DIRECTION_LTR;
1258+
1259+ gtk_menu_bar_set_pack_direction (GTK_MENU_BAR (priv->menubar), packdirection);
1260+ gtk_container_foreach (GTK_CONTAINER (priv->menubar), reorient_box_cb, self);
1261 }
1262
1263 #ifdef N_
1264@@ -948,35 +826,37 @@
1265 #endif
1266 #define N_(x) x
1267
1268-static gboolean
1269-applet_fill_cb (PanelApplet * applet, const gchar * iid G_GNUC_UNUSED,
1270- gpointer data G_GNUC_UNUSED)
1271+static void
1272+indicator_applet_setup (IndicatorApplet *self)
1273 {
1274 ido_init();
1275
1276 static const GActionEntry menu_actions[] = {
1277- {"about", about_cb }
1278+ {"about", about_cb },
1279+ { NULL }
1280 };
1281 static const gchar *menu_xml = ""
1282+ "<interface>"
1283+ "<menu id=\"indicator-applet-menu\">"
1284 "<section>"
1285 "<item>"
1286 "<attribute name=\"label\" translatable=\"yes\">_About</attribute>"
1287 "<attribute name=\"action\">indicator-applet.about</attribute>"
1288 "</item>"
1289- "</section>";
1290+ "</section>"
1291+ "</menu>"
1292+ "</interface>";
1293
1294 static gboolean first_time = FALSE;
1295- GtkWidget *menubar;
1296 gint indicators_loaded = 0;
1297- GSimpleActionGroup *action_group;
1298+ IndicatorAppletPrivate *priv;
1299+ GpApplet *applet;
1300+ GtkOrientation orientation;
1301+ GtkPackDirection packdirection;
1302+ const char *hotkey_keycode;
1303
1304-#ifdef INDICATOR_APPLET_SESSION
1305- /* check if we are running stracciatella session */
1306- if (g_strcmp0(g_getenv("GDMSESSION"), "gnome-stracciatella") == 0) {
1307- g_debug("Running stracciatella GNOME session, disabling myself");
1308- return TRUE;
1309- }
1310-#endif
1311+ priv = indicator_applet_get_instance_private (self);
1312+ applet = GP_APPLET (self);
1313
1314 if (!first_time)
1315 {
1316@@ -987,60 +867,31 @@
1317
1318 /* Set panel options */
1319 gtk_container_set_border_width(GTK_CONTAINER (applet), 0);
1320- panel_applet_set_flags(applet, PANEL_APPLET_EXPAND_MINOR);
1321- menubar = gtk_menu_bar_new();
1322-
1323- action_group = g_simple_action_group_new ();
1324- g_action_map_add_action_entries (G_ACTION_MAP (action_group), menu_actions,
1325- G_N_ELEMENTS (menu_actions), menubar);
1326- panel_applet_setup_menu(applet, menu_xml, action_group, GETTEXT_PACKAGE);
1327- gtk_widget_insert_action_group (GTK_WIDGET (applet), "indicator-applet", G_ACTION_GROUP (action_group));
1328- g_object_unref(action_group);
1329-
1330-#ifdef INDICATOR_APPLET
1331- atk_object_set_name (gtk_widget_get_accessible (GTK_WIDGET (applet)),
1332- "indicator-applet");
1333-#endif
1334-#ifdef INDICATOR_APPLET_SESSION
1335- atk_object_set_name (gtk_widget_get_accessible (GTK_WIDGET (applet)),
1336- "indicator-applet-session");
1337-#endif
1338-#ifdef INDICATOR_APPLET_COMPLETE
1339- atk_object_set_name (gtk_widget_get_accessible (GTK_WIDGET (applet)),
1340- "indicator-applet-complete");
1341-#endif
1342-#ifdef INDICATOR_APPLET_APPMENU
1343- atk_object_set_name (gtk_widget_get_accessible (GTK_WIDGET (applet)),
1344- "indicator-applet-appmenu");
1345-#endif
1346-
1347- /* Init some theme/icon stuff */
1348- gtk_icon_theme_append_search_path(gtk_icon_theme_get_default(),
1349- INDICATOR_ICONS_DIR);
1350- g_debug("Icons directory: %s", INDICATOR_ICONS_DIR);
1351+ gp_applet_set_flags (applet, GP_APPLET_FLAGS_EXPAND_MINOR);
1352+ priv->menubar = gtk_menu_bar_new ();
1353+
1354+ gp_applet_setup_menu (applet, menu_xml, menu_actions);
1355
1356 gtk_widget_set_name(GTK_WIDGET (applet), "fast-user-switch-applet");
1357
1358 /* Build menubar */
1359- orient = (panel_applet_get_orient(applet));
1360- packdirection = ((orient == PANEL_APPLET_ORIENT_UP) ||
1361- (orient == PANEL_APPLET_ORIENT_DOWN)) ?
1362+ orientation = gp_applet_get_orientation (applet);
1363+ packdirection = (orientation == GTK_ORIENTATION_HORIZONTAL) ?
1364 GTK_PACK_DIRECTION_LTR : GTK_PACK_DIRECTION_TTB;
1365- gtk_menu_bar_set_pack_direction(GTK_MENU_BAR(menubar),
1366- packdirection);
1367- gtk_widget_set_can_focus (GTK_WIDGET (menubar), TRUE);
1368- gtk_widget_set_name(GTK_WIDGET (menubar), "fast-user-switch-menubar");
1369- g_signal_connect(menubar, "button-press-event", G_CALLBACK(menubar_press), NULL);
1370- g_signal_connect(applet, "change-orient",
1371- G_CALLBACK(panelapplet_reorient_cb), menubar);
1372- gtk_container_set_border_width(GTK_CONTAINER(menubar), 0);
1373+ gtk_menu_bar_set_pack_direction (GTK_MENU_BAR (priv->menubar), packdirection);
1374+ gtk_widget_set_can_focus (GTK_WIDGET (priv->menubar), TRUE);
1375+ gtk_widget_set_name (GTK_WIDGET (priv->menubar), "fast-user-switch-menubar");
1376+ g_signal_connect (priv->menubar, "button-press-event", G_CALLBACK (menubar_press), NULL);
1377+ g_signal_connect (applet, "placement-changed", G_CALLBACK (placement_changed_cb), self);
1378+ gtk_container_set_border_width (GTK_CONTAINER (priv->menubar), 0);
1379
1380 /* Add in filter func */
1381- tomboy_keybinder_bind(hotkey_keycode, hotkey_filter, menubar);
1382+ hotkey_keycode = INDICATOR_APPLET_GET_CLASS (self)->get_hotkey_keycode ();
1383+ tomboy_keybinder_bind (hotkey_keycode, hotkey_filter, priv->menubar);
1384
1385 /* load indicators */
1386- load_modules(menubar, &indicators_loaded);
1387- load_indicators_from_indicator_files(menubar, &indicators_loaded);
1388+ load_modules (self, &indicators_loaded);
1389+ load_indicators_from_indicator_files (self, &indicators_loaded);
1390
1391 if (indicators_loaded == 0) {
1392 /* A label to allow for click through */
1393@@ -1048,11 +899,102 @@
1394 gtk_container_add(GTK_CONTAINER(applet), item);
1395 gtk_widget_show(item);
1396 } else {
1397- gtk_container_add(GTK_CONTAINER(applet), menubar);
1398- gtk_widget_show(menubar);
1399+ gtk_container_add (GTK_CONTAINER (applet), priv->menubar);
1400+ gtk_widget_show (priv->menubar);
1401 }
1402
1403 gtk_widget_show(GTK_WIDGET(applet));
1404-
1405- return TRUE;
1406+}
1407+
1408+static void
1409+indicator_applet_constructed (GObject *object)
1410+{
1411+ G_OBJECT_CLASS (indicator_applet_parent_class)->constructed (object);
1412+ indicator_applet_setup (INDICATOR_APPLET (object));
1413+}
1414+
1415+static const char *
1416+indicator_applet_get_name (void)
1417+{
1418+ return _("Indicator Applet");
1419+}
1420+
1421+static const char *
1422+indicator_applet_get_description (void)
1423+{
1424+ return _("An applet to hold all of the system indicators.");
1425+}
1426+
1427+static const char *
1428+indicator_applet_get_indicator_env (void)
1429+{
1430+ return "indicator-applet-original";
1431+}
1432+
1433+static gboolean
1434+indicator_applet_load_module (const char *name)
1435+{
1436+ if (g_strcmp0 (name, "libappmenu.so") == 0)
1437+ return FALSE;
1438+ else if (g_strcmp0 (name, "libdatetime.so") == 0)
1439+ return FALSE;
1440+ else if (g_strcmp0 (name, "libme.so") == 0)
1441+ return FALSE;
1442+ else if (g_strcmp0 (name, "libsession.so") == 0)
1443+ return FALSE;
1444+
1445+ return TRUE;
1446+}
1447+
1448+static gboolean
1449+indicator_applet_load_indicator (const char *name)
1450+{
1451+ if (g_strcmp0 (name, "com.canonical.indicator.appmenu") == 0)
1452+ return FALSE;
1453+ else if (g_strcmp0 (name, "com.canonical.indicator.datetime") == 0)
1454+ return FALSE;
1455+ else if (g_strcmp0 (name, "com.canonical.indicator.me") == 0)
1456+ return FALSE;
1457+ else if (g_strcmp0 (name, "com.canonical.indicator.session") == 0)
1458+ return FALSE;
1459+
1460+ return TRUE;
1461+}
1462+
1463+static const char *
1464+indicator_applet_get_hotkey_keycode (void)
1465+{
1466+ return "<Super>M";
1467+}
1468+
1469+static void
1470+indicator_applet_class_init (IndicatorAppletClass *self_class)
1471+{
1472+ GObjectClass *object_class;
1473+
1474+ object_class = G_OBJECT_CLASS (self_class);
1475+
1476+ object_class->constructed = indicator_applet_constructed;
1477+
1478+ self_class->get_name = indicator_applet_get_name;
1479+ self_class->get_description = indicator_applet_get_description;
1480+ self_class->get_indicator_env = indicator_applet_get_indicator_env;
1481+ self_class->load_module = indicator_applet_load_module;
1482+ self_class->load_indicator = indicator_applet_load_indicator;
1483+ self_class->get_hotkey_keycode = indicator_applet_get_hotkey_keycode;
1484+}
1485+
1486+static void
1487+indicator_applet_init (IndicatorApplet *self)
1488+{
1489+ GtkIconTheme *icon_theme;
1490+ AtkObject *atk_object;
1491+
1492+ /* Init some theme/icon stuff */
1493+ icon_theme = gtk_icon_theme_get_default ();
1494+ gtk_icon_theme_append_search_path (icon_theme, INDICATOR_ICONS_DIR);
1495+ g_debug ("Icons directory: %s", INDICATOR_ICONS_DIR);
1496+
1497+ atk_object = gtk_widget_get_accessible (GTK_WIDGET (self));
1498+ atk_object_set_name (atk_object, "indicator-applet");
1499 }
1500
1501=== added file 'src/indicator-applet.h'
1502--- src/indicator-applet.h 1970-01-01 00:00:00 +0000
1503+++ src/indicator-applet.h 2020-03-22 12:39:21 +0000
1504@@ -0,0 +1,46 @@
1505+/*
1506+ * Copyright (C) 2020 Alberts Muktupāvels
1507+ *
1508+ * This program is free software: you can redistribute it and/or modify
1509+ * it under the terms of the GNU General Public License as published by
1510+ * the Free Software Foundation, either version 3 of the License, or
1511+ * (at your option) any later version.
1512+ *
1513+ * This program is distributed in the hope that it will be useful,
1514+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1515+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1516+ * GNU General Public License for more details.
1517+ *
1518+ * You should have received a copy of the GNU General Public License
1519+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
1520+ */
1521+
1522+#ifndef INDICATOR_APPLET_H
1523+#define INDICATOR_APPLET_H
1524+
1525+#include <libgnome-panel/gp-applet.h>
1526+
1527+G_BEGIN_DECLS
1528+
1529+#define INDICATOR_TYPE_APPLET (indicator_applet_get_type ())
1530+G_DECLARE_DERIVABLE_TYPE (IndicatorApplet, indicator_applet,
1531+ INDICATOR, APPLET, GpApplet)
1532+
1533+struct _IndicatorAppletClass
1534+{
1535+ GpAppletClass parent_class;
1536+
1537+ const char * (* get_name) (void);
1538+ const char * (* get_description) (void);
1539+
1540+ const char * (* get_indicator_env) (void);
1541+
1542+ gboolean (* load_module) (const char *name);
1543+ gboolean (* load_indicator) (const char *name);
1544+
1545+ const char * (* get_hotkey_keycode) (void);
1546+};
1547+
1548+G_END_DECLS
1549+
1550+#endif
1551
1552=== added file 'src/indicator-module.c'
1553--- src/indicator-module.c 1970-01-01 00:00:00 +0000
1554+++ src/indicator-module.c 2020-03-22 12:39:21 +0000
1555@@ -0,0 +1,106 @@
1556+/*
1557+ * Copyright (C) 2020 Alberts Muktupāvels
1558+ *
1559+ * This program is free software: you can redistribute it and/or modify
1560+ * it under the terms of the GNU General Public License as published by
1561+ * the Free Software Foundation, either version 3 of the License, or
1562+ * (at your option) any later version.
1563+ *
1564+ * This program is distributed in the hope that it will be useful,
1565+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1566+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1567+ * GNU General Public License for more details.
1568+ *
1569+ * You should have received a copy of the GNU General Public License
1570+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
1571+ */
1572+
1573+#include "config.h"
1574+
1575+#include <glib/gi18n-lib.h>
1576+#include <libgnome-panel/gp-module.h>
1577+
1578+#include "indicator-applet.h"
1579+#include "indicator-applet-appmenu.h"
1580+#include "indicator-applet-complete.h"
1581+#include "indicator-applet-session.h"
1582+
1583+static GpAppletInfo *
1584+indicator_get_applet_info (const char *id)
1585+{
1586+ GpGetAppletTypeFunc type_func;
1587+ const gchar *name;
1588+ const gchar *description;
1589+ GpAppletInfo *info;
1590+
1591+ if (g_strcmp0 (id, "indicator") == 0)
1592+ {
1593+ type_func = indicator_applet_get_type;
1594+ name = _("Indicator Applet");
1595+ description = _("An indicator of something that needs your attention on the desktop");
1596+ }
1597+ else if (g_strcmp0 (id, "indicator-appmenu") == 0)
1598+ {
1599+ type_func = indicator_applet_appmenu_get_type;
1600+ name = _("Indicator Applet Appmenu");
1601+ description = _("A applet containing the application menus.");
1602+ }
1603+ else if (g_strcmp0 (id, "indicator-complete") == 0)
1604+ {
1605+ type_func = indicator_applet_complete_get_type;
1606+ name = _("Indicator Applet Complete");
1607+ description = _("A unified applet containing all of the indicators.");
1608+ }
1609+ else if (g_strcmp0 (id, "indicator-session") == 0)
1610+ {
1611+ type_func = indicator_applet_session_get_type;
1612+ name = _("Indicator Applet Session");
1613+ description = _("A place to adjust your status, change users or exit your session.");
1614+ }
1615+ else
1616+ {
1617+ g_assert_not_reached ();
1618+ return NULL;
1619+ }
1620+
1621+ info = gp_applet_info_new (type_func, name, description, "indicator-applet");
1622+
1623+ return info;
1624+}
1625+
1626+static const gchar *
1627+indicator_get_applet_id_from_iid (const gchar *iid)
1628+{
1629+ if (g_strcmp0 (iid, "IndicatorAppletFactory::IndicatorApplet") == 0)
1630+ return "indicator";
1631+ else if (g_strcmp0 (iid, "IndicatorAppletAppmenuFactory::IndicatorAppletAppmenu") == 0)
1632+ return "indicator-appmenu";
1633+ else if (g_strcmp0 (iid, "IndicatorAppletCompleteFactory::IndicatorAppletComplete") == 0)
1634+ return "indicator-complete";
1635+ else if (g_strcmp0 (iid, "FastUserSwitchAppletFactory::FastUserSwitchApplet") == 0)
1636+ return "indicator-session";
1637+
1638+ return NULL;
1639+}
1640+
1641+void
1642+gp_module_load (GpModule *module)
1643+{
1644+ bindtextdomain (GETTEXT_PACKAGE, LOCALE_DIR);
1645+ bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
1646+ gp_module_set_gettext_domain (module, GETTEXT_PACKAGE);
1647+
1648+ gp_module_set_abi_version (module, GP_MODULE_ABI_VERSION);
1649+
1650+ gp_module_set_id (module, "org.ayatana.indicator-applet");
1651+ gp_module_set_version (module, PACKAGE_VERSION);
1652+
1653+ gp_module_set_applet_ids (module,
1654+ "indicator",
1655+ "indicator-appmenu",
1656+ "indicator-complete",
1657+ "indicator-session", NULL);
1658+
1659+ gp_module_set_get_applet_info (module, indicator_get_applet_info);
1660+ gp_module_set_compatibility (module, indicator_get_applet_id_from_iid);
1661+}

Subscribers

People subscribed via source and target branches