aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJavier <dev.git@javispedro.com>2015-02-13 01:51:42 +0100
committerJavier <dev.git@javispedro.com>2015-02-13 01:51:42 +0100
commit1779190286a37b0e414ecc4a17ecb69994ee6005 (patch)
tree39e551f923de477fa0a9b34cade21b8ddc1adc37
parentc28922d801d81a6be9bbcb0212a12fab8a12f392 (diff)
downloadtopmenu-gtk-1779190286a37b0e414ecc4a17ecb69994ee6005.tar.gz
topmenu-gtk-1779190286a37b0e414ecc4a17ecb69994ee6005.zip
preeliminary xfce mate applet
-rw-r--r--Makefile.am2
-rw-r--r--config.h.in6
-rw-r--r--configure.ac18
-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
7 files changed, 183 insertions, 3 deletions
diff --git a/Makefile.am b/Makefile.am
index d369e3e..11946ff 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,4 +1,4 @@
AUTOMAKE_OPTIONS = foreign
-SUBDIRS = libtopmenu-server libtopmenu-client module test mate-applet icons
+SUBDIRS = libtopmenu-server libtopmenu-client module test mate-applet xfce-applet icons
noinst_HEADERS = global.h
diff --git a/config.h.in b/config.h.in
index 0b8a065..90fca35 100644
--- a/config.h.in
+++ b/config.h.in
@@ -45,8 +45,10 @@
/* Define if you have libwnck-3.0 */
#undef HAVE_WNCK3
-/* Define to the sub-directory in which libtool stores uninstalled libraries.
- */
+/* Define if you have libxfce4panel */
+#undef HAVE_XFCEPANELAPPLET
+
+/* Define to the sub-directory where libtool stores uninstalled libraries. */
#undef LT_OBJDIR
/* Define to 1 if your C compiler doesn't accept -c and -o together. */
diff --git a/configure.ac b/configure.ac
index 28d66d5..8c67f7a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -31,6 +31,11 @@ AC_ARG_ENABLE([mate-applet],
[],
[enable_mate_applet=check])
+AC_ARG_ENABLE([xfce-applet],
+ [AS_HELP_STRING([--enable-xfce-applet], [build the Xfce panel applet @<:@default=check@:>@])],
+ [],
+ [enable_xfce_applet=check])
+
AM_CONDITIONAL([GTK3], [test GTK$with_gtk = GTK3])
AC_SUBST([GTK_VERSION], [$with_gtk])
AC_DEFINE_UNQUOTED([GTK_VERSION], [$with_gtk], [Define to GTK major version used])
@@ -86,9 +91,21 @@ AS_IF([test "x$with_gtk" = x3],
[if test "x$enable_mate_applet" = xyes; then
AC_MSG_FAILURE([--enable-mate-applet was given, but test for libmatepanelapplet failed])
fi]
+ )])
+
+ AS_IF([test "x$enable_xfce_applet" != xno],
+ [PKG_CHECK_MODULES([XFCEPANELAPPLET], [libxfce4panel-1.0 >= 4.8],
+ [
+ AC_DEFINE([HAVE_XFCEPANELAPPLET], [1], [Define if you have libxfce4panel])
+ enable_xfce_applet=yes
+ ],
+ [if test "x$enable_xfce_applet" = xyes; then
+ AC_MSG_FAILURE([--enable-xfce-applet was given, but test for libxfce4panel failed])
+ fi]
)])])
AM_CONDITIONAL([WANT_MATE_APPLET], [test x$enable_mate_applet = xyes])
+AM_CONDITIONAL([WANT_XFCE_APPLET], [test x$enable_xfce_applet = xyes])
# Output files
AC_CONFIG_FILES([
@@ -97,6 +114,7 @@ AC_CONFIG_FILES([
libtopmenu-server/Makefile
module/Makefile
mate-applet/Makefile
+ xfce-applet/Makefile
icons/Makefile
test/Makefile
])
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