[Xfce4-commits] [xfce/xfce4-power-manager] 01/63: Start porting to GTK3

noreply at xfce.org noreply at xfce.org
Sun Mar 22 13:01:56 CET 2015


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

eric pushed a commit to branch master
in repository xfce/xfce4-power-manager.

commit 2087d60f7f535d920ba7590535ee42ba0c2fe394
Author: Eric Koegel <eric.koegel at gmail.com>
Date:   Sun Mar 1 22:04:29 2015 +0300

    Start porting to GTK3
    
    This starts the port to GTK3. The deprecated warnings for GTK
    dropping the system tray are ignored, we can deal with that in
    GTK4.
---
 configure.ac.in                                     |    6 +++---
 .../power-manager-plugin/power-manager-button.c     |   19 +++++++++++--------
 settings/xfpm-settings-main.c                       |    3 ++-
 settings/xfpm-settings.c                            |    2 +-
 settings/xfpm-settings.h                            |    3 ++-
 src/xfpm-manager.c                                  |   10 ++++++++++
 6 files changed, 29 insertions(+), 14 deletions(-)

diff --git a/configure.ac.in b/configure.ac.in
index 5c68465..b01654a 100644
--- a/configure.ac.in
+++ b/configure.ac.in
@@ -59,7 +59,7 @@ XDT_I18N([@LINGUAS@])
 #==================================================== #
 #          Check for required packages 		      #
 #=====================================================#
-m4_define([gtk_minimum_version], [2.24.0])
+m4_define([gtk_minimum_version], [3.10.0])
 m4_define([glib_minimum_version], [2.30.0])
 m4_define([dbus_minimum_version], [1.1])
 m4_define([dbus_glib_minimum_version], [0.84])
@@ -76,7 +76,7 @@ m4_define([upower_minimum_version], [0.9.7])
 m4_define([xrandr_minimum_version], [1.2.0])
 m4_define([x11_minimum_version], [1.0.0])
 
-XDT_CHECK_PACKAGE([GTK], [gtk+-2.0], [gtk_minimum_version])
+XDT_CHECK_PACKAGE([GTK], [gtk+-3.0], [gtk_minimum_version])
 XDT_CHECK_PACKAGE([GLIB], [glib-2.0], [glib_minimum_version])
 XDT_CHECK_PACKAGE([GOBJECT], [gobject-2.0], [glib_minimum_version])
 XDT_CHECK_PACKAGE([GTHREAD], [gthread-2.0], [glib_minimum_version])
@@ -84,7 +84,7 @@ XDT_CHECK_PACKAGE([GMODULE], [gmodule-2.0], [glib_minimum_version])
 XDT_CHECK_PACKAGE([DBUS], [dbus-1], [dbus_minimum_version])
 XDT_CHECK_PACKAGE([DBUS_GLIB], [dbus-glib-1], [dbus_glib_minimum_version])
 XDT_CHECK_PACKAGE([XFCONF], [libxfconf-0],[xfconf_minimum_version])
-XDT_CHECK_PACKAGE([LIBXFCE4UI], [libxfce4ui-1],[libxfce4ui_minimum_version])
+XDT_CHECK_PACKAGE([LIBXFCE4UI], [libxfce4ui-2],[libxfce4ui_minimum_version])
 XDT_CHECK_PACKAGE([LIBXFCE4UTIL], [libxfce4util-1.0],[libxfce4util_minimum_version])
 XDT_CHECK_PACKAGE([LIBNOTIFY],[libnotify], [libnotify_minimum_version])
 XDT_CHECK_PACKAGE([UPOWER],[upower-glib], [upower_minimum_version])
