Commit 6456ab37 authored by Tristan Matthews's avatar Tristan Matthews

* #6623: gnome- cleanup, fixed memleaks, removed unused cruft

parent b2428335
This diff is collapsed.
......@@ -579,53 +579,50 @@ GtkWidget* create_account_list (GtkDialog * dialog UNUSED)
void
show_account_list_config_dialog (void)
{
GtkWidget * accountFrame;
GtkWidget * tab;
accountListDialog = GTK_DIALOG (gtk_dialog_new_with_buttons (_ ("Accounts"),
accountListDialog = GTK_DIALOG (gtk_dialog_new_with_buttons (_("Accounts"),
GTK_WINDOW (get_main_window()),
GTK_DIALOG_DESTROY_WITH_PARENT,
NULL));
/* Set window properties */
gtk_container_set_border_width (GTK_CONTAINER (accountListDialog), 0);
gtk_window_set_resizable (GTK_WINDOW (accountListDialog), FALSE);
gtk_container_set_border_width(GTK_CONTAINER(accountListDialog), 0);
gtk_window_set_resizable(GTK_WINDOW(accountListDialog), FALSE);
gnome_main_section_new (_ ("Configured Accounts"), &accountFrame);
gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area(accountListDialog)), accountFrame , TRUE, TRUE, 0);
gtk_widget_show (accountFrame);
GtkWidget *accountFrame = gnome_main_section_new(_("Configured Accounts"));
gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(accountListDialog)),
accountFrame, TRUE, TRUE, 0);
gtk_widget_show(accountFrame);
/* Accounts tab */
tab = create_account_list (accountListDialog);
gtk_widget_show (tab);
gtk_container_add (GTK_CONTAINER (accountFrame), tab);
GtkWidget *tab = create_account_list(accountListDialog);
gtk_widget_show(tab);
gtk_container_add(GTK_CONTAINER(accountFrame), tab);
/* Status bar for the account list */
status_bar = gtk_statusbar_new();
gtk_statusbar_set_has_resize_grip (GTK_STATUSBAR (status_bar), FALSE);
gtk_widget_show (status_bar);
gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area(accountListDialog)), status_bar, TRUE, TRUE, 0);
gtk_statusbar_set_has_resize_grip(GTK_STATUSBAR(status_bar), FALSE);
gtk_widget_show(status_bar);
gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(accountListDialog)),
status_bar, TRUE, TRUE, 0);
int number_accounts = account_list_get_registered_accounts ();
int number_accounts = account_list_get_registered_accounts();
if (number_accounts) {
gchar * message = g_strdup_printf (n_ ("There is %d active account",
"There are %d active accounts", number_accounts),
number_accounts);
gtk_statusbar_push (GTK_STATUSBAR (status_bar), CONTEXT_ID_REGISTRATION, message);
g_free (message);
} else {
gtk_statusbar_push (GTK_STATUSBAR (status_bar), CONTEXT_ID_REGISTRATION, _ ("You have no active account"));
}
gchar * message = g_strdup_printf(n_("There is %d active account",
"There are %d active accounts",
number_accounts), number_accounts);
gtk_statusbar_push(GTK_STATUSBAR(status_bar), CONTEXT_ID_REGISTRATION, message);
g_free(message);
} else
gtk_statusbar_push(GTK_STATUSBAR(status_bar), CONTEXT_ID_REGISTRATION,
_("You have no active account"));
gtk_dialog_run (accountListDialog);
gtk_dialog_run(accountListDialog);
status_bar_display_account ();
gtk_widget_destroy (GTK_WIDGET (accountListDialog));
status_bar_display_account();
gtk_widget_destroy(GTK_WIDGET(accountListDialog));
accountListDialog = NULL;
update_actions ();
update_actions();
}
This diff is collapsed.
......@@ -137,8 +137,7 @@ static void phone_number_enabled_cb (GtkWidget *widget)
GtkWidget* create_hooks_settings ()
{
GtkWidget *ret, *frame, *table, *label, *widg, *info_bar;
GtkWidget *ret, *frame, *table, *label, *widg;
// Load the user value
hooks_load_parameters (&_urlhook_config);
......@@ -151,8 +150,8 @@ GtkWidget* create_hooks_settings ()
gtk_widget_show (frame);
gchar *message = "<small>Custom commands on incoming calls with URL. %s will be replaced with the passed URL.</small>";
gnome_info_bar (message, GTK_MESSAGE_INFO, &info_bar);
gtk_table_attach (GTK_TABLE (table), info_bar, 0, 2, 0, 1, GTK_FILL | GTK_EXPAND, GTK_SHRINK, 10, 10);
GtkWidget *info_bar = gnome_info_bar(message, GTK_MESSAGE_INFO);
gtk_table_attach(GTK_TABLE (table), info_bar, 0, 2, 0, 1, GTK_FILL | GTK_EXPAND, GTK_SHRINK, 10, 10);
widg = gtk_check_button_new_with_mnemonic (_ ("Trigger on specific _SIP header"));
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widg), (g_strcasecmp (_urlhook_config->sip_enabled, "true") ==0) ?TRUE:FALSE);
......
......@@ -37,46 +37,37 @@ static void
accel_cleared (GtkCellRendererAccel *renderer UNUSED, gchar *path,
GtkTreeView *treeview)
{
DEBUG ("Accel cleared");
GtkTreeModel *model;
GtkTreeIter iter;
// Update treeview
model = gtk_tree_view_get_model (treeview);
GtkTreeModel *model = gtk_tree_view_get_model(treeview);
GtkTreeIter iter;
if (gtk_tree_model_get_iter_from_string (model, &iter, path))
gtk_list_store_set (GTK_LIST_STORE (model), &iter, MASK, 0, VALUE, 0, -1);
gtk_list_store_set(GTK_LIST_STORE(model), &iter, MASK, 0, VALUE, 0, -1);
// Update GDK bindings
shortcuts_update_bindings (atoi (path), 0, 0);
shortcuts_update_bindings(atoi(path), 0, 0);
}
static void
accel_edited (GtkCellRendererAccel *renderer UNUSED, gchar *path, guint accel_key,
GdkModifierType mask, guint hardware_keycode UNUSED, GtkTreeView *treeview)
{
DEBUG ("Accel edited");
GtkTreeModel *model;
// Disable existing binding if key already used
GtkTreeModel *model = gtk_tree_view_get_model(treeview);
GtkTreeIter iter;
gtk_tree_model_get_iter_first(model, &iter);
Accelerator* list = shortcuts_get_list ();
model = gtk_tree_view_get_model (treeview);
guint code = XKeysymToKeycode (GDK_DISPLAY(), accel_key);
// Disable existing binding if key already used
int i = 0;
gtk_tree_model_get_iter_first (model, &iter);
const guint code = XKeysymToKeycode(GDK_DISPLAY(), accel_key);
guint i = 0;
while (list[i].action != NULL) {
if (list[i].key == code && list[i].mask == mask) {
gtk_list_store_set (GTK_LIST_STORE (model), &iter, MASK, 0, VALUE, 0,
-1);
WARN ("This key was already affected");
gtk_list_store_set(GTK_LIST_STORE (model), &iter, MASK, 0, VALUE, 0,
-1);
WARN("This key was already affected");
}
gtk_tree_model_iter_next (model, &iter);
gtk_tree_model_iter_next(model, &iter);
i++;
}
......@@ -86,74 +77,70 @@ accel_edited (GtkCellRendererAccel *renderer UNUSED, gchar *path, guint accel_ke
VALUE, accel_key, -1);
// Update GDK bindings
shortcuts_update_bindings (atoi (path), code, mask);
shortcuts_update_bindings(atoi(path), code, mask);
}
/*
* Create a tree view with two columns. The first is an action and the
* Create a tree view with two columns. The first is an action and the
* second is a keyboard accelerator.
*/
static void
setup_tree_view (GtkWidget *treeview)
{
GtkCellRenderer *renderer;
GtkTreeViewColumn *column;
renderer = gtk_cell_renderer_text_new ();
column = gtk_tree_view_column_new_with_attributes ("Action", renderer,
"text", ACTION, NULL);
gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column);
renderer = gtk_cell_renderer_accel_new ();
g_object_set (renderer, "accel-mode", GTK_CELL_RENDERER_ACCEL_MODE_GTK,
"editable", TRUE, NULL);
GtkCellRenderer *renderer = gtk_cell_renderer_text_new ();
GtkTreeViewColumn *column = gtk_tree_view_column_new_with_attributes("Action", renderer,
"text", ACTION, NULL);
gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column);
renderer = gtk_cell_renderer_accel_new();
g_object_set(renderer, "accel-mode", GTK_CELL_RENDERER_ACCEL_MODE_GTK,
"editable", TRUE, NULL);
column = gtk_tree_view_column_new_with_attributes ("Shortcut", renderer,
"accel-mods", MASK, "accel-key", VALUE, NULL);
gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column);
g_signal_connect (G_OBJECT (renderer), "accel_edited", G_CALLBACK (accel_edited), (gpointer) treeview);
g_signal_connect (G_OBJECT (renderer), "accel_cleared", G_CALLBACK (accel_cleared), (gpointer) treeview);
gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column);
g_signal_connect(renderer, "accel_edited", G_CALLBACK(accel_edited),
(gpointer) treeview);
g_signal_connect(renderer, "accel_cleared", G_CALLBACK(accel_cleared),
(gpointer) treeview);
}
GtkWidget*
create_shortcuts_settings ()
{
GtkWidget *vbox, *result_frame, *treeview, *label;
GtkTreeIter iter;
guint i = 0;
vbox = gtk_vbox_new (FALSE, 10);
GtkWidget *vbox = gtk_vbox_new (FALSE, 10);
gtk_container_set_border_width (GTK_CONTAINER (vbox), 10);
gnome_main_section_new (_ ("General"), &result_frame);
GtkWidget * result_frame = gnome_main_section_new(_("General"));
label = gtk_label_new (
_ ("Be careful: these shortcuts might override system-wide shortcuts."));
treeview = gtk_tree_view_new ();
setup_tree_view (treeview);
GtkWidget *label = gtk_label_new(_("Be careful: these shortcuts might "
"override system-wide shortcuts."));
GtkWidget *treeview = gtk_tree_view_new();
setup_tree_view(treeview);
GtkListStore *store = gtk_list_store_new (COLUMNS, G_TYPE_STRING, G_TYPE_INT,
G_TYPE_UINT);
GtkListStore *store = gtk_list_store_new(COLUMNS, G_TYPE_STRING, G_TYPE_INT,
G_TYPE_UINT);
Accelerator* list = shortcuts_get_list ();
Accelerator* list = shortcuts_get_list();
guint i = 0;
while (list[i].action != NULL) {
gtk_list_store_append (store, &iter);
gtk_list_store_set (store, &iter, ACTION, _ (list[i].action), MASK,
(gint) list[i].mask, VALUE, XKeycodeToKeysym (GDK_DISPLAY(),
list[i].key, 0), -1);
GtkTreeIter iter;
gtk_list_store_append(store, &iter);
gtk_list_store_set(store, &iter, ACTION, _(list[i].action), MASK,
(gint) list[i].mask, VALUE,
XKeycodeToKeysym(GDK_DISPLAY(), list[i].key, 0), -1);
i++;
}
gtk_tree_view_set_model (GTK_TREE_VIEW (treeview), GTK_TREE_MODEL (store));
g_object_unref (store);
gtk_tree_view_set_model(GTK_TREE_VIEW(treeview), GTK_TREE_MODEL(store));
g_object_unref(store);
gtk_container_add (GTK_CONTAINER (result_frame), treeview);
gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (vbox), result_frame, FALSE, FALSE, 0);
gtk_container_add(GTK_CONTAINER(result_frame), treeview);
gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(vbox), result_frame, FALSE, FALSE, 0);
gtk_widget_show_all (vbox);
gtk_widget_show_all(vbox);
return vbox;
}
......
......@@ -29,108 +29,65 @@
*/
#include "utils.h"
#include <sflphone_const.h>
#include "sflphone_const.h"
void gnome_main_section_new_with_table (gchar *title, GtkWidget **frame, GtkWidget **table, gint nb_col, gint nb_row)
void gnome_main_section_new_with_table(gchar *title, GtkWidget **frame, GtkWidget **table, gint nb_col, gint nb_row)
{
GtkWidget *_frame, *_table, *label, *align;
PangoAttrList *attrs = NULL;
PangoAttribute *attr = NULL;
attrs = pango_attr_list_new ();
attr = pango_attr_weight_new (PANGO_WEIGHT_BOLD);
PangoAttrList *attrs = pango_attr_list_new();
PangoAttribute *attr = pango_attr_weight_new (PANGO_WEIGHT_BOLD);
attr->start_index = 0;
attr->end_index = -1;
pango_attr_list_insert (attrs, attr);
_frame = gtk_frame_new (title);
gtk_frame_set_shadow_type (GTK_FRAME (_frame), GTK_SHADOW_NONE);
gtk_container_set_border_width (GTK_CONTAINER (_frame), 2);
label = gtk_frame_get_label_widget (GTK_FRAME (_frame));
gtk_label_set_attributes (GTK_LABEL (label), attrs);
pango_attr_list_unref (attrs);
*frame = gtk_frame_new(title);
gtk_frame_set_shadow_type(GTK_FRAME(*frame), GTK_SHADOW_NONE);
gtk_container_set_border_width(GTK_CONTAINER(*frame), 2);
align = gtk_alignment_new (0.08, 0.2, 0.1, 0.1);
gtk_container_add (GTK_CONTAINER (_frame), align);
GtkWidget *label = gtk_frame_get_label_widget(GTK_FRAME(*frame));
gtk_label_set_attributes(GTK_LABEL(label), attrs);
pango_attr_list_unref(attrs);
_table = gtk_table_new (nb_col, nb_row, FALSE);
gtk_table_set_row_spacings (GTK_TABLE (_table), 2);
gtk_table_set_col_spacings (GTK_TABLE (_table), 2);
gtk_widget_show (_table);
gtk_container_add (GTK_CONTAINER (align), _table);
GtkWidget *align = gtk_alignment_new(0.08, 0.2, 0.1, 0.1);
gtk_container_add(GTK_CONTAINER(*frame), align);
*table = _table;
*frame = _frame;
*table = gtk_table_new (nb_col, nb_row, FALSE);
gtk_table_set_row_spacings(GTK_TABLE(*table), 2);
gtk_table_set_col_spacings(GTK_TABLE(*table), 2);
gtk_widget_show(*table);
gtk_container_add(GTK_CONTAINER(align), *table);
}
void gnome_main_section_new_with_vbox (gchar *title, GtkWidget **frame, GtkWidget **vbox, gint nb_row UNUSED)
{
GtkWidget *_frame, *_vbox, *label, *align;
PangoAttrList *attrs = NULL;
PangoAttribute *attr = NULL;
attrs = pango_attr_list_new ();
attr = pango_attr_weight_new (PANGO_WEIGHT_BOLD);
attr->start_index = 0;
attr->end_index = -1;
pango_attr_list_insert (attrs, attr);
_frame = gtk_frame_new (title);
gtk_frame_set_shadow_type (GTK_FRAME (_frame), GTK_SHADOW_NONE);
gtk_container_set_border_width (GTK_CONTAINER (_frame), 2);
label = gtk_frame_get_label_widget (GTK_FRAME (_frame));
gtk_label_set_attributes (GTK_LABEL (label), attrs);
pango_attr_list_unref (attrs);
align = gtk_alignment_new (0.08, 0.2, 0.1, 0.1);
gtk_container_add (GTK_CONTAINER (_frame), align);
_vbox = gtk_vbox_new (FALSE, 10);
gtk_widget_show (_vbox);
gtk_container_add (GTK_CONTAINER (align), _vbox);
*vbox = _vbox;
*frame = _frame;
}
void gnome_main_section_new (gchar *title, GtkWidget **frame)
GtkWidget *gnome_main_section_new(const gchar * const title)
{
GtkWidget *_frame, *label;
PangoAttrList *attrs = NULL;
PangoAttribute *attr = NULL;
attrs = pango_attr_list_new ();
attr = pango_attr_weight_new (PANGO_WEIGHT_BOLD);
PangoAttrList *attrs = pango_attr_list_new();
PangoAttribute *attr = pango_attr_weight_new(PANGO_WEIGHT_BOLD);
attr->start_index = 0;
attr->end_index = -1;
pango_attr_list_insert (attrs, attr);
pango_attr_list_insert(attrs, attr);
_frame = gtk_frame_new (title);
gtk_frame_set_shadow_type (GTK_FRAME (_frame), GTK_SHADOW_NONE);
gtk_container_set_border_width (GTK_CONTAINER (_frame), 2);
GtkWidget *frame = gtk_frame_new(title);
gtk_frame_set_shadow_type (GTK_FRAME(frame), GTK_SHADOW_NONE);
gtk_container_set_border_width(GTK_CONTAINER(frame), 2);
label = gtk_frame_get_label_widget (GTK_FRAME (_frame));
gtk_label_set_attributes (GTK_LABEL (label), attrs);
pango_attr_list_unref (attrs);
GtkWidget *label = gtk_frame_get_label_widget(GTK_FRAME(frame));
gtk_label_set_attributes(GTK_LABEL(label), attrs);
pango_attr_list_unref(attrs);
*frame = _frame;
return frame;
}
void gnome_info_bar (gchar *message, GtkMessageType type, GtkWidget **info_bar)
GtkWidget *gnome_info_bar(gchar *message, GtkMessageType type)
{
GtkWidget *_info_bar, *message_label, *content_area;
_info_bar = gtk_info_bar_new();
gtk_widget_set_no_show_all (_info_bar, TRUE);
message_label = gtk_label_new (NULL);
gtk_widget_show (message_label);
content_area = gtk_info_bar_get_content_area (GTK_INFO_BAR (_info_bar));
gtk_container_add (GTK_CONTAINER (content_area), message_label);
gtk_label_set_markup (GTK_LABEL (message_label), message); //message);
gtk_info_bar_set_message_type (GTK_INFO_BAR (_info_bar), type);
gtk_widget_show (_info_bar);
*info_bar = _info_bar;
GtkWidget *info_bar = gtk_info_bar_new();
gtk_widget_set_no_show_all(info_bar, TRUE);
GtkWidget *message_label = gtk_label_new(NULL);
gtk_widget_show(message_label);
GtkWidget *content_area = gtk_info_bar_get_content_area(GTK_INFO_BAR(info_bar));
gtk_container_add(GTK_CONTAINER(content_area), message_label);
gtk_label_set_markup(GTK_LABEL(message_label), message);
gtk_info_bar_set_message_type(GTK_INFO_BAR(info_bar), type);
gtk_widget_show(info_bar);
return info_bar;
}
......@@ -35,10 +35,9 @@
G_BEGIN_DECLS
void gnome_main_section_new (gchar *title, GtkWidget**);
GtkWidget *gnome_main_section_new(const gchar * const title);
void gnome_main_section_new_with_table (gchar *title, GtkWidget**, GtkWidget**, gint nb_col, gint nb_row);
void gnome_main_section_new_with_vbox (gchar *title, GtkWidget **frame, GtkWidget **vbox, gint nb_row);
void gnome_info_bar (gchar *message, GtkMessageType type, GtkWidget **info_bar);
GtkWidget *gnome_info_bar (gchar *message, GtkMessageType type);
G_END_DECLS
......
......@@ -1649,7 +1649,7 @@ dbus_get_record_path (void)
{
GError* error = NULL;
gchar *path;
org_sflphone_SFLphone_ConfigurationManager_get_record_path (
org_sflphone_SFLphone_ConfigurationManager_get_record_path(
configurationManagerProxy, &path, &error);
if (error)
......
......@@ -27,7 +27,7 @@
* shall include the source code for the parts of OpenSSL used as well
* as that of the covered work.
*/
#include <eel-gconf-extensions.h>
#include "eel-gconf-extensions.h"
#include "config.h"
#include "sflnotify.h"
......
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