[Xfce4-commits] [panel-plugins/xfce4-xkb-plugin] 01/17: Port to GTK 3

noreply at xfce.org noreply at xfce.org
Sat Jun 10 14:31:34 CEST 2017


This is an automated email from the git hooks/post-receive script.

n   i   n   e   t   l   s       p   u   s   h   e   d       a       c   o   m   m   i   t       t   o       b   r   a   n   c   h       m   a   s   t   e   r   
   in repository panel-plugins/xfce4-xkb-plugin.

commit b6716e83da0e98b63ea1203f7ef766e1c498e45c
Author: Viktor Odintsev <zakhams at gmail.com>
Date:   Wed Mar 15 15:10:13 2017 +0300

    Port to GTK 3
---
 .gitignore                                         |  5 +-
 configure.in.in => configure.ac.in                 | 19 ++---
 panel-plugin/Makefile.am                           | 95 ++++++++++++----------
 panel-plugin/xfce4-xkb-plugin.c                    | 50 +++++++-----
 panel-plugin/xfce4-xkb-plugin.h                    | 15 ----
 panel-plugin/xkb-cairo.c                           | 52 +++---------
 panel-plugin/xkb-cairo.h                           | 11 +--
 panel-plugin/xkb-callbacks.c                       | 80 +++++-------------
 panel-plugin/xkb-callbacks.h                       | 16 +---
 panel-plugin/xkb-config.c                          |  3 +-
 panel-plugin/xkb-settings-dialog.c                 | 41 ++++++----
 panel-plugin/xkb-util.c                            |  1 -
 .../{xkb-plugin.desktop.in.in => xkb.desktop.in}   |  4 +-
 po/POTFILES.in                                     |  3 +-
 14 files changed, 158 insertions(+), 237 deletions(-)

