Commit bca9fa60 authored by Cosimo Cecchi's avatar Cosimo Cecchi Committed by Sjoerd Simons

Add a parent window property to the assistant

parent 665eea7d
......@@ -51,6 +51,10 @@ enum {
PAGE_SALUT_ONLY = 3
};
enum {
PROP_PARENT = 1
};
typedef struct {
FirstPageResponse first_resp;
......@@ -432,9 +436,71 @@ account_assistant_build_enter_or_create_page (EmpathyAccountAssistant *self,
return main_vbox;
}
static void
do_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec)
{
EmpathyAccountAssistantPriv *priv = GET_PRIV (object);
switch (property_id)
{
case PROP_PARENT:
g_value_set_object (value, priv->parent_window);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
}
}
static void
do_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
{
EmpathyAccountAssistantPriv *priv = GET_PRIV (object);
switch (property_id)
{
case PROP_PARENT:
priv->parent_window = g_value_get_object (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
}
}
static void
do_constructed (GObject *object)
{
EmpathyAccountAssistantPriv *priv = GET_PRIV (object);
/* set us as transient for the parent window if any */
if (priv->parent_window)
gtk_window_set_transient_for (GTK_WINDOW (object),
priv->parent_window);
gtk_window_set_type_hint (GTK_WINDOW (object), GDK_WINDOW_TYPE_HINT_DIALOG);
}
static void
empathy_account_assistant_class_init (EmpathyAccountAssistantClass *klass)
{
GObjectClass *oclass = G_OBJECT_CLASS (klass);
GParamSpec *param_spec;
oclass->get_property = do_get_property;
oclass->set_property = do_set_property;
oclass->constructed = do_constructed;
param_spec = g_param_spec_object ("parent-window",
"parent-window", "The parent window",
GTK_TYPE_WINDOW,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT_ONLY);
g_object_class_install_property (oclass, PROP_PARENT, param_spec);
g_type_class_add_private (klass, sizeof (EmpathyAccountAssistantPriv));
}
......@@ -484,7 +550,8 @@ empathy_account_assistant_init (EmpathyAccountAssistant *self)
}
GtkWidget *
empathy_account_assistant_new (void)
empathy_account_assistant_new (GtkWindow *window)
{
return g_object_new (EMPATHY_TYPE_ACCOUNT_ASSISTANT, NULL);
return g_object_new (EMPATHY_TYPE_ACCOUNT_ASSISTANT, "parent-window",
window, NULL);
}
......@@ -56,7 +56,7 @@ typedef struct {
GType empathy_account_assistant_get_type (void);
GtkWidget *empathy_account_assistant_new (void);
GtkWidget *empathy_account_assistant_new (GtkWindow *parent);
G_END_DECLS
......
......@@ -63,6 +63,7 @@
#include <libempathy-gtk/empathy-ui-utils.h>
#include <libempathy-gtk/empathy-location-manager.h>
#include "empathy-account-assistant.h"
#include "empathy-accounts-dialog.h"
#include "empathy-main-window.h"
#include "empathy-status-icon.h"
......@@ -532,12 +533,17 @@ account_manager_ready_cb (EmpathyAccountManager *manager,
GParamSpec *spec,
gpointer user_data)
{
GtkWidget *assistant;
if (!empathy_account_manager_is_ready (manager))
return;
if (empathy_account_manager_get_count (manager) == 0)
empathy_accounts_dialog_show (GTK_WINDOW (empathy_main_window_get ()),
NULL);
{
assistant = empathy_account_assistant_new (
GTK_WINDOW (empathy_main_window_get ()));
gtk_window_present (GTK_WINDOW (assistant));
}
create_salut_account ();
}
......
......@@ -12,7 +12,7 @@ int main (int argc, char **argv)
gtk_init (&argc, &argv);
empathy_gtk_init ();
assistant = empathy_account_assistant_new ();
assistant = empathy_account_assistant_new (NULL);
gtk_widget_show_all (assistant);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment