[gnome-panel] notification-area: port to libgnome-panel
- From: Alberts Muktupāvels <muktupavels src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-panel] notification-area: port to libgnome-panel
- Date: Mon, 31 Oct 2016 15:43:49 +0000 (UTC)
commit 592b6a2f53f1ca94d1cfcd041ce1913730dd29c3
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date: Mon Oct 31 13:19:37 2016 +0200
notification-area: port to libgnome-panel
applets/notification-area/Makefile.am | 40 +---
applets/notification-area/na-applet.c | 224 ++++++++------------
applets/notification-area/na-applet.h | 35 +---
applets/notification-area/na-module.c | 76 +++++++
applets/notification-area/na-tray.c | 2 -
...panel.NotificationAreaApplet.panel-applet.in.in | 15 --
po/POTFILES.in | 2 +-
7 files changed, 176 insertions(+), 218 deletions(-)
---
diff --git a/applets/notification-area/Makefile.am b/applets/notification-area/Makefile.am
index cf009d1..78bdc95 100644
--- a/applets/notification-area/Makefile.am
+++ b/applets/notification-area/Makefile.am
@@ -1,20 +1,18 @@
NULL =
-notification_area_libdir = $(pkglibdir)
+notification_area_libdir = $(libdir)/gnome-panel/applets
notification_area_lib_LTLIBRARIES = notification-area.la
notification_area_la_CPPFLAGS = \
- -DGNOMELOCALEDIR=\""$(localedir)"\" \
- -DG_LOG_DOMAIN=\""notification-area-applet"\" \
- -I$(srcdir) \
- -I$(srcdir)/../../libpanel-applet \
- -I$(top_builddir)/libpanel-applet \
+ -DLOCALEDIR=\""$(localedir)"\" \
+ -DG_LOG_DOMAIN=\""notification-area"\" \
+ -I$(top_srcdir) \
$(AM_CPPFLAGS) \
$(NULL)
notification_area_la_CFLAGS = \
$(NOTIFICATION_AREA_CFLAGS) \
- $(LIBPANEL_APPLET_CFLAGS) \
+ $(LIBGNOME_PANEL_CFLAGS) \
$(WARN_CFLAGS) \
$(AM_CFLAGS) \
$(NULL)
@@ -24,6 +22,7 @@ notification_area_la_SOURCES = \
fixedtip.c \
na-applet.c \
na-applet.h \
+ na-module.c \
na-tray.c \
na-tray.h \
na-tray-child.c \
@@ -33,9 +32,9 @@ notification_area_la_SOURCES = \
$(NULL)
notification_area_la_LIBADD = \
- $(top_builddir)/libpanel-applet/libpanel-applet.la \
+ $(top_builddir)/libgnome-panel/libgnome-panel.la \
$(NOTIFICATION_AREA_LIBS) \
- $(LIBPANEL_APPLET_LIBS) \
+ $(LIBGNOME_PANEL_LIBS) \
$(NULL)
notification_area_la_LDFLAGS = \
@@ -44,27 +43,4 @@ notification_area_la_LDFLAGS = \
$(AM_LDFLAGS) \
$(NULL)
-APPLET_LOCATION = $(pkglibdir)/notification-area.so
-
-appletdir = $(appletsdir)
-applet_in_files = org.gnome.panel.NotificationAreaApplet.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.NotificationAreaApplet.panel-applet.in.in \
- $(NULL)
-
-CLEANFILES = \
- $(applet_DATA) \
- $(applet_DATA).in \
- $(NULL)
-
-include $(top_srcdir)/git.mk
diff --git a/applets/notification-area/na-applet.c b/applets/notification-area/na-applet.c
index 7cb4935..8b30e65 100644
--- a/applets/notification-area/na-applet.c
+++ b/applets/notification-area/na-applet.c
@@ -1,5 +1,3 @@
-/* System tray main() */
-
/*
* Copyright (C) 2002 Red Hat, Inc.
* Copyright (C) 2003-2006 Vincent Untz
@@ -18,98 +16,38 @@
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
-#include <config.h>
-#include <string.h>
-
-#include <panel-applet.h>
+#include "config.h"
#include <glib/gi18n.h>
#include <gtk/gtk.h>
+#include <string.h>
#include "na-applet.h"
#include "na-tray-manager.h"
#include "na-tray.h"
#include "fixedtip.h"
-#define NOTIFICATION_AREA_ICON "gnome-panel-notification-area"
-
-static void na_tray_applet_style_updated (GtkWidget *widget);
-
-struct _NaTrayAppletPrivate
+struct _NaApplet
{
- NaTray *tray;
+ GpApplet parent;
+ NaTray *tray;
};
-G_DEFINE_TYPE (NaTrayApplet, na_tray_applet, PANEL_TYPE_APPLET)
-
-static GtkOrientation
-get_gtk_orientation_from_applet_orient (PanelAppletOrient orient)
-{
- switch (orient)
- {
- case PANEL_APPLET_ORIENT_LEFT:
- case PANEL_APPLET_ORIENT_RIGHT:
- return GTK_ORIENTATION_VERTICAL;
- case PANEL_APPLET_ORIENT_UP:
- case PANEL_APPLET_ORIENT_DOWN:
- default:
- return GTK_ORIENTATION_HORIZONTAL;
- }
-
- g_assert_not_reached ();
-
- return GTK_ORIENTATION_HORIZONTAL;
-}
+G_DEFINE_TYPE (NaApplet, na_applet, GP_TYPE_APPLET)
static void
-na_tray_applet_realize (GtkWidget *widget)
+update_style (GtkWidget *widget)
{
- NaTrayApplet *applet = NA_TRAY_APPLET (widget);
- PanelAppletOrient orient;
-
- GTK_WIDGET_CLASS (na_tray_applet_parent_class)->realize (widget);
-
- g_assert (applet->priv->tray == NULL);
-
- orient = panel_applet_get_orient (PANEL_APPLET (widget));
-
- applet->priv->tray = na_tray_new_for_screen (gtk_widget_get_screen (widget),
- get_gtk_orientation_from_applet_orient (orient));
-
- gtk_container_add (GTK_CONTAINER (widget), GTK_WIDGET (applet->priv->tray));
- na_tray_applet_style_updated (widget);
- gtk_widget_show (GTK_WIDGET (applet->priv->tray));
-}
-
-static void
-na_tray_applet_unrealize (GtkWidget *widget)
-{
- NaTrayApplet *applet = NA_TRAY_APPLET (widget);
-
- g_assert (applet->priv->tray != NULL);
-
- gtk_widget_destroy (GTK_WIDGET (applet->priv->tray));
- applet->priv->tray = NULL;
-
- GTK_WIDGET_CLASS (na_tray_applet_parent_class)->unrealize (widget);
-}
-
-static void
-na_tray_applet_style_updated (GtkWidget *widget)
-{
- NaTrayApplet *applet = NA_TRAY_APPLET (widget);
+ NaApplet *na;
GtkStyleContext *context;
- GdkRGBA fg;
- GdkRGBA error;
- GdkRGBA warning;
- GdkRGBA success;
- gint padding;
- gint icon_size;
-
- GTK_WIDGET_CLASS (na_tray_applet_parent_class)->style_updated (widget);
+ GdkRGBA fg;
+ GdkRGBA error;
+ GdkRGBA warning;
+ GdkRGBA success;
+ gint padding;
+ gint icon_size;
- if (!applet->priv->tray)
- return;
+ na = NA_APPLET (widget);
context = gtk_widget_get_style_context (widget);
@@ -127,94 +65,102 @@ na_tray_applet_style_updated (GtkWidget *widget)
gtk_style_context_restore (context);
- na_tray_set_colors (applet->priv->tray, &fg, &error, &warning, &success);
+ na_tray_set_colors (na->tray, &fg, &error, &warning, &success);
gtk_widget_style_get (widget, "icon-padding", &padding, NULL);
- na_tray_set_padding (applet->priv->tray, padding);
+ na_tray_set_padding (na->tray, padding);
gtk_widget_style_get (widget, "icon-size", &icon_size, NULL);
- na_tray_set_icon_size (applet->priv->tray, icon_size);
+ na_tray_set_icon_size (na->tray, icon_size);
}
static void
-na_tray_applet_change_orient (PanelApplet *panel_applet,
- PanelAppletOrient orient)
+na_applet_style_updated (GtkWidget *widget)
{
- NaTrayApplet *applet = NA_TRAY_APPLET (panel_applet);
-
- if (!applet->priv->tray)
- return;
+ GTK_WIDGET_CLASS (na_applet_parent_class)->style_updated (widget);
+ update_style (widget);
+}
- na_tray_set_orientation (applet->priv->tray,
- get_gtk_orientation_from_applet_orient (orient));
+static void
+na_applet_constructed (GObject *object)
+{
+ G_OBJECT_CLASS (na_applet_parent_class)->constructed (object);
+ gtk_widget_show (GTK_WIDGET (object));
}
static void
-na_tray_applet_class_init (NaTrayAppletClass *class)
+na_applet_placement_changed (GpApplet *applet,
+ GtkOrientation orientation,
+ GtkPositionType position)
{
- GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
- PanelAppletClass *applet_class = PANEL_APPLET_CLASS (class);
-
- widget_class->realize = na_tray_applet_realize;
- widget_class->unrealize = na_tray_applet_unrealize;
- widget_class->style_updated = na_tray_applet_style_updated;
- applet_class->change_orient = na_tray_applet_change_orient;
-
- gtk_widget_class_install_style_property (
- widget_class,
- g_param_spec_int ("icon-padding",
- "Padding around icons",
- "Padding that should be put around icons, in pixels",
- 0, G_MAXINT, 0,
- G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
-
- gtk_widget_class_install_style_property (
- widget_class,
- g_param_spec_int ("icon-size",
- "Icon size",
- "If non-zero, hardcodes the size of the icons in pixels",
- 0, G_MAXINT, 0,
- G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
-
- g_type_class_add_private (class, sizeof (NaTrayAppletPrivate));
+ NaApplet *na;
- gtk_widget_class_set_css_name (widget_class, "na-tray-applet");
+ na = NA_APPLET (applet);
+
+ na_tray_set_orientation (na->tray, orientation);
}
static void
-na_tray_applet_init (NaTrayApplet *applet)
+install_style_properties (GtkWidgetClass *widget_class)
{
- AtkObject *atko;
+ GParamSpec *spec;
- applet->priv = G_TYPE_INSTANCE_GET_PRIVATE (applet, NA_TYPE_TRAY_APPLET,
- NaTrayAppletPrivate);
+ spec = g_param_spec_int ("icon-padding",
+ "Padding around icons",
+ "Padding that should be put around icons, in pixels",
+ 0, G_MAXINT, 0, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
- /* Defer creating NaTray until applet is added to panel so
- * gtk_widget_get_screen returns correct information */
- applet->priv->tray = NULL;
+ gtk_widget_class_install_style_property (widget_class, spec);
- atko = gtk_widget_get_accessible (GTK_WIDGET (applet));
- atk_object_set_name (atko, _("Panel Notification Area"));
+ spec = g_param_spec_int ("icon-size",
+ "Icon size",
+ "If non-zero, hardcodes the size of the icons in pixels",
+ 0, G_MAXINT, 0, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
- panel_applet_set_flags (PANEL_APPLET (applet),
- PANEL_APPLET_HAS_HANDLE|PANEL_APPLET_EXPAND_MINOR);
+ gtk_widget_class_install_style_property (widget_class, spec);
}
-static gboolean
-applet_factory (PanelApplet *applet,
- const gchar *iid,
- gpointer user_data)
+static void
+na_applet_class_init (NaAppletClass *na_class)
{
- if (!(strcmp (iid, "NotificationArea") == 0 ||
- strcmp (iid, "SystemTrayApplet") == 0))
- return FALSE;
+ GObjectClass *object_class;
+ GtkWidgetClass *widget_class;
+ GpAppletClass *applet_class;
+
+ object_class = G_OBJECT_CLASS (na_class);
+ widget_class = GTK_WIDGET_CLASS (na_class);
+ applet_class = GP_APPLET_CLASS (na_class);
- gtk_widget_show_all (GTK_WIDGET (applet));
+ object_class->constructed = na_applet_constructed;
- return TRUE;
+ widget_class->style_updated = na_applet_style_updated;
+
+ applet_class->placement_changed = na_applet_placement_changed;
+
+ gtk_widget_class_set_css_name (widget_class, "na-tray-applet");
+ install_style_properties (widget_class);
}
-PANEL_APPLET_IN_PROCESS_FACTORY ("NotificationAreaAppletFactory",
- NA_TYPE_TRAY_APPLET,
- applet_factory,
- NULL)
+static void
+na_applet_init (NaApplet *na)
+{
+ GpAppletFlags flags;
+ AtkObject *atk_object;
+ GdkScreen *screen;
+ GtkOrientation orientation;
+
+ flags = GP_APPLET_FLAGS_HAS_HANDLE | GP_APPLET_FLAGS_EXPAND_MINOR;
+ gp_applet_set_flags (GP_APPLET (na), flags);
+
+ atk_object = gtk_widget_get_accessible (GTK_WIDGET (na));
+ atk_object_set_name (atk_object, _("Panel Notification Area"));
+
+ screen = gdk_screen_get_default ();
+ orientation = gp_applet_get_orientation (GP_APPLET (na));
+ na->tray = na_tray_new_for_screen (screen, orientation);
+
+ gtk_container_add (GTK_CONTAINER (na), GTK_WIDGET (na->tray));
+ gtk_widget_show (GTK_WIDGET (na->tray));
+
+ update_style (GTK_WIDGET (na));
+}
diff --git a/applets/notification-area/na-applet.h b/applets/notification-area/na-applet.h
index fee7352..be531d7 100644
--- a/applets/notification-area/na-applet.h
+++ b/applets/notification-area/na-applet.h
@@ -17,39 +17,16 @@
*/
-#ifndef __NA_TRAY_APPLET_H__
-#define __NA_TRAY_APPLET_H__
+#ifndef NA_APPLET_H
+#define NA_APPLET_H
-#include <panel-applet.h>
+#include <libgnome-panel/gp-applet.h>
G_BEGIN_DECLS
-#define NA_TYPE_TRAY_APPLET (na_tray_applet_get_type ())
-#define NA_TRAY_APPLET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NA_TYPE_TRAY_APPLET,
NaTrayApplet))
-#define NA_TRAY_APPLET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NA_TYPE_TRAY_APPLET,
NaTrayAppletClass))
-#define NA_IS_TRAY_APPLET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NA_TYPE_TRAY_APPLET))
-#define NA_IS_TRAY_APPLET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NA_TYPE_TRAY_APPLET))
-#define NA_TRAY_APPLET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), NA_TYPE_TRAY_APPLET,
NaTrayAppletClass))
-
-typedef struct _NaTrayApplet NaTrayApplet;
-typedef struct _NaTrayAppletClass NaTrayAppletClass;
-typedef struct _NaTrayAppletPrivate NaTrayAppletPrivate;
-
-struct _NaTrayApplet
-{
- PanelApplet parent_object;
-
- /*< private >*/
- NaTrayAppletPrivate *priv;
-};
-
-struct _NaTrayAppletClass
-{
- PanelAppletClass parent_class;
-};
-
-GType na_tray_applet_get_type (void) G_GNUC_CONST;
+#define NA_TYPE_APPLET na_applet_get_type ()
+G_DECLARE_FINAL_TYPE (NaApplet, na_applet, NA, APPLET, GpApplet)
G_END_DECLS
-#endif /* __NA_TRAY_APPLET_H__ */
+#endif
diff --git a/applets/notification-area/na-module.c b/applets/notification-area/na-module.c
new file mode 100644
index 0000000..f3a7a80
--- /dev/null
+++ b/applets/notification-area/na-module.c
@@ -0,0 +1,76 @@
+/*
+ * 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 "na-applet.h"
+
+static GpModuleInfo *
+na_get_module_info (void)
+{
+ GpModuleInfo *info;
+
+ bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
+ bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+
+ info = gp_module_info_new ("notification-area", PACKAGE_VERSION);
+
+ gp_module_info_set_applets (info, "notification-area", NULL);
+ gp_module_info_set_translation_domain (info, GETTEXT_PACKAGE);
+
+ return info;
+}
+
+static GpAppletInfo *
+na_get_applet_info (const gchar *applet)
+{
+ GpAppletInfo *info;
+
+ info = gp_applet_info_new (_("Notification Area"),
+ _("Area where notification icons appear"),
+ "gnome-panel-notification-area");
+
+ gp_applet_info_set_backends (info, "x11");
+
+ return info;
+}
+
+static GType
+na_get_applet_type (const gchar *applet)
+{
+ return NA_TYPE_APPLET;
+}
+
+guint32
+gp_module_get_abi_version (void)
+{
+ return GP_MODULE_ABI_VERSION;
+}
+
+void
+gp_module_get_vtable (GpModuleVTable *vtable)
+{
+ *vtable = (GpModuleVTable) {
+ na_get_module_info,
+ na_get_applet_info,
+ na_get_applet_type,
+ NULL
+ };
+}
diff --git a/applets/notification-area/na-tray.c b/applets/notification-area/na-tray.c
index d6f1cb2..0868c28 100644
--- a/applets/notification-area/na-tray.c
+++ b/applets/notification-area/na-tray.c
@@ -20,8 +20,6 @@
#include <config.h>
#include <string.h>
-#include <panel-applet.h>
-
#include <gtk/gtk.h>
#include "na-tray-manager.h"
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 0044708..394f4ee 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -15,8 +15,8 @@ applets/fish/fish-module.c
[type: gettext/glade]applets/fish/fish-menu.ui
[type: gettext/glade]applets/fish/fish.ui
applets/notification-area/na-applet.c
+applets/notification-area/na-module.c
applets/notification-area/na-tray-manager.c
-[type: gettext/ini]applets/notification-area/org.gnome.panel.NotificationAreaApplet.panel-applet.in.in
[type: gettext/ini]applets/status-notifier/org.gnome.panel.SnApplet.panel-applet.in.in
[type: gettext/ini]applets/wncklet/org.gnome.panel.Wncklet.panel-applet.in.in
applets/wncklet/showdesktop.c
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]