2012-03-12 14:35:24 +01:00
|
|
|
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
|
|
|
|
*
|
2013-01-28 15:59:05 +01:00
|
|
|
* Copyright (C) 2012, 2013 Red Hat, Inc.
|
2012-03-12 14:35:24 +01:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library 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
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General
|
2014-01-23 12:57:27 +01:00
|
|
|
* Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
2012-03-12 14:35:24 +01:00
|
|
|
*
|
|
|
|
* Author: Debarshi Ray <debarshir@gnome.org>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include <glib/gi18n-lib.h>
|
|
|
|
|
|
|
|
#define GOA_API_IS_SUBJECT_TO_CHANGE
|
|
|
|
#define GOA_BACKEND_API_IS_SUBJECT_TO_CHANGE
|
|
|
|
#include <goabackend/goabackend.h>
|
|
|
|
|
|
|
|
#include "cc-online-accounts-add-account-dialog.h"
|
|
|
|
|
2013-01-28 15:59:05 +01:00
|
|
|
#define BRANDED_PAGE "_branded"
|
|
|
|
#define OTHER_PAGE "_other"
|
|
|
|
|
2012-03-12 14:35:24 +01:00
|
|
|
struct _GoaPanelAddAccountDialogPrivate
|
|
|
|
{
|
2013-06-13 12:21:48 +02:00
|
|
|
GtkListBox *branded_list_box;
|
|
|
|
GtkListBox *contacts_list_box;
|
|
|
|
GtkListBox *mail_list_box;
|
2013-07-25 13:08:58 +01:00
|
|
|
GtkListBox *chat_list_box;
|
2013-06-13 12:21:48 +02:00
|
|
|
GtkListBox *ticketing_list_box;
|
2012-03-12 14:35:24 +01:00
|
|
|
GError *error;
|
|
|
|
GoaClient *client;
|
|
|
|
GoaObject *object;
|
2013-03-01 12:11:14 +01:00
|
|
|
GoaProvider *provider;
|
2012-03-12 14:35:24 +01:00
|
|
|
GtkListStore *list_store;
|
2013-01-28 15:59:05 +01:00
|
|
|
GtkWidget *contacts_grid;
|
|
|
|
GtkWidget *mail_grid;
|
2013-07-25 13:08:58 +01:00
|
|
|
GtkWidget *chat_grid;
|
2013-01-28 15:59:05 +01:00
|
|
|
GtkWidget *ticketing_grid;
|
|
|
|
GtkWidget *stack;
|
|
|
|
gboolean add_other;
|
2012-03-12 14:35:24 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#define GOA_ADD_ACCOUNT_DIALOG_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GOA_TYPE_PANEL_ADD_ACCOUNT_DIALOG, GoaPanelAddAccountDialogPrivate))
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
PROP_0,
|
|
|
|
PROP_CLIENT,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
COLUMN_PROVIDER,
|
|
|
|
COLUMN_ICON,
|
|
|
|
COLUMN_MARKUP,
|
|
|
|
N_COLUMNS
|
|
|
|
};
|
|
|
|
|
|
|
|
G_DEFINE_TYPE (GoaPanelAddAccountDialog, goa_panel_add_account_dialog, GTK_TYPE_DIALOG)
|
|
|
|
|
|
|
|
static void
|
2013-03-01 12:11:14 +01:00
|
|
|
add_account_dialog_add_account (GoaPanelAddAccountDialog *add_account,
|
|
|
|
GoaProvider *provider)
|
2012-03-12 14:35:24 +01:00
|
|
|
{
|
|
|
|
GoaPanelAddAccountDialogPrivate *priv = add_account->priv;
|
|
|
|
GList *children;
|
|
|
|
GList *l;
|
|
|
|
GtkWidget *action_area;
|
|
|
|
GtkWidget *vbox;
|
|
|
|
|
|
|
|
action_area = gtk_dialog_get_action_area (GTK_DIALOG (add_account));
|
|
|
|
vbox = gtk_dialog_get_content_area (GTK_DIALOG (add_account));
|
|
|
|
children = gtk_container_get_children (GTK_CONTAINER (vbox));
|
|
|
|
for (l = children; l != NULL; l = l->next)
|
|
|
|
{
|
|
|
|
GtkWidget *child = l->data;
|
|
|
|
if (child != action_area)
|
|
|
|
gtk_container_remove (GTK_CONTAINER (vbox), child);
|
|
|
|
}
|
|
|
|
g_list_free (children);
|
|
|
|
|
2013-03-01 12:11:14 +01:00
|
|
|
/* This spins gtk_dialog_run() */
|
2012-03-12 14:35:24 +01:00
|
|
|
priv->object = goa_provider_add_account (provider,
|
|
|
|
priv->client,
|
|
|
|
GTK_DIALOG (add_account),
|
|
|
|
GTK_BOX (vbox),
|
|
|
|
&priv->error);
|
|
|
|
}
|
|
|
|
|
2013-01-24 13:15:17 +01:00
|
|
|
static void
|
2013-06-13 12:21:48 +02:00
|
|
|
list_box_row_activated_cb (GoaPanelAddAccountDialog *add_account, GtkListBoxRow *row)
|
2012-03-12 14:35:24 +01:00
|
|
|
{
|
2013-01-24 13:15:17 +01:00
|
|
|
GoaProvider *provider;
|
2012-03-12 14:35:24 +01:00
|
|
|
|
2013-06-13 12:21:48 +02:00
|
|
|
provider = g_object_get_data (G_OBJECT (row), "provider");
|
2013-01-28 15:59:05 +01:00
|
|
|
if (provider == NULL)
|
|
|
|
{
|
2013-04-24 11:10:46 +02:00
|
|
|
gtk_stack_set_visible_child_name (GTK_STACK (add_account->priv->stack), OTHER_PAGE);
|
2013-01-28 15:59:05 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-01-24 13:15:17 +01:00
|
|
|
add_account_dialog_add_account (add_account, provider);
|
2012-03-12 14:35:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2013-06-13 12:21:48 +02:00
|
|
|
update_header_func (GtkListBoxRow *row,
|
|
|
|
GtkListBoxRow *before,
|
|
|
|
gpointer user_data)
|
2012-03-12 14:35:24 +01:00
|
|
|
{
|
2013-06-13 12:21:48 +02:00
|
|
|
GtkWidget *current;
|
|
|
|
|
|
|
|
if (before == NULL)
|
|
|
|
return;
|
2012-03-12 14:35:24 +01:00
|
|
|
|
2013-06-13 12:21:48 +02:00
|
|
|
current = gtk_list_box_row_get_header (row);
|
|
|
|
if (current == NULL)
|
|
|
|
{
|
|
|
|
current = gtk_separator_new (GTK_ORIENTATION_HORIZONTAL);
|
|
|
|
gtk_widget_show (current);
|
|
|
|
gtk_list_box_row_set_header (row, current);
|
2013-01-24 13:15:17 +01:00
|
|
|
}
|
2012-03-12 14:35:24 +01:00
|
|
|
}
|
|
|
|
|
2013-01-28 15:59:05 +01:00
|
|
|
static void
|
|
|
|
add_account_dialog_create_group_ui (GoaPanelAddAccountDialog *add_account,
|
2013-06-13 12:21:48 +02:00
|
|
|
GtkListBox **list_box,
|
2013-01-28 15:59:05 +01:00
|
|
|
GtkWidget **group_grid,
|
|
|
|
GtkWidget *page_grid,
|
|
|
|
const gchar *name)
|
|
|
|
{
|
|
|
|
GtkWidget *label;
|
|
|
|
GtkWidget *sw;
|
|
|
|
gchar *markup;
|
|
|
|
|
|
|
|
*group_grid = gtk_grid_new ();
|
|
|
|
gtk_widget_set_no_show_all (*group_grid, TRUE);
|
|
|
|
gtk_orientable_set_orientation (GTK_ORIENTABLE (*group_grid), GTK_ORIENTATION_VERTICAL);
|
|
|
|
gtk_grid_set_row_spacing (GTK_GRID (*group_grid), 6);
|
|
|
|
gtk_container_add (GTK_CONTAINER (page_grid), *group_grid);
|
|
|
|
|
|
|
|
markup = g_strdup_printf ("<b>%s</b>", name);
|
|
|
|
label = gtk_label_new (NULL);
|
|
|
|
gtk_widget_set_halign (label, GTK_ALIGN_START);
|
|
|
|
gtk_widget_set_hexpand (label, TRUE);
|
|
|
|
gtk_label_set_markup (GTK_LABEL (label), markup);
|
|
|
|
gtk_container_add (GTK_CONTAINER (*group_grid), label);
|
|
|
|
g_free (markup);
|
|
|
|
|
|
|
|
sw = gtk_scrolled_window_new (NULL, NULL);
|
|
|
|
gtk_widget_set_hexpand (sw, TRUE);
|
|
|
|
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
|
|
|
|
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw), GTK_SHADOW_IN);
|
|
|
|
gtk_container_add (GTK_CONTAINER (*group_grid), sw);
|
|
|
|
|
2013-06-13 12:21:48 +02:00
|
|
|
*list_box = GTK_LIST_BOX (gtk_list_box_new ());
|
|
|
|
gtk_container_add (GTK_CONTAINER (sw), GTK_WIDGET (*list_box));
|
|
|
|
gtk_list_box_set_selection_mode (*list_box, GTK_SELECTION_NONE);
|
|
|
|
gtk_list_box_set_header_func (*list_box, update_header_func, NULL, NULL);
|
|
|
|
g_signal_connect_swapped (*list_box, "row-activated",
|
|
|
|
G_CALLBACK (list_box_row_activated_cb), add_account);
|
2013-01-28 15:59:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
add_account_dialog_create_provider_ui (GoaPanelAddAccountDialog *add_account,
|
|
|
|
GoaProvider *provider,
|
2013-06-13 12:21:48 +02:00
|
|
|
GtkListBox *list_box)
|
2013-01-28 15:59:05 +01:00
|
|
|
{
|
|
|
|
GIcon *icon;
|
2013-08-15 13:55:45 +01:00
|
|
|
GList *children;
|
2013-06-13 12:21:48 +02:00
|
|
|
GtkWidget *row;
|
2013-01-28 15:59:05 +01:00
|
|
|
GtkWidget *row_grid;
|
|
|
|
GtkWidget *image;
|
|
|
|
GtkWidget *label;
|
|
|
|
gchar *markup;
|
|
|
|
gchar *name;
|
|
|
|
|
2013-06-13 12:21:48 +02:00
|
|
|
row = gtk_list_box_row_new ();
|
2013-01-28 15:59:05 +01:00
|
|
|
row_grid = gtk_grid_new ();
|
|
|
|
gtk_orientable_set_orientation (GTK_ORIENTABLE (row_grid), GTK_ORIENTATION_HORIZONTAL);
|
|
|
|
gtk_grid_set_column_spacing (GTK_GRID (row_grid), 6);
|
2013-06-13 12:21:48 +02:00
|
|
|
gtk_container_add (GTK_CONTAINER (row), row_grid);
|
2013-01-28 15:59:05 +01:00
|
|
|
|
|
|
|
if (provider == NULL)
|
|
|
|
{
|
2013-06-13 12:21:48 +02:00
|
|
|
g_object_set_data (G_OBJECT (row), "provider", NULL);
|
2013-01-28 15:59:05 +01:00
|
|
|
icon = g_themed_icon_new_with_default_fallbacks ("goa-account");
|
2013-04-03 18:40:17 -04:00
|
|
|
name = g_strdup (C_("Online Account", "Other"));
|
2013-01-28 15:59:05 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-06-13 12:21:48 +02:00
|
|
|
g_object_set_data_full (G_OBJECT (row), "provider", g_object_ref (provider), g_object_unref);
|
2013-01-28 15:59:05 +01:00
|
|
|
icon = goa_provider_get_provider_icon (provider, NULL);
|
|
|
|
name = goa_provider_get_provider_name (provider, NULL);
|
|
|
|
}
|
|
|
|
|
2013-08-15 13:55:45 +01:00
|
|
|
children = gtk_container_get_children (GTK_CONTAINER (list_box));
|
|
|
|
if (children != NULL)
|
|
|
|
{
|
|
|
|
/* FIXME: Ideally we want the list boxes to use as much space as
|
|
|
|
* it's available to try to show all the content, but GtkScrolledView
|
|
|
|
* ignores its child's natural size,
|
|
|
|
* see https://bugzilla.gnome.org/show_bug.cgi?id=660654
|
|
|
|
* For now we just make list boxes with multiple children expand as
|
|
|
|
* the result is quite similar. */
|
|
|
|
GtkWidget *sw;
|
|
|
|
sw = gtk_widget_get_parent (GTK_WIDGET (list_box));
|
|
|
|
gtk_widget_set_vexpand (sw, TRUE);
|
|
|
|
g_list_free (children);
|
|
|
|
}
|
|
|
|
|
2013-06-13 12:21:48 +02:00
|
|
|
gtk_container_add (GTK_CONTAINER (list_box), row);
|
|
|
|
|
2013-01-28 15:59:05 +01:00
|
|
|
image = gtk_image_new_from_gicon (icon, GTK_ICON_SIZE_DIALOG);
|
|
|
|
gtk_container_add (GTK_CONTAINER (row_grid), image);
|
|
|
|
|
|
|
|
markup = g_strdup_printf ("<b>%s</b>", name);
|
|
|
|
label = gtk_label_new (NULL);
|
|
|
|
gtk_label_set_markup (GTK_LABEL (label), markup);
|
|
|
|
gtk_container_add (GTK_CONTAINER (row_grid), label);
|
|
|
|
g_free (markup);
|
|
|
|
|
|
|
|
g_free (name);
|
|
|
|
g_object_unref (icon);
|
|
|
|
}
|
|
|
|
|
2012-03-12 14:35:24 +01:00
|
|
|
static void
|
|
|
|
goa_panel_add_account_dialog_realize (GtkWidget *widget)
|
|
|
|
{
|
|
|
|
GoaPanelAddAccountDialog *add_account = GOA_PANEL_ADD_ACCOUNT_DIALOG (widget);
|
2012-11-09 19:12:46 +01:00
|
|
|
GtkWidget *button;
|
2012-03-12 14:35:24 +01:00
|
|
|
GtkWindow *parent;
|
|
|
|
|
|
|
|
parent = gtk_window_get_transient_for (GTK_WINDOW (add_account));
|
|
|
|
if (parent != NULL)
|
|
|
|
{
|
|
|
|
gint width;
|
|
|
|
gint height;
|
|
|
|
|
|
|
|
gtk_window_get_size (parent, &width, &height);
|
2013-09-02 18:53:50 +02:00
|
|
|
gtk_widget_set_size_request (GTK_WIDGET (add_account), (gint) (0.5 * width), (gint) (1.25 * height));
|
2012-03-12 14:35:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
GTK_WIDGET_CLASS (goa_panel_add_account_dialog_parent_class)->realize (widget);
|
2012-11-09 19:12:46 +01:00
|
|
|
|
|
|
|
button = gtk_dialog_get_widget_for_response (GTK_DIALOG (add_account), GTK_RESPONSE_CANCEL);
|
|
|
|
gtk_widget_grab_focus (button);
|
2012-03-12 14:35:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
goa_panel_add_account_dialog_dispose (GObject *object)
|
|
|
|
{
|
|
|
|
GoaPanelAddAccountDialog *add_account = GOA_PANEL_ADD_ACCOUNT_DIALOG (object);
|
|
|
|
GoaPanelAddAccountDialogPrivate *priv = add_account->priv;
|
|
|
|
|
|
|
|
g_clear_object (&priv->object);
|
|
|
|
g_clear_object (&priv->client);
|
2013-03-01 12:11:14 +01:00
|
|
|
g_clear_object (&priv->provider);
|
2012-03-12 14:35:24 +01:00
|
|
|
|
|
|
|
G_OBJECT_CLASS (goa_panel_add_account_dialog_parent_class)->dispose (object);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
goa_panel_add_account_dialog_finalize (GObject *object)
|
|
|
|
{
|
|
|
|
GoaPanelAddAccountDialog *add_account = GOA_PANEL_ADD_ACCOUNT_DIALOG (object);
|
|
|
|
GoaPanelAddAccountDialogPrivate *priv = add_account->priv;
|
|
|
|
|
2013-03-14 19:48:53 +01:00
|
|
|
g_clear_error (&priv->error);
|
2012-03-12 14:35:24 +01:00
|
|
|
|
|
|
|
G_OBJECT_CLASS (goa_panel_add_account_dialog_parent_class)->finalize (object);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
goa_panel_add_account_dialog_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
GoaPanelAddAccountDialog *add_account = GOA_PANEL_ADD_ACCOUNT_DIALOG (object);
|
|
|
|
GoaPanelAddAccountDialogPrivate *priv = add_account->priv;
|
|
|
|
|
|
|
|
switch (prop_id)
|
|
|
|
{
|
|
|
|
case PROP_CLIENT:
|
|
|
|
priv->client = GOA_CLIENT (g_value_dup_object (value));
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
goa_panel_add_account_dialog_init (GoaPanelAddAccountDialog *add_account)
|
|
|
|
{
|
|
|
|
GoaPanelAddAccountDialogPrivate *priv;
|
|
|
|
GtkWidget *sw;
|
|
|
|
GtkWidget *vbox;
|
2012-06-15 11:01:52 -04:00
|
|
|
GtkWidget *grid;
|
2012-03-12 14:35:24 +01:00
|
|
|
|
|
|
|
add_account->priv = GOA_ADD_ACCOUNT_DIALOG_GET_PRIVATE (add_account);
|
|
|
|
priv = add_account->priv;
|
|
|
|
|
2012-06-15 11:01:52 -04:00
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (add_account), 6);
|
2012-03-12 14:35:24 +01:00
|
|
|
gtk_window_set_modal (GTK_WINDOW (add_account), TRUE);
|
|
|
|
gtk_window_set_resizable (GTK_WINDOW (add_account), FALSE);
|
2012-09-14 13:38:06 +02:00
|
|
|
/* translators: This is the title of the "Add Account" dialog. */
|
2012-03-12 14:35:24 +01:00
|
|
|
gtk_window_set_title (GTK_WINDOW (add_account), _("Add Account"));
|
|
|
|
|
|
|
|
vbox = gtk_dialog_get_content_area (GTK_DIALOG (add_account));
|
2012-06-15 11:01:52 -04:00
|
|
|
grid = gtk_grid_new ();
|
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (grid), 5);
|
|
|
|
gtk_widget_set_margin_bottom (grid, 6);
|
|
|
|
gtk_orientable_set_orientation (GTK_ORIENTABLE (grid), GTK_ORIENTATION_VERTICAL);
|
|
|
|
gtk_grid_set_row_spacing (GTK_GRID (grid), 12);
|
|
|
|
gtk_container_add (GTK_CONTAINER (vbox), grid);
|
2012-03-12 14:35:24 +01:00
|
|
|
|
|
|
|
priv->list_store = gtk_list_store_new (N_COLUMNS, GOA_TYPE_PROVIDER, G_TYPE_ICON, G_TYPE_STRING);
|
|
|
|
|
2013-04-24 11:10:46 +02:00
|
|
|
priv->stack = gtk_stack_new ();
|
|
|
|
gtk_stack_set_transition_type (GTK_STACK (priv->stack), GTK_STACK_TRANSITION_TYPE_CROSSFADE);
|
2013-01-28 15:59:05 +01:00
|
|
|
gtk_container_add (GTK_CONTAINER (grid), priv->stack);
|
|
|
|
|
2012-03-12 14:35:24 +01:00
|
|
|
sw = gtk_scrolled_window_new (NULL, NULL);
|
|
|
|
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
|
|
|
|
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw), GTK_SHADOW_IN);
|
2012-06-15 11:01:52 -04:00
|
|
|
gtk_widget_set_hexpand (sw, TRUE);
|
|
|
|
gtk_widget_set_vexpand (sw, TRUE);
|
2013-04-24 11:10:46 +02:00
|
|
|
gtk_stack_add_named (GTK_STACK (priv->stack), sw, BRANDED_PAGE);
|
2012-03-12 14:35:24 +01:00
|
|
|
|
2013-06-13 12:21:48 +02:00
|
|
|
priv->branded_list_box = GTK_LIST_BOX (gtk_list_box_new ());
|
|
|
|
gtk_container_add (GTK_CONTAINER (sw), GTK_WIDGET (priv->branded_list_box));
|
|
|
|
gtk_list_box_set_selection_mode (priv->branded_list_box, GTK_SELECTION_NONE);
|
|
|
|
gtk_list_box_set_header_func (priv->branded_list_box, update_header_func, NULL, NULL);
|
|
|
|
g_signal_connect_swapped (priv->branded_list_box, "row-activated",
|
|
|
|
G_CALLBACK (list_box_row_activated_cb), add_account);
|
2012-03-12 14:35:24 +01:00
|
|
|
|
2013-01-28 15:59:05 +01:00
|
|
|
grid = gtk_grid_new ();
|
|
|
|
gtk_orientable_set_orientation (GTK_ORIENTABLE (grid), GTK_ORIENTATION_VERTICAL);
|
|
|
|
gtk_grid_set_row_spacing (GTK_GRID (grid), 12);
|
2013-04-24 11:10:46 +02:00
|
|
|
gtk_stack_add_named (GTK_STACK (priv->stack), grid, OTHER_PAGE);
|
2013-01-28 15:59:05 +01:00
|
|
|
|
|
|
|
add_account_dialog_create_group_ui (add_account,
|
|
|
|
&priv->mail_list_box,
|
|
|
|
&priv->mail_grid,
|
|
|
|
grid,
|
|
|
|
_("Mail"));
|
|
|
|
|
|
|
|
add_account_dialog_create_group_ui (add_account,
|
|
|
|
&priv->contacts_list_box,
|
|
|
|
&priv->contacts_grid,
|
|
|
|
grid,
|
|
|
|
_("Contacts"));
|
|
|
|
|
2013-07-25 13:08:58 +01:00
|
|
|
add_account_dialog_create_group_ui (add_account,
|
|
|
|
&priv->chat_list_box,
|
|
|
|
&priv->chat_grid,
|
|
|
|
grid,
|
|
|
|
_("Chat"));
|
|
|
|
|
2013-01-28 15:59:05 +01:00
|
|
|
add_account_dialog_create_group_ui (add_account,
|
|
|
|
&priv->ticketing_list_box,
|
|
|
|
&priv->ticketing_grid,
|
|
|
|
grid,
|
|
|
|
_("Resources"));
|
|
|
|
|
2013-04-24 11:10:46 +02:00
|
|
|
gtk_stack_set_visible_child_name (GTK_STACK (priv->stack), BRANDED_PAGE);
|
2013-01-28 15:59:05 +01:00
|
|
|
|
2013-07-19 15:57:12 +03:00
|
|
|
gtk_dialog_add_button (GTK_DIALOG (add_account), _("_Cancel"), GTK_RESPONSE_CANCEL);
|
2012-03-12 14:35:24 +01:00
|
|
|
gtk_dialog_set_default_response (GTK_DIALOG (add_account), GTK_RESPONSE_CANCEL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
goa_panel_add_account_dialog_class_init (GoaPanelAddAccountDialogClass *klass)
|
|
|
|
{
|
|
|
|
GObjectClass *object_class;
|
|
|
|
GtkWidgetClass *widget_class;
|
|
|
|
|
|
|
|
object_class = G_OBJECT_CLASS (klass);
|
|
|
|
object_class->dispose = goa_panel_add_account_dialog_dispose;
|
|
|
|
object_class->finalize = goa_panel_add_account_dialog_finalize;
|
|
|
|
object_class->set_property = goa_panel_add_account_dialog_set_property;
|
|
|
|
|
|
|
|
widget_class = GTK_WIDGET_CLASS (klass);
|
|
|
|
widget_class->realize = goa_panel_add_account_dialog_realize;
|
|
|
|
|
|
|
|
g_type_class_add_private (object_class, sizeof (GoaPanelAddAccountDialogPrivate));
|
|
|
|
|
|
|
|
g_object_class_install_property (object_class,
|
|
|
|
PROP_CLIENT,
|
|
|
|
g_param_spec_object ("client",
|
|
|
|
"Goa Client",
|
|
|
|
"A Goa client for talking to the Goa daemon.",
|
|
|
|
GOA_TYPE_CLIENT,
|
|
|
|
G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
|
|
|
|
}
|
|
|
|
|
|
|
|
GtkWidget *
|
|
|
|
goa_panel_add_account_dialog_new (GoaClient *client)
|
|
|
|
{
|
|
|
|
return g_object_new (GOA_TYPE_PANEL_ADD_ACCOUNT_DIALOG, "client", client, NULL);
|
|
|
|
}
|
|
|
|
|
2013-03-01 12:11:14 +01:00
|
|
|
void
|
|
|
|
goa_panel_add_account_dialog_set_preseed_data (GoaPanelAddAccountDialog *add_account,
|
|
|
|
GoaProvider *provider,
|
|
|
|
GVariant *preseed)
|
|
|
|
{
|
|
|
|
GoaPanelAddAccountDialogPrivate *priv = add_account->priv;
|
|
|
|
|
|
|
|
g_clear_object (&priv->provider);
|
|
|
|
|
|
|
|
if (provider != NULL)
|
|
|
|
{
|
|
|
|
priv->provider = g_object_ref (provider);
|
|
|
|
goa_provider_set_preseed_data (provider, preseed);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-03-12 14:35:24 +01:00
|
|
|
void
|
|
|
|
goa_panel_add_account_dialog_add_provider (GoaPanelAddAccountDialog *add_account, GoaProvider *provider)
|
|
|
|
{
|
|
|
|
GoaPanelAddAccountDialogPrivate *priv = add_account->priv;
|
2013-06-13 12:21:48 +02:00
|
|
|
GtkListBox *list_box;
|
2013-01-28 15:59:05 +01:00
|
|
|
GoaProviderGroup group;
|
|
|
|
GtkWidget *group_grid = NULL;
|
2012-03-12 14:35:24 +01:00
|
|
|
|
2013-01-28 15:59:05 +01:00
|
|
|
g_return_if_fail (provider != NULL);
|
2013-01-24 13:15:17 +01:00
|
|
|
|
2013-01-28 15:59:05 +01:00
|
|
|
group = goa_provider_get_provider_group (provider);
|
2013-01-24 13:15:17 +01:00
|
|
|
|
2013-01-28 15:59:05 +01:00
|
|
|
/* The list of providers returned by GOA are sorted such that all
|
|
|
|
* the branded providers are at the beginning of the list, followed
|
|
|
|
* by the others. Since this is the order in which they are added,
|
|
|
|
* we can rely on this fact, which helps to simplify the code.
|
|
|
|
*/
|
|
|
|
if (group != GOA_PROVIDER_GROUP_BRANDED && !priv->add_other)
|
|
|
|
{
|
|
|
|
add_account_dialog_create_provider_ui (add_account, NULL, priv->branded_list_box);
|
|
|
|
priv->add_other = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (group)
|
|
|
|
{
|
|
|
|
case GOA_PROVIDER_GROUP_BRANDED:
|
|
|
|
list_box = priv->branded_list_box;
|
|
|
|
break;
|
|
|
|
case GOA_PROVIDER_GROUP_CONTACTS:
|
|
|
|
group_grid = priv->contacts_grid;
|
|
|
|
list_box = priv->contacts_list_box;
|
|
|
|
break;
|
|
|
|
case GOA_PROVIDER_GROUP_MAIL:
|
|
|
|
group_grid = priv->mail_grid;
|
|
|
|
list_box = priv->mail_list_box;
|
|
|
|
break;
|
2013-07-25 13:08:58 +01:00
|
|
|
case GOA_PROVIDER_GROUP_CHAT:
|
|
|
|
group_grid = priv->chat_grid;
|
|
|
|
list_box = priv->chat_list_box;
|
|
|
|
break;
|
2013-01-28 15:59:05 +01:00
|
|
|
case GOA_PROVIDER_GROUP_TICKETING:
|
|
|
|
group_grid = priv->ticketing_grid;
|
|
|
|
list_box = priv->ticketing_list_box;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
g_assert_not_reached ();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
add_account_dialog_create_provider_ui (add_account, provider, list_box);
|
|
|
|
|
|
|
|
if (group_grid != NULL)
|
|
|
|
{
|
|
|
|
gtk_widget_set_no_show_all (group_grid, FALSE);
|
|
|
|
gtk_widget_show_all (group_grid);
|
|
|
|
}
|
2012-03-12 14:35:24 +01:00
|
|
|
}
|
|
|
|
|
2013-03-01 12:11:14 +01:00
|
|
|
void
|
|
|
|
goa_panel_add_account_dialog_run (GoaPanelAddAccountDialog *add_account)
|
|
|
|
{
|
|
|
|
GoaPanelAddAccountDialogPrivate *priv = add_account->priv;
|
|
|
|
if (priv->provider != NULL)
|
|
|
|
add_account_dialog_add_account (add_account, priv->provider);
|
|
|
|
else
|
|
|
|
gtk_dialog_run (GTK_DIALOG (add_account));
|
|
|
|
}
|
|
|
|
|
2012-03-12 14:35:24 +01:00
|
|
|
GoaObject *
|
|
|
|
goa_panel_add_account_dialog_get_account (GoaPanelAddAccountDialog *add_account, GError **error)
|
|
|
|
{
|
|
|
|
GoaPanelAddAccountDialogPrivate *priv = add_account->priv;
|
|
|
|
|
|
|
|
if (error != NULL && priv->error != NULL)
|
|
|
|
*error = g_error_copy (priv->error);
|
|
|
|
|
|
|
|
if (priv->object != NULL)
|
|
|
|
g_object_ref (priv->object);
|
|
|
|
|
|
|
|
return priv->object;
|
|
|
|
}
|