Updating branch refs/heads/master to 124892a90fa2e5d09ced6a1d6ac5e249eb14b22d (commit) from 6092d3948b20170f06abd1e7c02a243dde57d49b (commit)
commit 124892a90fa2e5d09ced6a1d6ac5e249eb14b22d Author: Simon Steinbeiss <och...@xfce.org> Date: Wed Jul 18 20:22:08 2012 +0200 Port from libxfcegui4 to libxfce4ui configure.ac.in | 4 +- src/Makefile.am | 7 +- src/gst/Makefile.am | 2 +- src/gst/parole-gst.c | 15 ++-- src/main.c | 15 +--- src/parole-about.c | 110 +++++++++++++------------- src/parole-about.h | 2 +- src/parole-player.c | 153 ++++++++++++++++++++++++++++++------ src/parole-player.h | 2 +- src/parole-plugins-manager.c | 7 +- src/parole-session.c | 178 ------------------------------------------ src/parole-session.h | 61 -------------- 12 files changed, 209 insertions(+), 347 deletions(-) diff --git a/configure.ac.in b/configure.ac.in index 93cbd7d..029db4b 100644 --- a/configure.ac.in +++ b/configure.ac.in @@ -75,7 +75,7 @@ m4_define([gstreamer_minimum_version], [0.10.11]) m4_define([dbus_minimum_version], [0.60]) m4_define([dbus_glib_minimum_version], [0.70]) -m4_define([libxfcegui4_minimum_version],[4.6.0]) +m4_define([libxfce4ui_minimum_version],[4.7.0]) m4_define([libxfce4util_minimum_version],[4.6.0]) m4_define([libnotify_minimum_version], [0.4.1]) @@ -95,7 +95,7 @@ XDT_CHECK_PACKAGE([GST_INTERFACES], [gstreamer-interfaces-0.10], [gstreamer_mini XDT_CHECK_PACKAGE([DBUS], [dbus-1], [dbus_minimum_version]) XDT_CHECK_PACKAGE([DBUS_GLIB], [dbus-glib-1], [dbus_glib_minimum_version]) -XDT_CHECK_PACKAGE([LIBXFCE4GUI], [libxfcegui4-1.0],[libxfcegui4_minimum_version]) +XDT_CHECK_PACKAGE([LIBXFCE4UI], [libxfce4ui-1],[libxfce4ui_minimum_version]) XDT_CHECK_PACKAGE([LIBXFCE4UTIL], [libxfce4util-1.0],[libxfce4util_minimum_version]) #=======================================================# diff --git a/src/Makefile.am b/src/Makefile.am index 4c480e3..8469028 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -15,6 +15,7 @@ INCLUDES = \ -I$(top_srcdir)/src/dbus \ -I$(top_srcdir)/src/common \ -DLOCALEDIR=\"$(localedir)\" \ + -DDESKTOPDIR=\"$(datadir)/applications\"\ -DG_LOG_DOMAIN=\"parole\" \ -DPAROLE_PLUGINS_DIR=\"$(libdir)/parole-$(PAROLE_VERSION_API)\"\ -DPAROLE_PLUGINS_DATA_DIR=\"$(datadir)/src/misc/parole-plugins-$(PAROLE_VERSION_API)\"\ @@ -23,7 +24,7 @@ INCLUDES = \ $(GIO_CFLAGS) \ $(GMODULE_CFLAGS) \ $(DBUS_GLIB_CFLAGS) \ - $(LIBXFCE4GUI_CFLAGS) \ + $(LIBXFCE4UI_CFLAGS) \ $(GST_VIDEO_CFLAGS) \ $(GST_INTERFACES_CFLAGS) \ $(TAGLIBC_CFLAGS) @@ -69,8 +70,6 @@ parole_SOURCES = \ parole-open-location.h \ parole-disc-menu.c \ parole-disc-menu.h \ - parole-session.c \ - parole-session.h \ parole-button.c \ parole-button.h \ parole-plugin-player.c \ @@ -86,7 +85,7 @@ parole_LDADD = \ $(GIO_LIBS) \ $(GMODULE_LIBS) \ $(DBUS_GLIB_LIBS) \ - $(LIBXFCE4GUI_LIBS) \ + $(LIBXFCE4UI_LIBS) \ $(GST_VIDEO_LIBS) \ $(GST_INTERFACES_LIBS) \ $(TAGLIBC_LIBS) diff --git a/src/gst/Makefile.am b/src/gst/Makefile.am index 299b7d5..30e7c08 100644 --- a/src/gst/Makefile.am +++ b/src/gst/Makefile.am @@ -25,7 +25,7 @@ libparolegst_la_CFLAGS = \ $(GST_VIDEO_CFLAGS) \ $(GST_INTERFACES_CFLAGS) \ $(GTHREAD_CFLAGS) \ - $(LIBXFCE4GUI_CFLAGS) + $(LIBXFCE4UI_CFLAGS) libparolegst_la_LIBADD = \ $(top_builddir)/src/misc/libparole.la\ diff --git a/src/gst/parole-gst.c b/src/gst/parole-gst.c index ad9f6d9..344869e 100644 --- a/src/gst/parole-gst.c +++ b/src/gst/parole-gst.c @@ -34,7 +34,7 @@ #include <gst/video/video.h> #include <libxfce4util/libxfce4util.h> -#include <libxfcegui4/libxfcegui4.h> +#include <libxfce4ui/libxfce4ui.h> #include <gdk/gdkx.h> @@ -1491,12 +1491,11 @@ parole_gst_check_state_change_timeout (gpointer data) if ( gst->priv->state != gst->priv->target ) { - gboolean ret_val = 1; - /*FIXME gboolean ret_val = xfce_dialog_confirm (GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (gst))), + gboolean ret_val = xfce_dialog_confirm (GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (gst))), GTK_STOCK_YES, _("Stop"), _("The stream is taking too much time to load"), - NULL);*/ + NULL); if ( ret_val ) { @@ -1667,8 +1666,8 @@ parole_gst_constructed (GObject *object) error = g_error_new (0, 0, "%s", _("Unable to load playbin GStreamer plugin" ", check your GStreamer installation")); - /*FIXME xfce_dialog_show_error (GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (gst))), - error, NULL);*/ + xfce_dialog_show_error (GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (gst))), + error, NULL); g_error_free (error); g_error ("playbin load failed"); } @@ -1690,8 +1689,8 @@ parole_gst_constructed (GObject *object) GError *error; error = g_error_new (0, 0, "%s", _("Unable to load video GStreamer plugin" ", check your GStreamer installation")); - /*FIXME xfce_dialog_show_error (GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (gst))), - error, NULL);*/ + xfce_dialog_show_error (GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (gst))), + error, NULL); g_error_free (error); g_error ("ximagesink load failed"); } diff --git a/src/main.c b/src/main.c index 026076a..dffdde8 100644 --- a/src/main.c +++ b/src/main.c @@ -43,10 +43,10 @@ #include "parole-player.h" #include "parole-plugins-manager.h" #include "parole-utils.h" -#include "parole-session.h" #include "parole-dbus.h" #include "parole-builder.h" #include "parole-rc-utils.h" +//#include "parole-setup.h" static void G_GNUC_NORETURN show_version (void) @@ -196,7 +196,6 @@ xv_option_given (const gchar *name, const gchar *value, gpointer data, GError ** int main (int argc, char **argv) { ParolePlayer *player; - ParoleSession *session; ParolePluginsManager *plugins; GtkBuilder *builder; GOptionContext *ctx; @@ -313,13 +312,10 @@ int main (int argc, char **argv) { builder = parole_builder_get_main_interface (); parole_dbus_register_name (PAROLE_DBUS_NAME); - session = parole_session_get (); - - if ( client_id ) - parole_session_set_client_id (session, client_id); - - parole_session_real_init (session); - player = parole_player_new (); + + //parole_setup (); + player = parole_player_new (client_id); + g_free (client_id); if (fullscreen) parole_player_full_screen (player, TRUE); @@ -371,7 +367,6 @@ int main (int argc, char **argv) parole_dbus_release_name (PAROLE_DBUS_NAME); g_object_unref (plugins); - g_object_unref (session); } gst_deinit (); diff --git a/src/parole-about.c b/src/parole-about.c index 97e7f16..bf4251c 100644 --- a/src/parole-about.c +++ b/src/parole-about.c @@ -31,73 +31,73 @@ #undef XFCE_DISABLE_DEPRECATED #endif #include <libxfce4util/libxfce4util.h> -#include <libxfcegui4/libxfcegui4.h> +#include <libxfce4ui/libxfce4ui.h> #include "parole-about.h" #include "parole-utils.h" -void parole_about (void) +#if !GTK_CHECK_VERSION (2, 18, 0) +static void +parole_link_browser (GtkAboutDialog *about, const gchar *link, gpointer data) { - XfceAboutInfo *info; - GtkWidget *dialog; - gint x, y; - GdkPixbuf *icon; - guint n; + gchar *cmd; - static const struct - { - gchar *name, *email, *language; - } - translators[] = + cmd = g_strdup_printf ("%s %s","xdg-open", link); + + if ( !g_spawn_command_line_async (cmd, NULL) ) { - {"astur", "malditoas...@gmail.com", "ast",}, - {"Carles Muñoz Gorriz", "carle...@internautas.org", "ca.po",}, - {"Per Kongstad", "p_kongs...@op.pl", "da.po",}, - {"Christoph Wickert", "cwick...@fedoraproject.org", "de.po",}, - {"elega", "el...@elega.com.ar","es",}, - {"Piarres Beobide", "pi+deb...@beobide.net", "eu",}, - {"Douart Patrick", "patric...@laposte.net", "fr",}, - {"Leandro Regueiro", "leandro.regue...@gmail.com", "gl",}, - {"Andhika Padmawan", "andhika.padma...@gmail.com", "id",}, - {"Masato Hashimoto", "cabezon.hashim...@gmail.com", "ja",}, - {"Rihards Prieditis", "rpriedi...@gmail.com", "lv",}, - {"Mario Blättermann", "mari...@gnome.org", "nl",}, - {"Sérgio Marques", "smarque...@gmail.com", "pt",}, - {"Vlad Vasilev", "lort...@gmail.com", "ru",}, - {"Robert Hartl", "hartl.rob...@gmail.com", "sk",}, - {"Samed Beyribey", "ras...@eventualis.org", "tr",}, - {"Motsyo Gennadi", "dr...@altlinux.ru", "uk",}, - {"Hunt Xu", "hun...@live.cn", "zh_CN",}, - - }; + g_free (cmd); + cmd = g_strdup_printf ("%s %s","xfbrowser4", link); + g_spawn_command_line_async (cmd, NULL); + } + g_free (cmd); +} - info = xfce_about_info_new ("Parole", VERSION, _("Parole Media Player"), - XFCE_COPYRIGHT_TEXT ("2009-2011", "Ali Abdallah"), - XFCE_LICENSE_GPL); +static void +parole_link_mailto (GtkAboutDialog *about, const gchar *link, gpointer data) +{ + gchar *cmd = g_strdup_printf( "%s %s", "xdg-email", link); + g_spawn_command_line_async (cmd, NULL); + g_free (cmd); +} +#endif /*GTK_CHECK_VERSION (2, 18, 0)*/ - xfce_about_info_set_homepage (info, "http://goodies.xfce.org/projects/applications/parole"); - xfce_about_info_add_credit (info, "Ali Abdallah", "al...@xfce.org", _("Author/Maintainer")); - +void parole_about (GtkWindow *parent) +{ + GdkPixbuf *logo; + static const gchar *authors[] = + { + "Ali Abdallah <al...@xfce.org", + NULL, + }; - for (n = 0; n < G_N_ELEMENTS (translators); ++n) + static const gchar *documenters[] = { - gchar *s; - s = g_strdup_printf (_("Translator (%s)"), translators[n].language); - xfce_about_info_add_credit (info, translators[n].name, translators[n].email, s); - g_free (s); - } + "Ali Abdallah <al...@xfce.org", + NULL, + }; - gtk_icon_size_lookup (GTK_ICON_SIZE_DIALOG, &x, &y); - icon = parole_icon_load ("parole", x); - - dialog = xfce_about_dialog_new_with_values (NULL, info, icon); - - - gtk_dialog_run (GTK_DIALOG (dialog)); - gtk_widget_destroy (dialog); +#if !GTK_CHECK_VERSION (2, 18, 0) + gtk_about_dialog_set_url_hook (parole_link_browser, NULL, NULL); + gtk_about_dialog_set_email_hook (parole_link_mailto, NULL, NULL); +#endif - xfce_about_info_free (info); + logo = parole_icon_load ("parole", 128); - if (icon) - g_object_unref (G_OBJECT (icon)); + gtk_show_about_dialog (parent, + "authors", authors, + "comments", _("Parole Media Player"), + "documenters", documenters, + "copyright", "Copyright \302\251 2009-2010 Ali Abdallah", + "license", XFCE_LICENSE_GPL, + "logo", logo, + "program-name", PACKAGE_NAME, + "translator-credits", _("translator-credits"), + "version", PACKAGE_VERSION, + "website", "http://goodies.xfce.org/projects/applications/parole", + "website-label", _("Visit Parole website"), + NULL); + + if (logo) + g_object_unref (G_OBJECT (logo)); } diff --git a/src/parole-about.h b/src/parole-about.h index d75f9a8..6d34d7e 100644 --- a/src/parole-about.h +++ b/src/parole-about.h @@ -23,7 +23,7 @@ #include <gtk/gtk.h> -void parole_about (void); +void parole_about (GtkWindow *parent); #endif /* __PAROLE_ABOUT_H */ diff --git a/src/parole-player.c b/src/parole-player.c index ffb43c9..4b8d012 100644 --- a/src/parole-player.c +++ b/src/parole-player.c @@ -30,6 +30,8 @@ #include <X11/XF86keysym.h> #endif +#include <X11/Xatom.h> + #include <gdk/gdkx.h> #include <gdk/gdkkeysyms.h> #include <gtk/gtk.h> @@ -38,7 +40,7 @@ #undef XFCE_DISABLE_DEPRECATED #endif #include <libxfce4util/libxfce4util.h> -#include <libxfcegui4/libxfcegui4.h> +#include <libxfce4ui/libxfce4ui.h> #include <dbus/dbus-glib.h> @@ -60,7 +62,6 @@ #include "parole-conf.h" #include "parole-rc-utils.h" #include "parole-utils.h" -#include "parole-session.h" #include "parole-debug.h" #include "parole-button.h" #include "enum-gtypes.h" @@ -217,7 +218,8 @@ void ratio_16_9_toggled_cb (GtkWidget *widget, void ratio_20_9_toggled_cb (GtkWidget *widget, ParolePlayer *player); -void parole_show_about (GtkWidget *widget); +void parole_show_about (GtkWidget *widget, + ParolePlayer *player); gboolean parole_player_key_press (GtkWidget *widget, GdkEventKey *ev, @@ -243,10 +245,12 @@ struct ParolePlayerPrivate ParoleScreenSaver *screen_saver; ParoleConf *conf; ParoleDiscMenu *disc_menu; - ParoleSession *session; #ifdef HAVE_XF86_KEYSYM ParoleButton *button; #endif + + XfceSMClient *sm_client; + gchar *client_id; GtkFileFilter *video_filter; GtkRecentManager *recent; @@ -295,11 +299,17 @@ struct ParolePlayerPrivate }; +enum +{ + PROP_0, + PROP_CLIENT_ID +}; + G_DEFINE_TYPE (ParolePlayer, parole_player, G_TYPE_OBJECT) -void parole_show_about (GtkWidget *widget) +void parole_show_about (GtkWidget *widget, ParolePlayer *player) { - parole_about (); + parole_about (GTK_WINDOW (player->priv->window)); } void ratio_none_toggled_cb (GtkWidget *widget, ParolePlayer *player) @@ -1032,7 +1042,7 @@ parole_player_range_value_changed (GtkRange *range, ParolePlayer *player) static void parole_player_error_cb (ParoleGst *gst, const gchar *error, ParolePlayer *player) { - xfce_err ("%s", error); + parole_dialog_error (GTK_WINDOW (player->priv->window), _("GStreamer backend error"), error); parole_screen_saver_uninhibit (player->priv->screen_saver); parole_player_stopped (player); } @@ -1516,6 +1526,13 @@ parole_player_screen_size_change_changed_cb (GdkScreen *screen, ParolePlayer *pl } static void +parole_player_sm_quit_requested_cb (ParolePlayer *player) +{ + player->priv->exit = TRUE; + parole_gst_terminate (PAROLE_GST (player->priv->gst)); +} + +static void parole_player_finalize (GObject *object) { ParolePlayer *player; @@ -1531,7 +1548,12 @@ parole_player_finalize (GObject *object) g_object_unref (player->priv->disc); g_object_unref (player->priv->disc_menu); g_object_unref (player->priv->screen_saver); - + + if ( player->priv->client_id ) + g_free (player->priv->client_id); + + g_object_unref (player->priv->sm_client); + #ifdef HAVE_XF86_KEYSYM g_object_unref (player->priv->button); #endif @@ -1541,12 +1563,104 @@ parole_player_finalize (GObject *object) G_OBJECT_CLASS (parole_player_parent_class)->finalize (object); } +static void parole_player_set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec) +{ + ParolePlayer *player; + player = PAROLE_PLAYER (object); + + switch (prop_id) + { + case PROP_CLIENT_ID: + player->priv->client_id = g_value_dup_string (value); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +static void parole_player_get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec) +{ + ParolePlayer *player; + player = PAROLE_PLAYER (object); + + switch (prop_id) + { + case PROP_CLIENT_ID: + g_value_set_string (value, player->priv->client_id); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +/** + * Get the SM client + **/ +static void +parole_player_constructed (GObject *object) +{ + ParolePlayer *player; + gchar *current_dir; + + const gchar *restart_command[] = + { + "parole", + "--new-instance", + NULL + }; + + player = PAROLE_PLAYER (object); + + current_dir = g_get_current_dir (); + + player->priv->sm_client = xfce_sm_client_get_full (XFCE_SM_CLIENT_RESTART_NORMAL, + XFCE_SM_CLIENT_PRIORITY_DEFAULT, + player->priv->client_id, + current_dir, + restart_command, + DESKTOPDIR "/" PACKAGE_NAME ".desktop"); + + if ( xfce_sm_client_connect (player->priv->sm_client, NULL ) ) + { + g_signal_connect_swapped (player->priv->sm_client, "quit-requested", + G_CALLBACK (parole_player_sm_quit_requested_cb), player); + } + + g_free (current_dir); +} + static void parole_player_class_init (ParolePlayerClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); + object_class->constructed = parole_player_constructed; object_class->finalize = parole_player_finalize; + object_class->set_property = parole_player_set_property; + object_class->get_property = parole_player_get_property; + + + /** + * ParolePlayer:client-id: + * + * Sm Manager client ID + * Since: 0.2.2 + **/ + g_object_class_install_property (object_class, + PROP_CLIENT_ID, + g_param_spec_string ("client-id", + NULL, + NULL, + NULL, + G_PARAM_READWRITE|G_PARAM_CONSTRUCT_ONLY)); g_type_class_add_private (klass, sizeof (ParolePlayerPrivate)); @@ -1733,13 +1847,6 @@ parole_player_button_pressed_cb (ParoleButton *button, ParoleButtonKey key, Paro #endif static void -parole_player_session_die_cb (ParolePlayer *player) -{ - player->priv->exit = TRUE; - parole_gst_terminate (PAROLE_GST (player->priv->gst)); -} - -static void parole_gst_set_default_aspect_ratio (ParolePlayer *player, GtkBuilder *builder) { ParoleAspectRatio ratio; @@ -1927,7 +2034,10 @@ parole_player_init (ParolePlayer *player) gboolean repeat, shuffle; player->priv = PAROLE_PLAYER_GET_PRIVATE (player); - + + player->priv->client_id = NULL; + player->priv->sm_client = NULL; + player->priv->bus = parole_g_session_bus_get (); player->priv->video_filter = parole_get_supported_video_filter (); @@ -1939,12 +2049,7 @@ parole_player_init (ParolePlayer *player) g_signal_connect_swapped (player->priv->conf, "notify::reset-saver", G_CALLBACK (parole_player_reset_saver_changed_cb), player); - - player->priv->session = parole_session_get (); - - g_signal_connect_swapped (player->priv->session, "die", - G_CALLBACK (parole_player_session_die_cb), player); - + player->priv->gst = parole_gst_new (player->priv->conf); player->priv->disc = parole_disc_new (); @@ -2135,10 +2240,10 @@ parole_player_init (ParolePlayer *player) } ParolePlayer * -parole_player_new (void) +parole_player_new (const gchar *client_id) { ParolePlayer *player = NULL; - player = g_object_new (PAROLE_TYPE_PLAYER, NULL); + player = g_object_new (PAROLE_TYPE_PLAYER, "client-id", client_id, NULL); return player; } diff --git a/src/parole-player.h b/src/parole-player.h index 64ba339..a663e01 100644 --- a/src/parole-player.h +++ b/src/parole-player.h @@ -53,7 +53,7 @@ typedef struct } ParolePlayerClass; GType parole_player_get_type (void) G_GNUC_CONST; -ParolePlayer *parole_player_new (void); +ParolePlayer *parole_player_new (const gchar *client_id); ParoleMediaList *parole_player_get_media_list (ParolePlayer *player); diff --git a/src/parole-plugins-manager.c b/src/parole-plugins-manager.c index a0452e8..27fa2eb 100644 --- a/src/parole-plugins-manager.c +++ b/src/parole-plugins-manager.c @@ -33,7 +33,7 @@ #undef XFCE_DISABLE_DEPRECATED #endif #include <libxfce4util/libxfce4util.h> -#include <libxfcegui4/libxfcegui4.h> +#include <libxfce4ui/libxfce4ui.h> #include <src/misc/parole-provider-plugin.h> @@ -46,6 +46,7 @@ #include "parole-module.h" #include "gst/parole-gst.h" +#include "common/parole-common.h" #define PAROLE_PLUGIN_EXT = ".desktop" @@ -413,7 +414,9 @@ parole_plugins_manager_show_plugins_pref (GtkWidget *widget, ParolePluginsManage /*No plugins found*/ if ( manager->priv->array->len == 0 ) { - xfce_info ("%s", _("No installed plugins found on this system")); + parole_dialog_info (GTK_WINDOW (gtk_widget_get_toplevel (manager->priv->main_nt)), + _("No installed plugins found on this system"), + _("No installed plugins found on this system")); return; } diff --git a/src/parole-session.c b/src/parole-session.c deleted file mode 100644 index 94db37e..0000000 --- a/src/parole-session.c +++ /dev/null @@ -1,178 +0,0 @@ -/* - * * Copyright (C) 2009-2011 Ali <al...@xfce.org> - * - * Licensed under the GNU General Public License Version 2 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - - -#ifdef XFCE_DISABLE_DEPRECATED -#undef XFCE_DISABLE_DEPRECATED -#endif -#include <libxfce4util/libxfce4util.h> -#include <libxfcegui4/libxfcegui4.h> - -#include "parole-session.h" - -static void parole_session_finalize (GObject *object); - -#define PAROLE_SESSION_GET_PRIVATE(o) \ -(G_TYPE_INSTANCE_GET_PRIVATE ((o), PAROLE_TYPE_SESSION, ParoleSessionPrivate)) - -struct ParoleSessionPrivate -{ - SessionClient *client; - gboolean managed; -}; - -enum -{ - DIE, - SAVE_STATE, - LAST_SIGNAL -}; - -static guint signals [LAST_SIGNAL] = { 0 }; - -G_DEFINE_TYPE (ParoleSession, parole_session, G_TYPE_OBJECT) - -static void -parole_session_die (gpointer client_data) -{ - ParoleSession *session; - - session = parole_session_get (); - - if ( session->priv->managed ) - g_signal_emit (G_OBJECT (session), signals [DIE], 0); -} - -static void -parole_session_class_init (ParoleSessionClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - - signals [DIE] = - g_signal_new ("die", - PAROLE_TYPE_SESSION, - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET(ParoleSessionClass, die), - NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0, G_TYPE_NONE); - - - signals [SAVE_STATE] = - g_signal_new ("save-state", - PAROLE_TYPE_SESSION, - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET(ParoleSessionClass, save_state), - NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0, G_TYPE_NONE); - - object_class->finalize = parole_session_finalize; - - g_type_class_add_private (klass, sizeof (ParoleSessionPrivate)); -} - -static void -parole_session_init (ParoleSession *session) -{ - session->priv = PAROLE_SESSION_GET_PRIVATE (session); - - session->priv->client = NULL; - - session->priv->client = client_session_new_full (NULL, - SESSION_RESTART_NEVER, - 40, - NULL, - (gchar *) PACKAGE_NAME, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL); - - if ( G_UNLIKELY (session->priv->client == NULL ) ) - { - g_warning ("Failed to connect to session manager"); - return; - } - - session->priv->client->die = parole_session_die; -} - -static void -parole_session_finalize (GObject *object) -{ - ParoleSession *session; - - session = PAROLE_SESSION (object); - - if ( session->priv->client != NULL ) - { - client_session_free (session->priv->client); - } - - G_OBJECT_CLASS (parole_session_parent_class)->finalize (object); -} - -ParoleSession * -parole_session_get (void) -{ - static gpointer parole_session_obj = NULL; - - if ( G_LIKELY (parole_session_obj != NULL ) ) - { - g_object_ref (parole_session_obj); - } - else - { - parole_session_obj = g_object_new (PAROLE_TYPE_SESSION, NULL); - g_object_add_weak_pointer (parole_session_obj, &parole_session_obj); - } - - return PAROLE_SESSION (parole_session_obj); -} - -void parole_session_real_init (ParoleSession *session) -{ - g_return_if_fail (PAROLE_IS_SESSION (session)); - g_return_if_fail (session->priv->managed == FALSE); - - session->priv->managed = session_init (session->priv->client); -} - -void parole_session_set_client_id (ParoleSession *session, const gchar *client_id) -{ - g_return_if_fail (PAROLE_IS_SESSION (session)); - g_return_if_fail (session->priv->managed == FALSE); - - if ( G_UNLIKELY (session->priv->client == NULL) ) - return; - - client_session_set_client_id (session->priv->client, client_id); -} diff --git a/src/parole-session.h b/src/parole-session.h deleted file mode 100644 index 5816200..0000000 --- a/src/parole-session.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - * * Copyright (C) 2009-2011 Ali <al...@xfce.org> - * - * Licensed under the GNU General Public License Version 2 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef __PAROLE_SESSION_H -#define __PAROLE_SESSION_H - -#include <glib-object.h> - -G_BEGIN_DECLS - -#define PAROLE_TYPE_SESSION (parole_session_get_type () ) -#define PAROLE_SESSION(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), PAROLE_TYPE_SESSION, ParoleSession)) -#define PAROLE_IS_SESSION(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), PAROLE_TYPE_SESSION)) - -typedef struct ParoleSessionPrivate ParoleSessionPrivate; - -typedef struct -{ - GObject parent; - ParoleSessionPrivate *priv; - -} ParoleSession; - -typedef struct -{ - GObjectClass parent_class; - - void (*die) (ParoleSession *session); - - void (*save_state) (ParoleSession *session); - -} ParoleSessionClass; - -GType parole_session_get_type (void) G_GNUC_CONST; - -ParoleSession *parole_session_get (void); - -void parole_session_real_init (ParoleSession *session); - -void parole_session_set_client_id (ParoleSession *session, - const gchar *client_id); -G_END_DECLS - -#endif /* __PAROLE_SESSION_H */ _______________________________________________ Xfce4-commits mailing list Xfce4-commits@xfce.org https://mail.xfce.org/mailman/listinfo/xfce4-commits