diff --git a/panel-plugins/power-manager-plugin/power-manager-button.c b/panel-plugins/power-manager-plugin/power-manager-button.c
index 6d5844d..d5fef44 100644
--- a/panel-plugins/power-manager-plugin/power-manager-button.c
+++ b/panel-plugins/power-manager-plugin/power-manager-button.c
@@ -260,6 +260,7 @@ power_manager_button_device_icon_expose (GtkWidget *img, GdkEventExpose *event,
     gdouble min_height = 2;
     PangoLayout *layout = NULL;
     PangoRectangle ink_extent, log_extent;
+    GtkAllocation allocation;
 
     TRACE("entering");
 
@@ -288,16 +289,18 @@ power_manager_button_device_icon_expose (GtkWidget *img, GdkEventExpose *event,
         state = UP_DEVICE_STATE_UNKNOWN;
     }
 
-    cr = gdk_cairo_create (img->window);
-    width = img->allocation.width;
-    height = img->allocation.height;
+    gtk_widget_get_allocation (img, &allocation);
+
+    cr = gdk_cairo_create (gtk_widget_get_window (img));
+    width = allocation.width;
+    height = allocation.height;
 
     if (state != UP_DEVICE_STATE_UNKNOWN)
     {
         /* Draw the trough of the progressbar */
         cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
         cairo_set_line_width (cr, 1.0);
-        cairo_rectangle (cr, width - 3.5, img->allocation.y + 1.5, 5, height - 2);
+        cairo_rectangle (cr, width - 3.5, allocation.y + 1.5, 5, height - 2);
         cairo_set_source_rgb (cr, 0.87, 0.87, 0.87);
         cairo_fill_preserve (cr);
         cairo_set_source_rgb (cr, 0.53, 0.54, 0.52);
@@ -310,7 +313,7 @@ power_manager_button_device_icon_expose (GtkWidget *img, GdkEventExpose *event,
         if ((height * (percentage / 100)) > min_height)
            min_height = (height - 3) * (percentage / 100);
 
-        cairo_rectangle (cr, width - 3, img->allocation.y + height - min_height - 1, 4, min_height);
+        cairo_rectangle (cr, width - 3, allocation.y + height - min_height - 1, 4, min_height);
         if (percentage > 5 && percentage < 20)
             cairo_set_source_rgb (cr, 0.93, 0.83, 0.0);
         else if (percentage > 20 && percentage < 100)
@@ -321,7 +324,7 @@ power_manager_button_device_icon_expose (GtkWidget *img, GdkEventExpose *event,
             cairo_set_source_rgb (cr, 0.94, 0.16, 0.16);
         cairo_fill (cr);
 
-        cairo_rectangle (cr, width - 2.5, img->allocation.y + 2.5, 3, height - 4);
+        cairo_rectangle (cr, width - 2.5, allocation.y + 2.5, 3, height - 4);
         cairo_set_source_rgba (cr, 1.0, 1.0, 1.0, 0.75);
         cairo_stroke (cr);
     }
@@ -330,7 +333,7 @@ power_manager_button_device_icon_expose (GtkWidget *img, GdkEventExpose *event,
         /* Draw a bubble with a question mark for devices with unknown state */
         cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
         cairo_set_line_width (cr, 1.0);
-        cairo_arc(cr, width - 4.5, img->allocation.y + 6.5, 6, 0, 2*3.14159);
+        cairo_arc(cr, width - 4.5, allocation.y + 6.5, 6, 0, 2*3.14159);
         cairo_set_source_rgb (cr, 0.2, 0.54, 0.9);
         cairo_fill_preserve (cr);
         cairo_set_source_rgb (cr, 0.1, 0.37, 0.6);
@@ -339,7 +342,7 @@ power_manager_button_device_icon_expose (GtkWidget *img, GdkEventExpose *event,
         layout = gtk_widget_create_pango_layout (GTK_WIDGET (img), "?");
         pango_layout_set_font_description (layout, pango_font_description_from_string ("Sans Bold 9"));
         pango_layout_get_pixel_extents (layout, &ink_extent, &log_extent);
-        cairo_move_to (cr, (width - 5.5) - (log_extent.width / 2), (img->allocation.y + 5.5) - (log_extent.height / 2));
+        cairo_move_to (cr, (width - 5.5) - (log_extent.width / 2), (allocation.y + 5.5) - (log_extent.height / 2));
         cairo_set_source_rgb (cr, 1.0, 1.0, 1.0);
         pango_cairo_show_layout (cr, layout);
     }
diff --git a/settings/xfpm-settings-main.c b/settings/xfpm-settings-main.c
index c27208a..6a1d244 100644
--- a/settings/xfpm-settings-main.c
+++ b/settings/xfpm-settings-main.c
@@ -27,6 +27,7 @@
 #include <string.h>
 
 #include <gtk/gtk.h>
+#include <gtk/gtkx.h>
 #include <glib.h>
 
 #include <libxfce4util/libxfce4util.h>
@@ -69,7 +70,7 @@ int main (int argc, char **argv)
     gboolean start_xfpm_if_not_running;
     gboolean debug = FALSE;
 
-    GdkNativeWindow socket_id = 0;
+    Window socket_id = 0;
     gchar *device_id = NULL;
 
     XfconfChannel *channel;
diff --git a/settings/xfpm-settings.c b/settings/xfpm-settings.c
index aab02e0..4ff4178 100644
--- a/settings/xfpm-settings.c
+++ b/settings/xfpm-settings.c
@@ -2274,7 +2274,7 @@ xfpm_settings_dialog_new (XfconfChannel *channel, gboolean auth_suspend,
                           gboolean has_battery, gboolean has_lcd_brightness,
                           gboolean has_lid, gboolean has_sleep_button,
                           gboolean has_hibernate_button, gboolean has_power_button,
-                          GdkNativeWindow id, gchar *device_id)
+                          Window id, gchar *device_id)
 {
     GtkWidget *plug;
     GtkWidget *dialog;
diff --git a/settings/xfpm-settings.h b/settings/xfpm-settings.h
index b5a6cb4..2b54c16 100644
--- a/settings/xfpm-settings.h
+++ b/settings/xfpm-settings.h
@@ -21,6 +21,7 @@
 #ifndef __XFPM_SETTINGS_H
 #define __XFPM_SETTINGS_H
 
+#include <gtk/gtkx.h>
 
 GtkWidget *xfpm_settings_dialog_new (XfconfChannel *channel,
                                      gboolean auth_suspend,
@@ -34,7 +35,7 @@ GtkWidget *xfpm_settings_dialog_new (XfconfChannel *channel,
                                      gboolean has_sleep_button,
                                      gboolean has_hibernate_button,
                                      gboolean has_power_button,
-                                     GdkNativeWindow id,
+                                     Window id,
                                      gchar *device_id);
 
 #endif /* __XFPM_SETTINGS_H */
diff --git a/src/xfpm-manager.c b/src/xfpm-manager.c
index 755a50c..5b0f4dc 100644
--- a/src/xfpm-manager.c
+++ b/src/xfpm-manager.c
@@ -719,7 +719,9 @@ xfpm_manager_tray_update_tooltip (PowerManagerButton *button, XfpmManager *manag
     if (power_manager_button_get_tooltip (POWER_MANAGER_BUTTON(manager->priv->power_button)) == NULL)
         return;
 
+G_GNUC_BEGIN_IGNORE_DEPRECATIONS
     gtk_status_icon_set_tooltip_markup (manager->priv->adapter_icon, power_manager_button_get_tooltip (POWER_MANAGER_BUTTON(manager->priv->power_button)));
+G_GNUC_END_IGNORE_DEPRECATIONS
 }
 
 static void
@@ -730,7 +732,9 @@ xfpm_manager_tray_update_icon (PowerManagerButton *button, XfpmManager *manager)
 
     XFPM_DEBUG ("updating icon");
 
+G_GNUC_BEGIN_IGNORE_DEPRECATIONS
     gtk_status_icon_set_from_icon_name (manager->priv->adapter_icon, power_manager_button_get_icon_name (POWER_MANAGER_BUTTON(manager->priv->power_button)));
+G_GNUC_END_IGNORE_DEPRECATIONS
 }
 
 static void
@@ -747,8 +751,10 @@ xfpm_manager_show_tray_icon (XfpmManager *manager)
 	return;
     }
 
+G_GNUC_BEGIN_IGNORE_DEPRECATIONS
     manager->priv->adapter_icon = gtk_status_icon_new ();
     manager->priv->power_button = power_manager_button_new ();
+G_GNUC_END_IGNORE_DEPRECATIONS
 
     XFPM_DEBUG ("Showing tray icon");
 
@@ -763,7 +769,9 @@ xfpm_manager_show_tray_icon (XfpmManager *manager)
     g_signal_connect (G_OBJECT(manager->priv->power_button), "tooltip-changed",   G_CALLBACK(xfpm_manager_tray_update_tooltip), manager);
     g_signal_connect (G_OBJECT(manager->priv->power_button), "icon-name-changed", G_CALLBACK(xfpm_manager_tray_update_icon),    manager);
 
+G_GNUC_BEGIN_IGNORE_DEPRECATIONS
     gtk_status_icon_set_visible (manager->priv->adapter_icon, TRUE);
+G_GNUC_END_IGNORE_DEPRECATIONS
 
     g_signal_connect (manager->priv->adapter_icon, "popup-menu", G_CALLBACK (xfpm_manager_show_tray_menu), manager);
 }
@@ -774,7 +782,9 @@ xfpm_manager_hide_tray_icon (XfpmManager *manager)
     if (manager->priv->adapter_icon == NULL)
         return;
 
+G_GNUC_BEGIN_IGNORE_DEPRECATIONS
     gtk_status_icon_set_visible (manager->priv->adapter_icon, FALSE);
+G_GNUC_END_IGNORE_DEPRECATIONS
 
     /* disconnect from all the signals */
     g_signal_handlers_disconnect_by_func (G_OBJECT(manager->priv->power_button), G_CALLBACK(xfpm_manager_tray_update_tooltip), manager);

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


More information about the Xfce4-commits mailing list