[gnome-panel] status-notifier: port to libgnome-panel
- From: Alberts Muktupāvels <muktupavels src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-panel] status-notifier: port to libgnome-panel
- Date: Mon, 31 Oct 2016 16:44:56 +0000 (UTC)
commit 11e8cd0d28c174366eeed8b5dd3c05ea50dd2c1c
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date: Mon Oct 31 18:37:14 2016 +0200
status-notifier: port to libgnome-panel
And remove libstatus-notifier.
applets/Makefile.am | 5 +-
applets/status-notifier/Makefile.am | 58 ++----
.../org.gnome.panel.SnApplet.panel-applet.in.in | 15 --
applets/status-notifier/sn-applet.c | 200 +++-----------------
applets/status-notifier/sn-applet.h | 20 +--
applets/status-notifier/sn-module.c | 74 +++++++
configure.ac | 23 +--
po/POTFILES.in | 2 +-
8 files changed, 130 insertions(+), 267 deletions(-)
---
diff --git a/applets/Makefile.am b/applets/Makefile.am
index eeb88d2..8acde11 100644
--- a/applets/Makefile.am
+++ b/applets/Makefile.am
@@ -4,11 +4,8 @@ SUBDIRS = \
clock \
fish \
notification-area \
+ status-notifier \
wncklet \
$(NULL)
-if WITH_LIBSTATUS_NOTIFIER
-SUBDIRS += status-notifier
-endif
-
-include $(top_srcdir)/git.mk
diff --git a/applets/status-notifier/Makefile.am b/applets/status-notifier/Makefile.am
index f8e985e..cc92371 100644
--- a/applets/status-notifier/Makefile.am
+++ b/applets/status-notifier/Makefile.am
@@ -1,63 +1,37 @@
NULL =
-libsn_applet_la_CPPFLAGS = \
- -DGNOMELOCALEDIR=\""$(localedir)"\" \
- -I$(srcdir) \
- -I$(srcdir)/../../libpanel-applet \
- -I$(top_builddir)/libpanel-applet \
+status_notifier_libdir = $(libdir)/gnome-panel/applets
+status_notifier_lib_LTLIBRARIES = status-notifier.la
+
+status_notifier_la_CPPFLAGS = \
+ -DLOCALEDIR=\""$(localedir)"\" \
+ -I$(top_srcdir) \
+ $(AM_CPPFLAGS) \
$(NULL)
-libsn_applet_la_CFLAGS = \
- $(LIBPANEL_APPLET_CFLAGS) \
+status_notifier_la_CFLAGS = \
+ $(LIBGNOME_PANEL_CFLAGS) \
$(STATUS_NOTIFIER_CFLAGS) \
$(WARN_CFLAGS) \
$(AM_CFLAGS) \
$(NULL)
-libsn_applet_la_SOURCES = \
+status_notifier_la_SOURCES = \
sn-applet.c \
sn-applet.h \
- sn-button.c \
- sn-button.h \
+ sn-module.c \
$(NULL)
-libsn_applet_la_LIBADD = \
- ../../libpanel-applet/libpanel-applet.la \
- $(LIBPANEL_APPLET_LIBS) \
+status_notifier_la_LIBADD = \
+ $(top_builddir)/libgnome-panel/libgnome-panel.la \
+ $(LIBGNOME_PANEL_LIBS) \
$(STATUS_NOTIFIER_LIBS) \
$(NULL)
-libsn_applet_la_LDFLAGS = \
- -module \
- -avoid-version \
+status_notifier_la_LDFLAGS = \
+ -module -avoid-version \
$(WARN_LDFLAGS) \
$(AM_LDFLAGS) \
$(NULL)
-APPLET_LOCATION = $(pkglibdir)/libsn-applet.so
-
-sn_applet_libdir = $(pkglibdir)
-sn_applet_lib_LTLIBRARIES = libsn-applet.la
-
-appletdir = $(appletsdir)
-applet_in_files = org.gnome.panel.SnApplet.panel-applet.in
-applet_DATA = $(applet_in_files:.panel-applet.in=.panel-applet)
-
-$(applet_in_files): $(applet_in_files).in Makefile
- $(AM_V_GEN)sed \
- -e "s|\@LOCATION\@|$(APPLET_LOCATION)|" \
- -e "s|\@VERSION\@|$(PACKAGE_VERSION)|" \
- $< > $@
-
-@PANEL_INTLTOOL_PANEL_APPLET_RULE@
-
-EXTRA_DIST = \
- org.gnome.panel.SnApplet.panel-applet.in.in \
- $(NULL)
-
-CLEANFILES = \
- $(applet_DATA) \
- $(applet_DATA).in \
- $(NULL)
-
-include $(top_srcdir)/git.mk
diff --git a/applets/status-notifier/sn-applet.c b/applets/status-notifier/sn-applet.c
index 65cdc93..bb13d53 100644
--- a/applets/status-notifier/sn-applet.c
+++ b/applets/status-notifier/sn-applet.c
@@ -18,204 +18,66 @@
#include "config.h"
#include "sn-applet.h"
-#include "sn-button.h"
struct _SnApplet
{
- PanelApplet parent;
+ GpApplet parent;
- SnHost *host;
- GSList *items;
-
- GtkWidget *box;
+ GtkWidget *box;
};
-G_DEFINE_TYPE (SnApplet, sn_applet, PANEL_TYPE_APPLET)
-
-static gint
-compare_items (gconstpointer a,
- gconstpointer b)
-{
- SnItem *item1;
- SnItemCategory c1;
- const gchar *id1;
- SnItem *item2;
- SnItemCategory c2;
- const gchar *id2;
-
- item1 = SN_ITEM (a);
- c1 = sn_item_get_category (item1);
-
- item2 = SN_ITEM (b);
- c2 = sn_item_get_category (item2);
-
- if (c1 < c2)
- return -1;
-
- if (c2 < c1)
- return 1;
-
- id1 = sn_item_get_id (item1);
- id2 = sn_item_get_id (item2);
-
- return g_strcmp0 (id1, id2);
-}
-
-static void
-reorder_items (GtkWidget *widget,
- gpointer data)
-{
- SnApplet *applet;
- SnButton *button;
- gint position;
-
- applet = SN_APPLET (data);
- button = SN_BUTTON (widget);
-
- position = g_slist_index (applet->items, sn_button_get_item (button));
-
- gtk_box_reorder_child (GTK_BOX (applet->box), widget, position);
-}
+G_DEFINE_TYPE (SnApplet, sn_applet, GP_TYPE_APPLET)
static void
-item_added_cb (SnHost *host,
- SnItem *item,
- SnApplet *applet)
+sn_applet_constructed (GObject *object)
{
- GtkWidget *button;
-
- applet->items = g_slist_prepend (applet->items, item);
- applet->items = g_slist_sort (applet->items, compare_items);
-
- button = sn_button_new (item);
- gtk_box_pack_start (GTK_BOX (applet->box), button, FALSE, FALSE, 0);
- gtk_widget_show (button);
-
- g_object_bind_property (applet->box, "orientation", button, "orientation",
- G_BINDING_DEFAULT);
-
- gtk_container_foreach (GTK_CONTAINER (applet->box), reorder_items, applet);
+ G_OBJECT_CLASS (sn_applet_parent_class)->constructed (object);
+ gtk_widget_show (GTK_WIDGET (object));
}
static void
-item_remove (GtkWidget *widget,
- gpointer data)
+sn_applet_placement_changed (GpApplet *applet,
+ GtkOrientation orientation,
+ GtkPositionType position)
{
- SnButton *button;
- SnItem *item;
+ SnApplet *sn;
+ GtkOrientable *orientable;
- button = SN_BUTTON (widget);
- item = SN_ITEM (data);
+ sn = SN_APPLET (applet);
+ orientable = GTK_ORIENTABLE (sn->box);
- if (sn_button_get_item (button) == item)
- gtk_widget_destroy (widget);
+ gtk_orientable_set_orientation (orientable, orientation);
}
static void
-item_removed_cb (SnHost *host,
- SnItem *item,
- SnApplet *applet)
-{
- GSList *l;
-
- for (l = applet->items; l != NULL; l = g_slist_next (l))
- {
- SnItem *tmp;
-
- tmp = SN_ITEM (l->data);
-
- if (tmp != item)
- continue;
-
- applet->items = g_slist_remove (applet->items, l->data);
- gtk_container_foreach (GTK_CONTAINER (applet->box),
- item_remove, item);
- }
-}
-
-static gboolean
-sn_applet_fill (SnApplet *applet)
-{
- applet->host = sn_host_new (SN_HOST_FLAGS_NONE);
-
- g_signal_connect (applet->host, "item-added",
- G_CALLBACK (item_added_cb), applet);
- g_signal_connect (applet->host, "item-removed",
- G_CALLBACK (item_removed_cb), applet);
-
- gtk_widget_show (GTK_WIDGET (applet));
-
- return TRUE;
-}
-
-static gboolean
-sn_applet_factory (PanelApplet *applet,
- const gchar *iid,
- gpointer user_data)
-{
- if (g_strcmp0 (iid, "SnApplet") == 0)
- return sn_applet_fill (SN_APPLET (applet));
-
- return FALSE;
-}
-
-static void
-sn_applet_dispose (GObject *object)
-{
- SnApplet *applet;
-
- applet = SN_APPLET (object);
-
- g_clear_object (&applet->host);
- g_clear_pointer (&applet->items, g_slist_free);
-
- G_OBJECT_CLASS (sn_applet_parent_class)->dispose (object);
-}
-
-static void
-sn_applet_change_orient (PanelApplet *applet,
- PanelAppletOrient orient)
-{
- SnApplet *sn_applet;
- GtkOrientation orientation;
-
- sn_applet = SN_APPLET (applet);
- orientation = panel_applet_get_gtk_orientation (applet);
-
- gtk_orientable_set_orientation (GTK_ORIENTABLE (sn_applet->box),
- orientation);
-}
-
-static void
-sn_applet_class_init (SnAppletClass *applet_class)
+sn_applet_class_init (SnAppletClass *sn_class)
{
GObjectClass *object_class;
- PanelAppletClass *panel_applet_class;
+ GpAppletClass *applet_class;
- object_class = G_OBJECT_CLASS (applet_class);
- panel_applet_class = PANEL_APPLET_CLASS (applet_class);
+ object_class = G_OBJECT_CLASS (sn_class);
+ applet_class = GP_APPLET_CLASS (sn_class);
- object_class->dispose = sn_applet_dispose;
+ object_class->constructed = sn_applet_constructed;
- panel_applet_class->change_orient = sn_applet_change_orient;
+ applet_class->placement_changed = sn_applet_placement_changed;
}
static void
-sn_applet_init (SnApplet *applet)
+sn_applet_init (SnApplet *sn)
{
- PanelApplet *panel_applet;
+ GpApplet *applet;
+ GpAppletFlags flags;
GtkOrientation orientation;
- panel_applet = PANEL_APPLET (applet);
- orientation = panel_applet_get_gtk_orientation (panel_applet);
+ applet = GP_APPLET (sn);
- panel_applet_set_flags (panel_applet, PANEL_APPLET_HAS_HANDLE |
- PANEL_APPLET_EXPAND_MINOR);
+ flags = GP_APPLET_FLAGS_EXPAND_MINOR | GP_APPLET_FLAGS_HAS_HANDLE;
+ orientation = gp_applet_get_orientation (applet);
- applet->box = gtk_box_new (orientation, 0);
- gtk_container_add (GTK_CONTAINER (applet), applet->box);
- gtk_widget_show (applet->box);
-}
+ gp_applet_set_flags (applet, flags);
-PANEL_APPLET_IN_PROCESS_FACTORY ("SnAppletFactory", SN_TYPE_APPLET,
- sn_applet_factory, NULL);
+ sn->box = gtk_box_new (orientation, 0);
+ gtk_container_add (GTK_CONTAINER (sn), sn->box);
+ gtk_widget_show (sn->box);
+}
diff --git a/applets/status-notifier/sn-applet.h b/applets/status-notifier/sn-applet.h
index db97c66..a4f01c1 100644
--- a/applets/status-notifier/sn-applet.h
+++ b/applets/status-notifier/sn-applet.h
@@ -18,26 +18,12 @@
#ifndef SN_APPLET_H
#define SN_APPLET_H
-#include <panel-applet.h>
+#include <libgnome-panel/gp-applet.h>
G_BEGIN_DECLS
-#define SN_TYPE_APPLET (sn_applet_get_type())
-#define SN_APPLET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SN_TYPE_APPLET, SnApplet))
-#define SN_APPLET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SN_TYPE_APPLET, SnAppletClass))
-#define SN_IS_APPLET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SN_TYPE_APPLET))
-#define SN_IS_APPLET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SN_TYPE_APPLET))
-#define SN_APPLET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), SN_TYPE_APPLET, SnAppletClass))
-
-typedef struct _SnApplet SnApplet;
-typedef struct _SnAppletClass SnAppletClass;
-
-struct _SnAppletClass
-{
- PanelAppletClass parent_class;
-};
-
-GType sn_applet_get_type (void);
+#define SN_TYPE_APPLET sn_applet_get_type ()
+G_DECLARE_FINAL_TYPE (SnApplet, sn_applet, SN, APPLET, GpApplet)
G_END_DECLS
diff --git a/applets/status-notifier/sn-module.c b/applets/status-notifier/sn-module.c
new file mode 100644
index 0000000..952c181
--- /dev/null
+++ b/applets/status-notifier/sn-module.c
@@ -0,0 +1,74 @@
+/*
+ * Copyright (C) 2016 Alberts Muktupāvels
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "config.h"
+
+#include <glib/gi18n-lib.h>
+#include <libgnome-panel/gp-module.h>
+
+#include "sn-applet.h"
+
+static GpModuleInfo *
+sn_get_module_info (void)
+{
+ GpModuleInfo *info;
+
+ bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
+ bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+
+ info = gp_module_info_new ("status-notifier", PACKAGE_VERSION);
+
+ gp_module_info_set_applets (info, "status-notifier", NULL);
+ gp_module_info_set_translation_domain (info, GETTEXT_PACKAGE);
+
+ return info;
+}
+
+static GpAppletInfo *
+sn_get_applet_info (const gchar *applet)
+{
+ const gchar *description;
+ GpAppletInfo *info;
+
+ description = _("Display all Status Notifier Items");
+ info = gp_applet_info_new (_("Status Notifier Host"), description, NULL);
+
+ return info;
+}
+
+static GType
+sn_get_applet_type (const gchar *applet)
+{
+ return SN_TYPE_APPLET;
+}
+
+guint32
+gp_module_get_abi_version (void)
+{
+ return GP_MODULE_ABI_VERSION;
+}
+
+void
+gp_module_get_vtable (GpModuleVTable *vtable)
+{
+ *vtable = (GpModuleVTable) {
+ sn_get_module_info,
+ sn_get_applet_info,
+ sn_get_applet_type,
+ NULL
+ };
+}
diff --git a/configure.ac b/configure.ac
index d29881b..da24937 100644
--- a/configure.ac
+++ b/configure.ac
@@ -148,6 +148,10 @@ PKG_CHECK_MODULES([NOTIFICATION_AREA], [
x11
])
+PKG_CHECK_MODULES([STATUS_NOTIFIER], [
+ gtk+-3.0 >= $GTK_REQUIRED
+])
+
PKG_CHECK_MODULES(WNCKLET, gtk+-3.0 >= $GTK_REQUIRED libwnck-3.0 >= $LIBWNCK_REQUIRED)
AC_SUBST(WNCKLET_CFLAGS)
AC_SUBST(WNCKLET_LIBS)
@@ -191,23 +195,6 @@ AM_CONDITIONAL(ENABLE_EDS, test "$enable_eds" = "yes")
AC_SUBST(CLOCK_EDS_ICONDIR)
dnl **************************************************************************
-dnl Build with libstatus-notifier (experimental)
-dnl **************************************************************************
-
-AC_ARG_WITH([libstatus-notifier],
- [AS_HELP_STRING([--with-libstatus-notifier],
- [Build with libstatus-notifier (experimental)])],
- [with_libstatus_notifier="$withval"],
- [with_libstatus_notifier=no])
-
-AS_IF([test "x$with_libstatus_notifier" = "xyes"], [
- PKG_CHECK_MODULES([STATUS_NOTIFIER], [libstatus-notifier-3.0])
-])
-
-AM_CONDITIONAL([WITH_LIBSTATUS_NOTIFIER],
- [test "x$with_libstatus_notifier" = "xyes"])
-
-dnl **************************************************************************
dnl Check if struct dirent contains a d_type member, for run dialog
dnl **************************************************************************
@@ -327,5 +314,3 @@ echo ""
echo " Evolution-Data-Server support ...: ${enable_eds}"
echo " Build gtk-doc documentation .....: ${enable_gtk_doc}"
echo ""
-echo " Build with libstatus-notifier ...: ${with_libstatus_notifier}"
-echo ""
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 394f4ee..5dcb64d 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -17,7 +17,7 @@ applets/fish/fish-module.c
applets/notification-area/na-applet.c
applets/notification-area/na-module.c
applets/notification-area/na-tray-manager.c
-[type: gettext/ini]applets/status-notifier/org.gnome.panel.SnApplet.panel-applet.in.in
+applets/status-notifier/sn-module.c
[type: gettext/ini]applets/wncklet/org.gnome.panel.Wncklet.panel-applet.in.in
applets/wncklet/showdesktop.c
applets/wncklet/window-list.c
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]