Re: Making system scope the default one



On Monday 25 of October 2010 14:48:19 Ozan Çağlayan wrote:
> Pazartesi 25 Ekim 2010 günü (saat 13:15:49) Jirka Klimes şunları yazmıştı:
> > On Saturday 23 of October 2010 13:11:48 Ozan Çağlayan wrote:
> > 
> > diff --git a/src/connection-editor/ce-page.c
> > b/src/connection-editor/ce-page.c index bcb90de..0fa1916 100644
> > --- a/src/connection-editor/ce-page.c
> > +++ b/src/connection-editor/ce-page.c
> > @@ -407,7 +407,7 @@ ce_page_new_connection (const char *format,
> > 
> >         GSList *connections;
> > 	
> > 	connection = nm_connection_new ();
> > 
> > -	nm_connection_set_scope (connection, NM_CONNECTION_SCOPE_USER);
> > +	nm_connection_set_scope (connection, NM_CONNECTION_SCOPE_SYSTEM);
> > 
> > 	s_con = NM_SETTING_CONNECTION (nm_setting_connection_new ());
> > 	nm_connection_add_setting (connection, NM_SETTING (s_con));
> 
> Ah, thanks this seems to fix the issue but a minor glitch stays. When we
> uncheck the system_checkbutton in a new connection window, the buttons
> stays polkit-aware, but actually the connection is added to user scope.
> I've done the following modification in nm-connection-editor.c but can't
> be sure if it is the correct place/way to handle this.
> 
> 
> @@ -264,8 +264,7 @@ system_checkbutton_toggled_cb (GtkWidget
>  ·   * original connection scope was USER and the "system" checkbutton is
>  ·   * unchecked.
>  ·   */
> -·  if (   !gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget))
> -·      && (editor->orig_scope == NM_CONNECTION_SCOPE_USER))
> +·  if (   !gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)))
>  ·  ·   use_polkit = FALSE;
> 
> 

That change would also allow users to switch existing system connections to 
user without polkit, which you don't want.

Polkit protection is not needed just when the existing connection is user or
it is new (not stored yet). Something like this could do that:

diff --git a/src/connection-editor/nm-connection-editor.c b/src/connection-
editor/nm-connection-editor.c
index 39c8b31..d0afc0b 100644
--- a/src/connection-editor/nm-connection-editor.c
+++ b/src/connection-editor/nm-connection-editor.c
@@ -265,7 +265,7 @@ system_checkbutton_toggled_cb (GtkWidget *widget, 
NMConnectionEditor *editor)
         * unchecked.
         */
        if (   !gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget))
-           && (editor->orig_scope == NM_CONNECTION_SCOPE_USER))
+           && (editor->orig_scope == NM_CONNECTION_SCOPE_USER || editor-
>connection_is_new))
                use_polkit = FALSE;

        ce_polkit_button_set_use_polkit (CE_POLKIT_BUTTON (editor->ok_button), 
use_polkit);
diff --git a/src/connection-editor/nm-connection-editor.h b/src/connection-
editor/nm-connection-editor.h
index 4fe21e6..c95335e 100644
--- a/src/connection-editor/nm-connection-editor.h
+++ b/src/connection-editor/nm-connection-editor.h
@@ -59,6 +59,7 @@ typedef struct {
        GtkWidget *cancel_button;

        gboolean busy;
+       gboolean connection_is_new;
 } NMConnectionEditor;

 typedef struct {
diff --git a/src/connection-editor/nm-connection-list.c b/src/connection-
editor/nm-connection-list.c
index 32fbc49..e0eb5e0 100644
--- a/src/connection-editor/nm-connection-list.c
+++ b/src/connection-editor/nm-connection-list.c
@@ -676,6 +676,9 @@ really_add_connection (NMConnection *connection,
                return;
        }

+       /* Mark the connection as unsaved yet */
+       editor->connection_is_new = TRUE;
+
        g_signal_connect (editor, "done", G_CALLBACK (add_response_cb), info);
        g_hash_table_insert (info->list->editors, connection, editor);

Jirka


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]