Commit 2d63d5ec authored by Stepan Salenikovich's avatar Stepan Salenikovich
Browse files

gnome: move accounts to settings view

The other settings/preferences will go there.

Refs #69020

Change-Id: I62d60d093ee39f42813961689f0564d855bff8d6
parent 033dc83c
......@@ -33,6 +33,7 @@ FIND_PACKAGE(LibRingClient REQUIRED)
FIND_PACKAGE(Qt5Core REQUIRED)
PKG_CHECK_MODULES(CLUTTER REQUIRED clutter-1.0)
PKG_CHECK_MODULES(CLUTTERGTK REQUIRED clutter-gtk-1.0)
PKG_CHECK_MODULES(ICONSYMBLIC REQUIRED gnome-icon-theme-symbolic)
# include libs
INCLUDE_DIRECTORIES(${GTK3_INCLUDE_DIRS})
......
......@@ -103,7 +103,6 @@ codec_active_toggled(GtkCellRendererToggle *renderer, gchar *path, AccountAudioT
QModelIndex idx = gtk_q_sort_filter_tree_model_get_source_idx(GTK_Q_SORT_FILTER_TREE_MODEL(model), &iter);
if (idx.isValid()) {
priv->account->codecModel()->audioCodecs()->setData(idx, QVariant(toggle), Qt::CheckStateRole);
priv->account->codecModel()->save();
}
}
......@@ -139,7 +138,6 @@ move_selected_codec(AccountAudioTab *view, int position_diff)
idx.row() + position_diff,
0,
QModelIndex());
priv->account->codecModel()->save();
/* now make sure to select the same codec which was moved
* TODO: UGLY! this should be somehow done in the qt modle bindings,
......
......@@ -113,7 +113,6 @@ codec_active_toggled(GtkCellRendererToggle *renderer, gchar *path, AccountVideoT
QModelIndex idx = gtk_q_sort_filter_tree_model_get_source_idx(GTK_Q_SORT_FILTER_TREE_MODEL(model), &iter);
if (idx.isValid()) {
priv->account->codecModel()->videoCodecs()->setData(idx, QVariant(toggle), Qt::CheckStateRole);
priv->account->codecModel()->save();
}
}
......@@ -149,7 +148,6 @@ move_selected_codec(AccountVideoTab *view, int position_diff)
idx.row() + position_diff,
0,
QModelIndex());
priv->account->codecModel()->save();
/* now make sure to select the same codec which was moved
* TODO: UGLY! this should be somehow done in the qt modle bindings,
......
......@@ -63,12 +63,10 @@ struct _AccountViewPrivate
GtkWidget *button_add_account;
GtkWidget *combobox_account_type;
gint current_page; /* keeps tr#include "activeitemproxymodel.h"ack of current notebook page displayed */
QMetaObject::Connection account_changed;
QMetaObject::Connection codecs_changed;
gint current_page; /* keeps track of current notebook page displayed */
ActiveItemProxyModel *active_protocols;
QMetaObject::Connection protocol_selection_changed;
};
G_DEFINE_TYPE_WITH_PRIVATE(AccountView, account_view, GTK_TYPE_BOX);
......@@ -81,12 +79,22 @@ account_view_dispose(GObject *object)
AccountView *view = ACCOUNT_VIEW(object);
AccountViewPrivate *priv = ACCOUNT_VIEW_GET_PRIVATE(view);
QObject::disconnect(priv->account_changed);
QObject::disconnect(priv->codecs_changed);
QObject::disconnect(priv->protocol_selection_changed);
G_OBJECT_CLASS(account_view_parent_class)->dispose(object);
}
static void
account_view_finalize(GObject *object)
{
AccountView *view = ACCOUNT_VIEW(object);
AccountViewPrivate *priv = ACCOUNT_VIEW_GET_PRIVATE(view);
delete priv->active_protocols;
G_OBJECT_CLASS(account_view_parent_class)->finalize(object);
}
static QModelIndex
get_index_from_selection(GtkTreeSelection *selection)
{
......@@ -100,48 +108,6 @@ get_index_from_selection(GtkTreeSelection *selection)
}
}
static void
cancel_account_changes(G_GNUC_UNUSED GtkButton *button, AccountView *view)
{
g_debug("cancel changes");
g_return_if_fail(IS_ACCOUNT_VIEW(view));
AccountViewPrivate *priv = ACCOUNT_VIEW_GET_PRIVATE(view);
GtkTreeSelection *selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(priv->treeview_account_list));
QModelIndex account_idx = get_index_from_selection(selection);
g_return_if_fail(account_idx.isValid());
/* reload the current account view unselectin and re-selecting it */
GtkTreeIter iter;
gtk_q_tree_model_source_index_to_iter(
GTK_Q_TREE_MODEL(gtk_tree_view_get_model(GTK_TREE_VIEW(priv->treeview_account_list))),
account_idx,
&iter);
QObject::disconnect(priv->account_changed);
QObject::disconnect(priv->codecs_changed);
gtk_tree_selection_unselect_all(selection);
/* reload account */
Account *account = AccountModel::instance()->getAccountByModelIndex(account_idx);
account->performAction(Account::EditAction::CANCEL);
/* TODO: clear the codecModel changes once this method is added */
// account->codecModel()->cancel();
/* re-select same item */
gtk_tree_selection_select_iter(selection, &iter);
}
static void
apply_account_changes(G_GNUC_UNUSED GtkButton *button, Account *account)
{
account->performAction(Account::EditAction::SAVE);
/* TODO: save the codecModel changes once the method to clear them is added */
// account->codecModel()->save();
}
static void
update_account_model_selection(GtkTreeSelection *selection, G_GNUC_UNUSED gpointer user_data)
{
......@@ -202,55 +168,6 @@ account_selection_changed(GtkTreeSelection *selection, AccountView *view)
/* set the tab displayed to the same as the prev account selected */
gtk_notebook_set_current_page(GTK_NOTEBOOK(priv->current_account_notebook), priv->current_page);
/* button box with cancel and apply buttons */
GtkWidget *account_button_box = gtk_button_box_new(GTK_ORIENTATION_HORIZONTAL);
GtkWidget *account_change_cancel = gtk_button_new_with_label("Cancel");
GtkWidget *account_change_apply = gtk_button_new_with_label("Apply");
if (account->editState() != Account::EditState::MODIFIED) {
gtk_widget_set_sensitive(account_change_cancel, FALSE);
gtk_widget_set_sensitive(account_change_apply, FALSE);
}
gtk_box_pack_end(GTK_BOX(account_button_box), account_change_cancel, FALSE, FALSE, 0);
gtk_box_pack_end(GTK_BOX(account_button_box), account_change_apply, FALSE, FALSE, 0);
gtk_widget_set_halign(account_button_box, GTK_ALIGN_END);
gtk_box_set_spacing(GTK_BOX(account_button_box), 10);
gtk_box_pack_start(GTK_BOX(hbox_account), account_button_box, FALSE, FALSE, 0);
/* connect signals to buttons */
QObject::disconnect(priv->account_changed);
priv->account_changed = QObject::connect(
account,
&Account::changed,
[=](Account* a) {
if (a->editState() == Account::EditState::MODIFIED) {
/* account has been modified, enable buttons */
gtk_widget_set_sensitive(account_change_cancel, TRUE);
gtk_widget_set_sensitive(account_change_apply, TRUE);
} else {
gtk_widget_set_sensitive(account_change_cancel, FALSE);
gtk_widget_set_sensitive(account_change_apply, FALSE);
}
}
);
/* add the following signal once the 'cancel' method is added to the contactModel */
// QObject::disconnect(priv->codecs_changed);
// priv->codecs_changed = QObject::connect(
// account->codecModel(),
// &CodecModel::dataChanged,
// [=]() {
// /* data changed in codec model, this probably happened because
// * codecs were (de)selected */
// gtk_widget_set_sensitive(account_change_cancel, TRUE);
// gtk_widget_set_sensitive(account_change_apply, TRUE);
// }
// );
g_signal_connect(account_change_cancel, "clicked", G_CALLBACK(cancel_account_changes), view);
g_signal_connect(account_change_apply, "clicked", G_CALLBACK(apply_account_changes), account);
gtk_widget_show_all(hbox_account);
/* set the new account view as visible */
......@@ -300,7 +217,6 @@ remove_account_dialog(Account *account)
"Are you sure you want to delete account \"%s\"?",
account->alias().toLocal8Bit().constData());
// gtk_window_set_title(GTK_WINDOW(dialog), _("Ring delete account"));
switch (gtk_dialog_run(GTK_DIALOG(dialog))) {
case GTK_RESPONSE_OK:
response = TRUE;
......@@ -329,7 +245,6 @@ remove_account(G_GNUC_UNUSED GtkWidget *entry, AccountView *view)
Account *account = AccountModel::instance()->getAccountByModelIndex(idx);
if (remove_account_dialog(account)) {
AccountModel::instance()->remove(idx);
AccountModel::instance()->save();
}
}
}
......@@ -350,7 +265,6 @@ add_account(G_GNUC_UNUSED GtkWidget *entry, AccountView *view)
if (protocol_idx.isValid()) {
protocol_idx = priv->active_protocols->mapToSource(protocol_idx);
AccountModel::instance()->add(QString("New Account"), protocol_idx);
AccountModel::instance()->save();
}
}
}
......@@ -412,7 +326,7 @@ account_view_init(AccountView *view)
"text", 0, NULL);
/* connect signals to and from the selection model of the account model */
QObject::connect(
priv->protocol_selection_changed = QObject::connect(
AccountModel::instance()->selectionModel(),
&QItemSelectionModel::currentChanged,
[=](const QModelIndex & current, const QModelIndex & previous) {
......@@ -466,6 +380,7 @@ static void
account_view_class_init(AccountViewClass *klass)
{
G_OBJECT_CLASS(klass)->dispose = account_view_dispose;
G_OBJECT_CLASS(klass)->finalize = account_view_finalize;
gtk_widget_class_set_template_from_resource(GTK_WIDGET_CLASS (klass),
"/cx/ring/RingGnome/accountview.ui");
......
......@@ -85,11 +85,38 @@ init_exception_dialog(const char* msg)
gtk_widget_destroy(dialog);
}
static void
ring_accelerators(RingClient *client)
{
#if GTK_CHECK_VERSION(3,10,0)
const gchar *quit_accels[2] = { "<Ctrl>Q", NULL };
gtk_application_set_accels_for_action(GTK_APPLICATION(client), "app.quit", quit_accels);
#else
gtk_application_add_accelerator(GTK_APPLICATION(client), "<Control>Q", "win.quit", NULL);
#endif
}
static void
action_quit(G_GNUC_UNUSED GSimpleAction *simple,
G_GNUC_UNUSED GVariant *parameter,
gpointer user_data)
{
g_return_if_fail(G_IS_APPLICATION(user_data));
#if GLIB_CHECK_VERSION(2,32,0)
g_application_quit(G_APPLICATION(user_data));
#else
RingClientPrivate *priv = RING_CLIENT_GET_PRIVATE(user_data);
gtk_widget_destroy(priv->win);
#endif
}
static const GActionEntry ring_actions[] =
{
{ "accept", NULL, NULL, NULL, NULL, {0} },
{ "hangup", NULL, NULL, NULL, NULL, {0} },
{ "hold", NULL, NULL, "false", NULL, {0} },
{ "accept", NULL, NULL, NULL, NULL, {0} },
{ "hangup", NULL, NULL, NULL, NULL, {0} },
{ "hold", NULL, NULL, "false", NULL, {0} },
{ "quit", action_quit, NULL, NULL, NULL, {0} }
/* TODO implement the other actions */
// { "mute_audio", NULL, NULL, "false", NULL, {0} },
// { "mute_video", NULL, NULL, "false", NULL, {0} },
......@@ -162,7 +189,10 @@ ring_client_startup(GApplication *app, gint argc, gchar **argv)
/* add GActions */
g_action_map_add_action_entries(
G_ACTION_MAP(app), ring_actions, G_N_ELEMENTS(ring_actions), client);
G_ACTION_MAP(app), ring_actions, G_N_ELEMENTS(ring_actions), app);
/* add accelerators */
ring_accelerators(RING_CLIENT(app));
/* Bind GActions to the UserActionModel */
UserActionModel* uam = CallModel::instance()->userActionModel();
......@@ -238,6 +268,8 @@ ring_client_shutdown(GApplication *app)
RingClient *self = RING_CLIENT(app);
RingClientPrivate *priv = RING_CLIENT_GET_PRIVATE(self);
g_debug("quitting");
QObject::disconnect(priv->uam_updated);
/* free the QCoreApplication, which will destroy all libRingClient models
......
......@@ -43,9 +43,15 @@
#include <QtCore/QSortFilterProxyModel>
#include "models/gtkqsortfiltertreemodel.h"
#include "accountview.h"
#include <accountmodel.h>
#include <audio/codecmodel.h>
#define CALL_VIEW_NAME "calls"
#define GENERAL_SETTINGS_VIEW_NAME "general"
#define AUDIO_SETTINGS_VIEW_NAME "audio"
#define VIDEO_SETTINGS_VIEW_NAME "video"
#define ACCOUNT_SETTINGS_VIEW_NAME "accounts"
#define DEFAULT_VIEW_NAME "placeholder"
#define ACCOUNT_VIEW_NAME "account"
#define VIEW_CONTACTS "contacts"
#define VIEW_HISTORY "history"
#define VIEW_PRESENCE "presence"
......@@ -64,8 +70,12 @@ typedef struct _RingMainWindowPrivate RingMainWindowPrivate;
struct _RingMainWindowPrivate
{
GtkWidget *gears;
GtkWidget *gears_image;
GtkWidget *ring_menu;
GtkWidget *image_ring;
GtkWidget *ring_settings;
GtkWidget *image_settings;
GtkWidget *hbox_search;
GtkWidget *hbox_settings;
GtkWidget *stack_contacts_history_presence;
GtkWidget *radiobutton_contacts;
GtkWidget *radiobutton_history;
......@@ -73,8 +83,16 @@ struct _RingMainWindowPrivate
GtkWidget *treeview_call;
GtkWidget *search_entry;
GtkWidget *stack_main_view;
GtkWidget *vbox_call_view;
GtkWidget *stack_call_view;
GtkWidget *button_placecall;
GtkWidget *account_view;
GtkWidget *account_settings_view;
GtkWidget *radiobutton_audio_settings;
GtkWidget *radiobutton_general_settings;
GtkWidget *radiobutton_video_settings;
GtkWidget *radiobutton_account_settings;
gboolean show_settings;
};
G_DEFINE_TYPE_WITH_PRIVATE(RingMainWindow, ring_main_window, GTK_TYPE_APPLICATION_WINDOW);
......@@ -110,7 +128,7 @@ call_selection_changed(GtkTreeSelection *selection, gpointer win)
RingMainWindowPrivate *priv = RING_MAIN_WINDOW_GET_PRIVATE(RING_MAIN_WINDOW(win));
/* get the current visible stack child */
GtkWidget *old_call_view = gtk_stack_get_visible_child(GTK_STACK(priv->stack_main_view));
GtkWidget *old_call_view = gtk_stack_get_visible_child(GTK_STACK(priv->stack_call_view));
QModelIndex idx = get_index_from_selection(selection);
if (idx.isValid()) {
......@@ -140,28 +158,28 @@ call_selection_changed(GtkTreeSelection *selection, gpointer win)
break;
}
gtk_stack_add_named(GTK_STACK(priv->stack_main_view), new_call_view, new_call_view_name);
gtk_stack_set_visible_child(GTK_STACK(priv->stack_main_view), new_call_view);
gtk_stack_add_named(GTK_STACK(priv->stack_call_view), new_call_view, new_call_view_name);
gtk_stack_set_visible_child(GTK_STACK(priv->stack_call_view), new_call_view);
g_free(new_call_view_name);
} else {
/* nothing selected in the call model, so show the default screen */
/* TODO: replace stack paceholder view */
gtk_stack_set_transition_type(GTK_STACK(priv->stack_main_view), GTK_STACK_TRANSITION_TYPE_SLIDE_LEFT);
gtk_stack_set_visible_child_name(GTK_STACK(priv->stack_main_view), DEFAULT_VIEW_NAME);
gtk_stack_set_transition_type(GTK_STACK(priv->stack_main_view), GTK_STACK_TRANSITION_TYPE_SLIDE_RIGHT);
gtk_stack_set_transition_type(GTK_STACK(priv->stack_call_view), GTK_STACK_TRANSITION_TYPE_SLIDE_LEFT);
gtk_stack_set_visible_child_name(GTK_STACK(priv->stack_call_view), DEFAULT_VIEW_NAME);
gtk_stack_set_transition_type(GTK_STACK(priv->stack_call_view), GTK_STACK_TRANSITION_TYPE_SLIDE_RIGHT);
}
/* check if we changed the visible child */
GtkWidget *current_call_view = gtk_stack_get_visible_child(GTK_STACK(priv->stack_main_view));
GtkWidget *current_call_view = gtk_stack_get_visible_child(GTK_STACK(priv->stack_call_view));
if (current_call_view != old_call_view && old_call_view != NULL) {
/* if the previous child was a call view, then remove it from
* the stack; removing it should destory it since there should not
* be any other references to it */
if (IS_INCOMING_CALL_VIEW(old_call_view) || IS_CURRENT_CALL_VIEW(old_call_view)) {
gtk_container_remove(GTK_CONTAINER(priv->stack_main_view), old_call_view);
gtk_container_remove(GTK_CONTAINER(priv->stack_call_view), old_call_view);
}
}
}
......@@ -178,7 +196,7 @@ call_state_changed(Call *call, gpointer win)
if( idx_selected.isValid() && call == CallModel::instance()->getCall(idx_selected)) {
g_debug("selected call state changed");
/* check if we need to change the view */
GtkWidget *old_call_view = gtk_stack_get_visible_child(GTK_STACK(priv->stack_main_view));
GtkWidget *old_call_view = gtk_stack_get_visible_child(GTK_STACK(priv->stack_call_view));
GtkWidget *new_call_view = NULL;
QVariant state = CallModel::instance()->data(idx_selected, static_cast<int>(Call::Role::LifeCycleState));
......@@ -203,11 +221,11 @@ call_state_changed(Call *call, gpointer win)
/* use the pointer of the call as a unique name */
char* new_call_view_name = NULL;
new_call_view_name = g_strdup_printf("%p_current", (void *)CallModel::instance()->getCall(idx_selected));
gtk_stack_add_named(GTK_STACK(priv->stack_main_view), new_call_view, new_call_view_name);
gtk_stack_add_named(GTK_STACK(priv->stack_call_view), new_call_view, new_call_view_name);
g_free(new_call_view_name);
gtk_stack_set_transition_type(GTK_STACK(priv->stack_main_view), GTK_STACK_TRANSITION_TYPE_SLIDE_UP);
gtk_stack_set_visible_child(GTK_STACK(priv->stack_main_view), new_call_view);
gtk_stack_set_transition_type(GTK_STACK(priv->stack_main_view), GTK_STACK_TRANSITION_TYPE_SLIDE_RIGHT);
gtk_stack_set_transition_type(GTK_STACK(priv->stack_call_view), GTK_STACK_TRANSITION_TYPE_SLIDE_UP);
gtk_stack_set_visible_child(GTK_STACK(priv->stack_call_view), new_call_view);
gtk_stack_set_transition_type(GTK_STACK(priv->stack_call_view), GTK_STACK_TRANSITION_TYPE_SLIDE_RIGHT);
}
break;
case Call::LifeCycleState::FINISHED:
......@@ -219,30 +237,18 @@ call_state_changed(Call *call, gpointer win)
}
/* check if we changed the visible child */
GtkWidget *current_call_view = gtk_stack_get_visible_child(GTK_STACK(priv->stack_main_view));
GtkWidget *current_call_view = gtk_stack_get_visible_child(GTK_STACK(priv->stack_call_view));
if (current_call_view != old_call_view && old_call_view != NULL) {
/* if the previous child was a call view, then remove it from
* the stack; removing it should destory it since there should not
* be any other references to it */
if (IS_INCOMING_CALL_VIEW(old_call_view) || IS_CURRENT_CALL_VIEW(old_call_view)) {
gtk_container_remove(GTK_CONTAINER(priv->stack_main_view), old_call_view);
gtk_container_remove(GTK_CONTAINER(priv->stack_call_view), old_call_view);
}
}
}
}
static void
show_account_view(G_GNUC_UNUSED GSimpleAction *action, G_GNUC_UNUSED GVariant *param, gpointer win)
{
g_debug("show account view");
RingMainWindowPrivate *priv = RING_MAIN_WINDOW_GET_PRIVATE(RING_MAIN_WINDOW(win));
/* clear call selection so we can re-select any ongoing calls */
CallModel::instance()->selectionModel()->clearCurrentIndex();
gtk_stack_set_visible_child_name(GTK_STACK(priv->stack_main_view), ACCOUNT_VIEW_NAME);
}
static void
search_entry_placecall(G_GNUC_UNUSED GtkWidget *entry, gpointer win)
{
......@@ -360,6 +366,45 @@ navbutton_history_toggled(GtkToggleButton *navbutton, RingMainWindow *win)
}
}
static void
settings_clicked(G_GNUC_UNUSED GtkButton *button, RingMainWindow *win)
{
g_return_if_fail(IS_RING_MAIN_WINDOW(win));
RingMainWindowPrivate *priv = RING_MAIN_WINDOW_GET_PRIVATE(win);
/* toggle show settings */
priv->show_settings = !priv->show_settings;
/* check which view to show */
if (priv->show_settings) {
/* show settings */
gtk_image_set_from_icon_name(GTK_IMAGE(priv->image_settings), "emblem-ok-symbolic", GTK_ICON_SIZE_LARGE_TOOLBAR);
gtk_widget_hide(priv->hbox_search);
gtk_widget_show(priv->hbox_settings);
gtk_stack_set_transition_type(GTK_STACK(priv->stack_main_view), GTK_STACK_TRANSITION_TYPE_SLIDE_UP);
gtk_stack_set_visible_child_name(GTK_STACK(priv->stack_main_view), ACCOUNT_SETTINGS_VIEW_NAME);
} else {
/* show calls */
gtk_image_set_from_icon_name(GTK_IMAGE(priv->image_settings), "emblem-system-symbolic", GTK_ICON_SIZE_LARGE_TOOLBAR);
gtk_widget_show(priv->hbox_search);
gtk_widget_hide(priv->hbox_settings);
gtk_stack_set_transition_type(GTK_STACK(priv->stack_main_view), GTK_STACK_TRANSITION_TYPE_SLIDE_DOWN);
gtk_stack_set_visible_child_name(GTK_STACK(priv->stack_main_view), CALL_VIEW_NAME);
/* save changes to accounts */
AccountModel::instance()->save();
/* save changes to codecs */
for (int i = 0; i < AccountModel::instance()->rowCount(); i++) {
QModelIndex idx = AccountModel::instance()->index(i, 0);
AccountModel::instance()->getAccountByModelIndex(idx)->codecModel()->save();
}
}
}
static void
ring_main_window_init(RingMainWindow *win)
{
......@@ -376,20 +421,40 @@ ring_main_window_init(RingMainWindow *win)
gtk_window_set_icon(GTK_WINDOW(win), icon);
/* set menu icon */
GdkPixbuf* ring_gears = gdk_pixbuf_new_from_resource_at_scale("/cx/ring/RingGnome/ring-logo-blue",
-1, 22, TRUE, &error);
if (ring_gears == NULL) {
GdkPixbuf* image_ring = gdk_pixbuf_new_from_resource_at_scale("/cx/ring/RingGnome/ring-symbol-blue",
-1, 24, TRUE, &error);
if (image_ring == NULL) {
g_debug("Could not load icon: %s", error->message);
g_error_free(error);
} else
gtk_image_set_from_pixbuf(GTK_IMAGE(priv->gears_image), ring_gears);
gtk_image_set_from_pixbuf(GTK_IMAGE(priv->image_ring), image_ring);
/* gears menu */
/* ring menu */
GtkBuilder *builder = gtk_builder_new_from_resource("/cx/ring/RingGnome/ringgearsmenu.ui");
GMenuModel *menu = G_MENU_MODEL(gtk_builder_get_object(builder, "menu"));
gtk_menu_button_set_menu_model(GTK_MENU_BUTTON(priv->gears), menu);
gtk_menu_button_set_menu_model(GTK_MENU_BUTTON(priv->ring_menu), menu);
g_object_unref(builder);
/* settings icon */
gtk_image_set_from_icon_name(GTK_IMAGE(priv->image_settings), "emblem-system-symbolic", GTK_ICON_SIZE_LARGE_TOOLBAR);
/* connect settings button signal */
g_signal_connect(priv->ring_settings, "clicked", G_CALLBACK(settings_clicked), win);
/* add the call view to the main stack */
gtk_stack_add_named(GTK_STACK(priv->stack_main_view),
priv->vbox_call_view,
CALL_VIEW_NAME);
gtk_stack_set_visible_child(GTK_STACK(priv->stack_main_view), priv->vbox_call_view);
/* init the settings views */
/* make the setting we will show first the active one */
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(priv->radiobutton_account_settings), TRUE);
priv->account_settings_view = account_view_new();
gtk_stack_add_named(GTK_STACK(priv->stack_main_view), priv->account_settings_view, ACCOUNT_SETTINGS_VIEW_NAME);
/* call model */
GtkQTreeModel *call_model;
GtkCellRenderer *renderer;
......@@ -539,7 +604,7 @@ ring_main_window_init(RingMainWindow *win)
/* TODO: replace stack paceholder view */
GtkWidget *placeholder_view = gtk_tree_view_new();
gtk_widget_show(placeholder_view);
gtk_stack_add_named(GTK_STACK(priv->stack_main_view), placeholder_view, DEFAULT_VIEW_NAME);
gtk_stack_add_named(GTK_STACK(priv->stack_call_view), placeholder_view, DEFAULT_VIEW_NAME);
/* connect signals */
g_signal_connect(call_selection, "changed", G_CALLBACK(call_selection_changed), win);
......@@ -558,10 +623,6 @@ ring_main_window_init(RingMainWindow *win)
CallModel::instance()->getIndex(call), QItemSelectionModel::ClearAndSelect);
}
);
/* init the account view */
priv->account_view = account_view_new();
gtk_stack_add_named(GTK_STACK(priv->stack_main_view), priv->account_view, ACCOUNT_VIEW_NAME);
}
static void
......@@ -583,28 +644,27 @@ ring_main_window_class_init(RingMainWindowClass *klass)
gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), RingMainWindow, radiobutton_contacts);
gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), RingMainWindow, radiobutton_history);
gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), RingMainWindow, radiobutton_presence);
gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), RingMainWindow, gears);
gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), RingMainWindow, gears_image);
gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), RingMainWindow, ring_menu);
gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), RingMainWindow, image_ring);
gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), RingMainWindow, ring_settings);
gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), RingMainWindow, image_settings);
gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), RingMainWindow, hbox_search);
gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), RingMainWindow, hbox_settings);
gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), RingMainWindow, search_entry);
gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), RingMainWindow, stack_main_view);
gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), RingMainWindow, vbox_call_view);
gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), RingMainWindow, stack_call_view);
gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), RingMainWindow, button_placecall);
gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), RingMainWindow, radiobutton_audio_settings);
gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), RingMainWindow, radiobutton_general_settings);
gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), RingMainWindow, radiobutton_video_settings);
gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), RingMainWindow, radiobutton_account_settings);
}
static const GActionEntry ring_actions[] =
{
{ "accountview", show_account_view, NULL, NULL, NULL, {0} },
/* TODO: add preferences view */
// { "accountview", show_preferences_view, NULL, NULL, NULL, {0} },
};
GtkWidget *
ring_main_window_new (GtkApplication *app)
{
gpointer win = g_object_new(RING_MAIN_WINDOW_TYPE, "application", app, NULL);
/* map actions */
g_action_map_add_action_entries(
G_ACTION_MAP(app), ring_actions, G_N_ELEMENTS(ring_actions), win);
return (GtkWidget *)win;
}
......@@ -3,24 +3,23 @@
<!-- interface-requires gtk+ 3.0 -->
<menu id="menu">
<section>
<item>
<attribute name="label" translatable="yes">_Preferences</attribute>
<attribute name="action">app.preferences</attribute>
</item>
<item>
<attribute name="label" translatable="yes">_Account Settings</attribute>
<attribute name="action">app.accountview</attribute>
</item>
</section>
<section>
<!-- TODO: add help
<item>
<attribute name="label" translatable="yes">_Help</attribute>
<attribute name="action">app.help</attribute>
</item>
-->
<item>
<attribute name="label" translatable="yes">_About</attribute>
<attribute name="action">app.about</attribute>
</item>
</section>
<section>
<item>
<attribute name="label" translatable="yes">_Quit</attribute>