diff --git a/.gitignore b/.gitignore
index eb0ea70..238f737 100644
--- a/.gitignore
+++ b/.gitignore
@@ -6,7 +6,10 @@ po/*.gmo
 *.o
 *.tar.*
 config.*
-configure*
 m4/*.m4
 *.m4
 *.in
+/configure*
+!/configure.ac.in
+!/po/POTFILES.in
+!/panel-plugin/xkb.desktop.in
diff --git a/configure.in.in b/configure.ac.in
similarity index 78%
rename from configure.in.in
rename to configure.ac.in
index c35d72d..933982d 100644
--- a/configure.in.in
+++ b/configure.ac.in
@@ -34,6 +34,7 @@ dnl ***************************
 AM_INIT_AUTOMAKE([1.8 dist-bzip2 tar-ustar])
 AM_CONFIG_HEADER([config.h])
 AM_MAINTAINER_MODE()
+m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
 
 dnl *******************************
 dnl *** Check for UNIX variants ***
@@ -70,16 +71,14 @@ XDT_I18N([@LINGUAS@])
 dnl ***********************************
 dnl *** Check for required packages ***
 dnl ***********************************
-XDT_CHECK_PACKAGE([GTK], [gtk+-2.0], [2.6.0])
-XDT_CHECK_PACKAGE([LIBXFCE4UTIL], [libxfce4util-1.0], [4.8.0])
-XDT_CHECK_PACKAGE([LIBXFCE4UI], [libxfce4ui-1], [4.8.0])
-XDT_CHECK_PACKAGE([LIBXFCE4PANEL], [libxfce4panel-1.0], [4.8.0])
-XDT_CHECK_PACKAGE([LIBXKLAVIER], [libxklavier], [5.0])
-XDT_CHECK_PACKAGE([LIBRSVG], [librsvg-2.0], [2.18])
-dnl check librsvg version to see if including headers other than rsvg.h is deprecated
-XDT_CHECK_OPTIONAL_PACKAGE([LIBRSVG_2_36_2], [librsvg-2.0], [2.36.2], [librsvg_2.36.2], [deprecated includes of librsvg header files (always leave enabled)], yes)
-XDT_CHECK_PACKAGE([LIBWNCK], [libwnck-1.0], [2.12])
-XDT_CHECK_PACKAGE([GARCON], [garcon-1], [0.1.5])
+XDT_CHECK_PACKAGE([GTK], [gtk+-3.0], [3.20.0])
+XDT_CHECK_PACKAGE([LIBXFCE4PANEL], [libxfce4panel-2.0], [4.12.0])
+XDT_CHECK_PACKAGE([LIBXFCE4UTIL], [libxfce4util-1.0], [4.12.0])
+XDT_CHECK_PACKAGE([LIBXFCE4UI], [libxfce4ui-2], [4.12.0])
+XDT_CHECK_PACKAGE([LIBXKLAVIER], [libxklavier], [5.4])
+XDT_CHECK_PACKAGE([LIBRSVG], [librsvg-2.0], [2.40])
+XDT_CHECK_PACKAGE([LIBWNCK], [libwnck-3.0], [3.14])
+XDT_CHECK_PACKAGE([GARCON], [garcon-1], [0.4.0])
 
 dnl ***********************************
 dnl *** Check for debugging support ***
diff --git a/panel-plugin/Makefile.am b/panel-plugin/Makefile.am
index a4bb4c3..dc33005 100644
--- a/panel-plugin/Makefile.am
+++ b/panel-plugin/Makefile.am
@@ -1,65 +1,72 @@
 # $Id$
 
-plugindir = $(libexecdir)/xfce4/panel-plugins
+plugindir = \
+	$(libdir)/xfce4/panel/plugins
 
-plugin_PROGRAMS = xfce4-xkb-plugin
+plugin_LTLIBRARIES = \
+	libxkb.la
 
-xfce4_xkb_plugin_SOURCES =								\
-	xfce4-xkb-plugin.h								\
-	xfce4-xkb-plugin-private.h							\
-	xfce4-xkb-plugin.c								\
-	xkb-settings-dialog.h								\
-	xkb-settings-dialog.c								\
-	xkb-config.h									\
-	xkb-config.c									\
-	xkb-util.h									\
-	xkb-util.c									\
-	xkb-cairo.h									\
-	xkb-cairo.c									\
-	xkb-callbacks.h									\
+libxkb_la_SOURCES = \
+	xfce4-xkb-plugin.h \
+	xfce4-xkb-plugin-private.h \
+	xfce4-xkb-plugin.c \
+	xkb-settings-dialog.h \
+	xkb-settings-dialog.c \
+	xkb-config.h \
+	xkb-config.c \
+	xkb-util.h \
+	xkb-util.c \
+	xkb-cairo.h \
+	xkb-cairo.c \
+	xkb-callbacks.h \
 	xkb-callbacks.c
 
+libxkb_la_CPPFLAGS = \
+	-I$(top_srcdir) \
+	$(PLATFORM_CPPFLAGS)
 
-xfce4_xkb_plugin_CFLAGS =								\
-	@LIBXFCE4PANEL_CFLAGS@								\
-	@GTK_CFLAGS@									\
-	@LIBXFCE4UI_CFLAGS@								\
-	@LIBXFCE4UTIL_CFLAGS@								\
-	@LIBXKLAVIER_CFLAGS@								\
-	@LIBRSVG_CFLAGS@								\
-	@LIBWNCK_CFLAGS@								\
-	@GARCON_CFLAGS@								\
-	-DPACKAGE_LOCALE_DIR=\"$(localedir)\"						\
-	-DFLAGSDIR=\"$(datadir)/xfce4/xkb/flags\"					\
+libxkb_la_CFLAGS = \
+	$(GTK_CFLAGS) \
+	$(LIBXFCE4PANEL_CFLAGS) \
+	$(LIBXFCE4UTIL_CFLAGS) \
+	$(LIBXFCE4UI_CFLAGS) \
+	$(LIBXKLAVIER_CFLAGS) \
+	$(LIBRSVG_CFLAGS) \
+	$(LIBWNCK_CFLAGS) \
+	$(GARCON_CFLAGS) \
+	$(PLATFORM_CFLAGS) \
+	-DPACKAGE_LOCALE_DIR=\"$(localedir)\" \
+	-DFLAGSDIR=\"$(datadir)/xfce4/xkb/flags\" \
 	-DWNCK_I_KNOW_THIS_IS_UNSTABLE
 
+libxkb_la_LDFLAGS = \
+	-avoid-version \
+	-module \
+	-no-undefined \
+	$(PLATFORM_LDFLAGS)
 
-xfce4_xkb_plugin_LDADD = 								\
-	@LIBXFCE4PANEL_LIBS@								\
-	@GTK_LIBS@									\
-	@LIBXFCE4UI_LIBS@								\
-	@LIBXFCE4UTIL_LIBS@								\
-	@LIBXKLAVIER_LIBS@								\
-	@LIBWNCK_LIBS@									\
-	@GARCON_LIBS@									\
-	@LIBRSVG_LIBS@
+libxkb_la_LIBADD = \
+	$(GTK_LIBS) \
+	$(LIBXFCE4PANEL_LIBS) \
+	$(LIBXFCE4UTIL_LIBS) \
+	$(LIBXFCE4UI_LIBS) \
+	$(LIBXKLAVIER_LIBS) \
+	$(LIBWNCK_LIBS) \
+	$(GARCON_LIBS) \
+	$(LIBRSVG_LIBS)
 
 #
 # Desktop file
 #
-desktopdir = $(datadir)/xfce4/panel-plugins
-desktop_in_in_files = xkb-plugin.desktop.in.in
-desktop_in_files = $(desktop_in_in_files:.desktop.in.in=.desktop.in)
-%.desktop.in: %.desktop.in.in
-	sed -e "s,\@libexecdir\@,$(libexecdir),g" < $< > $@
+desktopdir = $(datadir)/xfce4/panel/plugins
+desktop_in_files = xkb.desktop.in
 desktop_DATA = $(desktop_in_files:.desktop.in=.desktop)
 @INTLTOOL_DESKTOP_RULE@
 
-EXTRA_DIST =								\
-	$(desktop_in_in_files)
+EXTRA_DIST = \
+	$(desktop_in_files)
 
-CLEANFILES =								\
-	$(desktop_in_files)						\
+CLEANFILES = \
 	$(desktop_DATA)
 
 # vi:set ts=8 sw=8 noet ai nocindent syntax=automake:
diff --git a/panel-plugin/xfce4-xkb-plugin.c b/panel-plugin/xfce4-xkb-plugin.c
index 2d24f4e..0486ab1 100644
--- a/panel-plugin/xfce4-xkb-plugin.c
+++ b/panel-plugin/xfce4-xkb-plugin.c
@@ -91,7 +91,7 @@ static void         xfce_xkb_configure_layout           (GtkWidget *widget,
  *                        Implementation                              *
  * ================================================================== */
 
