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
This commit is contained in:
Gerd Kohlberger 2010-10-16 15:26:35 +02:00 committed by Bastien Nocera
parent e8b5261049
commit 9b985450f1
3 changed files with 47 additions and 13 deletions

View file

@ -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;
}

View file

@ -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

View file

@ -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