aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2009-11-17 19:05:41 +0800
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2009-11-23 23:06:37 +0800
commit6738d193bf3e30d0befaa3e8183cc75ffe607982 (patch)
treec623af60d80971d84874e2ef35483dea7f5c5431
parentdb4180342c107e1641ae528739409e4168ba7d91 (diff)
downloadgsoc2013-empathy-6738d193bf3e30d0befaa3e8183cc75ffe607982.tar
gsoc2013-empathy-6738d193bf3e30d0befaa3e8183cc75ffe607982.tar.gz
gsoc2013-empathy-6738d193bf3e30d0befaa3e8183cc75ffe607982.tar.bz2
gsoc2013-empathy-6738d193bf3e30d0befaa3e8183cc75ffe607982.tar.lz
gsoc2013-empathy-6738d193bf3e30d0befaa3e8183cc75ffe607982.tar.xz
gsoc2013-empathy-6738d193bf3e30d0befaa3e8183cc75ffe607982.tar.zst
gsoc2013-empathy-6738d193bf3e30d0befaa3e8183cc75ffe607982.zip
Set explicitely the model of combo box
The value of the param has to be in the first column as a string. This allow us to display translated strings in the combo box.
-rw-r--r--libempathy-gtk/empathy-account-widget-sip.c81
-rw-r--r--libempathy-gtk/empathy-account-widget.c13
2 files changed, 69 insertions, 25 deletions
diff --git a/libempathy-gtk/empathy-account-widget-sip.c b/libempathy-gtk/empathy-account-widget-sip.c
index 71efa4f24..ab839eb68 100644
--- a/libempathy-gtk/empathy-account-widget-sip.c
+++ b/libempathy-gtk/empathy-account-widget-sip.c
@@ -71,15 +71,22 @@ static void
keep_alive_mechanism_combobox_change_cb (GtkWidget *widget,
EmpathyAccountWidgetSip *self)
{
- const gchar *mechanism;
+ GtkTreeIter iter;
+ GtkTreeModel *model;
+ gchar *mechanism;
gboolean enabled;
/* Unsensitive the keep-alive spin button if keep-alive is disabled */
- mechanism = gtk_combo_box_get_active_text (GTK_COMBO_BOX (widget));
+ if (!gtk_combo_box_get_active_iter (GTK_COMBO_BOX (widget), &iter))
+ return;
+
+ model = gtk_combo_box_get_model (GTK_COMBO_BOX (widget));
+ gtk_tree_model_get (model, &iter, 0, &mechanism, -1);
enabled = tp_strdiff (mechanism, "none");
gtk_widget_set_sensitive (self->spinbutton_keepalive_interval, enabled);
+ g_free (mechanism);
}
void
@@ -109,6 +116,10 @@ empathy_account_widget_sip_build (EmpathyAccountWidget *self,
}
else
{
+ GtkListStore *store;
+ GtkTreeIter iter;
+ GtkCellRenderer *renderer;
+
settings = g_slice_new0 (EmpathyAccountWidgetSip);
settings->self = self;
@@ -151,18 +162,29 @@ empathy_account_widget_sip_build (EmpathyAccountWidget *self,
self->ui_details->add_forget = TRUE;
self->ui_details->default_focus = g_strdup ("entry_userid");
- /* Create the 'transport' combobox as Glade doesn't allow us to create a
- * GtkComboBox using gtk_combo_box_new_text () */
- settings->combobox_transport = gtk_combo_box_new_text ();
+ /* Create the 'transport' combo box. The first column has to contain the
+ * value of the param. */
+ store = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_STRING);
+ settings->combobox_transport = gtk_combo_box_new_with_model (
+ GTK_TREE_MODEL (store));
+
+ renderer = gtk_cell_renderer_text_new ();
+ gtk_cell_layout_pack_start (
+ GTK_CELL_LAYOUT (settings->combobox_transport), renderer, TRUE);
+ gtk_cell_layout_add_attribute (
+ GTK_CELL_LAYOUT (settings->combobox_transport), renderer, "text", 1);
+
+ gtk_list_store_append (store, &iter);
+ gtk_list_store_set (store, &iter, 0, "auto", 1, _("Auto"), -1);
+
+ gtk_list_store_append (store, &iter);
+ gtk_list_store_set (store, &iter, 0, "udp", 1, "UDP", -1);
+
+ gtk_list_store_append (store, &iter);
+ gtk_list_store_set (store, &iter, 0, "tcp", 1, "TCP", -1);
- gtk_combo_box_append_text (GTK_COMBO_BOX (settings->combobox_transport),
- "auto");
- gtk_combo_box_append_text (GTK_COMBO_BOX (settings->combobox_transport),
- "udp");
- gtk_combo_box_append_text (GTK_COMBO_BOX (settings->combobox_transport),
- "tcp");
- gtk_combo_box_append_text (GTK_COMBO_BOX (settings->combobox_transport),
- "tls");
+ gtk_list_store_append (store, &iter);
+ gtk_list_store_set (store, &iter, 0, "tls", 1, "TLS", -1);
account_widget_setup_widget (self, settings->combobox_transport,
"transport");
@@ -173,16 +195,29 @@ empathy_account_widget_sip_build (EmpathyAccountWidget *self,
gtk_widget_show (settings->combobox_transport);
/* Create the 'keep-alive mechanism' combo box */
- settings->combobox_keep_alive_mechanism = gtk_combo_box_new_text ();
-
- gtk_combo_box_append_text (
- GTK_COMBO_BOX (settings->combobox_keep_alive_mechanism), "auto");
- gtk_combo_box_append_text (
- GTK_COMBO_BOX (settings->combobox_keep_alive_mechanism), "register");
- gtk_combo_box_append_text (
- GTK_COMBO_BOX (settings->combobox_keep_alive_mechanism), "options");
- gtk_combo_box_append_text (
- GTK_COMBO_BOX (settings->combobox_keep_alive_mechanism), "none");
+ store = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_STRING);
+ settings->combobox_keep_alive_mechanism = gtk_combo_box_new_with_model (
+ GTK_TREE_MODEL (store));
+
+ renderer = gtk_cell_renderer_text_new ();
+ gtk_cell_layout_pack_start (
+ GTK_CELL_LAYOUT (settings->combobox_keep_alive_mechanism), renderer,
+ TRUE);
+ gtk_cell_layout_add_attribute (
+ GTK_CELL_LAYOUT (settings->combobox_keep_alive_mechanism), renderer,
+ "text", 1);
+
+ gtk_list_store_append (store, &iter);
+ gtk_list_store_set (store, &iter, 0, "auto", 1, _("Auto"), -1);
+
+ gtk_list_store_append (store, &iter);
+ gtk_list_store_set (store, &iter, 0, "register", 1, "Register", -1);
+
+ gtk_list_store_append (store, &iter);
+ gtk_list_store_set (store, &iter, 0, "options", 1, "Options", -1);
+
+ gtk_list_store_append (store, &iter);
+ gtk_list_store_set (store, &iter, 0, "none", 1, _("None"), -1);
g_signal_connect (settings->combobox_keep_alive_mechanism, "changed",
G_CALLBACK (keep_alive_mechanism_combobox_change_cb), settings);
diff --git a/libempathy-gtk/empathy-account-widget.c b/libempathy-gtk/empathy-account-widget.c
index 6d804a7a0..caa899859 100644
--- a/libempathy-gtk/empathy-account-widget.c
+++ b/libempathy-gtk/empathy-account-widget.c
@@ -300,13 +300,21 @@ static void
account_widget_combobox_changed_cb (GtkWidget *widget,
EmpathyAccountWidget *self)
{
+ GtkTreeIter iter;
+ GtkTreeModel *model;
const gchar *value;
const GValue *v;
const gchar *default_value;
const gchar *param_name;
EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
- value = gtk_combo_box_get_active_text (GTK_COMBO_BOX (widget));
+ if (!gtk_combo_box_get_active_iter (GTK_COMBO_BOX (widget), &iter))
+ return;
+
+ model = gtk_combo_box_get_model (GTK_COMBO_BOX (widget));
+ /* the param value is stored in the first column */
+ gtk_tree_model_get (model, &iter, 0, &value, -1);
+
param_name = g_object_get_data (G_OBJECT (widget), "param_name");
v = empathy_account_settings_get_default (priv->settings, param_name);
@@ -404,7 +412,8 @@ account_widget_setup_widget (EmpathyAccountWidget *self,
}
else if (GTK_IS_COMBO_BOX (widget))
{
- /* Only support GtkComboBox created using gtk_combo_box_new_text () */
+ /* The combo box's model has to contain the param value in its first
+ * column (as a string) */
const gchar *str;
GtkTreeModel *model;
GtkTreeIter iter;