From a6efbbceb5b1122512cd01609eab99fe522d8435 Mon Sep 17 00:00:00 2001 From: Stefano Karapetsas Date: Sat, 26 Oct 2013 14:34:04 +0200 Subject: mate-panel: Add GTK3 support --- mate-panel/libpanel-util/panel-icon-chooser.c | 18 ++++++++++++++++++ mate-panel/libpanel-util/panel-launch.c | 25 +++++++++++++++++++++++++ 2 files changed, 43 insertions(+) (limited to 'mate-panel/libpanel-util') diff --git a/mate-panel/libpanel-util/panel-icon-chooser.c b/mate-panel/libpanel-util/panel-icon-chooser.c index 7cd56fb4..a24d425e 100644 --- a/mate-panel/libpanel-util/panel-icon-chooser.c +++ b/mate-panel/libpanel-util/panel-icon-chooser.c @@ -141,7 +141,11 @@ panel_icon_chooser_set_property (GObject *object, } static void +#if GTK_CHECK_VERSION (3, 0, 0) +panel_icon_chooser_dispose (GObject *object) +#else panel_icon_chooser_destroy (GtkObject *object) +#endif { PanelIconChooser *chooser; @@ -166,14 +170,20 @@ panel_icon_chooser_destroy (GtkObject *object) g_free (chooser->priv->icon_theme_dir); chooser->priv->icon_theme_dir = NULL; +#if GTK_CHECK_VERSION (3, 0, 0) + G_OBJECT_CLASS (panel_icon_chooser_parent_class)->dispose (object); +#else GTK_OBJECT_CLASS (panel_icon_chooser_parent_class)->destroy (object); +#endif } static void panel_icon_chooser_class_init (PanelIconChooserClass *class) { GObjectClass *gobject_class = G_OBJECT_CLASS (class); +#if !GTK_CHECK_VERSION (3, 0, 0) GtkObjectClass *gtkobject_class = GTK_OBJECT_CLASS (class); +#endif GtkWidgetClass *gtkwidget_class = GTK_WIDGET_CLASS (class); GtkButtonClass *gtkbutton_class = GTK_BUTTON_CLASS (class); @@ -181,7 +191,11 @@ panel_icon_chooser_class_init (PanelIconChooserClass *class) gobject_class->get_property = panel_icon_chooser_get_property; gobject_class->set_property = panel_icon_chooser_set_property; +#if GTK_CHECK_VERSION (3, 0, 0) + gobject_class->dispose = panel_icon_chooser_dispose; +#else gtkobject_class->destroy = panel_icon_chooser_destroy; +#endif gtkwidget_class->style_set = _panel_icon_chooser_style_set; gtkwidget_class->screen_changed = _panel_icon_chooser_screen_changed; @@ -422,7 +436,11 @@ _panel_icon_chooser_clicked (GtkButton *button) if (info) { path = g_strdup (gtk_icon_info_get_filename (info)); +#if GTK_CHECK_VERSION (3, 8, 0) + g_object_unref (info); +#else gtk_icon_info_free (info); +#endif } } diff --git a/mate-panel/libpanel-util/panel-launch.c b/mate-panel/libpanel-util/panel-launch.c index c332d09a..28824269 100644 --- a/mate-panel/libpanel-util/panel-launch.c +++ b/mate-panel/libpanel-util/panel-launch.c @@ -221,6 +221,15 @@ panel_launch_desktop_file (const char *desktop_file, return retval; } +/* + * Set the DISPLAY variable, to be use by g_spawn_async. + */ +static void +set_environment (gpointer display) +{ + g_setenv ("DISPLAY", display, TRUE); +} + gboolean panel_launch_desktop_file_with_fallback (const char *desktop_file, const char *fallback_exec, @@ -231,6 +240,9 @@ panel_launch_desktop_file_with_fallback (const char *desktop_file, GError *local_error; gboolean retval; GPid pid; +#if GTK_CHECK_VERSION (3, 0, 0) + char *display; +#endif g_return_val_if_fail (desktop_file != NULL, FALSE); g_return_val_if_fail (fallback_exec != NULL, FALSE); @@ -247,9 +259,22 @@ panel_launch_desktop_file_with_fallback (const char *desktop_file, local_error = NULL; } +#if GTK_CHECK_VERSION (3, 0, 0) + display = gdk_screen_make_display_name (screen); + retval = g_spawn_async (NULL, /* working directory */ + argv, + NULL, /* envp */ + G_SPAWN_SEARCH_PATH, + set_environment, + &display, + NULL, + &local_error); + g_free (display); +#else retval = gdk_spawn_on_screen (screen, NULL, argv, NULL, G_SPAWN_SEARCH_PATH | G_SPAWN_DO_NOT_REAP_CHILD, NULL, NULL, &pid, &local_error); +#endif if (local_error == NULL && retval == TRUE) { g_child_watch_add (pid, dummy_child_watch, NULL); -- cgit v1.2.1