aboutsummaryrefslogtreecommitdiff
path: root/xfce-applet
diff options
context:
space:
mode:
Diffstat (limited to 'xfce-applet')
-rw-r--r--xfce-applet/Makefile.am22
-rw-r--r--xfce-applet/topmenu-xfce-panel-applet.c75
-rw-r--r--xfce-applet/topmenu-xfce-panel-applet.h56
-rw-r--r--xfce-applet/topmenu.desktop.in7
4 files changed, 160 insertions, 0 deletions
diff --git a/xfce-applet/Makefile.am b/xfce-applet/Makefile.am
new file mode 100644
index 0000000..a1e36a1
--- /dev/null
+++ b/xfce-applet/Makefile.am
@@ -0,0 +1,22 @@
+if WANT_XFCE_APPLET
+
+plugindir = $(libdir)/xfce4/panel-plugins
+plugin_LTLIBRARIES = libtopmenu.la
+
+libtopmenu_la_SOURCES = topmenu-xfce-panel-applet.c topmenu-xfce-panel-applet.h
+libtopmenu_la_CPPFLAGS = $(GTK_CFLAGS) $(XFCEPANELAPPLET_CFLAGS) -DG_LOG_DOMAIN=\"topmenu-xfce-panel-applet\"
+libtopmenu_la_LIBADD = $(GTK_LIBS) $(XFCEPANELAPPLET_LIBS) ../libtopmenu-server/libtopmenu-server-gtk$(GTK_VERSION).la
+libtopmenu_la_LDFLAGS = -avoid-version -shared -no-undefined -export-symbols-regex '^xfce_panel_module_(preinit|init|construct)'
+
+desktopdir = $(datadir)/xfce4/panel-plugins
+desktop_DATA = topmenu.desktop
+
+$(desktop_DATA): %: %.in Makefile
+ $(AM_V_GEN)sed \
+ -e "s|\@LIBEXECDIR\@|$(libexecdir)|" \
+ $< > $@
+
+EXTRA_DIST = topmenu.desktop.in
+CLEANFILES = $(desktop_DATA)
+
+endif
diff --git a/xfce-applet/topmenu-xfce-panel-applet.c b/xfce-applet/topmenu-xfce-panel-applet.c
new file mode 100644
index 0000000..a2e6309
--- /dev/null
+++ b/xfce-applet/topmenu-xfce-panel-applet.c
@@ -0,0 +1,75 @@
+/*
+ * Copyright 2014 Javier S. Pedro <maemo@javispedro.com>
+ *
+ * This file is part of TopMenu.
+ *
+ * TopMenu is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * TopMenu 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 Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with TopMenu. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "topmenu-xfce-panel-applet.h"
+
+XFCE_PANEL_DEFINE_PLUGIN_RESIDENT(TopMenuXfcePanelApplet, topmenu_xfce_panel_applet)
+
+static void topmenu_xfce_panel_applet_construct(XfcePanelPlugin *plugin)
+{
+ TopMenuXfcePanelApplet *self = TOPMENU_XFCE_PANEL_APPLET(plugin);
+ xfce_panel_plugin_set_expand(plugin, TRUE);
+ xfce_panel_plugin_add_action_widget(plugin, GTK_WIDGET(self->menu_widget));
+}
+
+static gboolean topmenu_xfce_panel_applet_size_changed(XfcePanelPlugin *plugin, gint size)
+{
+ return TRUE;
+}
+
+static void topmenu_xfce_panel_applet_size_allocate(GtkWidget *widget, GtkAllocation *allocation)
+{
+ TopMenuXfcePanelApplet *self = TOPMENU_XFCE_PANEL_APPLET(widget);
+ if (self->menu_widget) {
+ gtk_widget_size_allocate(GTK_WIDGET(self->menu_widget), allocation);
+ }
+ GTK_WIDGET_CLASS(topmenu_xfce_panel_applet_parent_class)->size_allocate(widget, allocation);
+}
+
+static void topmenu_xfce_panel_applet_size_request(GtkWidget *widget, GtkRequisition *requisition)
+{
+ TopMenuXfcePanelApplet *self = TOPMENU_XFCE_PANEL_APPLET(widget);
+ if (self->menu_widget) {
+ gtk_widget_size_request(GTK_WIDGET(self->menu_widget), requisition);
+ }
+}
+
+static void topmenu_xfce_panel_applet_class_init(TopMenuXfcePanelAppletClass *klass)
+{
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(klass);
+ widget_class->size_allocate = topmenu_xfce_panel_applet_size_allocate;
+ widget_class->size_request = topmenu_xfce_panel_applet_size_request;
+
+ XfcePanelPluginClass *plugin_class = XFCE_PANEL_PLUGIN_CLASS(klass);
+ plugin_class->construct = topmenu_xfce_panel_applet_construct;
+ plugin_class->size_changed = topmenu_xfce_panel_applet_size_changed;
+}
+
+static void topmenu_xfce_panel_applet_init(TopMenuXfcePanelApplet *self)
+{
+ self->menu_widget = TOPMENU_WIDGET(topmenu_widget_new());
+ gtk_widget_set_can_focus(GTK_WIDGET(self->menu_widget), TRUE);
+ gtk_container_add(GTK_CONTAINER(self), GTK_WIDGET(self->menu_widget));
+ gtk_widget_show_all(GTK_WIDGET(self->menu_widget));
+}
+
+XfcePanelPlugin *topmenu_xfce_panel_applet_new(void)
+{
+ return XFCE_PANEL_PLUGIN(g_object_new(TOPMENU_TYPE_XFCE_PANEL_APPLET, NULL));
+}
diff --git a/xfce-applet/topmenu-xfce-panel-applet.h b/xfce-applet/topmenu-xfce-panel-applet.h
new file mode 100644
index 0000000..c948fda
--- /dev/null
+++ b/xfce-applet/topmenu-xfce-panel-applet.h
@@ -0,0 +1,56 @@
+/*
+ * Copyright 2014 Javier S. Pedro <maemo@javispedro.com>
+ *
+ * This file is part of TopMenu.
+ *
+ * TopMenu is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * TopMenu 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 Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with TopMenu. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef _TOPMENU_XFCE_PANEL_APPLET_H_
+#define _TOPMENU_XFCE_PANEL_APPLET_H_
+
+#include <libxfce4panel/xfce-panel-plugin.h>
+#include "../libtopmenu-server/topmenu-widget.h"
+
+G_BEGIN_DECLS
+
+#define TOPMENU_TYPE_XFCE_PANEL_APPLET topmenu_xfce_panel_applet_get_type()
+#define TOPMENU_XFCE_PANEL_APPLET(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), TOPMENU_TYPE_XFCE_PANEL_APPLET, TopMenuXfcePanelApplet))
+#define TOPMENU_IS_XFCE_PANEL_APPLET(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), TOPMENU_TYPE_XFCE_PANEL_APPLET))
+#define TOPMENU_XFCE_PANEL_APPLET_CLASS(c) (G_TYPE_CHECK_CLASS_CAST((c), TOPMENU_TYPE_XFCE_PANEL_APPLET, TopMenuXfcePanelAppletClass))
+#define TOPMENU_IS_XFCE_PANEL_APPLET_CLASS(c) (G_TYPE_CHECK_CLASS_TYPE((c), TOPMENU_TYPE_XFCE_PANEL_APPLET))
+#define TOPMENU_XFCE_PANEL_APPLET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), TOPMENU_TYPE_XFCE_PANEL_APPLET, TopMenuXfcePanelAppletClass))
+
+typedef struct _TopMenuXfcePanelApplet TopMenuXfcePanelApplet;
+typedef struct _TopMenuXfcePanelAppletClass TopMenuXfcePanelAppletClass;
+
+struct _TopMenuXfcePanelApplet
+{
+ XfcePanelPlugin parent_instance;
+ TopMenuWidget *menu_widget;
+ GtkActionGroup *actions;
+};
+
+struct _TopMenuXfcePanelAppletClass
+{
+ XfcePanelPluginClass parent_class;
+};
+
+GType topmenu_xfce_panel_applet_get_type(void);
+
+XfcePanelPlugin *topmenu_xfce_panel_applet_new(void);
+
+G_END_DECLS
+
+#endif /* _TOPMENU_XFCE_PANEL_APPLET_H_ */
diff --git a/xfce-applet/topmenu.desktop.in b/xfce-applet/topmenu.desktop.in
new file mode 100644
index 0000000..91c107d
--- /dev/null
+++ b/xfce-applet/topmenu.desktop.in
@@ -0,0 +1,7 @@
+[Xfce Panel]
+Type=X-XFCE-PanelPlugin
+Encoding=UTF-8
+Name=TopMenu
+Comment=Shows the topmenu menu bar
+Icon=topmenu-applet
+X-XFCE-Module=topmenu