network: Fix for GtkCombo text changes
This commit is contained in:
parent
07552b5d7f
commit
830e540aad
1 changed files with 22 additions and 3 deletions
|
@ -831,12 +831,27 @@ location_new (GtkBuilder *capplet_builder, GtkWidget *parent)
|
||||||
g_object_unref (client);
|
g_object_unref (client);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static char *
|
||||||
|
get_active_location (GtkComboBox *box)
|
||||||
|
{
|
||||||
|
GtkTreeIter iter;
|
||||||
|
GtkTreeModel *model;
|
||||||
|
char *location;
|
||||||
|
|
||||||
|
model = gtk_combo_box_get_model (box);
|
||||||
|
if (gtk_combo_box_get_active_iter (box, &iter) == FALSE)
|
||||||
|
return NULL;
|
||||||
|
gtk_tree_model_get (model, &iter, COL_NAME, &location, -1);
|
||||||
|
|
||||||
|
return location;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
cb_location_changed (GtkWidget *location,
|
cb_location_changed (GtkWidget *location,
|
||||||
GtkBuilder *builder)
|
GtkBuilder *builder)
|
||||||
{
|
{
|
||||||
gchar *current;
|
gchar *current;
|
||||||
gchar *name = gtk_combo_box_get_active_text (GTK_COMBO_BOX (location));
|
gchar *name = get_active_location (GTK_COMBO_BOX (location));
|
||||||
GConfClient *client;
|
GConfClient *client;
|
||||||
|
|
||||||
if (name == NULL)
|
if (name == NULL)
|
||||||
|
@ -893,17 +908,21 @@ cb_delete_button_clicked (GtkWidget *button,
|
||||||
"location_combobox"));
|
"location_combobox"));
|
||||||
int active = gtk_combo_box_get_active (box);
|
int active = gtk_combo_box_get_active (box);
|
||||||
gchar *current, *key, *esc;
|
gchar *current, *key, *esc;
|
||||||
|
GtkTreeIter iter;
|
||||||
|
|
||||||
/* prevent the current settings from being saved by blocking
|
/* prevent the current settings from being saved by blocking
|
||||||
* the signal handler */
|
* the signal handler */
|
||||||
g_signal_handlers_block_by_func (box, cb_location_changed, builder);
|
g_signal_handlers_block_by_func (box, cb_location_changed, builder);
|
||||||
|
if (gtk_combo_box_get_active_iter (box, &iter) != FALSE) {
|
||||||
|
gtk_list_store_remove (GTK_LIST_STORE (gtk_combo_box_get_model (box)),
|
||||||
|
&iter);
|
||||||
|
}
|
||||||
gtk_combo_box_set_active (box, (active == 0) ? 1 : 0);
|
gtk_combo_box_set_active (box, (active == 0) ? 1 : 0);
|
||||||
gtk_combo_box_remove_text (box, active);
|
|
||||||
g_signal_handlers_unblock_by_func (box, cb_location_changed, builder);
|
g_signal_handlers_unblock_by_func (box, cb_location_changed, builder);
|
||||||
|
|
||||||
/* set the new location */
|
/* set the new location */
|
||||||
client = gconf_client_get_default ();
|
client = gconf_client_get_default ();
|
||||||
current = gtk_combo_box_get_active_text (box);
|
current = get_active_location (GTK_COMBO_BOX (box));
|
||||||
|
|
||||||
esc = gconf_escape_key (current, -1);
|
esc = gconf_escape_key (current, -1);
|
||||||
key = g_strconcat (LOCATION_DIR "/", esc, NULL);
|
key = g_strconcat (LOCATION_DIR "/", esc, NULL);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue