[gnome-flashback] end-session-dialog: rename FlashbackEndSessionDialog to GfEndSessionDialog



commit 22996ef6015bebc3bcb8305721a47d1f678ab9d2
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date:   Sun Sep 13 22:38:54 2015 +0300

    end-session-dialog: rename FlashbackEndSessionDialog to GfEndSessionDialog

 gnome-flashback/flashback-application.c            |    6 +-
 .../libend-session-dialog/gf-end-session-dialog.c  |  341 ++++++++++----------
 .../libend-session-dialog/gf-end-session-dialog.h  |   27 +--
 3 files changed, 179 insertions(+), 195 deletions(-)
---
diff --git a/gnome-flashback/flashback-application.c b/gnome-flashback/flashback-application.c
index 4496e2f..cc11fc0 100644
--- a/gnome-flashback/flashback-application.c
+++ b/gnome-flashback/flashback-application.c
@@ -47,13 +47,13 @@ struct _FlashbackApplication
 
   GsdAutomountManager       *automount;
   FlashbackDisplayConfig    *config;
-  FlashbackEndSessionDialog *dialog;
   FlashbackIdleMonitor      *idle_monitor;
   FlashbackPolkit           *polkit;
   FlashbackScreencast       *screencast;
   FlashbackShell            *shell;
   GfBluetoothApplet         *bluetooth;
   GfDesktopBackground       *background;
+  GfEndSessionDialog        *dialog;
   GfPowerApplet             *power;
   GfScreenshot              *screenshot;
   GfSoundApplet             *sound;
@@ -139,12 +139,12 @@ settings_changed (GSettings   *settings,
   SETTING_CHANGED (automount, "automount-manager", gsd_automount_manager_new)
   SETTING_CHANGED (config, "display-config", flashback_display_config_new)
   SETTING_CHANGED (idle_monitor, "idle-monitor", flashback_idle_monitor_new)
-  SETTING_CHANGED (dialog, "end-session-dialog", flashback_end_session_dialog_new)
   SETTING_CHANGED (polkit, "polkit", flashback_polkit_new)
   SETTING_CHANGED (screencast, "screencast", flashback_screencast_new)
   SETTING_CHANGED (shell, "shell", flashback_shell_new)
   SETTING_CHANGED (bluetooth, "bluetooth-applet", gf_bluetooth_applet_new)
   SETTING_CHANGED (background, "desktop-background", gf_desktop_background_new)
+  SETTING_CHANGED (dialog, "end-session-dialog", gf_end_session_dialog_new)
   SETTING_CHANGED (power, "power-applet", gf_power_applet_new)
   SETTING_CHANGED (screenshot, "screenshot", gf_screenshot_new)
   SETTING_CHANGED (sound, "sound-applet", gf_sound_applet_new)
@@ -175,13 +175,13 @@ flashback_application_finalize (GObject *object)
 
   g_clear_object (&application->automount);
   g_clear_object (&application->config);
-  g_clear_object (&application->dialog);
   g_clear_object (&application->idle_monitor);
   g_clear_object (&application->polkit);
   g_clear_object (&application->screencast);
   g_clear_object (&application->shell);
   g_clear_object (&application->bluetooth);
   g_clear_object (&application->background);
+  g_clear_object (&application->dialog);
   g_clear_object (&application->power);
   g_clear_object (&application->screenshot);
   g_clear_object (&application->sound);
diff --git a/gnome-flashback/libend-session-dialog/gf-end-session-dialog.c 
b/gnome-flashback/libend-session-dialog/gf-end-session-dialog.c
index 78e934c..15cd24b 100644
--- a/gnome-flashback/libend-session-dialog/gf-end-session-dialog.c
+++ b/gnome-flashback/libend-session-dialog/gf-end-session-dialog.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2014 Alberts Muktupāvels
+ * Copyright (C) 2014 - 2015 Alberts Muktupāvels
  *
  * 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
@@ -15,229 +15,226 @@
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
 
-#include <gtk/gtk.h>
 #include "config.h"
+
+#include <gtk/gtk.h>
+
 #include "dbus-end-session-dialog.h"
-#include "gf-end-session-dialog.h"
 #include "flashback-inhibit-dialog.h"
+#include "gf-end-session-dialog.h"
+
+struct _GfEndSessionDialog
+{
+  GObject                 parent;
 
-struct _FlashbackEndSessionDialogPrivate {
-       gint                    bus_name;
-       GDBusInterfaceSkeleton *iface;
-       GtkWidget              *dialog;
+  gint                    bus_name;
+  GDBusInterfaceSkeleton *iface;
+
+  GtkWidget              *dialog;
 };
 
-G_DEFINE_TYPE (FlashbackEndSessionDialog, flashback_end_session_dialog, G_TYPE_OBJECT);
+G_DEFINE_TYPE (GfEndSessionDialog, gf_end_session_dialog, G_TYPE_OBJECT)
 
 static void
 inhibit_dialog_response (FlashbackInhibitDialog *dialog,
                          guint                   response_id,
-                         DBusEndSessionDialog   *object)
+                         gpointer                user_data)
 {
-       int action;
-
-       g_object_get (dialog, "action", &action, NULL);
-
-       switch (response_id) {
-       case FLASHBACK_RESPONSE_CANCEL:
-               break;
-       case FLASHBACK_RESPONSE_ACCEPT:
-               if (action == FLASHBACK_LOGOUT_ACTION_LOGOUT) {
-                       dbus_end_session_dialog_emit_confirmed_logout (object);
-               } else if (action == FLASHBACK_LOGOUT_ACTION_SHUTDOWN) {
-                       dbus_end_session_dialog_emit_confirmed_shutdown (object);
-               } else if (action == FLASHBACK_LOGOUT_ACTION_REBOOT) {
-                       dbus_end_session_dialog_emit_confirmed_reboot (object);
-               } else if (action == FLASHBACK_LOGOUT_ACTION_HIBERNATE) {
-                       dbus_end_session_dialog_emit_confirmed_hibernate (object);
-               } else if (action == FLASHBACK_LOGOUT_ACTION_SUSPEND) {
-                       dbus_end_session_dialog_emit_confirmed_suspend (object);
-               } else if (action == FLASHBACK_LOGOUT_ACTION_HYBRID_SLEEP) {
-                       dbus_end_session_dialog_emit_confirmed_hybrid_sleep (object);
-               } else {
-                       g_assert_not_reached ();
-               }
-               break;
-       default:
-               g_assert_not_reached ();
-               break;
-       }
-
-       flashback_inhibit_dialog_close (dialog);
+  DBusEndSessionDialog *object;
+  gint action;
+
+  object = DBUS_END_SESSION_DIALOG (user_data);
+  g_object_get (dialog, "action", &action, NULL);
+
+  switch (response_id)
+    {
+      case FLASHBACK_RESPONSE_CANCEL:
+        break;
+
+      case FLASHBACK_RESPONSE_ACCEPT:
+        if (action == FLASHBACK_LOGOUT_ACTION_LOGOUT)
+          dbus_end_session_dialog_emit_confirmed_logout (object);
+        else if (action == FLASHBACK_LOGOUT_ACTION_SHUTDOWN)
+          dbus_end_session_dialog_emit_confirmed_shutdown (object);
+        else if (action == FLASHBACK_LOGOUT_ACTION_REBOOT)
+          dbus_end_session_dialog_emit_confirmed_reboot (object);
+        else if (action == FLASHBACK_LOGOUT_ACTION_HIBERNATE)
+          dbus_end_session_dialog_emit_confirmed_hibernate (object);
+        else if (action == FLASHBACK_LOGOUT_ACTION_SUSPEND)
+          dbus_end_session_dialog_emit_confirmed_suspend (object);
+        else if (action == FLASHBACK_LOGOUT_ACTION_HYBRID_SLEEP)
+          dbus_end_session_dialog_emit_confirmed_hybrid_sleep (object);
+        else
+          g_assert_not_reached ();
+        break;
+
+      default:
+        g_assert_not_reached ();
+        break;
+    }
+
+  flashback_inhibit_dialog_close (dialog);
 }
 
 static void
 inhibit_dialog_close (FlashbackInhibitDialog *dialog,
-                      DBusEndSessionDialog   *object)
+                      gpointer                user_data)
 {
-       dbus_end_session_dialog_emit_canceled (object);
-       dbus_end_session_dialog_emit_closed (object);
+  DBusEndSessionDialog *object;
+
+  object = DBUS_END_SESSION_DIALOG (user_data);
+
+  dbus_end_session_dialog_emit_canceled (object);
+  dbus_end_session_dialog_emit_closed (object);
 }
 
 static void
-closed (DBusEndSessionDialog      *object,
-        FlashbackEndSessionDialog *dialog)
+closed (DBusEndSessionDialog *object,
+        gpointer              user_data)
 {
-       dialog->priv->dialog = NULL;
+  GfEndSessionDialog *dialog;
+
+  dialog = GF_END_SESSION_DIALOG (user_data);
+
+  dialog->dialog = NULL;
 }
 
 static gboolean
-handle_open (DBusEndSessionDialog *object,
-             GDBusMethodInvocation          *invocation,
-             guint                           arg_type,
-             guint                           arg_timestamp,
-             guint                           arg_seconds_to_stay_open,
-             const gchar *const             *arg_inhibitor_object_paths,
-             gpointer                        user_data)
+handle_open (DBusEndSessionDialog  *object,
+             GDBusMethodInvocation *invocation,
+             guint                  type,
+             guint                  timestamp,
+             guint                  seconds_to_stay_open,
+             const gchar *const    *inhibitor_object_paths,
+             gpointer               user_data)
 {
-       FlashbackEndSessionDialog *dialog = user_data;
-
-       if (dialog->priv->dialog != NULL) {
-               g_object_set (dialog->priv->dialog, "inhibitor-paths", arg_inhibitor_object_paths, NULL);
-
-               if (arg_timestamp != 0) {
-                       gtk_window_present_with_time (GTK_WINDOW (dialog->priv->dialog), arg_timestamp);
-               } else {
-                       gtk_window_present (GTK_WINDOW (dialog->priv->dialog));
-               }
-
-               dbus_end_session_dialog_complete_open (object, invocation);
-               return TRUE;
-       }
-
-       dialog->priv->dialog = flashback_inhibit_dialog_new (arg_type,
-                                                            arg_seconds_to_stay_open,
-                                                            arg_inhibitor_object_paths);
-
-       g_signal_connect (dialog->priv->dialog, "response", G_CALLBACK (inhibit_dialog_response), object);
-       g_signal_connect (dialog->priv->dialog, "destroy", G_CALLBACK (inhibit_dialog_close), object);
-       g_signal_connect (dialog->priv->dialog, "close", G_CALLBACK (inhibit_dialog_close), object);
-       g_signal_connect (object, "closed", G_CALLBACK (closed), dialog);
-
-       if (arg_timestamp != 0) {
-               gtk_window_present_with_time (GTK_WINDOW (dialog->priv->dialog), arg_timestamp);
-       } else {
-               gtk_window_present (GTK_WINDOW (dialog->priv->dialog));
-       }
-
-       dbus_end_session_dialog_complete_open (object, invocation);
-       return TRUE;
+  GfEndSessionDialog *dialog;
+
+  dialog = GF_END_SESSION_DIALOG (user_data);
+
+  if (dialog->dialog != NULL)
+    {
+      g_object_set (dialog->dialog,
+                    "inhibitor-paths", inhibitor_object_paths,
+                    NULL);
+
+      if (timestamp != 0)
+        gtk_window_present_with_time (GTK_WINDOW (dialog->dialog), timestamp);
+      else
+        gtk_window_present (GTK_WINDOW (dialog->dialog));
+
+      dbus_end_session_dialog_complete_open (object, invocation);
+
+      return TRUE;
+    }
+
+  dialog->dialog = flashback_inhibit_dialog_new (type, seconds_to_stay_open,
+                                                 inhibitor_object_paths);
+
+  g_signal_connect (dialog->dialog, "response",
+                    G_CALLBACK (inhibit_dialog_response), object);
+  g_signal_connect (dialog->dialog, "destroy",
+                    G_CALLBACK (inhibit_dialog_close), object);
+  g_signal_connect (dialog->dialog, "close",
+                    G_CALLBACK (inhibit_dialog_close), object);
+
+  g_signal_connect (object, "closed",
+                    G_CALLBACK (closed), dialog);
+
+  if (timestamp != 0)
+    gtk_window_present_with_time (GTK_WINDOW (dialog->dialog), timestamp);
+  else
+    gtk_window_present (GTK_WINDOW (dialog->dialog));
+
+  dbus_end_session_dialog_complete_open (object, invocation);
+
+  return TRUE;
 }
 
 static void
