network-manager-applet r965 - in trunk: . src/connection-editor
- From: dcbw svn gnome org
- To: svn-commits-list gnome org
- Subject: network-manager-applet r965 - in trunk: . src/connection-editor
- Date: Thu, 23 Oct 2008 14:48:32 +0000 (UTC)
Author: dcbw
Date: Thu Oct 23 14:48:32 2008
New Revision: 965
URL: http://svn.gnome.org/viewvc/network-manager-applet?rev=965&view=rev
Log:
2008-10-23 Dan Williams <dcbw redhat com>
* src/connection-editor/nm-connection-list.c
- (create_new_connection_for_type): set initial connection scope
* src/connection-editor/nm-connection-editor.h
- Change the editor window from a dialog to a window to allow the
action area to be more fully customized; move the system settting
checkbox down there
* src/connection-editor/nm-connection-editor.c
src/connection-editor/nm-connection-editor.h
- (nm_connection_editor_init): hook the system connection checkbox up
to PolicyKit authorizations
- (populate_connection_ui): set the system connection checkbox elsewhere
- (nm_connection_editor_set_connection): set initial value of system
connection checkbox based on the connection's scope
- (nm_connection_editor_run): fix up signal handling since the editor
window is no longer a dialog
Modified:
trunk/ChangeLog
trunk/src/connection-editor/nm-connection-editor.c
trunk/src/connection-editor/nm-connection-editor.glade
trunk/src/connection-editor/nm-connection-editor.h
trunk/src/connection-editor/nm-connection-list.c
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 Thu Oct 23 14:48:32 2008
@@ -1,7 +1,9 @@
-/* -*- Mode: C; tab-width: 5; indent-tabs-mode: t; c-basic-offset: 5 -*- */
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
/* NetworkManager Connection editor -- Connection editor for NetworkManager
*
* Rodrigo Moya <rodrigo gnome-db org>
+ * Dan Williams <dcbw redhat com>
+ * Tambet Ingo <tambet gmail com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -17,7 +19,8 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
- * (C) Copyright 2004-2005 Red Hat, Inc.
+ * (C) Copyright 2007 - 2008 Red Hat, Inc.
+ * (C) Copyright 2007 - 2008 Novell, Inc.
*/
#include <string.h>
@@ -34,6 +37,12 @@
#include <gtk/gtklabel.h>
#include <glib/gi18n.h>
+#ifdef NO_POLKIT_GNOME
+#include "polkit-06-helpers.h"
+#else
+#include <polkit-gnome/polkit-gnome.h>
+#endif
+
#include <nm-setting-connection.h>
#include <nm-setting-ip4-config.h>
#include <nm-setting-wired.h>
@@ -71,13 +80,7 @@
static guint editor_signals[EDITOR_LAST_SIGNAL] = { 0 };
static void nm_connection_editor_set_connection (NMConnectionEditor *editor,
- NMConnection *connection);
-
-static void
-dialog_response_cb (GtkDialog *dialog, guint response, gpointer user_data)
-{
- gtk_widget_hide (GTK_WIDGET (dialog));
-}
+ NMConnection *connection);
static void
nm_connection_editor_update_title (NMConnectionEditor *editor)
@@ -91,10 +94,10 @@
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);
+ gtk_window_set_title (GTK_WINDOW (editor->window), title);
g_free (title);
} else
- gtk_window_set_title (GTK_WINDOW (editor->dialog), _("Editing un-named connection"));
+ gtk_window_set_title (GTK_WINDOW (editor->window), _("Editing un-named connection"));
}
static gboolean
@@ -121,8 +124,7 @@
autoconnect = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
g_object_set (G_OBJECT (s_con), NM_SETTING_CONNECTION_AUTOCONNECT, autoconnect, NULL);
- widget = glade_xml_get_widget (editor->xml, "connection_system");
- if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)))
+ if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (editor->system_button)))
nm_connection_set_scope (editor->connection, NM_CONNECTION_SCOPE_SYSTEM);
else
nm_connection_set_scope (editor->connection, NM_CONNECTION_SCOPE_USER);
@@ -163,6 +165,7 @@
nm_connection_editor_init (NMConnectionEditor *editor)
{
GtkWidget *dialog;
+ PolKitAction *pk_action;
/* Yes, we mean applet.glade, not nm-connection-editor.glade. The wireless security bits
are taken from applet.glade. */
@@ -178,7 +181,7 @@
return;
}
- editor->xml = glade_xml_new (GLADEDIR "/nm-connection-editor.glade", NULL, NULL);
+ editor->xml = glade_xml_new (GLADEDIR "/nm-connection-editor.glade", "nm-connection-editor", NULL);
if (!editor->xml) {
dialog = gtk_message_dialog_new (NULL, 0,
GTK_MESSAGE_ERROR,
@@ -191,14 +194,24 @@
return;
}
- editor->dialog = glade_xml_get_widget (editor->xml, "NMConnectionEditor");
- g_signal_connect (G_OBJECT (editor->dialog), "response", G_CALLBACK (dialog_response_cb), editor);
-
+ editor->window = glade_xml_get_widget (editor->xml, "nm-connection-editor");
editor->ok_button = glade_xml_get_widget (editor->xml, "ok_button");
+ editor->cancel_button = glade_xml_get_widget (editor->xml, "cancel_button");
gtk_window_set_default_icon_name ("preferences-system-network");
editor->pages = NULL;
+
+ pk_action = polkit_action_new ();
+ polkit_action_set_action_id (pk_action, "org.freedesktop.network-manager-settings.system.modify");
+ editor->system_action = polkit_gnome_toggle_action_new_default ("system", pk_action,
+ _("Available to everyone..."),
+ _("Available to everyone"));
+ polkit_action_unref (pk_action);
+
+ editor->system_button = glade_xml_get_widget (editor->xml, "system_checkbutton");
+ gtk_action_connect_proxy (GTK_ACTION (editor->system_action), editor->system_button);
+ g_signal_connect_swapped (editor->system_button, "toggled", G_CALLBACK (connection_editor_validate), editor);
}
static void
@@ -206,7 +219,7 @@
{
NMConnectionEditor *editor = NM_CONNECTION_EDITOR (object);
- gtk_widget_hide (GTK_WIDGET (editor->dialog));
+ gtk_widget_hide (GTK_WIDGET (editor->window));
g_slist_foreach (editor->pages, (GFunc) g_object_unref, NULL);
g_slist_free (editor->pages);
@@ -215,9 +228,11 @@
if (editor->connection)
g_object_unref (editor->connection);
- gtk_widget_destroy (editor->dialog);
+ gtk_widget_destroy (editor->window);
g_object_unref (editor->xml);
+ g_object_unref (editor->system_action);
+
G_OBJECT_CLASS (nm_connection_editor_parent_class)->dispose (object);
}
@@ -267,26 +282,20 @@
NMSettingConnection *s_con;
GtkWidget *name;
GtkWidget *autoconnect;
- GtkWidget *system;
name = glade_xml_get_widget (editor->xml, "connection_name");
autoconnect = glade_xml_get_widget (editor->xml, "connection_autoconnect");
- system = glade_xml_get_widget (editor->xml, "connection_system");
s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (editor->connection, NM_TYPE_SETTING_CONNECTION));
if (s_con) {
gtk_entry_set_text (GTK_ENTRY (name), s_con->id);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (autoconnect), s_con->autoconnect);
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (system), nm_connection_get_scope (editor->connection) == NM_CONNECTION_SCOPE_SYSTEM);
} else {
gtk_entry_set_text (GTK_ENTRY (name), NULL);
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (autoconnect), FALSE);
}
- g_signal_connect_swapped (name, "changed",
- G_CALLBACK (connection_editor_validate), editor);
- g_signal_connect_swapped (autoconnect, "toggled",
- G_CALLBACK (connection_editor_validate), editor);
+ g_signal_connect_swapped (name, "changed", G_CALLBACK (connection_editor_validate), editor);
+ g_signal_connect_swapped (autoconnect, "toggled", G_CALLBACK (connection_editor_validate), editor);
}
static void
@@ -332,6 +341,15 @@
g_object_unref (editor->connection);
editor->connection = g_object_ref (connection);
+ if (nm_connection_get_scope (connection) == NM_CONNECTION_SCOPE_SYSTEM) {
+ gtk_action_block_activate_from (GTK_ACTION (editor->system_action), editor->system_button);
+ g_signal_handlers_block_by_func (editor->system_button, connection_editor_validate, editor);
+
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (editor->system_button), TRUE);
+
+ g_signal_handlers_unblock_by_func (editor->system_button, connection_editor_validate, editor);
+ gtk_action_unblock_activate_from (GTK_ACTION (editor->system_action), editor->system_button);
+ }
nm_connection_editor_update_title (editor);
s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (editor->connection, NM_TYPE_SETTING_CONNECTION));
@@ -371,34 +389,47 @@
{
g_return_if_fail (NM_IS_CONNECTION_EDITOR (editor));
- gtk_window_present (GTK_WINDOW (editor->dialog));
+ gtk_window_present (GTK_WINDOW (editor->window));
}
static void
-editor_response_cb (GtkDialog *dialog, gint response, gpointer user_data)
+cancel_button_clicked_cb (GtkWidget *widget, gpointer user_data)
{
- NMConnectionEditor *editor = NM_CONNECTION_EDITOR (user_data);
+ NMConnectionEditor *self = NM_CONNECTION_EDITOR (user_data);
- g_signal_emit (editor, editor_signals[EDITOR_DONE], 0, response);
+ gtk_widget_hide (widget);
+ g_signal_emit (self, editor_signals[EDITOR_DONE], 0, GTK_RESPONSE_CANCEL);
}
static void
-editor_close_cb (GtkDialog *dialog, gpointer user_data)
+editor_closed_cb (GtkWidget *widget, GdkEvent *event, gpointer user_data)
{
- gtk_dialog_response (dialog, GTK_RESPONSE_CLOSE);
+ cancel_button_clicked_cb (widget, user_data);
+}
+
+static void
+ok_button_clicked_cb (GtkWidget *widget, gpointer user_data)
+{
+ NMConnectionEditor *self = NM_CONNECTION_EDITOR (user_data);
+
+ gtk_widget_hide (widget);
+ g_signal_emit (self, editor_signals[EDITOR_DONE], 0, GTK_RESPONSE_OK);
}
void
-nm_connection_editor_run (NMConnectionEditor *editor)
+nm_connection_editor_run (NMConnectionEditor *self)
{
- g_return_if_fail (NM_IS_CONNECTION_EDITOR (editor));
+ g_return_if_fail (NM_IS_CONNECTION_EDITOR (self));
+
+ g_signal_connect (G_OBJECT (self->window), "delete-event",
+ G_CALLBACK (editor_closed_cb), self);
- 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);
+ g_signal_connect (G_OBJECT (self->ok_button), "clicked",
+ G_CALLBACK (ok_button_clicked_cb), self);
+ g_signal_connect (G_OBJECT (self->cancel_button), "clicked",
+ G_CALLBACK (cancel_button_clicked_cb), self);
- nm_connection_editor_present (editor);
+ nm_connection_editor_present (self);
}
void
Modified: trunk/src/connection-editor/nm-connection-editor.glade
==============================================================================
--- trunk/src/connection-editor/nm-connection-editor.glade (original)
+++ trunk/src/connection-editor/nm-connection-editor.glade Thu Oct 23 14:48:32 2008
@@ -2,133 +2,6 @@
<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
<!--*- mode: xml -*-->
<glade-interface>
- <widget class="GtkDialog" id="NMConnectionEditor">
- <property name="border_width">5</property>
- <property name="title" translatable="yes">Connection Editor</property>
- <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
- <property name="has_separator">False</property>
- <child internal-child="vbox">
- <widget class="GtkVBox" id="dialog-vbox1">
- <property name="visible">True</property>
- <property name="spacing">2</property>
- <child>
- <widget class="GtkVBox" id="vbox1">
- <property name="visible">True</property>
- <property name="border_width">5</property>
- <property name="spacing">6</property>
- <child>
- <widget class="GtkHBox" id="hbox2">
- <property name="visible">True</property>
- <property name="spacing">12</property>
- <child>
- <widget class="GtkLabel" id="label40">
- <property name="visible">True</property>
- <property name="label" translatable="yes">Connection _name:</property>
- <property name="use_underline">True</property>
- <property name="mnemonic_widget">connection_name</property>
- </widget>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- </packing>
- </child>
- <child>
- <widget class="GtkEntry" id="connection_name">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- </widget>
- <packing>
- <property name="position">1</property>
- </packing>
- </child>
- </widget>
- <packing>
- <property name="expand">False</property>
- </packing>
- </child>
- <child>
- <widget class="GtkCheckButton" id="connection_autoconnect">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="label" translatable="yes">Connect _automatically</property>
- <property name="use_underline">True</property>
- <property name="response_id">0</property>
- <property name="active">True</property>
- <property name="draw_indicator">True</property>
- </widget>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">1</property>
- </packing>
- </child>
- <child>
- <widget class="GtkCheckButton" id="connection_system">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="label" translatable="yes">System setting</property>
- <property name="use_underline">True</property>
- <property name="response_id">0</property>
- <property name="draw_indicator">True</property>
- </widget>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">2</property>
- </packing>
- </child>
- <child>
- <widget class="GtkNotebook" id="notebook">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- </widget>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">3</property>
- </packing>
- </child>
- </widget>
- <packing>
- <property name="position">1</property>
- </packing>
- </child>
- <child internal-child="action_area">
- <widget class="GtkHButtonBox" id="dialog-action_area1">
- <property name="visible">True</property>
- <property name="layout_style">GTK_BUTTONBOX_END</property>
- <child>
- <widget class="GtkButton" id="cancel_button">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="can_default">True</property>
- <property name="label">gtk-cancel</property>
- <property name="use_stock">True</property>
- <property name="response_id">-6</property>
- </widget>
- </child>
- <child>
- <widget class="GtkButton" id="ok_button">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="can_default">True</property>
- <property name="label">gtk-ok</property>
- <property name="use_stock">True</property>
- <property name="response_id">-5</property>
- </widget>
- <packing>
- <property name="position">1</property>
- </packing>
- </child>
- </widget>
- <packing>
- <property name="expand">False</property>
- <property name="pack_type">GTK_PACK_END</property>
- </packing>
- </child>
- </widget>
- </child>
- </widget>
<widget class="GtkDialog" id="NMConnectionList">
<property name="border_width">4</property>
<property name="title" translatable="yes">Network Connections</property>
@@ -642,4 +515,147 @@
</widget>
</child>
</widget>
+ <widget class="GtkWindow" id="nm-connection-editor">
+ <property name="modal">True</property>
+ <property name="window_position">GTK_WIN_POS_CENTER</property>
+ <property name="destroy_with_parent">True</property>
+ <property name="icon_name">preferences-system-network</property>
+ <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
+ <child>
+ <widget class="GtkVBox" id="ce-vbox">
+ <property name="visible">True</property>
+ <property name="spacing">6</property>
+ <child>
+ <widget class="GtkVBox" id="vbox3">
+ <property name="visible">True</property>
+ <property name="border_width">5</property>
+ <property name="spacing">6</property>
+ <child>
+ <widget class="GtkHBox" id="hbox3">
+ <property name="visible">True</property>
+ <property name="spacing">12</property>
+ <child>
+ <widget class="GtkLabel" id="label1">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Connection _name:</property>
+ <property name="use_underline">True</property>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkEntry" id="connection_name">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ </widget>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkCheckButton" id="connection_autoconnect">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="label" translatable="yes">Connect _automatically</property>
+ <property name="use_underline">True</property>
+ <property name="response_id">0</property>
+ <property name="active">True</property>
+ <property name="draw_indicator">True</property>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkNotebook" id="notebook">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ </widget>
+ </child>
+ <child>
+ <widget class="GtkHBox" id="hbox1">
+ <property name="visible">True</property>
+ <property name="spacing">6</property>
+ <child>
+ <widget class="GtkHButtonBox" id="system_hbox">
+ <property name="visible">True</property>
+ <property name="spacing">6</property>
+ <child>
+ <widget class="GtkCheckButton" id="system_checkbutton">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="label" translatable="yes">Available to all users...</property>
+ <property name="response_id">0</property>
+ <property name="draw_indicator">True</property>
+ </widget>
+ </child>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="padding">6</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkHButtonBox" id="hbuttonbox2">
+ <property name="visible">True</property>
+ <property name="spacing">6</property>
+ <property name="layout_style">GTK_BUTTONBOX_END</property>
+ <child>
+ <widget class="GtkButton" id="cancel_button">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="label" translatable="yes">gtk-cancel</property>
+ <property name="use_stock">True</property>
+ <property name="response_id">0</property>
+ </widget>
+ </child>
+ <child>
+ <widget class="GtkButton" id="ok_button">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="label" translatable="yes">gtk-ok</property>
+ <property name="use_stock">True</property>
+ <property name="response_id">0</property>
+ </widget>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="padding">6</property>
+ <property name="pack_type">GTK_PACK_END</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="padding">6</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </widget>
+ </child>
+ </widget>
</glade-interface>
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 Thu Oct 23 14:48:32 2008
@@ -26,6 +26,11 @@
#include <glib-object.h>
#include <glade/glade-xml.h>
#include <nm-settings.h>
+#ifdef NO_POLKIT_GNOME
+#include "polkit-06-helpers.h"
+#else
+#include <polkit-gnome/polkit-gnome.h>
+#endif
#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))
@@ -37,10 +42,14 @@
/* private data */
NMConnection *connection;
+ PolKitGnomeToggleAction *system_action;
+ GtkWidget *system_button;
+
GSList *pages;
GladeXML *xml;
- GtkWidget *dialog;
+ GtkWidget *window;
GtkWidget *ok_button;
+ GtkWidget *cancel_button;
} NMConnectionEditor;
typedef struct {
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 Thu Oct 23 14:48:32 2008
@@ -782,6 +782,7 @@
ctype = nm_connection_lookup_setting_type (connection_type);
connection = nm_connection_new ();
+ nm_connection_set_scope (connection, NM_CONNECTION_SCOPE_USER);
s_con = NM_SETTING_CONNECTION (nm_setting_connection_new ());
s_con->uuid = nm_utils_uuid_generate ();
nm_connection_add_setting (connection, NM_SETTING (s_con));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]