[gnome-control-center] Add a get_toplevel accessor to CcShell



commit 9b985450f1c29ed59965e394df8a265a882c72f4
Author: Gerd Kohlberger <gerdk src gnome org>
Date:   Sat Oct 16 15:26:35 2010 +0200

    Add a get_toplevel accessor to CcShell
    
    Can be used to parent dialogs in CcPanel implementations.
    https://bugzilla.gnome.org/show_bug.cgi?id=621940

 libgnome-control-center/cc-shell.c |   28 ++++++++++++++++++++++++++++
 libgnome-control-center/cc-shell.h |   24 +++++++++++++-----------
 shell/gnome-control-center.c       |    8 ++++++--
 3 files changed, 47 insertions(+), 13 deletions(-)
---
diff --git a/libgnome-control-center/cc-shell.c b/libgnome-control-center/cc-shell.c
index cee3177..323b4d9 100644
--- a/libgnome-control-center/cc-shell.c
+++ b/libgnome-control-center/cc-shell.c
@@ -204,4 +204,32 @@ cc_shell_set_active_panel_from_id (CcShell      *shell,
     }
 }
 
+/**
+ * cc_shell_get_toplevel:
+ * @shell: A #CcShell
+ *
+ * Gets the toplevel window of the shell.
+ *
+ * Returns: The #GtkWidget of the shell window, or #NULL on error.
+ */
+GtkWidget *
+cc_shell_get_toplevel (CcShell *shell)
+{
+  CcShellClass *klass;
+
+  g_return_val_if_fail (CC_IS_SHELL (shell), NULL);
+
+  klass = CC_SHELL_GET_CLASS (shell);
+
+  if (klass->get_toplevel)
+    {
+        return klass->get_toplevel (shell);
+    }
+
+  g_warning ("Object of type \"%s\" does not implement required virtual"
+             " function \"get_toplevel\",",
+             G_OBJECT_TYPE_NAME (shell));
+
+  return NULL;
+}
 
diff --git a/libgnome-control-center/cc-shell.h b/libgnome-control-center/cc-shell.h
index 55567dc..1778afc 100644
--- a/libgnome-control-center/cc-shell.h
+++ b/libgnome-control-center/cc-shell.h
@@ -22,7 +22,7 @@
 #ifndef _CC_SHELL_H
 #define _CC_SHELL_H
 
-#include <glib-object.h>
+#include <gtk/gtk.h>
 
 G_BEGIN_DECLS
 
@@ -84,19 +84,21 @@ struct _CcShellClass
 
   /*< public >*/
   /* vfuncs */
-  gboolean (*set_active_panel_from_id) (CcShell      *shell,
-                                        const gchar  *id,
-                                        GError      **error);
+  gboolean    (*set_active_panel_from_id) (CcShell      *shell,
+                                           const gchar  *id,
+                                           GError      **error);
+  GtkWidget * (*get_toplevel)             (CcShell      *shell);
 };
 
-GType    cc_shell_get_type                 (void) G_GNUC_CONST;
+GType           cc_shell_get_type                 (void) G_GNUC_CONST;
 
-CcPanel* cc_shell_get_active_panel         (CcShell *shell);
-void     cc_shell_set_active_panel         (CcShell *shell,
-                                            CcPanel *panel);
-gboolean cc_shell_set_active_panel_from_id (CcShell      *shell,
-                                            const gchar  *id,
-                                            GError      **error);
+CcPanel*        cc_shell_get_active_panel         (CcShell      *shell);
+void            cc_shell_set_active_panel         (CcShell      *shell,
+                                                   CcPanel      *panel);
+gboolean        cc_shell_set_active_panel_from_id (CcShell      *shell,
+                                                   const gchar  *id,
+                                                   GError      **error);
+GtkWidget *     cc_shell_get_toplevel             (CcShell      *shell);
 
 G_END_DECLS
 
diff --git a/shell/gnome-control-center.c b/shell/gnome-control-center.c
index 512c740..bc73668 100644
--- a/shell/gnome-control-center.c
+++ b/shell/gnome-control-center.c
@@ -774,8 +774,11 @@ _shell_set_active_panel_from_id (CcShell      *shell,
     }
 }
 
-
-
+static GtkWidget *
+_shell_get_toplevel (CcShell *shell)
+{
+  return GNOME_CONTROL_CENTER (shell)->priv->window;
+}
 
 /* GObject Implementation */
 static void
@@ -883,6 +886,7 @@ gnome_control_center_class_init (GnomeControlCenterClass *klass)
   object_class->finalize = gnome_control_center_finalize;
 
   shell_class->set_active_panel_from_id = _shell_set_active_panel_from_id;
+  shell_class->get_toplevel = _shell_get_toplevel;
 }
 
 static void



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