Created
June 23, 2017 03:34
-
-
Save andreldm/c65d217789c670e4ba3f719ecc6b0234 to your computer and use it in GitHub Desktop.
Fallback for xfce4panel
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/configure.ac.in b/configure.ac.in | |
index 9012783..40b8806 100644 | |
--- a/configure.ac.in | |
+++ b/configure.ac.in | |
@@ -45,7 +45,7 @@ AC_HEADER_STDC | |
dnl *********************************** | |
dnl *** Check for required packages *** | |
dnl *********************************** | |
-XDT_CHECK_PACKAGE([LIBXFCE4PANEL], [libxfce4panel-2.0], [4.13.0]) | |
+XDT_CHECK_PACKAGE([LIBXFCE4PANEL], [libxfce4panel-2.0], [4.12.0]) | |
XDT_CHECK_PACKAGE([LIBXFCE4UTIL], [libxfce4util-1.0], [4.10.0]) | |
XDT_CHECK_PACKAGE([LIBXFCE4UI], [libxfce4ui-2], [4.12.0]) | |
XDT_CHECK_PACKAGE([GTHREAD], [gthread-2.0], [2.16.0]) | |
diff --git a/panel-plugin/screenshooter-plugin.c b/panel-plugin/screenshooter-plugin.c | |
index d3a4fad..2a3d252 100644 | |
--- a/panel-plugin/screenshooter-plugin.c | |
+++ b/panel-plugin/screenshooter-plugin.c | |
@@ -106,6 +106,31 @@ set_panel_button_tooltip (PluginData *pd); | |
/* Internal functions */ | |
+/* Returns a preferred icon size | |
+*/ | |
+static gint | |
+get_preferred_icon_size (XfcePanelPlugin *plugin) | |
+{ | |
+#if LIBXFCE4PANEL_CHECK_VERSION (4,13,0) | |
+ g_printf ("using 4.13\n"); | |
+ return xfce_panel_plugin_get_icon_size (plugin); | |
+#else | |
+ /* fall-back for older panel versions */ | |
+ g_printf ("using 4.12\n"); | |
+ gint width; | |
+ width = xfce_panel_plugin_get_size (plugin) / xfce_panel_plugin_get_nrows (plugin); | |
+ | |
+ if (width <= 27) | |
+ return 16; | |
+ else if (width < 34) | |
+ return 24; | |
+ else if (width < 40) | |
+ return 32; | |
+ else | |
+ return width; | |
+#endif | |
+} | |
+ | |
/* Modify the size of the panel button | |
@@ -122,7 +147,7 @@ cb_set_size (XfcePanelPlugin *plugin, int size, PluginData *pd) | |
TRACE ("Request size for the plugin"); | |
gtk_widget_set_size_request (GTK_WIDGET (plugin), size, size); | |
- icon_size = xfce_panel_plugin_get_icon_size (plugin); | |
+ icon_size = get_preferred_icon_size (plugin); | |
gtk_image_set_pixel_size (GTK_IMAGE (pd->image), icon_size); | |
return TRUE; | |
@@ -367,7 +392,7 @@ screenshooter_plugin_construct (XfcePanelPlugin *plugin) | |
TRACE ("Create the panel button"); | |
pd->button = xfce_create_panel_button (); | |
- icon_size = xfce_panel_plugin_get_icon_size (plugin); | |
+ icon_size = get_preferred_icon_size (plugin); | |
pd->image = gtk_image_new_from_icon_name (SCREENSHOT_ICON_NAME, icon_size); | |
gtk_container_add (GTK_CONTAINER (pd->button), GTK_WIDGET (pd->image)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment