[patch] make the passphrase dialog response based
- From: Christopher Aillon <caillon redhat com>
- To: networkmanager list <networkmanager-list gnome org>
- Subject: [patch] make the passphrase dialog response based
- Date: Thu, 18 Aug 2005 17:00:32 -0400
Right now, the passphrase dialog will only go through the "cancel"
codepath (trying a different network, etc) if the cancel button is
activated. It should also cancel the dialog if the Esc key is pressed
or the [X] is clicked.
Patch attached.
Index: gnome/applet/passphrase-dialog.c
===================================================================
RCS file: /cvs/gnome/NetworkManager/gnome/applet/passphrase-dialog.c,v
retrieving revision 1.11
diff -d -u -p -1 -0 -r1.11 passphrase-dialog.c
--- gnome/applet/passphrase-dialog.c 10 Aug 2005 14:30:41 -0000 1.11
+++ gnome/applet/passphrase-dialog.c 18 Aug 2005 20:54:43 -0000
@@ -162,96 +162,86 @@ static void nmi_passphrase_dialog_key_ty
gtk_label_set_label (entry_label, _("Hex Key:"));
break;
default:
break;
}
}
}
/*
- * nmi_passphrase_dialog_ok_clicked
- *
- * OK button handler; grab the passphrase and send it back
- * to NetworkManager. Get rid of the dialog.
+ * nmi_passphrase_dialog_response_received
*
+ * response handler; grab the passphrase and return it
+ * to NetworkManager if it was given to us, else return
+ * a cancellation message to NetworkManager.
+ * Either way, get rid of the dialog.
*/
-static void nmi_passphrase_dialog_ok_clicked (GtkWidget *ok_button, gpointer user_data)
+static void nmi_passphrase_dialog_response_received (GtkWidget *cancel_button, gint response, gpointer user_data)
{
- GtkWidget * dialog = gtk_widget_get_toplevel (ok_button);
+ GtkWidget * dialog = gtk_widget_get_toplevel (cancel_button);
NMWirelessApplet * applet = (NMWirelessApplet *)user_data;
+ GladeXML * dialog_xml;
+ GtkEntry * entry;
+ GtkComboBox * key_type_combo;
+ const char * passphrase;
+ NetworkDevice * dev;
+ WirelessNetwork * net;
+ DBusMessage * message;
+ NMEncKeyType key_type_return;
+
g_return_if_fail (applet != NULL);
- if (GTK_WIDGET_TOPLEVEL (dialog))
+ if (! GTK_WIDGET_TOPLEVEL (dialog))
+ return;
+
+ if (response != GTK_RESPONSE_OK)
{
- GladeXML * dialog_xml;
- GtkEntry * entry;
- GtkComboBox * key_type_combo;
- const char * passphrase;
- NetworkDevice * dev = g_object_get_data (G_OBJECT (dialog), "device");
- WirelessNetwork * net = g_object_get_data (G_OBJECT (dialog), "network");
DBusMessage * message = g_object_get_data (G_OBJECT (dialog), "dbus-message");
- NMEncKeyType key_type_return = NM_ENC_TYPE_UNKNOWN;
-
- g_return_if_fail ((dialog_xml = get_dialog_xml (dialog)) != NULL);
-
- entry = GTK_ENTRY (glade_xml_get_widget (dialog_xml, "passphrase_entry"));
- key_type_combo = GTK_COMBO_BOX (glade_xml_get_widget (dialog_xml, "key_type_combo"));
- passphrase = gtk_entry_get_text (entry);
-
- switch (gtk_combo_box_get_active (key_type_combo))
- {
- case KEY_TYPE_128_BIT_PASSPHRASE:
- key_type_return = NM_ENC_TYPE_128_BIT_PASSPHRASE;
- break;
- case KEY_TYPE_ASCII_KEY:
- key_type_return = NM_ENC_TYPE_ASCII_KEY;
- break;
- case KEY_TYPE_HEX_KEY:
- key_type_return = NM_ENC_TYPE_HEX_KEY;
- break;
- default:
- key_type_return = NM_ENC_TYPE_UNKNOWN;
- break;
- }
- /* Tell NetworkManager about the key the user typed in */
- nmi_dbus_return_user_key (applet->connection, message, passphrase, key_type_return);
+ nmi_dbus_return_user_key (applet->connection, message, "***canceled***", NM_ENC_TYPE_UNKNOWN);
nmi_passphrase_dialog_clear (dialog);
+
+ return;
}
-}
+ dev = g_object_get_data (G_OBJECT (dialog), "device");
+ net = g_object_get_data (G_OBJECT (dialog), "network");
+ message = g_object_get_data (G_OBJECT (dialog), "dbus-message");
+ key_type_return = NM_ENC_TYPE_UNKNOWN;
-/*
- * nmi_passphrase_dialog_cancel_clicked
- *
- * Cancel button handler; return a cancellation message to NetworkManager
- * and get rid of the dialog.
- *
- */
-static void nmi_passphrase_dialog_cancel_clicked (GtkWidget *cancel_button, gpointer user_data)
-{
- GtkWidget * dialog = gtk_widget_get_toplevel (cancel_button);
- NMWirelessApplet * applet = (NMWirelessApplet *)user_data;
+ g_return_if_fail ((dialog_xml = get_dialog_xml (dialog)) != NULL);
- g_return_if_fail (applet != NULL);
+ entry = GTK_ENTRY (glade_xml_get_widget (dialog_xml, "passphrase_entry"));
+ key_type_combo = GTK_COMBO_BOX (glade_xml_get_widget (dialog_xml, "key_type_combo"));
+ passphrase = gtk_entry_get_text (entry);
- if (GTK_WIDGET_TOPLEVEL (dialog))
+ switch (gtk_combo_box_get_active (key_type_combo))
{
- NetworkDevice * dev = g_object_get_data (G_OBJECT (dialog), "device");
- WirelessNetwork * net = g_object_get_data (G_OBJECT (dialog), "network");
- DBusMessage * message = g_object_get_data (G_OBJECT (dialog), "dbus-message");
-
- nmi_dbus_return_user_key (applet->connection, message, "***canceled***", NM_ENC_TYPE_UNKNOWN);
- nmi_passphrase_dialog_clear (dialog);
+ case KEY_TYPE_128_BIT_PASSPHRASE:
+ key_type_return = NM_ENC_TYPE_128_BIT_PASSPHRASE;
+ break;
+ case KEY_TYPE_ASCII_KEY:
+ key_type_return = NM_ENC_TYPE_ASCII_KEY;
+ break;
+ case KEY_TYPE_HEX_KEY:
+ key_type_return = NM_ENC_TYPE_HEX_KEY;
+ break;
+ default:
+ key_type_return = NM_ENC_TYPE_UNKNOWN;
+ break;
}
+
+ /* Tell NetworkManager about the key the user typed in */
+ nmi_dbus_return_user_key (applet->connection, message, passphrase, key_type_return);
+ nmi_passphrase_dialog_clear (dialog);
}
typedef struct PPDialogCBData
{
NMWirelessApplet * applet;
NetworkDevice * dev;
WirelessNetwork * net;
DBusMessage * message;
} PPDialogCBData;
@@ -403,25 +393,24 @@ GtkWidget *nmi_passphrase_dialog_init (N
g_object_set_data (G_OBJECT (dialog), "glade-xml", dialog_xml);
/* Save original label text to preserve the '%s' and other formatting that gets overwritten
* when the dialog is first shown.
*/
label = GTK_LABEL (glade_xml_get_widget (dialog_xml, "label1"));
orig_label_text = g_strdup (gtk_label_get_label (label));
g_object_set_data (G_OBJECT (dialog), "orig-label-text", orig_label_text);
+ g_signal_connect (G_OBJECT (dialog), "response", GTK_SIGNAL_FUNC (nmi_passphrase_dialog_response_received), applet);
+
ok_button = GTK_BUTTON (glade_xml_get_widget (dialog_xml, "login_button"));
- g_signal_connect (G_OBJECT (ok_button), "clicked", GTK_SIGNAL_FUNC (nmi_passphrase_dialog_ok_clicked), applet);
gtk_widget_grab_default (GTK_WIDGET (ok_button));
- cancel_button = GTK_BUTTON (glade_xml_get_widget (dialog_xml, "cancel_button"));
- g_signal_connect (G_OBJECT (cancel_button), "clicked", GTK_SIGNAL_FUNC (nmi_passphrase_dialog_cancel_clicked), applet);
entry = GTK_ENTRY (glade_xml_get_widget (dialog_xml, "passphrase_entry"));
nmi_passphrase_dialog_clear (dialog);
gtk_widget_set_sensitive (GTK_WIDGET (ok_button), FALSE);
g_signal_connect (entry, "changed", G_CALLBACK (update_button_cb), dialog_xml);
key_type_combo = GTK_COMBO_BOX (glade_xml_get_widget (dialog_xml, "key_type_combo"));
gtk_combo_box_set_active (key_type_combo, 0);
g_signal_connect (G_OBJECT (key_type_combo), "changed", GTK_SIGNAL_FUNC (nmi_passphrase_dialog_key_type_combo_changed), applet);
nmi_passphrase_dialog_key_type_combo_changed (GTK_WIDGET (key_type_combo), applet);
Index: gnome/applet/wireless-applet.glade
===================================================================
RCS file: /cvs/gnome/NetworkManager/gnome/applet/wireless-applet.glade,v
retrieving revision 1.6
diff -d -u -p -1 -0 -r1.6 wireless-applet.glade
--- gnome/applet/wireless-applet.glade 18 Aug 2005 15:00:22 -0000 1.6
+++ gnome/applet/wireless-applet.glade 18 Aug 2005 20:54:43 -0000
@@ -746,21 +746,21 @@ Hex key (WEP)</property>
<child>
<widget class="GtkButton" id="login_button">
<property name="visible">True</property>
<property name="can_default">True</property>
<property name="has_default">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">_Login to Network</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
- <property name="response_id">0</property>
+ <property name="response_id">-5</property>
</widget>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="pack_type">GTK_PACK_END</property>
</packing>
</child>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]