-/*
-on_bus_acquired (GDBusConnection *connection,
-                 const gchar     *name,
-                 gpointer         user_data)
-*/
 name_appeared_handler (GDBusConnection *connection,
                        const gchar     *name,
                        const gchar     *name_owner,
                        gpointer         user_data)
 {
-       FlashbackEndSessionDialog *dialog;
-       GError *error = NULL;
-
-       dialog = FLASHBACK_END_SESSION_DIALOG (user_data);
-       dialog->priv->iface = G_DBUS_INTERFACE_SKELETON (dbus_end_session_dialog_skeleton_new ());
-       g_signal_connect (dialog->priv->iface, "handle-open", G_CALLBACK (handle_open), dialog);
-
-       if (!g_dbus_interface_skeleton_export (dialog->priv->iface,
-                                              connection,
-                                              "/org/gnome/SessionManager/EndSessionDialog",
-                                              &error)) {
-               g_warning ("Failed to export interface: %s", error->message);
-               g_error_free (error);
-               return;
-       }
-}
+  GfEndSessionDialog *dialog;
+  DBusEndSessionDialog *skeleton;
+  GError *error;
 
-/*
-static void
-on_name_acquired (GDBusConnection *connection,
-                  const char      *name,
-                  gpointer         user_data)
-{
-}
+  dialog = GF_END_SESSION_DIALOG (user_data);
+  skeleton = dbus_end_session_dialog_skeleton_new ();
 
-static void
-on_name_lost (GDBusConnection *connection,
-              const char      *name,
-              gpointer         user_data)
-{
+  dialog->iface = G_DBUS_INTERFACE_SKELETON (skeleton);
+
+  g_signal_connect (skeleton, "handle-open",
+                    G_CALLBACK (handle_open), dialog);
+
+  error = NULL;
+  if (!g_dbus_interface_skeleton_export (dialog->iface, connection,
+                                         "/org/gnome/SessionManager/EndSessionDialog",
+                                         &error))
+    {
+      g_warning ("Failed to export interface: %s", error->message);
+      g_error_free (error);
+
+      return;
+    }
 }
-*/
 
 static void
-flashback_end_session_dialog_finalize (GObject *object)
+gf_end_session_dialog_finalize (GObject *object)
 {
-       FlashbackEndSessionDialog *dialog = FLASHBACK_END_SESSION_DIALOG (object);
+  GfEndSessionDialog *dialog;
 
-       if (dialog->priv->dialog) {
-               gtk_widget_destroy (dialog->priv->dialog);
-               dialog->priv->dialog = NULL;
-       }
+  dialog = GF_END_SESSION_DIALOG (object);
 
-       if (dialog->priv->iface) {
-               g_dbus_interface_skeleton_unexport (dialog->priv->iface);
+  if (dialog->dialog != NULL)
+    {
+      gtk_widget_destroy (dialog->dialog);
+      dialog->dialog = NULL;
+    }
 
-               g_object_unref (dialog->priv->iface);
-               dialog->priv->iface = NULL;
-       }
+  if (dialog->iface != NULL)
+    {
+      g_dbus_interface_skeleton_unexport (dialog->iface);
 
-       if (dialog->priv->bus_name) {
-               /*
-               g_bus_unown_name (dialog->priv->bus_name);
-               */
-               g_bus_unwatch_name (dialog->priv->bus_name);
-               dialog->priv->bus_name = 0;
-       }
+      g_object_unref (dialog->iface);
+      dialog->iface = NULL;
+    }
 
-       G_OBJECT_CLASS (flashback_end_session_dialog_parent_class)->finalize (object);
+  if (dialog->bus_name > 0)
+    {
+      g_bus_unwatch_name (dialog->bus_name);
+      dialog->bus_name = 0;
+    }
+
+  G_OBJECT_CLASS (gf_end_session_dialog_parent_class)->finalize (object);
 }
 
 static void
