Commit de896119 authored by Stepan Salenikovich's avatar Stepan Salenikovich Committed by Guillaume Roguez

gnome: add general settings

This adds some history controls

Refs #71873
Refs #71866

Change-Id: I01243031c4a6d485780b01b1fbfdacff4fe1d052
parent 0bd5349b
......@@ -193,6 +193,8 @@ SET( SRC_FILES
src/dialogs.c
src/mediasettingsview.h
src/mediasettingsview.cpp
src/generalsettingsview.h
src/generalsettingsview.cpp
src/backends/edscontactbackend.h
src/backends/edscontactbackend.cpp
src/delegates/pixbufdelegate.h
......
/*
* Copyright (C) 2015 Savoir-Faire Linux Inc.
* Author: Stepan Salenikovich <stepan.salenikovich@savoirfairelinux.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Additional permission under GNU GPL version 3 section 7:
*
* If you modify this program, or any covered work, by linking or
* combining it with the OpenSSL project's OpenSSL library (or a
* modified version of that library), containing parts covered by the
* terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc.
* grants you additional permission to convey the resulting work.
* Corresponding Source for a non-source form of such a combination
* shall include the source code for the parts of OpenSSL used as well
* as that of the covered work.
*/
#include "generalsettingsview.h"
#include <gtk/gtk.h>
#include <categorizedhistorymodel.h>
struct _GeneralSettingsView
{
GtkBox parent;
};
struct _GeneralSettingsViewClass
{
GtkBoxClass parent_class;
};
typedef struct _GeneralSettingsViewPrivate GeneralSettingsViewPrivate;
struct _GeneralSettingsViewPrivate
{
/* history settings */
GtkWidget *adjustment_history_duration;
GtkWidget *button_clear_history;
};
G_DEFINE_TYPE_WITH_PRIVATE(GeneralSettingsView, general_settings_view, GTK_TYPE_BOX);
#define GENERAL_SETTINGS_VIEW_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GENERAL_SETTINGS_VIEW_TYPE, GeneralSettingsViewPrivate))
static void
general_settings_view_dispose(GObject *object)
{
G_OBJECT_CLASS(general_settings_view_parent_class)->dispose(object);
}
static void
history_limit_changed(GtkAdjustment *adjustment, G_GNUC_UNUSED gpointer user_data)
{
int limit = (int)gtk_adjustment_get_value(GTK_ADJUSTMENT(adjustment));
CategorizedHistoryModel::instance()->setHistoryLimit(limit);
}
static gboolean
clear_history_dialog(GeneralSettingsView *self)
{
gboolean response = FALSE;
GtkWidget *dialog = gtk_message_dialog_new(NULL,
(GtkDialogFlags)(GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT),
GTK_MESSAGE_QUESTION, GTK_BUTTONS_OK_CANCEL,
"Are you sure you want to clear all your history?\n" \
"This operation will also reset the Frequen Contacts list");
gtk_window_set_destroy_with_parent(GTK_WINDOW(dialog), TRUE);
/* get parent window so we can center on it */
GtkWidget *parent = gtk_widget_get_toplevel(GTK_WIDGET(self));
if (gtk_widget_is_toplevel(parent)) {
gtk_window_set_transient_for(GTK_WINDOW(dialog), GTK_WINDOW(parent));
gtk_window_set_position(GTK_WINDOW(dialog), GTK_WIN_POS_CENTER_ON_PARENT);
}
switch (gtk_dialog_run(GTK_DIALOG(dialog))) {
case GTK_RESPONSE_OK:
response = TRUE;
break;
default:
response = FALSE;
break;
}
gtk_widget_destroy(dialog);
return response;
}
static void
clear_history(G_GNUC_UNUSED GtkWidget *button, GeneralSettingsView *self)
{
g_return_if_fail(IS_GENERAL_SETTINGS_VIEW(self));
if (clear_history_dialog(self) )
CategorizedHistoryModel::instance()->clearAllCollections();
}
static void
general_settings_view_init(GeneralSettingsView *self)
{
gtk_widget_init_template(GTK_WIDGET(self));
GeneralSettingsViewPrivate *priv = GENERAL_SETTINGS_VIEW_GET_PRIVATE(self);
/* history limit */
gtk_adjustment_set_value(GTK_ADJUSTMENT(priv->adjustment_history_duration),
CategorizedHistoryModel::instance()->historyLimit());
g_signal_connect(priv->adjustment_history_duration,
"value-changed", G_CALLBACK(history_limit_changed), NULL);
/* clear history */
g_signal_connect(priv->button_clear_history, "clicked", G_CALLBACK(clear_history), self);
}
static void
general_settings_view_class_init(GeneralSettingsViewClass *klass)
{
G_OBJECT_CLASS(klass)->dispose = general_settings_view_dispose;
gtk_widget_class_set_template_from_resource(GTK_WIDGET_CLASS (klass),
"/cx/ring/RingGnome/generalsettingsview.ui");
gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), GeneralSettingsView, adjustment_history_duration);
gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), GeneralSettingsView, button_clear_history);
}
GtkWidget *
general_settings_view_new()
{
gpointer view = g_object_new(GENERAL_SETTINGS_VIEW_TYPE, NULL);
return (GtkWidget *)view;
}
/*
* Copyright (C) 2015 Savoir-Faire Linux Inc.
* Author: Stepan Salenikovich <stepan.salenikovich@savoirfairelinux.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Additional permission under GNU GPL version 3 section 7:
*
* If you modify this program, or any covered work, by linking or
* combining it with the OpenSSL project's OpenSSL library (or a
* modified version of that library), containing parts covered by the
* terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc.
* grants you additional permission to convey the resulting work.
* Corresponding Source for a non-source form of such a combination
* shall include the source code for the parts of OpenSSL used as well
* as that of the covered work.
*/
#ifndef _GENERALSETTINGSVIEW_H
#define _GENERALSETTINGSVIEW_H
#include <gtk/gtk.h>
G_BEGIN_DECLS
#define GENERAL_SETTINGS_VIEW_TYPE (general_settings_view_get_type ())
#define GENERAL_SETTINGS_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GENERAL_SETTINGS_VIEW_TYPE, GeneralSettingsView))
#define GENERAL_SETTINGS_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GENERAL_SETTINGS_VIEW_TYPE, GeneralSettingsViewClass))
#define IS_GENERAL_SETTINGS_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GENERAL_SETTINGS_VIEW_TYPE))
#define IS_GENERAL_SETTINGS_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GENERAL_SETTINGS_VIEW_TYPE))
typedef struct _GeneralSettingsView GeneralSettingsView;
typedef struct _GeneralSettingsViewClass GeneralSettingsViewClass;
GType general_settings_view_get_type (void) G_GNUC_CONST;
GtkWidget *general_settings_view_new (void);
G_END_DECLS
#endif /* _GENERALSETTINGSVIEW_H */
\ No newline at end of file
......@@ -57,6 +57,7 @@
#include "contactsview.h"
#include "historyview.h"
#include "utils/models.h"
#include "generalsettingsview.h"
#define CALL_VIEW_NAME "calls"
#define CREATE_ACCOUNT_1_VIEW_NAME "create1"
......@@ -102,6 +103,7 @@ struct _RingMainWindowPrivate
GtkWidget *button_placecall;
GtkWidget *account_settings_view;
GtkWidget *media_settings_view;
GtkWidget *general_settings_view;
GtkWidget *last_settings_view;
GtkWidget *radiobutton_general_settings;
GtkWidget *radiobutton_media_settings;
......@@ -470,6 +472,19 @@ show_account_settings(GtkToggleButton *navbutton, RingMainWindow *win)
}
}
static void
show_general_settings(GtkToggleButton *navbutton, RingMainWindow *win)
{
g_return_if_fail(IS_RING_MAIN_WINDOW(win));
RingMainWindowPrivate *priv = RING_MAIN_WINDOW_GET_PRIVATE(win);
if (gtk_toggle_button_get_active(navbutton)) {
gtk_stack_set_transition_type(GTK_STACK(priv->stack_main_view), GTK_STACK_TRANSITION_TYPE_SLIDE_RIGHT);
gtk_stack_set_visible_child_name(GTK_STACK(priv->stack_main_view), GENERAL_SETTINGS_VIEW_NAME);
priv->last_settings_view = priv->general_settings_view;
}
}
static gboolean
has_ring_account()
{
......@@ -945,13 +960,17 @@ ring_main_window_init(RingMainWindow *win)
priv->media_settings_view = media_settings_view_new();
gtk_stack_add_named(GTK_STACK(priv->stack_main_view), priv->media_settings_view, MEDIA_SETTINGS_VIEW_NAME);
priv->general_settings_view = general_settings_view_new();
gtk_stack_add_named(GTK_STACK(priv->stack_main_view), priv->general_settings_view, GENERAL_SETTINGS_VIEW_NAME);
/* make the setting we will show first the active one */
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(priv->radiobutton_media_settings), TRUE);
priv->last_settings_view = priv->media_settings_view;
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(priv->radiobutton_general_settings), TRUE);
priv->last_settings_view = priv->general_settings_view;
/* connect the settings button signals to switch settings views */
g_signal_connect(priv->radiobutton_media_settings, "toggled", G_CALLBACK(show_media_settings), win);
g_signal_connect(priv->radiobutton_account_settings, "toggled", G_CALLBACK(show_account_settings), win);
g_signal_connect(priv->radiobutton_general_settings, "toggled", G_CALLBACK(show_general_settings), win);
/* call model */
GtkQTreeModel *call_model;
......
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<requires lib="gtk+" version="3.10"/>
<object class="GtkAdjustment" id="adjustment_history_duration">
<property name="value">0</property>
<property name="lower">0</property>
<property name="upper">65535</property>
<property name="step_increment">1</property>
<property name="page_increment">10</property>
</object>
<template class="GeneralSettingsView" parent="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="border_width">10</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkBox" id="vbox_main">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="spacing">10</property>
<!-- start history settings -->
<child>
<object class="GtkFrame" id="frame_history_settings">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label_xalign">0</property>
<property name="shadow_type">none</property>
<!-- start grid history settings-->
<child>
<object class="GtkGrid" id="grid_history_settings">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_left">10</property>
<property name="margin_top">10</property>
<property name="row_spacing">10</property>
<property name="column_spacing">10</property>
<child>
<object class="GtkLabel" id="label_history_duration">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Keep history for (days):</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkSpinButton" id="spinbutton_history_duration">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="value">0</property>
<property name="adjustment">adjustment_history_duration</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label_history_explanation">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">(set to 0 for unlimited history)</property>
</object>
<packing>
<property name="left_attach">2</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="button_clear_history">
<property name="label" translatable="yes">Clear all history</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="halign">start</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">1</property>
</packing>
</child>
</object>
</child>
<!-- end grid history settings -->
<!-- start frame label -->
<child type="label">
<object class="GtkLabel" id="label_history_settings">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">&lt;b&gt;History Settings&lt;/b&gt;</property>
<property name="use_markup">True</property>
</object>
</child>
<!-- end frame label -->
</object>
</child>
<!-- end history settings -->
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
</packing>
</child>
</template>
</interface>
......@@ -90,8 +90,7 @@
<child>
<object class="GtkRadioButton" id="radiobutton_general_settings">
<property name="label" translatable="yes">General</property>
<!-- TODO make visible when feature added -->
<property name="visible">False</property>
<property name="visible">True</property>
<property name="image">image_general_settings</property>
<property name="draw_indicator">False</property>
</object>
......
......@@ -11,5 +11,6 @@
<file preprocess="xml-stripblanks">accountvideotab.ui</file>
<file preprocess="xml-stripblanks">mediasettingsview.ui</file>
<file preprocess="xml-stripblanks">accountadvancedtab.ui</file>
<file preprocess="xml-stripblanks">generalsettingsview.ui</file>
</gresource>
</gresources>
\ No newline at end of file
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