[network-manager-applet] editor: disable "Create" button when no connection type is available
- From: Beniamino Galvani <bgalvani src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [network-manager-applet] editor: disable "Create" button when no connection type is available
- Date: Fri, 23 Sep 2016 20:53:13 +0000 (UTC)
commit b758deb79c0d05faf29baed01041828f1091a68b
Author: Beniamino Galvani <bgalvani redhat com>
Date: Fri Sep 23 14:41:49 2016 +0200
editor: disable "Create" button when no connection type is available
... instead of brutally crashing.
https://bugzilla.redhat.com/show_bug.cgi?id=1378451
src/connection-editor/connection-helpers.c | 33 +++++++++++++++++-----------
1 files changed, 20 insertions(+), 13 deletions(-)
---
diff --git a/src/connection-editor/connection-helpers.c b/src/connection-editor/connection-helpers.c
index 89d499a..322f4b3 100644
--- a/src/connection-editor/connection-helpers.c
+++ b/src/connection-editor/connection-helpers.c
@@ -478,6 +478,7 @@ new_connection_dialog_full (GtkWindow *parent_window,
gpointer detail_data = NULL;
GError *error = NULL;
CEPageVpnDetailData vpn_data;
+ GtkButton *create_button;
/* load GUI */
gui = gtk_builder_new ();
@@ -495,8 +496,13 @@ new_connection_dialog_full (GtkWindow *parent_window,
combo = GTK_COMBO_BOX (gtk_builder_get_object (gui, "new_connection_type_combo"));
label = GTK_LABEL (gtk_builder_get_object (gui, "new_connection_desc_label"));
+ create_button = GTK_BUTTON (gtk_builder_get_object (gui, "create_button"));
set_up_connection_type_combo (combo, label, type_filter_func, user_data);
+ /* Disable "Create" button if no item is available */
+ if (!gtk_tree_model_iter_n_children (gtk_combo_box_get_model (combo), NULL))
+ gtk_widget_set_sensitive (GTK_WIDGET (create_button), FALSE);
+
if (primary_label) {
label = GTK_LABEL (gtk_builder_get_object (gui, "new_connection_primary_label"));
gtk_label_set_text (label, primary_label);
@@ -508,20 +514,21 @@ new_connection_dialog_full (GtkWindow *parent_window,
response = gtk_dialog_run (type_dialog);
if (response == GTK_RESPONSE_OK) {
- gtk_combo_box_get_active_iter (combo, &iter);
- gtk_tree_model_get (gtk_combo_box_get_model (combo), &iter,
- COL_NEW_FUNC, &new_func,
- COL_VPN_SERVICE_TYPE, &vpn_service_type,
- COL_VPN_ADD_DETAIL_KEY, &vpn_add_detail_key,
- COL_VPN_ADD_DETAIL_VAL, &vpn_add_detail_val,
- -1);
- if (vpn_service_type) {
- memset (&vpn_data, 0, sizeof (vpn_data));
- vpn_data.add_detail_key = vpn_add_detail_key;
- vpn_data.add_detail_val = vpn_add_detail_val;
+ if (gtk_combo_box_get_active_iter (combo, &iter)) {
+ gtk_tree_model_get (gtk_combo_box_get_model (combo), &iter,
+ COL_NEW_FUNC, &new_func,
+ COL_VPN_SERVICE_TYPE, &vpn_service_type,
+ COL_VPN_ADD_DETAIL_KEY, &vpn_add_detail_key,
+ COL_VPN_ADD_DETAIL_VAL, &vpn_add_detail_val,
+ -1);
+ if (vpn_service_type) {
+ memset (&vpn_data, 0, sizeof (vpn_data));
+ vpn_data.add_detail_key = vpn_add_detail_key;
+ vpn_data.add_detail_val = vpn_add_detail_val;
- detail = vpn_service_type;
- detail_data = &vpn_data;
+ detail = vpn_service_type;
+ detail_data = &vpn_data;
+ }
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]