-flashback_end_session_dialog_init (FlashbackEndSessionDialog *dialog)
+gf_end_session_dialog_class_init (GfEndSessionDialogClass *dialog_class)
 {
-       dialog->priv = G_TYPE_INSTANCE_GET_PRIVATE (dialog,
-                                                   FLASHBACK_TYPE_END_SESSION_DIALOG,
-                                                   FlashbackEndSessionDialogPrivate);
-
-       dialog->priv->dialog = NULL;
-       dialog->priv->iface = NULL;
-       dialog->priv->bus_name = g_bus_watch_name (G_BUS_TYPE_SESSION,
-                                                  "org.gnome.Shell",
-                                                  G_BUS_NAME_WATCHER_FLAGS_NONE,
-                                                  name_appeared_handler,
-                                                  NULL,
-                                                  dialog,
-                                                  NULL);
-       /*
-       dialog->priv->bus_name = g_bus_own_name (G_BUS_TYPE_SESSION,
-                                                "org.gnome.Shell",
-                                                G_BUS_NAME_OWNER_FLAGS_ALLOW_REPLACEMENT |
-                                                G_BUS_NAME_OWNER_FLAGS_REPLACE,
-                                                on_bus_acquired,
-                                                on_name_acquired,
-                                                on_name_lost,
-                                                dialog,
-                                                NULL);
-       */
+  GObjectClass *object_class;
+
+  object_class = G_OBJECT_CLASS (dialog_class);
+
+  object_class->finalize = gf_end_session_dialog_finalize;
 }
 
 static void
-flashback_end_session_dialog_class_init (FlashbackEndSessionDialogClass *class)
+gf_end_session_dialog_init (GfEndSessionDialog *dialog)
 {
-       GObjectClass *object_class = G_OBJECT_CLASS (class);
-
-       object_class->finalize = flashback_end_session_dialog_finalize;
-
-       g_type_class_add_private (class, sizeof (FlashbackEndSessionDialogPrivate));
+  dialog->bus_name = g_bus_watch_name (G_BUS_TYPE_SESSION,
+                                       "org.gnome.Shell",
+                                       G_BUS_NAME_WATCHER_FLAGS_NONE,
+                                       name_appeared_handler,
+                                       NULL,
+                                       dialog,
+                                       NULL);
 }
 
-FlashbackEndSessionDialog *
-flashback_end_session_dialog_new (void)
+GfEndSessionDialog *
+gf_end_session_dialog_new (void)
 {
-       return g_object_new (FLASHBACK_TYPE_END_SESSION_DIALOG,
-                            NULL);
+  return g_object_new (GF_TYPE_END_SESSION_DIALOG, NULL);
 }
diff --git a/gnome-flashback/libend-session-dialog/gf-end-session-dialog.h 
b/gnome-flashback/libend-session-dialog/gf-end-session-dialog.h
index 15b8878..891fcab 100644
--- a/gnome-flashback/libend-session-dialog/gf-end-session-dialog.h
+++ b/gnome-flashback/libend-session-dialog/gf-end-session-dialog.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2014 Alberts Muktupāvels
+ * Copyright (C) 2014 - 2015 Alberts Muktupāvels
  *
  * 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
@@ -15,31 +15,18 @@
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
 
-#ifndef FLASHBACK_END_SESSION_DIALOG_H
-#define FLASHBACK_END_SESSION_DIALOG_H
+#ifndef GF_END_SESSION_DIALOG_H
+#define GF_END_SESSION_DIALOG_H
 
 #include <glib-object.h>
 
 G_BEGIN_DECLS
 
-#define FLASHBACK_TYPE_END_SESSION_DIALOG (flashback_end_session_dialog_get_type ())
-#define FLASHBACK_END_SESSION_DIALOG(o)   (G_TYPE_CHECK_INSTANCE_CAST ((o), 
FLASHBACK_TYPE_END_SESSION_DIALOG, FlashbackEndSessionDialog))
+#define GF_TYPE_END_SESSION_DIALOG gf_end_session_dialog_get_type ()
+G_DECLARE_FINAL_TYPE (GfEndSessionDialog, gf_end_session_dialog,
+                      GF, END_SESSION_DIALOG, GObject)
 
-typedef struct _FlashbackEndSessionDialog        FlashbackEndSessionDialog;
-typedef struct _FlashbackEndSessionDialogClass   FlashbackEndSessionDialogClass;
-typedef struct _FlashbackEndSessionDialogPrivate FlashbackEndSessionDialogPrivate;
-
-struct _FlashbackEndSessionDialog {
-       GObject                            parent;
-       FlashbackEndSessionDialogPrivate *priv;
-};
-
-struct _FlashbackEndSessionDialogClass {
-    GObjectClass parent_class;
-};
-
-GType                      flashback_end_session_dialog_get_type (void);
-FlashbackEndSessionDialog *flashback_end_session_dialog_new      (void);
+GfEndSessionDialog *gf_end_session_dialog_new (void);
 
 G_END_DECLS
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]