network-manager-applet r640 - in trunk: . src/connection-editor
- From: dcbw svn gnome org
- To: svn-commits-list gnome org
- Subject: network-manager-applet r640 - in trunk: . src/connection-editor
- Date: Tue, 1 Apr 2008 17:22:20 +0100 (BST)
Author: dcbw
Date: Tue Apr 1 17:22:19 2008
New Revision: 640
URL: http://svn.gnome.org/viewvc/network-manager-applet?rev=640&view=rev
Log:
2008-04-01 Dan Williams <dcbw redhat com>
* src/connection-editor/main.c
- exit cleanly
- (main): init gettext stuff; connection list is no longer modal
* src/connection-editor/page-wireless.c
- (ce_page_wireless_new): validate on SSID change
* src/connection-editor/nm-connection-list.c
src/connection-editor/nm-connection-list.h
- (add_connection_cb, edit_connection_cb, connection_double_clicked_cb):
allow multiple connection editors
- (nm_connection_list_run): new function; no longer modal so must
monitor response from dialog and re-emit for listeners
* src/connection-editor/nm-connection-editor.c
src/connection-editor/nm-connection-editor.h
- (connection_editor_validate): new function; perform validation of the
entire connection and set OK button accordingly
- (connection_name_changed): revalidate when name changes
- (nm_connection_editor_new): need a GConfClient and a GConf path
to be able to save an existing connection
- (page_changed): do complete validation if a page changes
- (connection_editor_update_connection): save a connection back to
GConf
- (nm_connection_editor_run): no longer modal; so set up signals to
monitor response from dialog, save connection as appropriate, and
re-emit for listeners
Modified:
trunk/ChangeLog
trunk/src/connection-editor/main.c
trunk/src/connection-editor/nm-connection-editor.c
trunk/src/connection-editor/nm-connection-editor.h
trunk/src/connection-editor/nm-connection-list.c
trunk/src/connection-editor/nm-connection-list.h
trunk/src/connection-editor/page-wireless.c
Modified: trunk/src/connection-editor/main.c
==============================================================================
--- trunk/src/connection-editor/main.c (original)
+++ trunk/src/connection-editor/main.c Tue Apr 1 17:22:19 2008
@@ -20,12 +20,52 @@
* (C) Copyright 2004-2005 Red Hat, Inc.
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <string.h>
+#include <stdlib.h>
+#include <signal.h>
+
#include <gtk/gtk.h>
+#include <glib/gi18n-lib.h>
#include <dbus/dbus-glib.h>
#include "nm-connection-list.h"
#include "crypto.h"
+static GMainLoop *loop = NULL;
+
+static void
+signal_handler (int signo)
+{
+ if (signo == SIGINT || signo == SIGTERM) {
+ g_message ("Caught signal %d, shutting down...", signo);
+ g_main_loop_quit (loop);
+ }
+}
+
+static void
+setup_signals (void)
+{
+ struct sigaction action;
+ sigset_t mask;
+
+ sigemptyset (&mask);
+ action.sa_handler = signal_handler;
+ action.sa_mask = mask;
+ action.sa_flags = 0;
+ sigaction (SIGTERM, &action, NULL);
+ sigaction (SIGINT, &action, NULL);
+}
+
+static void
+list_done_cb (NMConnectionList *list, gint response, gpointer user_data)
+{
+ g_main_loop_quit (loop);
+}
+
int
main (int argc, char *argv[])
{
@@ -33,7 +73,10 @@
DBusGConnection *ignore;
GError *error = NULL;
+ bindtextdomain (GETTEXT_PACKAGE, NMALOCALEDIR);
+ bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
gtk_init (&argc, &argv);
+ textdomain (GETTEXT_PACKAGE);
/* parse arguments: an idea is to use gconf://$setting_name / system://$setting_name to
allow this program to work with both GConf and system-wide settings */
@@ -48,11 +91,16 @@
return 1;
}
+ loop = g_main_loop_new (NULL, FALSE);
+
list = nm_connection_list_new ();
- nm_connection_list_run_and_close (list);
- g_object_unref (list);
+ g_signal_connect (G_OBJECT (list), "done", G_CALLBACK (list_done_cb), NULL);
+ nm_connection_list_run (list);
- crypto_deinit ();
+ setup_signals ();
+ g_main_loop_run (loop);
+ g_object_unref (list);
+ crypto_deinit ();
return 0;
}
Modified: trunk/src/connection-editor/nm-connection-editor.c
==============================================================================
--- trunk/src/connection-editor/nm-connection-editor.c (original)
+++ trunk/src/connection-editor/nm-connection-editor.c Tue Apr 1 17:22:19 2008
@@ -44,6 +44,7 @@
#include "nm-connection-editor.h"
#include "utils.h"
+#include "gconf-helpers.h"
#include "ce-page.h"
#include "page-wired.h"
@@ -55,6 +56,14 @@
G_DEFINE_TYPE (NMConnectionEditor, nm_connection_editor, G_TYPE_OBJECT)
+enum {
+ EDITOR_DONE,
+ EDITOR_LAST_SIGNAL
+};
+
+static guint editor_signals[EDITOR_LAST_SIGNAL] = { 0 };
+
+
static void
dialog_response_cb (GtkDialog *dialog, guint response, gpointer user_data)
{
@@ -103,7 +112,7 @@
s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (editor->connection, NM_TYPE_SETTING_CONNECTION));
g_assert (s_con);
- if (s_con->id) {
+ if (s_con->id && strlen (s_con->id)) {
char *title = g_strdup_printf (_("Editing %s"), s_con->id);
gtk_window_set_title (GTK_WINDOW (editor->dialog), title);
g_free (title);
@@ -112,15 +121,45 @@
}
static void
+connection_editor_validate (NMConnectionEditor *editor)
+{
+ GtkWidget *widget;
+ gboolean valid = FALSE;
+ const char *name;
+ GSList *iter;
+
+ widget = glade_xml_get_widget (editor->xml, "connection_name");
+ name = gtk_entry_get_text (GTK_ENTRY (widget));
+
+ /* Re-validate */
+ if (!name || !strlen (name))
+ goto done;
+
+ for (iter = editor->pages; iter; iter = g_slist_next (iter)) {
+ if (!ce_page_validate (CE_PAGE (iter->data)))
+ goto done;
+ }
+ valid = TRUE;
+
+done:
+ gtk_widget_set_sensitive (editor->ok_button, valid);
+}
+
+static void
connection_name_changed (GtkEditable *editable, gpointer user_data)
{
NMSettingConnection *s_con;
NMConnectionEditor *editor = NM_CONNECTION_EDITOR (user_data);
+ const char *name;
s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (editor->connection, NM_TYPE_SETTING_CONNECTION));
- if (s_con)
- g_object_set (G_OBJECT (s_con), NM_SETTING_CONNECTION_ID, gtk_entry_get_text (GTK_ENTRY (editable)), NULL);
+ g_assert (s_con);
+
+ name = gtk_entry_get_text (GTK_ENTRY (editable));
+ g_object_set (G_OBJECT (s_con), NM_SETTING_CONNECTION_ID, name, NULL);
nm_connection_editor_update_title (editor);
+
+ connection_editor_validate (editor);
}
static void
@@ -173,6 +212,8 @@
{
NMConnectionEditor *editor = NM_CONNECTION_EDITOR (object);
+ gtk_widget_hide (GTK_WIDGET (editor->dialog));
+
g_slist_foreach (editor->pages, (GFunc) g_object_unref, NULL);
g_slist_free (editor->pages);
editor->pages = NULL;
@@ -180,6 +221,9 @@
if (editor->connection)
g_object_unref (editor->connection);
+ g_object_unref (editor->gconf_client);
+ g_free (editor->gconf_path);
+
gtk_widget_destroy (editor->dialog);
g_object_unref (editor->xml);
@@ -193,17 +237,33 @@
/* virtual methods */
object_class->dispose = dispose;
+
+ /* Signals */
+ editor_signals[EDITOR_DONE] =
+ g_signal_new ("done",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (NMConnectionEditorClass, done),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__INT,
+ G_TYPE_NONE, 1, G_TYPE_INT);
}
NMConnectionEditor *
-nm_connection_editor_new (NMConnection *connection)
+nm_connection_editor_new (NMConnection *connection,
+ const char *gconf_path,
+ GConfClient *client)
{
NMConnectionEditor *editor;
g_return_val_if_fail (connection != NULL, NULL);
+ g_return_val_if_fail (client != NULL, NULL);
editor = g_object_new (NM_TYPE_CONNECTION_EDITOR, NULL);
nm_connection_editor_set_connection (editor, connection);
+ editor->gconf_client = g_object_ref (client);
+ if (gconf_path)
+ editor->gconf_path = g_strdup (gconf_path);
return editor;
}
@@ -216,6 +276,14 @@
return editor->connection;
}
+const char *
+nm_connection_editor_get_gconf_path (NMConnectionEditor *editor)
+{
+ g_return_val_if_fail (NM_IS_CONNECTION_EDITOR (editor), NULL);
+
+ return editor->gconf_path;
+}
+
gint
ce_spin_output_with_default (GtkSpinButton *spin, gpointer user_data)
{
@@ -261,7 +329,7 @@
{
NMConnectionEditor *editor = NM_CONNECTION_EDITOR (user_data);
- gtk_widget_set_sensitive (editor->ok_button, ce_page_validate (page));
+ connection_editor_validate (editor);
}
static void
@@ -333,11 +401,11 @@
}
void
-nm_connection_editor_show (NMConnectionEditor *editor)
+nm_connection_editor_present (NMConnectionEditor *editor)
{
g_return_if_fail (NM_IS_CONNECTION_EDITOR (editor));
- gtk_widget_show (editor->dialog);
+ gtk_window_present (GTK_WINDOW (editor->dialog));
}
static void
@@ -346,23 +414,80 @@
ce_page_update_connection (CE_PAGE (data), NM_CONNECTION (user_data));
}
-gint
-nm_connection_editor_run_and_close (NMConnectionEditor *editor)
+static void
+connection_editor_update_connection (NMConnectionEditor *editor)
{
- gint result;
+ NMSettingConnection *s_con;
+ GtkWidget *widget;
+ const char *name;
- g_return_val_if_fail (NM_IS_CONNECTION_EDITOR (editor), GTK_RESPONSE_CANCEL);
+ s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (editor->connection, NM_TYPE_SETTING_CONNECTION));
+ g_assert (s_con);
+
+ widget = glade_xml_get_widget (editor->xml, "connection_name");
+ name = gtk_entry_get_text (GTK_ENTRY (widget));
+ g_object_set (G_OBJECT (s_con), NM_SETTING_CONNECTION_ID, name, NULL);
+
+ g_slist_foreach (editor->pages, update_one_page, editor->connection);
+
+ if (!nm_connection_verify (editor->connection)) {
+ g_warning ("%s: connection invalid after update; bug in the connection editor.", __func__);
+ return;
+ }
- result = gtk_dialog_run (GTK_DIALOG (editor->dialog));
- gtk_widget_hide (editor->dialog);
+ if (!editor->gconf_path) {
+ guint32 i = 0;
- switch (result) {
- case GTK_RESPONSE_OK:
- g_slist_foreach (editor->pages, update_one_page, editor->connection);
- break;
- default:
- break;
+ /* Find free GConf directory */
+ while (i++ < G_MAXUINT32) {
+ char buf[255];
+
+ snprintf (&buf[0], 255, GCONF_PATH_CONNECTIONS"/%d", i);
+ if (!gconf_client_dir_exists (editor->gconf_client, buf, NULL)) {
+ editor->gconf_path = g_strdup_printf (buf);
+ break;
+ }
+ };
}
- return result;
+ if (editor->gconf_path) {
+ /* Save the connection back to GConf */
+ nm_gconf_write_connection (editor->connection,
+ editor->gconf_client,
+ editor->gconf_path);
+ gconf_client_notify (editor->gconf_client, editor->gconf_path);
+ gconf_client_suggest_sync (editor->gconf_client, NULL);
+ } else
+ nm_warning ("Couldn't find free GConf directory for new connection.");
+}
+
+static void
+editor_response_cb (GtkDialog *dialog, gint response, gpointer user_data)
+{
+ NMConnectionEditor *editor = NM_CONNECTION_EDITOR (user_data);
+
+ if (response == GTK_RESPONSE_OK)
+ connection_editor_update_connection (editor);
+
+ g_signal_emit (editor, editor_signals[EDITOR_DONE], 0, response);
+}
+
+static void
+editor_close_cb (GtkDialog *dialog, gpointer user_data)
+{
+ gtk_dialog_response (dialog, GTK_RESPONSE_CLOSE);
+}
+
+void
+nm_connection_editor_run (NMConnectionEditor *editor)
+{
+ g_return_if_fail (NM_IS_CONNECTION_EDITOR (editor));
+
+ g_signal_connect (G_OBJECT (editor->dialog), "response",
+ G_CALLBACK (editor_response_cb), editor);
+ g_signal_connect (G_OBJECT (editor->dialog), "close",
+ G_CALLBACK (editor_close_cb), editor);
+
+ nm_connection_editor_present (editor);
}
+
Modified: trunk/src/connection-editor/nm-connection-editor.h
==============================================================================
--- trunk/src/connection-editor/nm-connection-editor.h (original)
+++ trunk/src/connection-editor/nm-connection-editor.h Tue Apr 1 17:22:19 2008
@@ -28,6 +28,7 @@
#include <glade/glade-xml.h>
#include <gtk/gtksizegroup.h>
#include <gtk/gtkspinbutton.h>
+#include <gconf/gconf-client.h>
#define NM_TYPE_CONNECTION_EDITOR (nm_connection_editor_get_type ())
#define NM_IS_CONNECTION_EDITOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_CONNECTION_EDITOR))
@@ -38,6 +39,9 @@
/* private data */
NMConnection *connection;
+ char *gconf_path;
+ GConfClient *gconf_client;
+
GSList *pages;
GladeXML *xml;
GtkWidget *dialog;
@@ -46,14 +50,18 @@
typedef struct {
GObjectClass parent_class;
+
+ /* Signals */
+ void (*done) (NMConnectionEditor *editor, gint result);
} NMConnectionEditorClass;
GType nm_connection_editor_get_type (void);
-NMConnectionEditor *nm_connection_editor_new (NMConnection *connection);
+NMConnectionEditor *nm_connection_editor_new (NMConnection *connection, const char *path, GConfClient *client);
-void nm_connection_editor_show (NMConnectionEditor *editor);
-gint nm_connection_editor_run_and_close (NMConnectionEditor *editor);
-NMConnection *nm_connection_editor_get_connection (NMConnectionEditor *editor);
+void nm_connection_editor_present (NMConnectionEditor *editor);
+void nm_connection_editor_run (NMConnectionEditor *editor);
+const char * nm_connection_editor_get_gconf_path (NMConnectionEditor *editor);
+NMConnection * nm_connection_editor_get_connection (NMConnectionEditor *editor);
void nm_connection_editor_set_connection (NMConnectionEditor *editor, NMConnection *connection);
gint ce_spin_output_with_default (GtkSpinButton *spin, gpointer user_data);
Modified: trunk/src/connection-editor/nm-connection-list.c
==============================================================================
--- trunk/src/connection-editor/nm-connection-list.c (original)
+++ trunk/src/connection-editor/nm-connection-list.c Tue Apr 1 17:22:19 2008
@@ -50,7 +50,15 @@
G_DEFINE_TYPE (NMConnectionList, nm_connection_list, G_TYPE_OBJECT)
+enum {
+ LIST_DONE,
+ LIST_LAST_SIGNAL
+};
+
+static guint list_signals[LIST_LAST_SIGNAL] = { 0 };
+
#define CE_GCONF_PATH_TAG "ce-gconf-path"
+#define CONNECTION_LIST_TAG "nm-connection-list"
#define COL_ID 0
#define COL_LAST_USED 1
@@ -91,24 +99,110 @@
return connection;
}
+typedef struct {
+ NMConnectionList *list;
+ GtkWidget *clist;
+} EditorDoneInfo;
+
+static void
+add_done_cb (NMConnectionEditor *editor, gint response, gpointer user_data)
+{
+ EditorDoneInfo *info = (EditorDoneInfo *) user_data;
+ NMConnection *connection;
+
+ connection = nm_connection_editor_get_connection (editor);
+
+ if (response == GTK_RESPONSE_OK) {
+ const char *path;
+
+ path = nm_connection_editor_get_gconf_path (editor);
+
+ g_object_set_data_full (G_OBJECT (connection),
+ CE_GCONF_PATH_TAG,
+ g_strdup (path),
+ (GDestroyNotify) g_free);
+ // FIXME: add connection to the list
+ }
+
+ g_hash_table_remove (info->list->editors, connection);
+ g_free (info);
+}
+
static void
add_connection_cb (GtkButton *button, gpointer user_data)
{
+ GtkWidget *clist = GTK_WIDGET (user_data);
+ NMConnectionList *list;
NMConnectionEditor *editor;
- NMConnection *connection = nm_connection_new ();
+ NMConnection *connection;
+ EditorDoneInfo *info;
+
+ list = NM_CONNECTION_LIST (g_object_get_data (G_OBJECT (button), CONNECTION_LIST_TAG));
+ g_assert (list);
+
+ info = g_malloc0 (sizeof (EditorDoneInfo));
+ g_assert (info);
+ info->list = list;
+ info->clist = clist;
+
+ connection = nm_connection_new ();
+ editor = nm_connection_editor_new (connection, NULL, NULL);
+ g_signal_connect (G_OBJECT (editor), "done", G_CALLBACK (add_done_cb), info);
+ g_hash_table_insert (list->editors, connection, editor);
+
+ nm_connection_editor_run (editor);
+}
+
+static void
+edit_done_cb (NMConnectionEditor *editor, gint response, gpointer user_data)
+{
+ EditorDoneInfo *info = (EditorDoneInfo *) user_data;
+ NMConnection *connection;
+
+ connection = nm_connection_editor_get_connection (editor);
- editor = nm_connection_editor_new (connection);
- nm_connection_editor_run_and_close (editor);
+ if (response == GTK_RESPONSE_OK) {
+ // FIXME: update connection name in list if needed
+ }
- g_object_unref (editor);
- g_object_unref (connection);
+ g_hash_table_remove (info->list->editors, connection);
+ g_free (info);
+}
+
+static void
+do_edit (NMConnectionList *list, NMConnection *connection, GtkWidget *clist)
+{
+ NMConnectionEditor *editor;
+ const char *gconf_path;
+ EditorDoneInfo *info;
+
+ /* Don't allow two editors for the same connection */
+ editor = NM_CONNECTION_EDITOR (g_hash_table_lookup (list->editors, connection));
+ if (editor) {
+ nm_connection_editor_present (editor);
+ return;
+ }
+
+ gconf_path = g_object_get_data (G_OBJECT (connection), CE_GCONF_PATH_TAG);
+ g_assert (gconf_path);
+
+ info = g_malloc0 (sizeof (EditorDoneInfo));
+ g_assert (info);
+ info->list = list;
+ info->clist = clist;
+
+ editor = nm_connection_editor_new (connection, gconf_path, list->client);
+ g_signal_connect (G_OBJECT (editor), "done", G_CALLBACK (edit_done_cb), info);
+ g_hash_table_insert (list->editors, connection, editor);
+
+ nm_connection_editor_run (editor);
}
static void
edit_connection_cb (GtkButton *button, gpointer user_data)
{
+ NMConnectionList *list;
GtkWidget *clist = GTK_WIDGET (user_data);
- NMConnectionEditor *editor;
NMConnection *connection;
GtkTreeModel *ignore1 = NULL;
GtkTreeIter ignore2;
@@ -116,9 +210,10 @@
connection = get_connection_for_selection (clist, &ignore1, &ignore2);
g_return_if_fail (connection != NULL);
- editor = nm_connection_editor_new (connection);
- nm_connection_editor_run_and_close (editor);
- g_object_unref (editor);
+ list = NM_CONNECTION_LIST (g_object_get_data (G_OBJECT (button), CONNECTION_LIST_TAG));
+ g_assert (list);
+
+ do_edit (list, connection, clist);
}
static void
@@ -146,7 +241,7 @@
if (!s_con || !s_con->id)
return;
- list = NM_CONNECTION_LIST (g_object_get_data (G_OBJECT (button), "nm-connection-list"));
+ list = NM_CONNECTION_LIST (g_object_get_data (G_OBJECT (button), CONNECTION_LIST_TAG));
g_return_if_fail (list != NULL);
dialog = gtk_message_dialog_new (GTK_WINDOW (list->dialog),
@@ -235,9 +330,9 @@
GtkTreeViewColumn *column,
gpointer user_data)
{
+ NMConnectionList *list = NM_CONNECTION_LIST (user_data);
GtkTreeModel *model;
GtkTreeIter iter;
- NMConnectionEditor *editor;
NMConnection *connection;
gboolean success;
@@ -249,9 +344,7 @@
gtk_tree_model_get (model, &iter, COL_CONNECTION, &connection, -1);
g_return_if_fail (connection != NULL);
- editor = nm_connection_editor_new (connection);
- nm_connection_editor_run_and_close (editor);
- g_object_unref (editor);
+ do_edit (list, connection, GTK_WIDGET (tree_view));
}
static char *
@@ -420,7 +513,7 @@
g_signal_connect (G_OBJECT (clist),
"row-activated", G_CALLBACK (connection_double_clicked_cb),
- NULL);
+ list);
gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (clist),
-1, "Name", gtk_cell_renderer_text_new (),
@@ -442,13 +535,13 @@
name = g_strdup_printf ("%s_add", prefix);
button = glade_xml_get_widget (list->gui, name);
- g_object_set_data (G_OBJECT (button), "nm-connection-list", list);
+ g_object_set_data (G_OBJECT (button), CONNECTION_LIST_TAG, list);
g_signal_connect (G_OBJECT (button), "clicked", G_CALLBACK (add_connection_cb), clist);
g_free (name);
name = g_strdup_printf ("%s_edit", prefix);
button = glade_xml_get_widget (list->gui, name);
- g_object_set_data (G_OBJECT (button), "nm-connection-list", list);
+ g_object_set_data (G_OBJECT (button), CONNECTION_LIST_TAG, list);
g_signal_connect (G_OBJECT (button), "clicked", G_CALLBACK (edit_connection_cb), clist);
g_signal_connect (G_OBJECT (select),
"changed", G_CALLBACK (list_selection_changed_cb),
@@ -457,7 +550,7 @@
name = g_strdup_printf ("%s_delete", prefix);
button = glade_xml_get_widget (list->gui, name);
- g_object_set_data (G_OBJECT (button), "nm-connection-list", list);
+ g_object_set_data (G_OBJECT (button), CONNECTION_LIST_TAG, list);
g_signal_connect (G_OBJECT (button), "clicked", G_CALLBACK (delete_connection_cb), clist);
g_signal_connect (G_OBJECT (select),
"changed", G_CALLBACK (list_selection_changed_cb),
@@ -541,15 +634,21 @@
load_connections (list);
init_connection_lists (list);
+ list->editors = g_hash_table_new_full (g_direct_hash, g_direct_equal, g_object_unref, g_object_unref);
+
list->dialog = glade_xml_get_widget (list->gui, "NMConnectionList");
g_signal_connect (G_OBJECT (list->dialog), "response", G_CALLBACK (dialog_response_cb), list);
}
static void
-nm_connection_list_finalize (GObject *object)
+dispose (GObject *object)
{
NMConnectionList *list = NM_CONNECTION_LIST (object);
+ gtk_widget_hide (list->dialog);
+
+ g_hash_table_destroy (list->editors);
+
g_object_unref (list->wired_icon);
g_object_unref (list->wireless_icon);
g_object_unref (list->wwan_icon);
@@ -561,7 +660,7 @@
g_hash_table_destroy (list->connections);
g_object_unref (list->client);
- G_OBJECT_CLASS (nm_connection_list_parent_class)->finalize (object);
+ G_OBJECT_CLASS (nm_connection_list_parent_class)->dispose (object);
}
static void
@@ -570,7 +669,17 @@
GObjectClass *object_class = G_OBJECT_CLASS (klass);
/* virtual methods */
- object_class->finalize = nm_connection_list_finalize;
+ object_class->dispose = dispose;
+
+ /* Signals */
+ list_signals[LIST_DONE] =
+ g_signal_new ("done",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (NMConnectionListClass, done),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__INT,
+ G_TYPE_NONE, 1, G_TYPE_INT);
}
NMConnectionList *
@@ -583,23 +692,36 @@
return list;
}
-void
-nm_connection_list_show (NMConnectionList *list)
+static void
+nm_connection_list_present (NMConnectionList *list)
{
g_return_if_fail (NM_IS_CONNECTION_LIST (list));
- gtk_widget_show (GTK_WIDGET (list->dialog));
+ gtk_window_present (GTK_WINDOW (list->dialog));
}
-gint
-nm_connection_list_run_and_close (NMConnectionList *list)
+static void
+list_response_cb (GtkDialog *dialog, gint response, gpointer user_data)
{
- gint result;
+ g_signal_emit (NM_CONNECTION_LIST (user_data), list_signals[LIST_DONE], 0, response);
+}
- g_return_val_if_fail (NM_IS_CONNECTION_LIST (list), GTK_RESPONSE_CANCEL);
+static void
+list_close_cb (GtkDialog *dialog, gpointer user_data)
+{
+ gtk_dialog_response (dialog, GTK_RESPONSE_CLOSE);
+}
- result = gtk_dialog_run (GTK_DIALOG (list->dialog));
- gtk_widget_hide (GTK_WIDGET (list->dialog));
+void
+nm_connection_list_run (NMConnectionList *list)
+{
+ g_return_if_fail (NM_IS_CONNECTION_LIST (list));
+
+ g_signal_connect (G_OBJECT (list->dialog), "response",
+ G_CALLBACK (list_response_cb), list);
+ g_signal_connect (G_OBJECT (list->dialog), "close",
+ G_CALLBACK (list_close_cb), list);
- return result;
+ nm_connection_list_present (list);
}
+
Modified: trunk/src/connection-editor/nm-connection-list.h
==============================================================================
--- trunk/src/connection-editor/nm-connection-list.h (original)
+++ trunk/src/connection-editor/nm-connection-list.h Tue Apr 1 17:22:19 2008
@@ -39,6 +39,7 @@
/* private data */
GHashTable *connections;
+ GHashTable *editors;
GConfClient *client;
@@ -55,12 +56,14 @@
typedef struct {
GObjectClass parent_class;
+
+ /* Signals */
+ void (*done) (NMConnectionList *list, gint result);
} NMConnectionListClass;
GType nm_connection_list_get_type (void);
NMConnectionList *nm_connection_list_new (void);
-void nm_connection_list_show (NMConnectionList *list);
-gint nm_connection_list_run_and_close (NMConnectionList *list);
+void nm_connection_list_run (NMConnectionList *list);
#endif
Modified: trunk/src/connection-editor/page-wireless.c
==============================================================================
--- trunk/src/connection-editor/page-wireless.c (original)
+++ trunk/src/connection-editor/page-wireless.c Tue Apr 1 17:22:19 2008
@@ -148,6 +148,12 @@
}
}
+static void
+ssid_value_changed_cb (GtkEditable *entry, gpointer user_data)
+{
+ ce_page_changed (CE_PAGE (user_data));
+}
+
CEPageWireless *
ce_page_wireless_new (NMConnection *connection)
{
@@ -216,6 +222,7 @@
utf8_ssid = nm_utils_ssid_to_utf8 ((const char *) s_wireless->ssid->data, s_wireless->ssid->len);
gtk_entry_set_text (GTK_ENTRY (ssid), utf8_ssid);
g_free (utf8_ssid);
+ g_signal_connect (G_OBJECT (ssid), "changed", G_CALLBACK (ssid_value_changed_cb), self);
mode = glade_xml_get_widget (parent->xml, "wireless_mode");
if (!strcmp (s_wireless->mode ? s_wireless->mode : "", "infrastructure"))
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]