diff options
| author | Javier <dev.git@javispedro.com> | 2015-01-18 02:03:56 +0100 | 
|---|---|---|
| committer | Javier <dev.git@javispedro.com> | 2015-01-18 02:03:56 +0100 | 
| commit | a215500011290121925cfe929d71b80696732230 (patch) | |
| tree | c7b9fb078c42d65c8fc72e2bafe1aecd32f3f388 /mate-applet | |
| download | mdock-a215500011290121925cfe929d71b80696732230.tar.gz mdock-a215500011290121925cfe929d71b80696732230.zip | |
initial import
Diffstat (limited to 'mate-applet')
| -rw-r--r-- | mate-applet/Makefile.am | 29 | ||||
| -rw-r--r-- | mate-applet/main.c | 40 | ||||
| -rw-r--r-- | mate-applet/mdock-mate-panel-applet.c | 100 | ||||
| -rw-r--r-- | mate-applet/mdock-mate-panel-applet.h | 56 | 
4 files changed, 225 insertions, 0 deletions
| diff --git a/mate-applet/Makefile.am b/mate-applet/Makefile.am new file mode 100644 index 0000000..53c29a0 --- /dev/null +++ b/mate-applet/Makefile.am @@ -0,0 +1,29 @@ +if WANT_MATE_APPLET + +libexec_PROGRAMS = mdock-mate-panel-applet + +mdock_mate_panel_applet_SOURCES = main.c mdock-mate-panel-applet.c mdock-mate-panel-applet.h +mdock_mate_panel_applet_CPPFLAGS = $(GTK_CFLAGS) $(MATEPANELAPPLET_CFLAGS) -DG_LOG_DOMAIN=\"mdock-mate-panel-applet\" +mdock_mate_panel_applet_LDADD = $(GTK_LIBS) $(MATEPANELAPPLET_LIBS) ../libmdock/libmdock.la + +appletdir = $(datadir)/mate-panel/applets +applet_DATA = com.javispedro.mdock.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.MDockMatePanelAppletFactory.service + +$(service_DATA): %: %.in Makefile +	$(AM_V_GEN)sed \ +		-e "s|\@LIBEXECDIR\@|$(libexecdir)|" \ +		$< > $@ + +EXTRA_DIST = com.javispedro.mdock.MatePanelApplet.mate-panel-applet.in \ +	org.mate.panel.applet.MDockMatePanelAppletFactory.service.in +CLEANFILES = $(applet_DATA) $(service_DATA) + +endif diff --git a/mate-applet/main.c b/mate-applet/main.c new file mode 100644 index 0000000..15db52a --- /dev/null +++ b/mate-applet/main.c @@ -0,0 +1,40 @@ +/* + * Copyright 2015 Javier S. Pedro <dev.git@javispedro.com> + * + * This file is part of MDock. + * + * MDock 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 3 of the License, or + * (at your option) any later version. + * + * MDock 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 General Public License + * along with MDock.  If not, see <http://www.gnu.org/licenses/>. + */ + +#include <string.h> + +#include "mdock-mate-panel-applet.h" + +static gboolean mdock_mate_panel_applet_factory(MatePanelApplet *applet, +                                                const gchar *iid, +                                                gpointer data) +{ +	if (strcmp(iid, "MDockMatePanelApplet") == 0) { +		gtk_widget_show_all(GTK_WIDGET(applet)); +		return TRUE; +	} + +	return FALSE; +} + +MATE_PANEL_APPLET_OUT_PROCESS_FACTORY("MDockMatePanelAppletFactory", +                                      MDOCK_TYPE_MATE_PANEL_APPLET, +                                      "MDockMatePanelApplet", +                                      mdock_mate_panel_applet_factory, +                                      NULL) diff --git a/mate-applet/mdock-mate-panel-applet.c b/mate-applet/mdock-mate-panel-applet.c new file mode 100644 index 0000000..73b7920 --- /dev/null +++ b/mate-applet/mdock-mate-panel-applet.c @@ -0,0 +1,100 @@ +/* + * Copyright 2015 Javier S. Pedro <dev.git@javispedro.com> + * + * This file is part of MDock. + * + * MDock 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 3 of the License, or + * (at your option) any later version. + * + * MDock 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 General Public License + * along with MDock.  If not, see <http://www.gnu.org/licenses/>. + */ + +#include "mdock-mate-panel-applet.h" + +#include <glib/gi18n.h> +#include <gdk/gdkx.h> + +G_DEFINE_TYPE(MDockMatePanelApplet, mdock_mate_panel_applet, PANEL_TYPE_APPLET) + +static void display_preferences_dialog(GtkAction *action, MDockMatePanelApplet *self) +{ +	// TODO +} + +static void display_about_dialog(GtkAction *action, MDockMatePanelApplet *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", "MDock Mate Panel Applet", +	                      NULL); +} + +static const GtkActionEntry menu_verbs[] = { +	{ "MDockPreferences", GTK_STOCK_PROPERTIES, N_("_Preferences"), +	  NULL, NULL, +	  G_CALLBACK (display_preferences_dialog) }, +	{ "MDockAbout", GTK_STOCK_ABOUT, N_("_About"), +	  NULL, NULL, +	  G_CALLBACK (display_about_dialog) } +}; + +static void mdock_mate_panel_applet_size_allocate(GtkWidget *widget, GtkAllocation *allocation) +{ +	MDockMatePanelApplet *self = MDOCK_MATE_PANEL_APPLET(widget); +	if (self->dock) { +		gtk_widget_size_allocate(GTK_WIDGET(self->dock), allocation); +	} +	GTK_WIDGET_CLASS(mdock_mate_panel_applet_parent_class)->size_allocate(widget, allocation); +} + +static void mdock_mate_panel_applet_size_request(GtkWidget *widget, GtkRequisition *requisition) +{ +	MDockMatePanelApplet *self = MDOCK_MATE_PANEL_APPLET(widget); +	if (self->dock) { +		gtk_widget_size_request(GTK_WIDGET(self->dock), requisition); +	} +} + +static void mdock_mate_panel_applet_class_init(MDockMatePanelAppletClass *klass) +{ +	GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(klass); +	widget_class->size_allocate = mdock_mate_panel_applet_size_allocate; +	widget_class->size_request = mdock_mate_panel_applet_size_request; +} + +static void mdock_mate_panel_applet_init(MDockMatePanelApplet *self) +{ +	self->dock = MDOCK_WIDGET(mdock_widget_new()); +	gtk_container_add(GTK_CONTAINER(self), GTK_WIDGET(self->dock)); + +	GtkActionGroup *action_group = gtk_action_group_new("MDock 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=\"MDockPreferences\"/>" +	                             "<menuitem name=\"TopMenu About Item\" action=\"MDockAbout\"/>", +	                             action_group); + +	g_object_unref(action_group); +} + +MatePanelApplet *mdock_mate_panel_applet_new(void) +{ +	return MATE_PANEL_APPLET(g_object_new(MDOCK_TYPE_MATE_PANEL_APPLET, NULL)); +} diff --git a/mate-applet/mdock-mate-panel-applet.h b/mate-applet/mdock-mate-panel-applet.h new file mode 100644 index 0000000..a9c57db --- /dev/null +++ b/mate-applet/mdock-mate-panel-applet.h @@ -0,0 +1,56 @@ +/* + * Copyright 2015 Javier S. Pedro <dev.git@javispedro.com> + * + * This file is part of MDock. + * + * MDock 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 3 of the License, or + * (at your option) any later version. + * + * MDock 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 General Public License + * along with MDock.  If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef _MDOCK_MATE_PANEL_APPLET_H_ +#define _MDOCK_MATE_PANEL_APPLET_H_ + +#include <mate-panel-applet.h> +#include "../libmdock/mdock-widget.h" + +G_BEGIN_DECLS + +#define MDOCK_TYPE_MATE_PANEL_APPLET           mdock_mate_panel_applet_get_type() +#define MDOCK_MATE_PANEL_APPLET(obj)           (G_TYPE_CHECK_INSTANCE_CAST((obj), MDOCK_TYPE_MATE_PANEL_APPLET, MDockMatePanelApplet)) +#define MDOCK_IS_MATE_PANEL_APPLET(obj)        (G_TYPE_CHECK_INSTANCE_TYPE((obj), MDOCK_TYPE_MATE_PANEL_APPLET)) +#define MDOCK_MATE_PANEL_APPLET_CLASS(c)       (G_TYPE_CHECK_CLASS_CAST((c), MDOCK_TYPE_MATE_PANEL_APPLET, MDockMatePanelAppletClass)) +#define MDOCK_IS_MATE_PANEL_APPLET_CLASS(c)    (G_TYPE_CHECK_CLASS_TYPE((c), MDOCK_TYPE_MATE_PANEL_APPLET)) +#define MDOCK_MATE_PANEL_APPLET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), MDOCK_TYPE_MATE_PANEL_APPLET, MDockMatePanelAppletClass)) + +typedef struct _MDockMatePanelApplet        MDockMatePanelApplet; +typedef struct _MDockMatePanelAppletClass   MDockMatePanelAppletClass; + +struct _MDockMatePanelApplet +{ +	MatePanelApplet parent_instance; +	MDockWidget *dock; +	GtkActionGroup *actions; +}; + +struct _MDockMatePanelAppletClass +{ +	MatePanelAppletClass parent_class; +}; + +GType mdock_mate_panel_applet_get_type(void); + +MatePanelApplet *mdock_mate_panel_applet_new(void); + +G_END_DECLS + +#endif /* _MDOCK_MATE_PANEL_APPLET_H_ */ | 
