aboutsummaryrefslogtreecommitdiff
path: root/mate-applet
diff options
context:
space:
mode:
authorJavier <dev.git@javispedro.com>2014-01-28 16:50:47 +0100
committerJavier <dev.git@javispedro.com>2014-01-28 16:50:47 +0100
commitc2d6d46b9ca89cb1c0729ee599c3566d3d1e7cf7 (patch)
tree7e1e2285437816c06ac884d68284d854413cf41e /mate-applet
downloadtopmenu-gtk-c2d6d46b9ca89cb1c0729ee599c3566d3d1e7cf7.tar.gz
topmenu-gtk-c2d6d46b9ca89cb1c0729ee599c3566d3d1e7cf7.zip
initial import
Diffstat (limited to 'mate-applet')
-rw-r--r--mate-applet/Makefile.am29
-rw-r--r--mate-applet/com.javispedro.topmenu.MatePanelApplet.mate-panel-applet.in10
-rw-r--r--mate-applet/main.c21
-rw-r--r--mate-applet/org.mate.panel.applet.TopMenuMatePanelAppletFactory.service.in3
-rw-r--r--mate-applet/topmenu-mate-panel-applet.c82
-rw-r--r--mate-applet/topmenu-mate-panel-applet.h38
6 files changed, 183 insertions, 0 deletions
diff --git a/mate-applet/Makefile.am b/mate-applet/Makefile.am
new file mode 100644
index 0000000..dcebc77
--- /dev/null
+++ b/mate-applet/Makefile.am
@@ -0,0 +1,29 @@
+if WANT_MATE_APPLET
+
+libexec_PROGRAMS = topmenu-mate-panel-applet
+
+topmenu_mate_panel_applet_SOURCES = main.c topmenu-mate-panel-applet.c topmenu-mate-panel-applet.h
+topmenu_mate_panel_applet_CPPFLAGS = $(GTK_CFLAGS) $(MATEPANELAPPLET_CFLAGS) -DG_LOG_DOMAIN=\"topmenu-mate-panel-applet\"
+topmenu_mate_panel_applet_LDADD = $(GTK_LIBS) $(MATEPANELAPPLET_LIBS) ../libtopmenu-server/libtopmenu-server.la
+
+appletdir = $(datadir)/mate-panel/applets
+applet_DATA = com.javispedro.topmenu.MatePanelApplet.mate-panel-applet
+
+$(applet_DATA): %: %.in Makefile
+ $(AM_V_GEN)sed \
+ -e "s|\@LIBEXECDIR\@|$(libexecdir)|" \
+ $< > $@
+
+servicedir = $(datadir)/dbus-1/services
+service_DATA = org.mate.panel.applet.TopMenuMatePanelAppletFactory.service
+
+$(service_DATA): %: %.in Makefile
+ $(AM_V_GEN)sed \
+ -e "s|\@LIBEXECDIR\@|$(libexecdir)|" \
+ $< > $@
+
+EXTRA_DIST = com.javispedro.topmenu.MatePanelApplet.mate-panel-applet.in \
+ org.mate.panel.applet.TopMenuMatePanelAppletFactory.service.in
+CLEANFILES = $(applet_DATA) $(service_DATA)
+
+endif
diff --git a/mate-applet/com.javispedro.topmenu.MatePanelApplet.mate-panel-applet.in b/mate-applet/com.javispedro.topmenu.MatePanelApplet.mate-panel-applet.in
new file mode 100644
index 0000000..12b7618
--- /dev/null
+++ b/mate-applet/com.javispedro.topmenu.MatePanelApplet.mate-panel-applet.in
@@ -0,0 +1,10 @@
+[Applet Factory]
+Id=TopMenuMatePanelAppletFactory
+Location=@LIBEXECDIR@/topmenu-mate-panel-applet
+Name=TopMenu Mate Panel Applet Factory
+Description=Trash Applet Factory
+
+[TopMenuMatePanelApplet]
+Name=TopMenu Panel Applet
+Description=Shows the TopMenu menu bar
+Icon=user-trash-full
diff --git a/mate-applet/main.c b/mate-applet/main.c
new file mode 100644
index 0000000..2ce2e92
--- /dev/null
+++ b/mate-applet/main.c
@@ -0,0 +1,21 @@
+#include <string.h>
+
+#include "topmenu-mate-panel-applet.h"
+
+static gboolean topmenu_mate_panel_applet_factory(MatePanelApplet *applet,
+ const gchar *iid,
+ gpointer data)
+{
+ if (strcmp(iid, "TopMenuMatePanelApplet") == 0) {
+ gtk_widget_show_all(GTK_WIDGET(applet));
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+MATE_PANEL_APPLET_OUT_PROCESS_FACTORY("TopMenuMatePanelAppletFactory",
+ TOPMENU_TYPE_MATE_PANEL_APPLET,
+ "TopMenuMatePanelApplet",
+ topmenu_mate_panel_applet_factory,
+ NULL)
diff --git a/mate-applet/org.mate.panel.applet.TopMenuMatePanelAppletFactory.service.in b/mate-applet/org.mate.panel.applet.TopMenuMatePanelAppletFactory.service.in
new file mode 100644
index 0000000..05388eb
--- /dev/null
+++ b/mate-applet/org.mate.panel.applet.TopMenuMatePanelAppletFactory.service.in
@@ -0,0 +1,3 @@
+[D-BUS Service]
+Name=org.mate.panel.applet.TopMenuMatePanelAppletFactory
+Exec=@LIBEXECDIR@/topmenu-mate-panel-applet
diff --git a/mate-applet/topmenu-mate-panel-applet.c b/mate-applet/topmenu-mate-panel-applet.c
new file mode 100644
index 0000000..c5b996f
--- /dev/null
+++ b/mate-applet/topmenu-mate-panel-applet.c
@@ -0,0 +1,82 @@
+#include "topmenu-mate-panel-applet.h"
+
+#include <glib/gi18n.h>
+#include <gdk/gdkx.h>
+
+G_DEFINE_TYPE(TopMenuMatePanelApplet, topmenu_mate_panel_applet, PANEL_TYPE_APPLET)
+
+static void display_preferences_dialog(GtkAction *action, TopMenuMatePanelApplet *self)
+{
+ // TODO
+}
+
+static void display_about_dialog(GtkAction *action, TopMenuMatePanelApplet *self)
+{
+ GtkWindow *parent = NULL;
+ GtkWidget *parent_widget = gtk_widget_get_toplevel(GTK_WIDGET(self));
+ if (GTK_IS_WINDOW(parent_widget)) {
+ parent = GTK_WINDOW(parent_widget);
+ }
+
+ gtk_show_about_dialog(parent,
+ "program-name", "TopMenu Mate Panel Applet",
+ NULL);
+}
+
+static const GtkActionEntry menu_verbs[] = {
+ { "TopMenuPreferences", GTK_STOCK_PROPERTIES, N_("_Preferences"),
+ NULL, NULL,
+ G_CALLBACK (display_preferences_dialog) },
+ { "TopMenuAbout", GTK_STOCK_ABOUT, N_("_About"),
+ NULL, NULL,
+ G_CALLBACK (display_about_dialog) }
+};
+
+static void topmenu_mate_panel_applet_size_allocate(GtkWidget *widget, GtkAllocation *allocation)
+{
+ TopMenuMatePanelApplet *self = TOPMENU_MATE_PANEL_APPLET(widget);
+ if (self->menu_widget) {
+ gtk_widget_size_allocate(GTK_WIDGET(self->menu_widget), allocation);
+ }
+ GTK_WIDGET_CLASS(topmenu_mate_panel_applet_parent_class)->size_allocate(widget, allocation);
+}
+
+static void topmenu_mate_panel_applet_size_request(GtkWidget *widget, GtkRequisition *requisition)
+{
+ TopMenuMatePanelApplet *self = TOPMENU_MATE_PANEL_APPLET(widget);
+ if (self->menu_widget) {
+ gtk_widget_size_request(GTK_WIDGET(self->menu_widget), requisition);
+ }
+}
+
+static void topmenu_mate_panel_applet_class_init(TopMenuMatePanelAppletClass *klass)
+{
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(klass);
+ widget_class->size_allocate = topmenu_mate_panel_applet_size_allocate;
+ widget_class->size_request = topmenu_mate_panel_applet_size_request;
+}
+
+static void topmenu_mate_panel_applet_init(TopMenuMatePanelApplet *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));
+
+ GtkActionGroup *action_group = gtk_action_group_new("TopMenu Mate Panel Applet Actions");
+ gtk_action_group_add_actions(action_group,
+ menu_verbs, G_N_ELEMENTS(menu_verbs), self);
+
+ mate_panel_applet_set_flags(MATE_PANEL_APPLET(self),
+ MATE_PANEL_APPLET_EXPAND_MINOR);
+ mate_panel_applet_setup_menu(MATE_PANEL_APPLET(self),
+ "<menuitem name=\"TopMenu Preferences Item\" action=\"TopMenuPreferences\"/>"
+ "<menuitem name=\"TopMenu About Item\" action=\"TopMenuAbout\"/>",
+ action_group);
+
+ g_object_unref(action_group);
+}
+
+MatePanelApplet *topmenu_mate_panel_applet_new(void)
+{
+ return MATE_PANEL_APPLET(g_object_new(TOPMENU_TYPE_MATE_PANEL_APPLET, NULL));
+}
diff --git a/mate-applet/topmenu-mate-panel-applet.h b/mate-applet/topmenu-mate-panel-applet.h
new file mode 100644
index 0000000..0563597
--- /dev/null
+++ b/mate-applet/topmenu-mate-panel-applet.h
@@ -0,0 +1,38 @@
+#ifndef _TOPMENU_MATE_PANEL_APPLET_H_
+#define _TOPMENU_MATE_PANEL_APPLET_H_
+
+#include <mate-panel-applet.h>
+#include "../libtopmenu-server/topmenu-widget.h"
+
+G_BEGIN_DECLS
+
+#define TOPMENU_TYPE_MATE_PANEL_APPLET topmenu_mate_panel_applet_get_type()
+#define TOPMENU_MATE_PANEL_APPLET(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), TOPMENU_TYPE_MATE_PANEL_APPLET, TopMenuMatePanelApplet))
+#define TOPMENU_IS_MATE_PANEL_APPLET(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), TOPMENU_TYPE_MATE_PANEL_APPLET))
+#define TOPMENU_MATE_PANEL_APPLET_CLASS(c) (G_TYPE_CHECK_CLASS_CAST((c), TOPMENU_TYPE_MATE_PANEL_APPLET, TopMenuMatePanelAppletClass))
+#define TOPMENU_IS_MATE_PANEL_APPLET_CLASS(c) (G_TYPE_CHECK_CLASS_TYPE((c), TOPMENU_TYPE_MATE_PANEL_APPLET))
+#define TOPMENU_MATE_PANEL_APPLET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), TOPMENU_TYPE_MATE_PANEL_APPLET, TopMenuMatePanelAppletClass))
+
+typedef struct _TopMenuMatePanelApplet TopMenuMatePanelApplet;
+typedef struct _TopMenuMatePanelAppletClass TopMenuMatePanelAppletClass;
+
+struct _TopMenuMatePanelApplet
+{
+ MatePanelApplet parent_instance;
+ TopMenuWidget *menu_widget;
+ GdkWindow *cur_plug;
+ GtkActionGroup *actions;
+};
+
+struct _TopMenuMatePanelAppletClass
+{
+ MatePanelAppletClass parent_class;
+};
+
+GType topmenu_mate_panel_applet_get_type(void);
+
+MatePanelApplet *topmenu_mate_panel_applet_new(void);
+
+G_END_DECLS
+
+#endif /* _TOPMENU_MATE_PANEL_APPLET_H_ */