[gnome-panel] fish: port to libgnome-panel
- From: Alberts Muktupāvels <muktupavels src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-panel] fish: port to libgnome-panel
- Date: Thu, 27 Oct 2016 23:29:33 +0000 (UTC)
commit 2a6600e0c1888ba7fd9a6243da6c4d8791113775
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date: Fri Oct 28 02:24:35 2016 +0300
fish: port to libgnome-panel
applets/fish/Makefile.am | 30 +---
applets/fish/fish-applet.c | 163 +++++--------------
applets/fish/fish-applet.h | 4 +-
applets/fish/fish-menu.ui | 16 ++-
applets/fish/fish-module.c | 76 +++++++++
.../org.gnome.panel.FishApplet.panel-applet.in.in | 15 --
po/POTFILES.in | 2 +-
7 files changed, 138 insertions(+), 168 deletions(-)
---
diff --git a/applets/fish/Makefile.am b/applets/fish/Makefile.am
index ef1e875..c22d0d1 100644
--- a/applets/fish/Makefile.am
+++ b/applets/fish/Makefile.am
@@ -1,33 +1,32 @@
NULL =
-fish_libdir = $(pkglibdir)
+fish_libdir = $(libdir)/gnome-panel/applets
fish_lib_LTLIBRARIES = fish.la
fish_la_SOURCES = \
fish-applet.c \
fish-applet.h \
+ fish-module.c \
$(BUILT_SOURCES) \
$(NULL)
fish_la_CPPFLAGS = \
-DFISH_ICONDIR=\""$(fishbitmapsdir)"\" \
- -DGNOMELOCALEDIR=\""$(localedir)"\" \
- -I$(srcdir)/../../libpanel-applet \
- -I$(top_builddir)/libpanel-applet \
+ -DLOCALEDIR=\""$(localedir)"\" \
-I$(top_srcdir) \
$(AM_CPPFLAGS) \
$(NULL)
fish_la_CFLAGS = \
- $(LIBPANEL_APPLET_CFLAGS) \
+ $(LIBGNOME_PANEL_CFLAGS) \
$(FISH_CFLAGS) \
$(WARN_CFLAGS) \
$(AM_CFLAGS) \
$(NULL)
fish_la_LIBADD = \
- $(top_builddir)/libpanel-applet/libpanel-applet.la \
- $(LIBPANEL_APPLET_LIBS) \
+ $(top_builddir)/libgnome-panel/libgnome-panel.la \
+ $(LIBGNOME_PANEL_LIBS) \
$(FISH_LIBS) \
$(NULL)
@@ -37,20 +36,6 @@ fish_la_LDFLAGS = \
$(AM_LDFLAGS) \
$(NULL)
-APPLET_LOCATION = $(pkglibdir)/fish.so
-
-appletdir = $(appletsdir)
-applet_in_files = org.gnome.panel.FishApplet.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@
-
fishbitmapsdir = $(datadir)/gnome-panel/fish
fishbitmaps_DATA = \
wanda.fish \
@@ -83,15 +68,12 @@ BUILT_SOURCES = \
EXTRA_DIST = \
wanda.svg \
- org.gnome.panel.FishApplet.panel-applet.in.in \
fish.gresource.xml \
$(fishbitmaps_DATA) \
$(ui_FILES) \
$(NULL)
CLEANFILES = \
- $(applet_DATA) \
- $(applet_DATA).in \
$(BUILT_SOURCES) \
$(NULL)
diff --git a/applets/fish/fish-applet.c b/applets/fish/fish-applet.c
index 3d0134d..04c2889 100644
--- a/applets/fish/fish-applet.c
+++ b/applets/fish/fish-applet.c
@@ -56,7 +56,7 @@
struct _FishApplet
{
- PanelApplet applet;
+ GpApplet applet;
GSettings *settings;
GSettings *lockdown_settings;
@@ -68,8 +68,6 @@ struct _FishApplet
gdouble speed;
gboolean rotate;
- PanelAppletOrient orientation;
-
GtkWidget *frame;
GtkWidget *drawing_area;
GtkRequisition requisition;
@@ -102,7 +100,7 @@ static void something_fishy_going_on (FishApplet *fish,
static void display_fortune_dialog (FishApplet *fish);
static void set_tooltip (FishApplet *fish);
-G_DEFINE_TYPE (FishApplet, fish_applet, PANEL_TYPE_APPLET)
+G_DEFINE_TYPE (FishApplet, fish_applet, GP_TYPE_APPLET)
static int fools_day = 0;
static int fools_month = 0;
@@ -947,9 +945,7 @@ update_surface (FishApplet *fish)
if (!fish->pixbuf && !load_fish_image (fish))
return;
- if (fish->rotate &&
- (fish->orientation == PANEL_APPLET_ORIENT_LEFT ||
- fish->orientation == PANEL_APPLET_ORIENT_RIGHT))
+ if (fish->rotate && gp_applet_get_orientation (GP_APPLET (fish)) == GTK_ORIENTATION_VERTICAL)
rotate = TRUE;
pixbuf_width = gdk_pixbuf_get_width (fish->pixbuf);
@@ -957,8 +953,7 @@ update_surface (FishApplet *fish)
prev_requisition = fish->requisition;
- if (fish->orientation == PANEL_APPLET_ORIENT_UP ||
- fish->orientation == PANEL_APPLET_ORIENT_DOWN) {
+ if (gp_applet_get_orientation (GP_APPLET (fish)) == GTK_ORIENTATION_HORIZONTAL) {
height = allocation.height;
width = pixbuf_width * ((gdouble) height / pixbuf_height);
@@ -1019,7 +1014,7 @@ update_surface (FishApplet *fish)
}
if (rotate) {
- if (fish->orientation == PANEL_APPLET_ORIENT_RIGHT) {
+ if (gp_applet_get_position (GP_APPLET (fish)) == GTK_POS_LEFT) {
cairo_matrix_translate (&matrix, pixbuf_width - 1, 0);
cairo_matrix_rotate (&matrix, M_PI * 0.5);
} else {
@@ -1067,9 +1062,9 @@ fish_applet_draw (GtkWidget *widget,
src_y = 0;
if (fish->rotate) {
- if (fish->orientation == PANEL_APPLET_ORIENT_RIGHT)
+ if (gp_applet_get_position (GP_APPLET (fish)) == GTK_POS_LEFT)
src_y = ((height * (fish->n_frames - 1 - fish->current_frame)) / fish->n_frames);
- else if (fish->orientation == PANEL_APPLET_ORIENT_LEFT)
+ else if (gp_applet_get_position (GP_APPLET (fish)) == GTK_POS_RIGHT)
src_y = ((height * fish->current_frame) / fish->n_frames);
else
src_x = ((width * fish->current_frame) / fish->n_frames);
@@ -1115,21 +1110,6 @@ fish_applet_unrealize (GtkWidget *widget,
}
static void
-fish_applet_change_orient (PanelApplet *applet,
- PanelAppletOrient orientation)
-{
- FishApplet *fish = (FishApplet *) applet;
-
- if (fish->orientation == orientation)
- return;
-
- fish->orientation = orientation;
-
- if (fish->surface)
- update_surface (fish);
-}
-
-static void
change_water (FishApplet *fish)
{
GtkWidget *dialog;
@@ -1281,11 +1261,12 @@ setup_fish_widget (FishApplet *fish)
g_signal_connect (fish, "key_press_event",
G_CALLBACK (handle_keypress), fish);
- gtk_widget_show_all (widget);
+ gtk_widget_show_all (fish->frame);
}
static const GActionEntry fish_menu_actions [] = {
- { "preferences", display_preferences_dialog, NULL, NULL, NULL }
+ { "preferences", display_preferences_dialog, NULL, NULL, NULL },
+ { NULL }
};
static void
@@ -1365,8 +1346,7 @@ fish_applet_update_rotate (FishApplet *fish,
{
fish->rotate = rotate;
- if (fish->orientation == PANEL_APPLET_ORIENT_LEFT ||
- fish->orientation == PANEL_APPLET_ORIENT_RIGHT)
+ if (gp_applet_get_orientation (GP_APPLET (fish)) == GTK_ORIENTATION_VERTICAL)
update_surface (fish);
}
@@ -1406,58 +1386,32 @@ fish_applet_settings_changed (GSettings *settings,
}
}
-static gboolean
-fish_applet_fill (FishApplet *fish)
+static void
+fish_applet_constructed (GObject *object)
{
- PanelApplet *applet = PANEL_APPLET (fish);
- GSimpleActionGroup *action_group;
- GAction *action;
+ FishApplet *fish = FISH_APPLET (object);
+ GpApplet *applet = GP_APPLET (fish);
+ GAction *action;
- fish->orientation = panel_applet_get_orient (applet);
+ G_OBJECT_CLASS (fish_applet_parent_class)->constructed (object);
- fish->settings = panel_applet_settings_new (applet, FISH_SCHEMA);
+ fish->settings = gp_applet_settings_new (applet, FISH_SCHEMA);
fish->lockdown_settings = g_settings_new (LOCKDOWN_SCHEMA);
- action_group = g_simple_action_group_new ();
- g_action_map_add_action_entries (G_ACTION_MAP (action_group),
- fish_menu_actions,
- G_N_ELEMENTS (fish_menu_actions),
- fish);
- panel_applet_setup_menu_from_resource (applet,
- FISH_RESOURCE_PATH "fish-menu.ui",
- action_group,
- GETTEXT_PACKAGE);
-
- gtk_widget_insert_action_group (GTK_WIDGET (applet), "fish",
- G_ACTION_GROUP (action_group));
+ gp_applet_setup_menu_from_resource (applet,
+ FISH_RESOURCE_PATH "fish-menu.ui",
+ fish_menu_actions);
- action = g_action_map_lookup_action (G_ACTION_MAP (action_group), "preferences");
+ action = gp_applet_menu_lookup_action (applet, "preferences");
g_object_bind_property (applet, "locked-down",
action, "enabled",
G_BINDING_DEFAULT|G_BINDING_INVERT_BOOLEAN|G_BINDING_SYNC_CREATE);
- g_object_unref (action_group);
-
setup_fish_widget (fish);
g_signal_connect (fish->settings, "changed",
G_CALLBACK (fish_applet_settings_changed), fish);
fish_applet_settings_changed (fish->settings, NULL, fish);
-
- return TRUE;
-}
-
-static gboolean
-fishy_factory (PanelApplet *applet,
- const char *iid,
- gpointer data)
-{
- gboolean retval = FALSE;
-
- if (!strcmp (iid, "FishApplet"))
- retval = fish_applet_fill (FISH_APPLET (applet));
-
- return retval;
}
static void
@@ -1515,68 +1469,37 @@ fish_applet_dispose (GObject *object)
}
static void
-fish_applet_init (FishApplet *fish)
+fish_applet_placement_changed (GpApplet *applet,
+ GtkOrientation orientation,
+ GtkPositionType position)
{
- fish->settings = NULL;
- fish->lockdown_settings = NULL;
-
- fish->name = NULL;
- fish->image = NULL;
- fish->command = NULL;
- fish->n_frames = 1;
- fish->speed = 0.0;
- fish->rotate = FALSE;
-
- fish->orientation = PANEL_APPLET_ORIENT_UP;
-
- fish->frame = NULL;
- fish->drawing_area = NULL;
- fish->surface = NULL;
- fish->timeout = 0;
- fish->current_frame = 0;
- fish->in_applet = FALSE;
-
- fish->requisition.width = -1;
- fish->requisition.height = -1;
-
- fish->prev_allocation.x = -1;
- fish->prev_allocation.y = -1;
- fish->prev_allocation.width = -1;
- fish->prev_allocation.height = -1;
-
- fish->pixbuf = NULL;
-
- fish->preferences_dialog = NULL;
-
- fish->fortune_dialog = NULL;
- fish->fortune_view = NULL;
- fish->fortune_label = NULL;
- fish->fortune_cmd_label = NULL;
- fish->fortune_buffer = NULL;
-
- fish->source_id = 0;
- fish->io_channel = NULL;
+ FishApplet *fish;
- fish->april_fools = FALSE;
+ fish = FISH_APPLET (applet);
- panel_applet_set_flags (PANEL_APPLET (fish),
- PANEL_APPLET_EXPAND_MINOR);
+ if (fish->surface)
+ update_surface (fish);
}
static void
-fish_applet_class_init (FishAppletClass *klass)
+fish_applet_class_init (FishAppletClass *fish_class)
{
- PanelAppletClass *applet_class = (PanelAppletClass *) klass;
- GObjectClass *gobject_class = (GObjectClass *) klass;
+ GObjectClass *object_class;
+ GpAppletClass *applet_class;
- applet_class->change_orient = fish_applet_change_orient;
+ object_class = G_OBJECT_CLASS (fish_class);
+ applet_class = GP_APPLET_CLASS (fish_class);
- gobject_class->dispose = fish_applet_dispose;
+ object_class->constructed = fish_applet_constructed;
+ object_class->dispose = fish_applet_dispose;
+
+ applet_class->placement_changed = fish_applet_placement_changed;
init_fools_day ();
}
-PANEL_APPLET_IN_PROCESS_FACTORY ("FishAppletFactory",
- fish_applet_get_type (),
- fishy_factory,
- NULL)
+static void
+fish_applet_init (FishApplet *fish)
+{
+ gp_applet_set_flags (GP_APPLET (fish), GP_APPLET_FLAGS_EXPAND_MINOR);
+}
diff --git a/applets/fish/fish-applet.h b/applets/fish/fish-applet.h
index c79142a..c2cf375 100644
--- a/applets/fish/fish-applet.h
+++ b/applets/fish/fish-applet.h
@@ -18,12 +18,12 @@
#ifndef FISH_APPLET_H
#define FISH_APPLET_H
-#include <panel-applet.h>
+#include <libgnome-panel/gp-applet.h>
G_BEGIN_DECLS
#define FISH_TYPE_APPLET fish_applet_get_type ()
-G_DECLARE_FINAL_TYPE (FishApplet, fish_applet, FISH, APPLET, PanelApplet)
+G_DECLARE_FINAL_TYPE (FishApplet, fish_applet, FISH, APPLET, GpApplet)
G_END_DECLS
diff --git a/applets/fish/fish-menu.ui b/applets/fish/fish-menu.ui
index 9af7059..fc9c4c0 100644
--- a/applets/fish/fish-menu.ui
+++ b/applets/fish/fish-menu.ui
@@ -1,6 +1,10 @@
-<section>
- <item>
- <attribute name="label" translatable="yes">Preferences</attribute>
- <attribute name="action">fish.preferences</attribute>
- </item>
-</section>
+<interface>
+ <menu id="fish-menu">
+ <section>
+ <item>
+ <attribute name="label" translatable="yes">Preferences</attribute>
+ <attribute name="action">fish.preferences</attribute>
+ </item>
+ </section>
+ </menu>
+</interface>
diff --git a/applets/fish/fish-module.c b/applets/fish/fish-module.c
new file mode 100644
index 0000000..9dccb31
--- /dev/null
+++ b/applets/fish/fish-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 "fish-applet.h"
+
+static GpModuleInfo *
+fish_get_module_info (void)
+{
+ GpModuleInfo *info;
+
+ bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
+ bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+
+ info = gp_module_info_new ("fish", PACKAGE_VERSION);
+
+ gp_module_info_set_applets (info, "fish", NULL);
+ gp_module_info_set_translation_domain (info, GETTEXT_PACKAGE);
+
+ return info;
+}
+
+static GpAppletInfo *
+fish_get_applet_info (const gchar *applet)
+{
+ const gchar *description;
+ GpAppletInfo *info;
+
+ description = _("Display a swimming fish or another animated creature");
+ info = gp_applet_info_new (_("Fish"), description, "gnome-panel-fish");
+
+ gp_applet_info_set_backends (info, "x11");
+
+ return info;
+}
+
+static GType
+fish_get_applet_type (const gchar *applet)
+{
+ return FISH_TYPE_APPLET;
+}
+
+guint32
+gp_module_get_abi_version (void)
+{
+ return GP_MODULE_ABI_VERSION;
+}
+
+void
+gp_module_get_vtable (GpModuleVTable *vtable)
+{
+ *vtable = (GpModuleVTable) {
+ fish_get_module_info,
+ fish_get_applet_info,
+ fish_get_applet_type,
+ NULL
+ };
+}
diff --git a/po/POTFILES.in b/po/POTFILES.in
index fe20b3a..4e1fe20 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -11,9 +11,9 @@ applets/clock/clock-location-tile.c
applets/clock/clock-utils.c
[type: gettext/ini]applets/clock/org.gnome.panel.ClockApplet.panel-applet.in.in
applets/fish/fish-applet.c
+applets/fish/fish-module.c
[type: gettext/glade]applets/fish/fish-menu.ui
[type: gettext/glade]applets/fish/fish.ui
-[type: gettext/ini]applets/fish/org.gnome.panel.FishApplet.panel-applet.in.in
applets/notification_area/main.c
applets/notification_area/na-tray-manager.c
[type: gettext/ini]applets/notification_area/org.gnome.panel.NotificationAreaApplet.panel-applet.in.in
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]