-XFCE_PANEL_PLUGIN_REGISTER_EXTERNAL (xfce_xkb_construct);
+XFCE_PANEL_PLUGIN_REGISTER (xfce_xkb_construct);
 
 static void
 xfce_xkb_construct (XfcePanelPlugin *plugin)
@@ -201,6 +201,7 @@ xkb_new (XfcePanelPlugin *plugin)
     t_xkb *xkb;
     gchar *filename;
     WnckScreen *wnck_screen;
+    GtkCssProvider *css_provider;
 
     xkb = panel_slice_new0 (t_xkb);
     xkb->plugin = plugin;
@@ -216,7 +217,14 @@ xkb_new (XfcePanelPlugin *plugin)
     gtk_button_set_relief (GTK_BUTTON (xkb->btn), GTK_RELIEF_NONE);
     gtk_container_add (GTK_CONTAINER (xkb->plugin), xkb->btn);
     xfce_panel_plugin_add_action_widget (xkb->plugin, xkb->btn);
-    xkb->button_state = GTK_STATE_NORMAL;
+    gtk_widget_add_events (xkb->btn, GDK_SCROLL_MASK);
+
+    /* remove padding inside button */
+    css_provider = gtk_css_provider_new ();
+    gtk_css_provider_load_from_data (css_provider, ".xfce4-panel button {padding: 0;}", -1, NULL);
+    gtk_style_context_add_provider (GTK_STYLE_CONTEXT (gtk_widget_get_style_context (GTK_WIDGET (xkb->btn))),
+            GTK_STYLE_PROVIDER (css_provider), GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
+    g_object_unref (css_provider);
 
     gtk_widget_show (xkb->btn);
     g_signal_connect (xkb->btn, "clicked", G_CALLBACK (xkb_plugin_button_clicked), xkb);
@@ -227,17 +235,10 @@ xkb_new (XfcePanelPlugin *plugin)
     g_signal_connect (xkb->btn, "query-tooltip",
             G_CALLBACK (xkb_plugin_set_tooltip), xkb);
 
-    g_signal_connect (G_OBJECT (xkb->btn), "enter-notify-event",
-            G_CALLBACK (xkb_plugin_button_entered), xkb);
-    g_signal_connect (G_OBJECT (xkb->btn), "leave-notify-event",
-            G_CALLBACK (xkb_plugin_button_left), xkb);
-    g_signal_connect (G_OBJECT (xkb->btn), "size-allocate",
-            G_CALLBACK (xkb_plugin_button_size_allocated), xkb);
-
     xkb->layout_image = gtk_image_new ();
     gtk_container_add (GTK_CONTAINER (xkb->btn), xkb->layout_image);
-    g_signal_connect (G_OBJECT (xkb->layout_image), "expose-event",
-            G_CALLBACK (xkb_plugin_layout_image_exposed), xkb);
+    g_signal_connect (G_OBJECT (xkb->layout_image), "draw",
+            G_CALLBACK (xkb_plugin_layout_image_draw), xkb);
     gtk_widget_show (GTK_WIDGET (xkb->layout_image));
 
     if (xkb_config_initialize (xkb->group_policy, xkb_state_changed, xkb))
@@ -354,6 +355,7 @@ static gboolean
 xkb_calculate_sizes (t_xkb *xkb, GtkOrientation orientation, gint panel_size)
 {
     guint nrows;
+    gint hsize, vsize;
 
     nrows       = xfce_panel_plugin_get_nrows (xkb->plugin);
     panel_size /= nrows;
@@ -362,36 +364,37 @@ xkb_calculate_sizes (t_xkb *xkb, GtkOrientation orientation, gint panel_size)
     switch (orientation)
     {
         case GTK_ORIENTATION_HORIZONTAL:
-            xkb->vsize = panel_size;
+            vsize = panel_size;
             if (nrows > 1)
             {
-                xkb->hsize = xkb->vsize;
+                hsize = panel_size;
             }
             else
             {
-                xkb->hsize = (int) (1.33 * panel_size);
+                hsize = (int) (1.33 * panel_size);
             }
 
-            gtk_widget_set_size_request (xkb->btn, xkb->hsize, xkb->vsize);
+            gtk_widget_set_size_request (xkb->btn, hsize, vsize);
             break;
         case GTK_ORIENTATION_VERTICAL:
-            xkb->hsize = panel_size;
+            hsize = panel_size;
             if (nrows > 1)
             {
-                xkb->vsize = xkb->hsize;
+                vsize = panel_size;
             }
             else
             {
-                xkb->vsize = (int) (0.75 * panel_size);
+                vsize = (int) (0.75 * panel_size);
             }
-            if (xkb->vsize < 10) xkb->vsize = 10;
-            gtk_widget_set_size_request (xkb->btn, xkb->hsize, xkb->vsize);
+            if (vsize < 10) vsize = 10;
+
+            gtk_widget_set_size_request (xkb->btn, hsize, vsize);
             break;
         default:
             break;
     }
 
-    DBG ("size requested: h/v (%p: %d/%d)", xkb, xkb->hsize, xkb->vsize);
+    DBG ("size requested: h/v (%p: %d/%d)", xkb, hsize, vsize);
 
     xkb_refresh_gui (xkb);
     return TRUE;
@@ -470,10 +473,13 @@ void
 xkb_refresh_gui (t_xkb *xkb)
 {
     GdkDisplay * display;
+    GtkAllocation allocation;
+
+    gtk_widget_get_allocation (GTK_WIDGET (xkb->btn), &allocation);
 
     /* Part of the image may remain visible after display type change */
     gtk_widget_queue_draw_area (xkb->btn, 0, 0,
-            xkb->button_hsize, xkb->button_vsize);
+            allocation.width, allocation.height);
 
     display = gdk_display_get_default();
     if (display)
diff --git a/panel-plugin/xfce4-xkb-plugin.h b/panel-plugin/xfce4-xkb-plugin.h
index 372a27a..2b1f778 100644
--- a/panel-plugin/xfce4-xkb-plugin.h
+++ b/panel-plugin/xfce4-xkb-plugin.h
@@ -53,31 +53,16 @@ typedef struct
 {
     XfcePanelPlugin *plugin;
 
-    /* options */
-    gint hsize;                   /* plugin horizontal size */
-    gint vsize;                   /* plugin vertical size */
-    gint button_hsize;            /* real allocated button size - see below */
-    gint button_vsize;            /* read allocated button size - see below */
-
     t_display_type display_type;  /* display layout as image ot text */
     guint display_text_scale; /* text scale % for text layout */
     guint display_img_scale;  /* image scale % for flag layout */
     t_group_policy group_policy;     /* per-app/window/global policy */
 
-    gint button_state;            /* gtk state of the button */
-
     /* widgets */
     GtkWidget *btn;
     GtkWidget *layout_image;
     GtkWidget *popup;
 } t_xkb;
 
-/*
- * NOTE: The t_xkb->button_size field is due to xfce panel 4.4.1
- * prior versions, allowing a plugin to resize the whole panel.
- * This should be removed after xfce 4.4.2, where this behaviour
- * should not be possible.
- */
-
 #endif
 
diff --git a/panel-plugin/xkb-cairo.c b/panel-plugin/xkb-cairo.c
index 27454f3..ce79214 100644
--- a/panel-plugin/xkb-cairo.c
+++ b/panel-plugin/xkb-cairo.c
@@ -27,47 +27,25 @@
 #include "xkb-util.h"
 #include "xfce4-xkb-plugin.h"
 
-#ifndef HAVE_LIBRSVG_2_36_2
-#include <librsvg/rsvg-cairo.h>
-#endif
+#include <librsvg/rsvg.h>
 
 #define XKB_PREFERRED_FONT "Courier New, Courier 10 Pitch, Monospace Bold"
 
-#define xkb_cairo_arc_for_flag(cr, x, y, r, a1, a2) \
-    xx = x; yy = y; \
-    cairo_device_to_user (cr, &xx, &yy); \
-    cairo_arc (cr, xx, yy, r, a1, a2);
-
-#define xkb_cairo_arc_for_label(cr, x, y, r, a1, a2) xx = x; \
-    yy = y; \
-    cairo_device_to_user (cr, &xx, &yy); \
-    cairo_arc (cr, xx, yy, r, a1, a2);
-
-#define xkb_cairo_move_to(cr, x, y) xx = x; \
-    yy = y; \
-    cairo_device_to_user (cr, &xx, &yy); \
-    cairo_move_to (cr, xx, yy);
-
-
 void
 xkb_cairo_draw_flag (cairo_t *cr,
                      const gchar *group_name,
-                     gint panel_size,
                      gint actual_width,
                      gint actual_height,
-                     gint width,
-                     gint height,
                      gint variant_markers_count,
                      guint max_variant_markers_count,
                      guint img_scale,
                      guint text_scale,
-                     GdkColor fgcolor)
+                     GdkRGBA rgba)
 {
     gchar *filename;
     RsvgHandle *handle;
     RsvgDimensionData dim;
     double scalex, scaley;
-    double xx, yy;
     gint i;
     double layoutx, layouty, img_width, img_height;
     double radius, diameter;
@@ -85,19 +63,17 @@ xkb_cairo_draw_flag (cairo_t *cr,
     if (!handle)
     {
         xkb_cairo_draw_label (cr, group_name,
-                panel_size,
                 actual_width, actual_height,
-                width, height,
                 variant_markers_count,
                 text_scale,
-                fgcolor);
+                rgba);
         return;
     }
 
     rsvg_handle_get_dimensions (handle, &dim);
 
-    scalex = (double) (width - 4) / dim.width;
-    scaley = (double) (height - 4) / dim.height;
+    scalex = (double) (actual_width - 4) / dim.width;
+    scaley = (double) (actual_height - 4) / dim.height;
 
     scalex *= img_scale / 100.0;
     scaley *= img_scale / 100.0;
@@ -119,8 +95,8 @@ xkb_cairo_draw_flag (cairo_t *cr,
 
     cairo_restore (cr);
 
-    DBG ("actual width/height: %d/%d; w/h: %d/%d; img w/h: %.1f/%.1f; markers: %d, max markers: %d",
-         actual_width, actual_height, width, height, img_width, img_height,
+    DBG ("actual width/height: %d/%d; img w/h: %.1f/%.1f; markers: %d, max markers: %d",
+         actual_width, actual_height, img_width, img_height,
          variant_markers_count, max_variant_markers_count);
     DBG ("layout x/y: %.1f/%.1f", layoutx, layouty);
 
@@ -171,7 +147,7 @@ xkb_cairo_draw_flag (cairo_t *cr,
 
         DBG ("variant center x/y: %d/%d, diameter: %.1f, spacing: %d",
              x, y, diameter, spacing);
-        xkb_cairo_arc_for_flag (cr, x, y, radius, 0, 2 * G_PI);
+        cairo_arc (cr, x, y, radius, 0, 2 * G_PI);
 
         cairo_set_source_rgb (cr, 0, 0, 0);
         cairo_fill_preserve (cr);
@@ -186,19 +162,15 @@ xkb_cairo_draw_flag (cairo_t *cr,
 void
 xkb_cairo_draw_label (cairo_t *cr,
                       const gchar *group_name,
-                      const gint panel_size,
                       const gint actual_width,
                       const gint actual_height,
-                      const gint width,
-                      const gint height,
                       const gint variant_markers_count,
                       const guint text_scale,
-                      const GdkColor fgcolor)
+                      const GdkRGBA rgba)
 {
     gchar *normalized_group_name;
     gint pango_width, pango_height;
     double layoutx, layouty, text_width, text_height;
-    double xx, yy;
     double scalex, scaley;
     gint i;
     double radius, diameter;
@@ -228,7 +200,7 @@ xkb_cairo_draw_label (cairo_t *cr,
     pango_layout_set_font_description (layout, desc);
     pango_font_description_free (desc);
 
-    gdk_cairo_set_source_color (cr, &fgcolor);
+    gdk_cairo_set_source_rgba (cr, &rgba);
     pango_layout_get_pixel_size (layout, &pango_width, &pango_height);
     DBG ("pango_width/height: %d/%d", pango_width, pango_height);
 
@@ -262,8 +234,8 @@ xkb_cairo_draw_label (cairo_t *cr,
     DBG ("layout x/y: %.2f/%.2f scale x/y: %.2f/%.2f, radius: %.2f",
          layoutx, layouty, scalex, scaley, radius);
 
-    xkb_cairo_move_to (cr, layoutx, layouty);
     cairo_save (cr);
+    cairo_move_to (cr, layoutx, layouty);
     cairo_scale (cr, scalex, scaley);
     pango_cairo_show_layout (cr, layout);
     cairo_restore (cr);
@@ -272,7 +244,7 @@ xkb_cairo_draw_label (cairo_t *cr,
     {
         cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
         cairo_set_line_width (cr, 1);
-        xkb_cairo_arc_for_label (cr,
+        cairo_arc (cr,
                 layoutx + text_width + 3 + (diameter * i),
                 layouty + text_height - (text_height / 5),
                 radius, 0, 2 * G_PI
diff --git a/panel-plugin/xkb-cairo.h b/panel-plugin/xkb-cairo.h
index fbac467..ec06b93 100644
--- a/panel-plugin/xkb-cairo.h
+++ b/panel-plugin/xkb-cairo.h
@@ -30,32 +30,25 @@
 #include <glib/gprintf.h>
 #include <gdk/gdk.h>
 #include <cairo/cairo.h>
-#include <librsvg/rsvg.h>
 #include <pango/pangocairo.h>
 
 void        xkb_cairo_draw_flag     (cairo_t *cr,
                                      const gchar *flag_name,
-                                     gint panel_size,
                                      gint actual_width,
                                      gint actual_height,
-                                     gint width,
-                                     gint height,
                                      gint variant_markers_count,
                                      guint max_variant_markers_count,
                                      guint img_scale,
                                      guint text_scale,
-                                     GdkColor fgcolor);
+                                     GdkRGBA rgba);
 
 void        xkb_cairo_draw_label    (cairo_t *cr,
                                      const gchar *group_name,
-                                     const gint panel_size,
                                      const gint actual_width,
                                      const gint actual_height,
-                                     const gint width,
-                                     const gint height,
                                      const gint variant_markers_count,
                                      const guint text_scale,
-                                     const GdkColor fgcolor);
+                                     const GdkRGBA rgba);
 
 #endif
 
diff --git a/panel-plugin/xkb-callbacks.c b/panel-plugin/xkb-callbacks.c
index 3453c62..049ba20 100644
--- a/panel-plugin/xkb-callbacks.c
+++ b/panel-plugin/xkb-callbacks.c
@@ -70,93 +70,51 @@ xkb_plugin_window_closed (WnckScreen *screen,
     xkb_config_window_closed (window_id);
 }
 
-void
-xkb_plugin_button_size_allocated (GtkWidget *button,
-                                  GtkAllocation *allocation,
-                                  t_xkb *xkb)
-{
-    xkb->button_hsize = allocation->width;
-    xkb->button_vsize = allocation->height;
-
-    DBG ("size_allocated: h/v (%p: %d/%d)",
-         xkb, xkb->button_hsize, xkb->button_vsize);
-}
-
 gboolean
-xkb_plugin_button_entered (GtkWidget *widget,
-                           GdkEventCrossing *event,
-                           t_xkb *xkb)
-{
-    xkb->button_state = GTK_STATE_PRELIGHT;
-    return FALSE;
-}
-
-gboolean
-xkb_plugin_button_left (GtkWidget *widget,
-                        GdkEventCrossing *event,
-                        t_xkb *xkb)
-{
-    xkb->button_state = GTK_STATE_NORMAL;
-    return FALSE;
-}
-
-gboolean
-xkb_plugin_layout_image_exposed (GtkWidget *widget,
-                                 GdkEventExpose *event,
+xkb_plugin_layout_image_draw (GtkWidget *widget,
+                                 cairo_t *cr,
                                  t_xkb *xkb)
 {
     const gchar *group_name;
-    cairo_t *cr;
-    GtkStyle *style;
-    GdkColor fgcolor;
-    gint actual_hsize, actual_vsize, panel_size;
-    gint vsize;
-
-    actual_hsize = (xkb->button_hsize > xkb->hsize) ? xkb->button_hsize : xkb->hsize;
-    actual_vsize = (xkb->button_vsize > xkb->vsize) ? xkb->button_vsize : xkb->vsize;
-
-    vsize = MIN (xkb->vsize, (int) (xkb->hsize * 0.75));
-
-    panel_size   = xfce_panel_plugin_get_size (xkb->plugin);
-    panel_size  /= xfce_panel_plugin_get_nrows (xkb->plugin);
-
-    style = gtk_widget_get_style (GTK_WIDGET (xkb->btn));
-    fgcolor = style->fg[xkb->button_state];
+    GtkAllocation allocation;
+    GtkStyleContext *style_ctx;
+    GtkStateFlags state;
+    GdkRGBA rgba;
+    gint actual_hsize, actual_vsize;
+
+    gtk_widget_get_allocation (GTK_WIDGET (widget), &allocation);
+    actual_hsize = allocation.width;
+    actual_vsize = allocation.height;
+
+    state = gtk_widget_get_state_flags (GTK_WIDGET (xkb->btn));
+    style_ctx = gtk_widget_get_style_context (GTK_WIDGET (xkb->btn));
+    gtk_style_context_get_color (style_ctx, state, &rgba);
     group_name = xkb_config_get_group_name (-1);
 
-    DBG ("img_exposed: actual h/v (%d/%d), xkb h/v (%d/%d), panel sz (%d)",
-         actual_hsize, actual_vsize,
-         xkb->hsize, xkb->vsize, panel_size);
-
-    cr = gdk_cairo_create ((GTK_WIDGET (xkb->layout_image))->window);
+    DBG ("img_exposed: actual h/v (%d/%d)",
+         actual_hsize, actual_vsize);
 
     if (xkb->display_type == DISPLAY_TYPE_IMAGE)
     {
         xkb_cairo_draw_flag (cr, group_name,
-                panel_size,
                 actual_hsize, actual_vsize,
-                xkb->hsize, vsize,
                 xkb_config_variant_index_for_group (-1),
                 xkb_config_get_max_group_count (),
                 xkb->display_img_scale,
                 xkb->display_text_scale,
-                fgcolor
+                rgba
         );
     }
     else
     {
         xkb_cairo_draw_label (cr, group_name,
-                panel_size,
                 actual_hsize, actual_vsize,
-                xkb->hsize, vsize,
                 xkb_config_variant_index_for_group (-1),
                 xkb->display_text_scale,
-                fgcolor
+                rgba
         );
     }
 
-    cairo_destroy (cr);
-
     return FALSE;
 }
 
diff --git a/panel-plugin/xkb-callbacks.h b/panel-plugin/xkb-callbacks.h
index a06c22f..2aea893 100644
--- a/panel-plugin/xkb-callbacks.h
+++ b/panel-plugin/xkb-callbacks.h
@@ -32,20 +32,8 @@
 
 #include "xfce4-xkb-plugin.h"
 
-gboolean        xkb_plugin_layout_image_exposed     (GtkWidget *widget,
-                                 GdkEventExpose *event,
-                                 t_xkb *xkb);
-
-gboolean        xkb_plugin_button_entered       (GtkWidget *widget,
-                                 GdkEventCrossing *event,
-                                 t_xkb *xkb);
-
-gboolean        xkb_plugin_button_left          (GtkWidget *widget,
-                                 GdkEventCrossing *event,
-                                 t_xkb *xkb);
-
-void            xkb_plugin_button_size_allocated    (GtkWidget *button,
-                                 GtkAllocation *allocation,
+gboolean        xkb_plugin_layout_image_draw     (GtkWidget *widget,
+                                 cairo_t *cr,
                                  t_xkb *xkb);
 
 void            xkb_plugin_active_window_changed    (WnckScreen *screen,
diff --git a/panel-plugin/xkb-config.c b/panel-plugin/xkb-config.c
index b7234d2..b84fd09 100644
--- a/panel-plugin/xkb-config.c
+++ b/panel-plugin/xkb-config.c
@@ -38,6 +38,7 @@
 #include <librsvg/rsvg.h>
 
 #ifndef DEBUG
+#undef G_DISABLE_ASSERT
 #define G_DISABLE_ASSERT
 #endif
 
@@ -104,7 +105,7 @@ xkb_config_initialize (t_group_policy group_policy,
     config->callback = callback;
     config->callback_data = callback_data;
 
-    config->engine = xkl_engine_get_instance (GDK_DISPLAY ());
+    config->engine = xkl_engine_get_instance (gdk_x11_get_default_xdisplay ());
 
     if (!config->engine)
     {
diff --git a/panel-plugin/xkb-settings-dialog.c b/panel-plugin/xkb-settings-dialog.c
index 2431773..53f0baa 100644
--- a/panel-plugin/xkb-settings-dialog.c
+++ b/panel-plugin/xkb-settings-dialog.c
@@ -118,22 +118,26 @@ xfce_xkb_configure (XfcePanelPlugin *plugin,
     xfce_panel_plugin_block_menu (plugin);
 
     settings_dialog = xfce_titled_dialog_new_with_buttons (_("Keyboard Layouts"),
-            NULL, GTK_DIALOG_NO_SEPARATOR,
-            GTK_STOCK_CLOSE, GTK_RESPONSE_OK, NULL);
+            NULL, 0, "gtk-close", GTK_RESPONSE_OK, NULL);
     gtk_window_set_icon_name (GTK_WINDOW (settings_dialog), "xfce4-settings");
 
-    vbox = gtk_vbox_new (FALSE, 2);
+    vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 2);
+    gtk_box_set_homogeneous (GTK_BOX (vbox), FALSE);
+    gtk_widget_set_margin_start (vbox, 8);
+    gtk_widget_set_margin_end (vbox, 8);
+    gtk_widget_set_margin_top (vbox, 8);
+    gtk_widget_set_margin_bottom (vbox, 8);
     gtk_widget_show (vbox);
-    gtk_container_add (GTK_CONTAINER (GTK_DIALOG (settings_dialog)->vbox), vbox);
+    gtk_container_add (GTK_CONTAINER (gtk_dialog_get_content_area (GTK_DIALOG (settings_dialog))), vbox);
 
     /*****/
     display_type_frame = xfce_gtk_frame_box_new (_("Show layout as:"), &bin);
     gtk_widget_show (display_type_frame);
     gtk_box_pack_start (GTK_BOX (vbox), display_type_frame, TRUE, TRUE, 2);
 
-    display_type_optmenu = gtk_combo_box_new_text ();
-    gtk_combo_box_append_text (GTK_COMBO_BOX (display_type_optmenu), _("image"));
-    gtk_combo_box_append_text (GTK_COMBO_BOX (display_type_optmenu), _("text"));
+    display_type_optmenu = gtk_combo_box_text_new ();
+    gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (display_type_optmenu), _("image"));
+    gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (display_type_optmenu), _("text"));
     gtk_widget_set_size_request (display_type_optmenu, 230, -1);
     gtk_container_add (GTK_CONTAINER (bin), display_type_optmenu);
 
@@ -142,8 +146,7 @@ xfce_xkb_configure (XfcePanelPlugin *plugin,
     gtk_widget_show (display_textsize_frame);
     gtk_box_pack_start (GTK_BOX (vbox), display_textsize_frame, TRUE, TRUE, 2);
 
-    display_textsize_scale = gtk_hscale_new_with_range (0, 100, 1);
-    gtk_range_set_update_policy (GTK_RANGE (display_textsize_scale), GTK_UPDATE_CONTINUOUS);
+    display_textsize_scale = gtk_scale_new_with_range (GTK_ORIENTATION_HORIZONTAL, 0, 100, 1);
     gtk_scale_set_value_pos (GTK_SCALE (display_textsize_scale), GTK_POS_RIGHT);
     gtk_widget_set_size_request (display_textsize_scale, 230, -1);
     gtk_container_add (GTK_CONTAINER (bin), display_textsize_scale);
@@ -153,8 +156,7 @@ xfce_xkb_configure (XfcePanelPlugin *plugin,
     gtk_widget_show (display_imgsize_frame);
     gtk_box_pack_start (GTK_BOX (vbox), display_imgsize_frame, TRUE, TRUE, 2);
 
-    display_imgsize_scale = gtk_hscale_new_with_range (0, 100, 1);
-    gtk_range_set_update_policy (GTK_RANGE (display_imgsize_scale), GTK_UPDATE_CONTINUOUS);
+    display_imgsize_scale = gtk_scale_new_with_range (GTK_ORIENTATION_HORIZONTAL, 0, 100, 1);
     gtk_scale_set_value_pos (GTK_SCALE (display_imgsize_scale), GTK_POS_RIGHT);
     gtk_widget_set_size_request (display_imgsize_scale, 230, -1);
     gtk_container_add (GTK_CONTAINER (bin), display_imgsize_scale);
@@ -163,10 +165,10 @@ xfce_xkb_configure (XfcePanelPlugin *plugin,
     gtk_widget_show (group_policy_frame);
     gtk_box_pack_start (GTK_BOX (vbox), group_policy_frame, TRUE, TRUE, 2);
 
-    group_policy_combo = gtk_combo_box_new_text ();
-    gtk_combo_box_append_text (GTK_COMBO_BOX (group_policy_combo), _("globally"));
-    gtk_combo_box_append_text (GTK_COMBO_BOX (group_policy_combo), _("per window"));
-    gtk_combo_box_append_text (GTK_COMBO_BOX (group_policy_combo), _("per application"));
+    group_policy_combo = gtk_combo_box_text_new ();
+    gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (group_policy_combo), _("globally"));
+    gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (group_policy_combo), _("per window"));
+    gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (group_policy_combo), _("per application"));
     gtk_widget_set_size_request (group_policy_combo, 230, -1);
     gtk_container_add (GTK_CONTAINER (bin), group_policy_combo);
     gtk_widget_show (group_policy_combo);
@@ -193,6 +195,8 @@ void
 xfce_xkb_about (XfcePanelPlugin *plugin)
 {
     GtkWidget *about;
+    GdkPixbuf *icon;
+
     const gchar* authors[] = {
         "Alexander Iliev <sasoiliev at mamul.org>",
         "Gauvain Pocentek <gauvainpocentek at gmail.com>",
@@ -200,13 +204,14 @@ xfce_xkb_about (XfcePanelPlugin *plugin)
         NULL
     };
 
+    icon = xfce_panel_pixbuf_from_source ("preferences-desktop-keyboard", NULL, 32);
     about = gtk_about_dialog_new ();
-    gtk_about_dialog_set_name (GTK_ABOUT_DIALOG (about),
+    gtk_about_dialog_set_program_name (GTK_ABOUT_DIALOG (about),
             _("Keyboard Layouts Plugin"));
     gtk_about_dialog_set_version (GTK_ABOUT_DIALOG (about),
             PACKAGE_VERSION);
     gtk_about_dialog_set_logo (GTK_ABOUT_DIALOG (about),
-            NULL);
+            icon);
     gtk_about_dialog_set_license (GTK_ABOUT_DIALOG (about),
             xfce_get_license_text (XFCE_LICENSE_TEXT_GPL));
     gtk_about_dialog_set_authors (GTK_ABOUT_DIALOG (about),
@@ -219,4 +224,6 @@ xfce_xkb_about (XfcePanelPlugin *plugin)
             _("Other plugins available here"));
     gtk_dialog_run (GTK_DIALOG (about));
     gtk_widget_destroy (about);
+    if (icon)
+        g_object_unref (G_OBJECT (icon));
 }
diff --git a/panel-plugin/xkb-util.c b/panel-plugin/xkb-util.c
index 1e64cfc..3b7d9e1 100644
--- a/panel-plugin/xkb-util.c
+++ b/panel-plugin/xkb-util.c
@@ -24,7 +24,6 @@
  */
 
 #include <string.h>
-#include <librsvg/rsvg.h>
 #include <cairo/cairo.h>
 
 #include "xkb-util.h"
diff --git a/panel-plugin/xkb-plugin.desktop.in.in b/panel-plugin/xkb.desktop.in
similarity index 72%
rename from panel-plugin/xkb-plugin.desktop.in.in
rename to panel-plugin/xkb.desktop.in
index ca72592..e517648 100644
--- a/panel-plugin/xkb-plugin.desktop.in.in
+++ b/panel-plugin/xkb.desktop.in
@@ -3,5 +3,7 @@ Type=X-XFCE-PanelPlugin
 _Name=Keyboard Layouts
 _Comment=Keyboard layouts setup and switch plugin
 Icon=preferences-desktop-keyboard
-X-XFCE-Exec=@libexecdir@/xfce4/panel-plugins/xfce4-xkb-plugin
+X-XFCE-Module=xkb
 X-XFCE-Unique=TRUE
+X-XFCE-Internal=FALSE
+X-XFCE-API=2.0
diff --git a/po/POTFILES.in b/po/POTFILES.in
index da1b0ae..b658aef 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -4,4 +4,5 @@ panel-plugin/xkb-settings-dialog.c
 panel-plugin/xfce4-xkb-plugin.c
 
 # files added by intltool-prepare.
-panel-plugin/xkb-plugin.desktop.in.in
+
+panel-plugin/xkb.desktop.in

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list