diff options
author | Javier <dev.git@javispedro.com> | 2015-07-26 01:02:12 +0200 |
---|---|---|
committer | Javier <dev.git@javispedro.com> | 2015-07-26 01:02:12 +0200 |
commit | baef440d424640a6fc99edd8a12a6abcea80c5fc (patch) | |
tree | 7fb717c04564618d3c9c7b0db1c46ddde138bf5a /mate-applet | |
parent | f690cd97506f45e02bb6383fde2a7c8f06820408 (diff) | |
download | topmenu-gtk-baef440d424640a6fc99edd8a12a6abcea80c5fc.tar.gz topmenu-gtk-baef440d424640a6fc99edd8a12a6abcea80c5fc.zip |
initial gtk2 "transparent" background attempt
Diffstat (limited to 'mate-applet')
-rw-r--r-- | mate-applet/Makefile.am | 2 | ||||
-rw-r--r-- | mate-applet/topmenu-mate-panel-applet.c | 41 | ||||
-rw-r--r-- | mate-applet/topmenu-mate-panel-applet.h | 4 |
3 files changed, 43 insertions, 4 deletions
diff --git a/mate-applet/Makefile.am b/mate-applet/Makefile.am index 6877eff..b4945e1 100644 --- a/mate-applet/Makefile.am +++ b/mate-applet/Makefile.am @@ -3,7 +3,7 @@ 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_CPPFLAGS = $(GTK_CFLAGS) $(MATEPANELAPPLET_CFLAGS) -I../libtopmenu-server -I../libtopmenu-common -DG_LOG_DOMAIN=\"topmenu-mate-panel-applet\" topmenu_mate_panel_applet_LDADD = $(GTK_LIBS) $(MATEPANELAPPLET_LIBS) ../libtopmenu-server/libtopmenu-server-gtk$(GTK_VERSION).la appletdir = $(datadir)/mate-panel/applets diff --git a/mate-applet/topmenu-mate-panel-applet.c b/mate-applet/topmenu-mate-panel-applet.c index eb133bb..32841b7 100644 --- a/mate-applet/topmenu-mate-panel-applet.c +++ b/mate-applet/topmenu-mate-panel-applet.c @@ -21,12 +21,13 @@ #include <glib/gi18n.h> #include <gdk/gdkx.h> +#include <cairo-xlib.h> G_DEFINE_TYPE(TopMenuMatePanelApplet, topmenu_mate_panel_applet, PANEL_TYPE_APPLET) static void display_preferences_dialog(GtkAction *action, TopMenuMatePanelApplet *self) { - // TODO + // No preferences yet } static void display_about_dialog(GtkAction *action, TopMenuMatePanelApplet *self) @@ -51,6 +52,41 @@ static const GtkActionEntry menu_verbs[] = { G_CALLBACK (display_about_dialog) } }; +#if GTK_MAJOR_VERSION == 3 +static void topmenu_mate_panel_applet_change_background(MatePanelApplet* applet, MatePanelAppletBackgroundType type, GdkRGBA* color, cairo_pattern_t* pattern) +{ + TopMenuMatePanelApplet *self = TOPMENU_MATE_PANEL_APPLET(applet); + + if (type == PANEL_PIXMAP_BACKGROUND) { + topmenu_background_set_from_cairo_pattern(self->menu_widget->background, pattern); + } else if (type == PANEL_COLOR_BACKGROUND) { + topmenu_background_set_from_color(self->menu_widget->background, + color->red, color->green, color->blue, + color->alpha); + } else { + topmenu_background_clear(self->menu_widget->background); + } +} +#elif GTK_MAJOR_VERSION == 2 +static void topmenu_mate_panel_applet_change_background(MatePanelApplet* applet, MatePanelAppletBackgroundType type, GdkColor* color, GdkPixmap* pixmap) +{ + TopMenuMatePanelApplet *self = TOPMENU_MATE_PANEL_APPLET(applet); + + if (type == PANEL_PIXMAP_BACKGROUND) { + topmenu_background_set_from_drawable(self->menu_widget->background, + GDK_PIXMAP_XID(pixmap)); + } else if (type == PANEL_COLOR_BACKGROUND) { + topmenu_background_set_from_color(self->menu_widget->background, + color->red / 65535.0, + color->green / 65535.0, + color->blue / 65535.0, + 1.0); + } else { + topmenu_background_clear(self->menu_widget->background); + } +} +#endif + static void topmenu_mate_panel_applet_size_allocate(GtkWidget *widget, GtkAllocation *allocation) { TopMenuMatePanelApplet *self = TOPMENU_MATE_PANEL_APPLET(widget); @@ -70,6 +106,9 @@ static void topmenu_mate_panel_applet_size_request(GtkWidget *widget, GtkRequisi static void topmenu_mate_panel_applet_class_init(TopMenuMatePanelAppletClass *klass) { + MatePanelAppletClass *applet_class = MATE_PANEL_APPLET_CLASS(klass); + applet_class->change_background = topmenu_mate_panel_applet_change_background; + 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; diff --git a/mate-applet/topmenu-mate-panel-applet.h b/mate-applet/topmenu-mate-panel-applet.h index de28b10..05fcb48 100644 --- a/mate-applet/topmenu-mate-panel-applet.h +++ b/mate-applet/topmenu-mate-panel-applet.h @@ -21,7 +21,7 @@ #define _TOPMENU_MATE_PANEL_APPLET_H_ #include <mate-panel-applet.h> -#include "../libtopmenu-server/topmenu-widget.h" +#include <topmenu-widget.h> G_BEGIN_DECLS @@ -47,7 +47,7 @@ struct _TopMenuMatePanelAppletClass MatePanelAppletClass parent_class; }; -GType topmenu_mate_panel_applet_get_type(void); +GType topmenu_mate_panel_applet_get_type(void) G_GNUC_CONST; MatePanelApplet *topmenu_mate_panel_applet_new(void); |