Commit 6ab6193f authored by Sébastien Blin's avatar Sébastien Blin

wizardview: add create rendez-vous button

Change-Id: I59ca2d47aa201d018c02dea565820d310aa00599
Gitlab: #1196
parent c30a816c
<svg xmlns="http://www.w3.org/2000/svg" enable-background="new 0 0 24 24" height="24" viewBox="0 0 24 24" width="24" fill="grey"><rect fill="none" height="24" width="24"/><g><path d="M12,12.75c1.63,0,3.07,0.39,4.24,0.9c1.08,0.48,1.76,1.56,1.76,2.73L18,18H6l0-1.61c0-1.18,0.68-2.26,1.76-2.73 C8.93,13.14,10.37,12.75,12,12.75z M4,13c1.1,0,2-0.9,2-2c0-1.1-0.9-2-2-2s-2,0.9-2,2C2,12.1,2.9,13,4,13z M5.13,14.1 C4.76,14.04,4.39,14,4,14c-0.99,0-1.93,0.21-2.78,0.58C0.48,14.9,0,15.62,0,16.43V18l4.5,0v-1.61C4.5,15.56,4.73,14.78,5.13,14.1z M20,13c1.1,0,2-0.9,2-2c0-1.1-0.9-2-2-2s-2,0.9-2,2C18,12.1,18.9,13,20,13z M24,16.43c0-0.81-0.48-1.53-1.22-1.85 C21.93,14.21,20.99,14,20,14c-0.39,0-0.76,0.04-1.13,0.1c0.4,0.68,0.63,1.46,0.63,2.29V18l4.5,0V16.43z M12,6c1.66,0,3,1.34,3,3 c0,1.66-1.34,3-3,3s-3-1.34-3-3C9,7.34,10.34,6,12,6z"/></g></svg>
\ No newline at end of file
......@@ -62,5 +62,6 @@
<file alias="plugin_white">extension_white_24dp.svg</file>
<file alias="view">view.svg</file>
<file alias="more">more_vert-24px.svg</file>
<file alias="groups">groups-24px.svg</file>
</gresource>
</gresources>
......@@ -48,7 +48,8 @@ enum class Mode {
ADD_LOCAL,
IMPORT_FROM_DEVICE,
IMPORT_FROM_BACKUP,
CONNECT_TO_MANAGER
CONNECT_TO_MANAGER,
ADD_RENDEZVOUS
};
struct _AccountCreationWizardPrivate
......@@ -66,6 +67,7 @@ struct _AccountCreationWizardPrivate
GtkWidget *choose_account_type_vbox;
GtkWidget *choose_account_type_ring_logo;
GtkWidget *button_new_account;
GtkWidget *button_new_rendezvous;
GtkWidget *button_import_from_device;
GtkWidget *button_import_from_backup;
GtkWidget *button_show_advanced;
......@@ -96,6 +98,8 @@ struct _AccountCreationWizardPrivate
GtkWidget *button_account_creation_previous;
GtkWidget *box_avatarselection;
GtkWidget *avatar_manipulation;
GtkWidget *label_register;
GtkWidget *label_username;
GtkWidget *box_username_entry;
GtkWidget *switch_register;
GtkWidget *username_registration_box;
......@@ -103,6 +107,7 @@ struct _AccountCreationWizardPrivate
/* generating_account_spinner */
GtkWidget *vbox_generating_account_spinner;
GtkWidget *generating_label;
/* registering_username_spinner */
GtkWidget *vbox_registering_username_spinner;
......@@ -190,6 +195,7 @@ account_creation_wizard_class_init(AccountCreationWizardClass *klass)
gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), AccountCreationWizard, choose_account_type_vbox);
gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), AccountCreationWizard, choose_account_type_ring_logo);
gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), AccountCreationWizard, button_new_account);
gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), AccountCreationWizard, button_new_rendezvous);
gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), AccountCreationWizard, button_import_from_device);
gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), AccountCreationWizard, button_import_from_backup);
gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), AccountCreationWizard, button_show_advanced);
......@@ -218,12 +224,15 @@ account_creation_wizard_class_init(AccountCreationWizardClass *klass)
gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), AccountCreationWizard, button_account_creation_previous);
gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), AccountCreationWizard, box_avatarselection);
gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), AccountCreationWizard, label_password_error);
gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), AccountCreationWizard, label_register);
gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), AccountCreationWizard, label_username);
gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), AccountCreationWizard, box_username_entry);
gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), AccountCreationWizard, switch_register);
gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), AccountCreationWizard, entry_display_name);
/* generating_account_spinner */
gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), AccountCreationWizard, vbox_generating_account_spinner);
gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), AccountCreationWizard, generating_label);
/* registering_username_spinner */
gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), AccountCreationWizard, vbox_registering_username_spinner);
......@@ -288,6 +297,10 @@ account_creation_show_error_view(AccountCreationWizard *view, const std::string&
gtk_label_set_text(GTK_LABEL(priv->label_error_view),
_("An error occured during the account creation."));
break;
case Mode::ADD_RENDEZVOUS:
gtk_label_set_text(GTK_LABEL(priv->label_error_view),
_("An error occured during the rendez-vous creation."));
break;
case Mode::IMPORT_FROM_DEVICE:
gtk_label_set_text(GTK_LABEL(priv->label_error_view),
_("Cannot retrieve any account, please verify your PIN and your password."));
......@@ -376,6 +389,12 @@ account_creation_wizard_account_added(AccountCreationWizard *view, const std::st
}
}
if (priv->mode == Mode::ADD_RENDEZVOUS) {
auto conf = priv->accountModel_->getAccountConfig(priv->accountId);
conf.isRendezVous = true;
priv->accountModel_->setAccountConfig(priv->accountId, conf);
}
if (!g_settings_get_boolean(priv->settings, "never-show-backup-again") && priv->mode == Mode::ADD_LOCAL) {
gtk_button_set_label(GTK_BUTTON(priv->button_export_account), _("Export account"));
gtk_widget_show_all(priv->info_backup);
......@@ -470,6 +489,11 @@ static void
show_generating_account_spinner(AccountCreationWizard *view)
{
auto* priv = ACCOUNT_CREATION_WIZARD_GET_PRIVATE(view);
if (priv->mode == Mode::ADD_RENDEZVOUS) {
gtk_label_set_text(GTK_LABEL(priv->generating_label), _("Generating your rendez-vous…"));
} else {
gtk_label_set_text(GTK_LABEL(priv->generating_label), _("Generating your Jami account…"));
}
gtk_stack_set_visible_child(GTK_STACK(priv->stack_account_creation), priv->vbox_generating_account_spinner);
}
......@@ -853,6 +877,7 @@ build_creation_wizard_view(AccountCreationWizard *view)
/* choose_account_type signals */
g_signal_connect_swapped(priv->button_new_account, "clicked", G_CALLBACK(account_creation_wizard_show_preview), view);
g_signal_connect_swapped(priv->button_new_rendezvous, "clicked", G_CALLBACK(show_rendezvous_creation_wizard), view);
g_signal_connect_swapped(priv->button_import_from_device, "clicked", G_CALLBACK(show_import_from_device), view);
g_signal_connect_swapped(priv->button_import_from_backup, "clicked", G_CALLBACK(show_import_from_backup), view);
g_signal_connect(priv->button_show_advanced, "clicked", G_CALLBACK(show_advanced), view);
......@@ -928,12 +953,14 @@ account_creation_wizard_show_preview(AccountCreationWizard *win, gboolean show_p
auto* priv = ACCOUNT_CREATION_WIZARD_GET_PRIVATE(win);
if (priv->account_creation) {
if (show_preview)
gtk_label_set_text(GTK_LABEL(priv->label_register), _("Register username"));
gtk_label_set_text(GTK_LABEL(priv->label_username), _("Username"));
if (show_preview) {
gtk_widget_show(priv->account_creation);
else
priv->mode = Mode::ADD_LOCAL;
} else
gtk_widget_hide(priv->account_creation);
}
priv->mode = Mode::ADD_LOCAL;
/* Similarily to general settings view, we construct and destroy the avatar manipulation widget
each time the profile is made visible / hidden. While not the most elegant solution, this
......@@ -949,4 +976,33 @@ account_creation_wizard_show_preview(AccountCreationWizard *win, gboolean show_p
gtk_container_remove(GTK_CONTAINER(priv->box_avatarselection), priv->avatar_manipulation);
priv->avatar_manipulation = nullptr;
}
}
\ No newline at end of file
}
void
show_rendezvous_creation_wizard(AccountCreationWizard *win)
{
auto* priv = ACCOUNT_CREATION_WIZARD_GET_PRIVATE(win);
if (priv->account_creation) {
gtk_label_set_text(GTK_LABEL(priv->label_register), _("Register name"));
gtk_label_set_text(GTK_LABEL(priv->label_username), _("Name"));
gtk_widget_show(priv->account_creation);
}
priv->mode = Mode::ADD_RENDEZVOUS;
/* Similarily to general settings view, we construct and destroy the avatar manipulation widget
each time the profile is made visible / hidden. While not the most elegant solution, this
allows us to run the preview if and only if it is displayed, and always stop it when hidden. */
if (!priv->avatar_manipulation) {
priv->avatar_manipulation = avatar_manipulation_new_from_wizard(priv->avModel_);
gtk_box_pack_start(GTK_BOX(priv->box_avatarselection), priv->avatar_manipulation, true, true, 0);
gtk_stack_set_visible_child(GTK_STACK(priv->stack_account_creation), priv->account_creation);
} else {
/* make sure the AvatarManipulation widget is destroyed so the VideoWidget inside of it is too;
* NOTE: destorying its parent (box_avatarselection) first will cause a mystery 'BadDrawable'
* crash due to X error */
gtk_container_remove(GTK_CONTAINER(priv->box_avatarselection), priv->avatar_manipulation);
priv->avatar_manipulation = nullptr;
}
}
......@@ -51,6 +51,7 @@ GType account_creation_wizard_get_type (void) G_GNUC_CONST;
GtkWidget *account_creation_wizard_new (lrc::api::AVModel& avModel, lrc::api::NewAccountModel& accountModel);
void account_creation_wizard_show_preview (AccountCreationWizard *win, gboolean show_preview = TRUE);
void show_rendezvous_creation_wizard (AccountCreationWizard *win);
void account_creation_wizard_account_added (AccountCreationWizard *view, const std::string& id);
void account_creation_show_error_view (AccountCreationWizard *view, const std::string& id);
......
......@@ -422,6 +422,40 @@ private:
inline namespace gtk_callbacks
{
static void
render_rendezvous_mode(GtkCellLayout*,
GtkCellRenderer *cell,
GtkTreeModel *model,
GtkTreeIter *iter,
MainWindowPrivate* priv)
{
g_return_if_fail(priv->cpp->accountInfo_);
gchar *id;
gchar* avatar;
gchar* status;
gtk_tree_model_get (model, iter,
0 /* col# */, &id /* data */,
-1);
if (g_strcmp0("", id) != 0) {
try {
auto conf = priv->cpp->accountInfo_->accountModel->getAccountConfig(id);
if (conf.isRendezVous) {
GdkPixbuf* icon = gdk_pixbuf_new_from_resource("/net/jami/JamiGnome/groups", nullptr);
g_object_set(G_OBJECT(cell), "width", 32, nullptr);
g_object_set(G_OBJECT(cell), "height", 32, nullptr);
g_object_set(G_OBJECT(cell), "pixbuf", icon, nullptr);
} else {
g_object_set(G_OBJECT(cell), "pixbuf", nullptr, nullptr);
}
} catch (...) {}
}
g_free(id);
}
static void
on_video_double_clicked(MainWindow* self)
{
......@@ -1388,6 +1422,13 @@ CppImpl::init()
(GtkCellLayoutDataFunc )print_account_and_state,
widgets, nullptr);
renderer = gtk_cell_renderer_pixbuf_new();
gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(widgets->combobox_account_selector), renderer, true);
gtk_cell_layout_set_cell_data_func(GTK_CELL_LAYOUT(widgets->combobox_account_selector),
renderer,
(GtkCellLayoutDataFunc )render_rendezvous_mode,
widgets, nullptr);
// we closing any view opened to avoid confusion (especially between SIP and protocols).
g_signal_connect_swapped(widgets->combobox_account_selector, "changed", G_CALLBACK(on_account_changed), self);
......
......@@ -79,6 +79,14 @@
<property name="can_focus">True</property>
</object>
</child>
<child>
<object class="GtkButton" id="button_new_rendezvous">
<property name="label" translatable="yes">Create a rendez-vous</property>
<property name="tooltip_text" translatable="yes">Create new rendez-vous</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
</object>
</child>
<child>
<object class="GtkButton" id="button_import_from_device">
<property name="label" translatable="yes">Import from device</property>
......@@ -554,7 +562,7 @@
<property name="margin_top">10</property>
<property name="margin_bottom">10</property>
<child>
<object class="GtkLabel">
<object class="GtkLabel" id="label_register">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Register username</property>
......@@ -591,10 +599,9 @@
<property name="margin_top">10</property>
<property name="margin_bottom">10</property>
<child>
<object class="GtkLabel">
<object class="GtkLabel" id="label_username">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Username</property>
</object>
</child>
</object>
......@@ -729,10 +736,9 @@
<property name="orientation">vertical</property>
<property name="spacing">15</property>
<child>
<object class="GtkLabel">
<object class="GtkLabel" id="generating_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Generating your Jami account…</property>
</object>
</child>
<child>
......
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