connection-editor: Use GtkTemplate
This commit is contained in:
parent
52fdf95c41
commit
91af270cce
7 changed files with 76 additions and 111 deletions
|
@ -800,14 +800,6 @@ panel_check_network_manager_version (CcNetworkPanel *panel)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
editor_done (NetConnectionEditor *editor,
|
|
||||||
gboolean success,
|
|
||||||
gpointer user_data)
|
|
||||||
{
|
|
||||||
g_object_unref (editor);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
create_connection_cb (GtkWidget *button,
|
create_connection_cb (GtkWidget *button,
|
||||||
CcNetworkPanel *self)
|
CcNetworkPanel *self)
|
||||||
|
@ -817,7 +809,6 @@ create_connection_cb (GtkWidget *button,
|
||||||
|
|
||||||
toplevel = GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (self)));
|
toplevel = GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (self)));
|
||||||
editor = net_connection_editor_new (toplevel, NULL, NULL, NULL, self->client);
|
editor = net_connection_editor_new (toplevel, NULL, NULL, NULL, self->client);
|
||||||
g_signal_connect (editor, "done", G_CALLBACK (editor_done), self);
|
|
||||||
net_connection_editor_run (editor);
|
net_connection_editor_run (editor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<interface>
|
<interface>
|
||||||
<!-- interface-requires gtk+ 3.0 -->
|
<!-- interface-requires gtk+ 3.0 -->
|
||||||
<object class="GtkDialog" id="details_dialog">
|
<template class="NetConnectionEditor" parent="GtkDialog">
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
<property name="border_width">0</property>
|
<property name="border_width">0</property>
|
||||||
<property name="resizable">False</property>
|
<property name="resizable">False</property>
|
||||||
|
@ -9,24 +9,28 @@
|
||||||
<property name="default_width">500</property>
|
<property name="default_width">500</property>
|
||||||
<property name="default_height">300</property>
|
<property name="default_height">300</property>
|
||||||
<property name="type_hint">dialog</property>
|
<property name="type_hint">dialog</property>
|
||||||
|
<!-- This doesn't seem to work for a template, so it is also hardcoded. -->
|
||||||
<property name="use_header_bar">1</property>
|
<property name="use_header_bar">1</property>
|
||||||
|
<signal name="delete-event" handler="delete_event_cb" swapped="yes"/>
|
||||||
<child type="action">
|
<child type="action">
|
||||||
<object class="GtkButton" id="details_cancel_button">
|
<object class="GtkButton" id="cancel_button">
|
||||||
<property name="label" translatable="yes">_Cancel</property>
|
<property name="label" translatable="yes">_Cancel</property>
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">True</property>
|
<property name="can_focus">True</property>
|
||||||
<property name="receives_default">True</property>
|
<property name="receives_default">True</property>
|
||||||
<property name="use_underline">True</property>
|
<property name="use_underline">True</property>
|
||||||
|
<signal name="clicked" handler="cancel_clicked_cb" object="NetConnectionEditor" swapped="yes"/>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<child type="action">
|
<child type="action">
|
||||||
<object class="GtkButton" id="details_apply_button">
|
<object class="GtkButton" id="apply_button">
|
||||||
<property name="label" translatable="yes">_Apply</property>
|
<property name="label" translatable="yes">_Apply</property>
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">True</property>
|
<property name="can_focus">True</property>
|
||||||
<property name="can_default">True</property>
|
<property name="can_default">True</property>
|
||||||
<property name="receives_default">True</property>
|
<property name="receives_default">True</property>
|
||||||
<property name="use_underline">True</property>
|
<property name="use_underline">True</property>
|
||||||
|
<signal name="clicked" handler="apply_clicked_cb" object="NetConnectionEditor" swapped="yes"/>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<child internal-child="vbox">
|
<child internal-child="vbox">
|
||||||
|
@ -36,7 +40,7 @@
|
||||||
<property name="spacing">0</property>
|
<property name="spacing">0</property>
|
||||||
<property name="border_width">0</property>
|
<property name="border_width">0</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkNotebook" id="details_toplevel_notebook">
|
<object class="GtkNotebook" id="toplevel_notebook">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">True</property>
|
<property name="can_focus">True</property>
|
||||||
<property name="show_tabs">False</property>
|
<property name="show_tabs">False</property>
|
||||||
|
@ -46,7 +50,7 @@
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkNotebook" id="details_notebook">
|
<object class="GtkNotebook" id="notebook">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">True</property>
|
<property name="can_focus">True</property>
|
||||||
<property name="show_border">False</property>
|
<property name="show_border">False</property>
|
||||||
|
@ -65,16 +69,16 @@
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkBox" id="details_add_connection_outer_box">
|
<object class="GtkBox" id="add_connection_outer_box">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkBox" id="details_add_connection_inner_box">
|
<object class="GtkBox" id="add_connection_inner_box">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
<property name="orientation">vertical</property>
|
<property name="orientation">vertical</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkFrame" id="details_add_connection_frame">
|
<object class="GtkFrame" id="add_connection_frame">
|
||||||
<property name="width_request">300</property>
|
<property name="width_request">300</property>
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
|
@ -123,8 +127,8 @@
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<action-widgets>
|
<action-widgets>
|
||||||
<action-widget response="cancel">details_cancel_button</action-widget>
|
<action-widget response="cancel">cancel_button</action-widget>
|
||||||
<action-widget response="apply" default="true">details_apply_button</action-widget>
|
<action-widget response="apply" default="true">apply_button</action-widget>
|
||||||
</action-widgets>
|
</action-widgets>
|
||||||
</object>
|
</template>
|
||||||
</interface>
|
</interface>
|
||||||
|
|
|
@ -47,17 +47,29 @@ enum {
|
||||||
|
|
||||||
static guint signals[LAST_SIGNAL] = { 0 };
|
static guint signals[LAST_SIGNAL] = { 0 };
|
||||||
|
|
||||||
G_DEFINE_TYPE (NetConnectionEditor, net_connection_editor, G_TYPE_OBJECT)
|
G_DEFINE_TYPE (NetConnectionEditor, net_connection_editor, GTK_TYPE_DIALOG)
|
||||||
|
|
||||||
static void page_changed (CEPage *page, gpointer user_data);
|
static void page_changed (CEPage *page, gpointer user_data);
|
||||||
|
|
||||||
static void
|
static void
|
||||||
cancel_editing (NetConnectionEditor *editor)
|
cancel_editing (NetConnectionEditor *editor)
|
||||||
{
|
{
|
||||||
gtk_widget_hide (editor->window);
|
gtk_widget_hide (GTK_WIDGET (editor));
|
||||||
g_signal_emit (editor, signals[DONE], 0, FALSE);
|
g_signal_emit (editor, signals[DONE], 0, FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
delete_event_cb (NetConnectionEditor *editor)
|
||||||
|
{
|
||||||
|
cancel_editing (editor);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
cancel_clicked_cb (NetConnectionEditor *editor)
|
||||||
|
{
|
||||||
|
cancel_editing (editor);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
update_connection (NetConnectionEditor *editor)
|
update_connection (NetConnectionEditor *editor)
|
||||||
{
|
{
|
||||||
|
@ -72,7 +84,7 @@ static void
|
||||||
update_complete (NetConnectionEditor *editor,
|
update_complete (NetConnectionEditor *editor,
|
||||||
gboolean success)
|
gboolean success)
|
||||||
{
|
{
|
||||||
gtk_widget_hide (editor->window);
|
gtk_widget_hide (GTK_WIDGET (editor));
|
||||||
g_signal_emit (editor, signals[DONE], 0, success);
|
g_signal_emit (editor, signals[DONE], 0, success);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -121,7 +133,7 @@ added_connection_cb (GObject *source_object,
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
apply_edits (NetConnectionEditor *editor)
|
apply_clicked_cb (NetConnectionEditor *editor)
|
||||||
{
|
{
|
||||||
update_connection (editor);
|
update_connection (editor);
|
||||||
|
|
||||||
|
@ -145,38 +157,7 @@ apply_edits (NetConnectionEditor *editor)
|
||||||
static void
|
static void
|
||||||
net_connection_editor_init (NetConnectionEditor *editor)
|
net_connection_editor_init (NetConnectionEditor *editor)
|
||||||
{
|
{
|
||||||
GError *error = NULL;
|
gtk_widget_init_template (GTK_WIDGET (editor));
|
||||||
|
|
||||||
editor->builder = gtk_builder_new ();
|
|
||||||
|
|
||||||
gtk_builder_add_from_resource (editor->builder,
|
|
||||||
"/org/gnome/control-center/network/connection-editor.ui",
|
|
||||||
&error);
|
|
||||||
if (error != NULL) {
|
|
||||||
g_warning ("Could not load ui file: %s", error->message);
|
|
||||||
g_error_free (error);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
editor->window = GTK_WIDGET (gtk_builder_get_object (editor->builder, "details_dialog"));
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
net_connection_editor_run (NetConnectionEditor *editor)
|
|
||||||
{
|
|
||||||
GtkWidget *button;
|
|
||||||
|
|
||||||
button = GTK_WIDGET (gtk_builder_get_object (editor->builder, "details_cancel_button"));
|
|
||||||
g_signal_connect_swapped (button, "clicked",
|
|
||||||
G_CALLBACK (cancel_editing), editor);
|
|
||||||
g_signal_connect_swapped (editor->window, "delete-event",
|
|
||||||
G_CALLBACK (cancel_editing), editor);
|
|
||||||
|
|
||||||
button = GTK_WIDGET (gtk_builder_get_object (editor->builder, "details_apply_button"));
|
|
||||||
g_signal_connect_swapped (button, "clicked",
|
|
||||||
G_CALLBACK (apply_edits), editor);
|
|
||||||
|
|
||||||
net_connection_editor_present (editor);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -192,12 +173,7 @@ net_connection_editor_finalize (GObject *object)
|
||||||
g_signal_handler_disconnect (editor->client, editor->permission_id);
|
g_signal_handler_disconnect (editor->client, editor->permission_id);
|
||||||
g_clear_object (&editor->connection);
|
g_clear_object (&editor->connection);
|
||||||
g_clear_object (&editor->orig_connection);
|
g_clear_object (&editor->orig_connection);
|
||||||
if (editor->window) {
|
|
||||||
gtk_widget_destroy (editor->window);
|
|
||||||
editor->window = NULL;
|
|
||||||
}
|
|
||||||
g_clear_object (&editor->parent_window);
|
g_clear_object (&editor->parent_window);
|
||||||
g_clear_object (&editor->builder);
|
|
||||||
g_clear_object (&editor->device);
|
g_clear_object (&editor->device);
|
||||||
g_clear_object (&editor->client);
|
g_clear_object (&editor->client);
|
||||||
g_clear_object (&editor->ap);
|
g_clear_object (&editor->ap);
|
||||||
|
@ -209,6 +185,7 @@ static void
|
||||||
net_connection_editor_class_init (NetConnectionEditorClass *class)
|
net_connection_editor_class_init (NetConnectionEditorClass *class)
|
||||||
{
|
{
|
||||||
GObjectClass *object_class = G_OBJECT_CLASS (class);
|
GObjectClass *object_class = G_OBJECT_CLASS (class);
|
||||||
|
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
|
||||||
|
|
||||||
g_resources_register (net_connection_editor_get_resource ());
|
g_resources_register (net_connection_editor_get_resource ());
|
||||||
|
|
||||||
|
@ -221,6 +198,17 @@ net_connection_editor_class_init (NetConnectionEditorClass *class)
|
||||||
NULL, NULL,
|
NULL, NULL,
|
||||||
NULL,
|
NULL,
|
||||||
G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
|
G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
|
||||||
|
|
||||||
|
gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/control-center/network/connection-editor.ui");
|
||||||
|
|
||||||
|
gtk_widget_class_bind_template_child (widget_class, NetConnectionEditor, add_connection_frame);
|
||||||
|
gtk_widget_class_bind_template_child (widget_class, NetConnectionEditor, apply_button);
|
||||||
|
gtk_widget_class_bind_template_child (widget_class, NetConnectionEditor, cancel_button);
|
||||||
|
gtk_widget_class_bind_template_child (widget_class, NetConnectionEditor, notebook);
|
||||||
|
gtk_widget_class_bind_template_child (widget_class, NetConnectionEditor, toplevel_notebook);
|
||||||
|
gtk_widget_class_bind_template_callback (widget_class, delete_event_cb);
|
||||||
|
gtk_widget_class_bind_template_callback (widget_class, cancel_clicked_cb);
|
||||||
|
gtk_widget_class_bind_template_callback (widget_class, apply_clicked_cb);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -231,8 +219,8 @@ net_connection_editor_error_dialog (NetConnectionEditor *editor,
|
||||||
GtkWidget *dialog;
|
GtkWidget *dialog;
|
||||||
GtkWindow *parent;
|
GtkWindow *parent;
|
||||||
|
|
||||||
if (gtk_widget_is_visible (editor->window))
|
if (gtk_widget_is_visible (GTK_WIDGET (editor)))
|
||||||
parent = GTK_WINDOW (editor->window);
|
parent = GTK_WINDOW (editor);
|
||||||
else
|
else
|
||||||
parent = GTK_WINDOW (editor->parent_window);
|
parent = GTK_WINDOW (editor->parent_window);
|
||||||
|
|
||||||
|
@ -304,7 +292,7 @@ net_connection_editor_update_title (NetConnectionEditor *editor)
|
||||||
id = g_strdup (nm_connection_get_id (editor->connection));
|
id = g_strdup (nm_connection_get_id (editor->connection));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
gtk_window_set_title (GTK_WINDOW (editor->window), id);
|
gtk_window_set_title (GTK_WINDOW (editor), id);
|
||||||
g_free (id);
|
g_free (id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -365,7 +353,7 @@ validate (NetConnectionEditor *editor)
|
||||||
|
|
||||||
update_sensitivity (editor);
|
update_sensitivity (editor);
|
||||||
done:
|
done:
|
||||||
gtk_widget_set_sensitive (GTK_WIDGET (gtk_builder_get_object (editor->builder, "details_apply_button")), valid && editor->is_changed);
|
gtk_widget_set_sensitive (GTK_WIDGET (editor->apply_button), valid && editor->is_changed);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -389,16 +377,13 @@ idle_validate (gpointer user_data)
|
||||||
static void
|
static void
|
||||||
recheck_initialization (NetConnectionEditor *editor)
|
recheck_initialization (NetConnectionEditor *editor)
|
||||||
{
|
{
|
||||||
GtkNotebook *notebook;
|
|
||||||
|
|
||||||
if (!editor_is_initialized (editor))
|
if (!editor_is_initialized (editor))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
notebook = GTK_NOTEBOOK (gtk_builder_get_object (editor->builder, "details_notebook"));
|
gtk_notebook_set_current_page (editor->notebook, 0);
|
||||||
gtk_notebook_set_current_page (notebook, 0);
|
|
||||||
|
|
||||||
if (editor->show_when_initialized)
|
if (editor->show_when_initialized)
|
||||||
gtk_window_present (GTK_WINDOW (editor->window));
|
gtk_window_present (GTK_WINDOW (editor));
|
||||||
|
|
||||||
g_idle_add (idle_validate, editor);
|
g_idle_add (idle_validate, editor);
|
||||||
}
|
}
|
||||||
|
@ -406,18 +391,16 @@ recheck_initialization (NetConnectionEditor *editor)
|
||||||
static void
|
static void
|
||||||
page_initialized (CEPage *page, GError *error, NetConnectionEditor *editor)
|
page_initialized (CEPage *page, GError *error, NetConnectionEditor *editor)
|
||||||
{
|
{
|
||||||
GtkNotebook *notebook;
|
|
||||||
GtkWidget *widget;
|
GtkWidget *widget;
|
||||||
GtkWidget *label;
|
GtkWidget *label;
|
||||||
gint position;
|
gint position;
|
||||||
GList *children, *l;
|
GList *children, *l;
|
||||||
gint i;
|
gint i;
|
||||||
|
|
||||||
notebook = GTK_NOTEBOOK (gtk_builder_get_object (editor->builder, "details_notebook"));
|
|
||||||
widget = ce_page_get_page (page);
|
widget = ce_page_get_page (page);
|
||||||
position = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (page), "position"));
|
position = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (page), "position"));
|
||||||
g_object_set_data (G_OBJECT (widget), "position", GINT_TO_POINTER (position));
|
g_object_set_data (G_OBJECT (widget), "position", GINT_TO_POINTER (position));
|
||||||
children = gtk_container_get_children (GTK_CONTAINER (notebook));
|
children = gtk_container_get_children (GTK_CONTAINER (editor->notebook));
|
||||||
for (l = children, i = 0; l; l = l->next, i++) {
|
for (l = children, i = 0; l; l = l->next, i++) {
|
||||||
gint pos = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (l->data), "position"));
|
gint pos = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (l->data), "position"));
|
||||||
if (pos > position)
|
if (pos > position)
|
||||||
|
@ -427,7 +410,7 @@ page_initialized (CEPage *page, GError *error, NetConnectionEditor *editor)
|
||||||
|
|
||||||
label = gtk_label_new (ce_page_get_title (page));
|
label = gtk_label_new (ce_page_get_title (page));
|
||||||
|
|
||||||
gtk_notebook_insert_page (notebook, widget, label, i);
|
gtk_notebook_insert_page (editor->notebook, widget, label, i);
|
||||||
|
|
||||||
editor->initializing_pages = g_slist_remove (editor->initializing_pages, page);
|
editor->initializing_pages = g_slist_remove (editor->initializing_pages, page);
|
||||||
editor->pages = g_slist_append (editor->pages, page);
|
editor->pages = g_slist_append (editor->pages, page);
|
||||||
|
@ -511,10 +494,7 @@ net_connection_editor_set_connection (NetConnectionEditor *editor,
|
||||||
nm_connection_get_uuid (connection));
|
nm_connection_get_uuid (connection));
|
||||||
|
|
||||||
if (editor->is_new_connection) {
|
if (editor->is_new_connection) {
|
||||||
GtkWidget *button;
|
gtk_button_set_label (editor->apply_button, _("_Add"));
|
||||||
|
|
||||||
button = GTK_WIDGET (gtk_builder_get_object (editor->builder, "details_apply_button"));
|
|
||||||
gtk_button_set_label (GTK_BUTTON (button), _("_Add"));
|
|
||||||
editor->is_changed = TRUE;
|
editor->is_changed = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -623,15 +603,13 @@ complete_vpn_connection (NetConnectionEditor *editor, NMConnection *connection)
|
||||||
static void
|
static void
|
||||||
finish_add_connection (NetConnectionEditor *editor, NMConnection *connection)
|
finish_add_connection (NetConnectionEditor *editor, NMConnection *connection)
|
||||||
{
|
{
|
||||||
GtkNotebook *notebook;
|
|
||||||
GtkBin *frame;
|
GtkBin *frame;
|
||||||
|
|
||||||
frame = GTK_BIN (gtk_builder_get_object (editor->builder, "details_add_connection_frame"));
|
frame = GTK_BIN (editor->add_connection_frame);
|
||||||
gtk_widget_destroy (gtk_bin_get_child (frame));
|
gtk_widget_destroy (gtk_bin_get_child (frame));
|
||||||
|
|
||||||
notebook = GTK_NOTEBOOK (gtk_builder_get_object (editor->builder, "details_toplevel_notebook"));
|
gtk_notebook_set_current_page (editor->toplevel_notebook, 0);
|
||||||
gtk_notebook_set_current_page (notebook, 0);
|
gtk_widget_show (GTK_WIDGET (editor->apply_button));
|
||||||
gtk_widget_show (GTK_WIDGET (gtk_builder_get_object (editor->builder, "details_apply_button")));
|
|
||||||
|
|
||||||
if (connection)
|
if (connection)
|
||||||
net_connection_editor_set_connection (editor, connection);
|
net_connection_editor_set_connection (editor, connection);
|
||||||
|
@ -661,7 +639,7 @@ vpn_type_activated (GtkListBox *list, GtkWidget *row, NetConnectionEditor *edito
|
||||||
NMSettingConnection *s_con;
|
NMSettingConnection *s_con;
|
||||||
|
|
||||||
if (!strcmp (service_name, "import")) {
|
if (!strcmp (service_name, "import")) {
|
||||||
vpn_import (GTK_WINDOW (editor->window), vpn_import_complete, editor);
|
vpn_import (GTK_WINDOW (editor), vpn_import_complete, editor);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -762,12 +740,10 @@ select_vpn_type (NetConnectionEditor *editor, GtkListBox *list)
|
||||||
static void
|
static void
|
||||||
net_connection_editor_add_connection (NetConnectionEditor *editor)
|
net_connection_editor_add_connection (NetConnectionEditor *editor)
|
||||||
{
|
{
|
||||||
GtkNotebook *notebook;
|
|
||||||
GtkContainer *frame;
|
GtkContainer *frame;
|
||||||
GtkListBox *list;
|
GtkListBox *list;
|
||||||
|
|
||||||
notebook = GTK_NOTEBOOK (gtk_builder_get_object (editor->builder, "details_toplevel_notebook"));
|
frame = GTK_CONTAINER (editor->add_connection_frame);
|
||||||
frame = GTK_CONTAINER (gtk_builder_get_object (editor->builder, "details_add_connection_frame"));
|
|
||||||
|
|
||||||
list = GTK_LIST_BOX (gtk_list_box_new ());
|
list = GTK_LIST_BOX (gtk_list_box_new ());
|
||||||
gtk_list_box_set_selection_mode (list, GTK_SELECTION_NONE);
|
gtk_list_box_set_selection_mode (list, GTK_SELECTION_NONE);
|
||||||
|
@ -778,9 +754,9 @@ net_connection_editor_add_connection (NetConnectionEditor *editor)
|
||||||
gtk_widget_show_all (GTK_WIDGET (list));
|
gtk_widget_show_all (GTK_WIDGET (list));
|
||||||
gtk_container_add (frame, GTK_WIDGET (list));
|
gtk_container_add (frame, GTK_WIDGET (list));
|
||||||
|
|
||||||
gtk_notebook_set_current_page (notebook, 1);
|
gtk_notebook_set_current_page (editor->toplevel_notebook, 1);
|
||||||
gtk_widget_hide (GTK_WIDGET (gtk_builder_get_object (editor->builder, "details_apply_button")));
|
gtk_widget_hide (GTK_WIDGET (editor->apply_button));
|
||||||
gtk_window_set_title (GTK_WINDOW (editor->window), _("Add VPN"));
|
gtk_window_set_title (GTK_WINDOW (editor), _("Add VPN"));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -809,11 +785,14 @@ net_connection_editor_new (GtkWindow *parent_window,
|
||||||
{
|
{
|
||||||
NetConnectionEditor *editor;
|
NetConnectionEditor *editor;
|
||||||
|
|
||||||
editor = g_object_new (NET_TYPE_CONNECTION_EDITOR, NULL);
|
editor = g_object_new (NET_TYPE_CONNECTION_EDITOR,
|
||||||
|
/* This doesn't seem to work for a template, so it is also hardcoded. */
|
||||||
|
"use-header-bar", 1,
|
||||||
|
NULL);
|
||||||
|
|
||||||
if (parent_window) {
|
if (parent_window) {
|
||||||
editor->parent_window = GTK_WIDGET (g_object_ref (parent_window));
|
editor->parent_window = GTK_WIDGET (g_object_ref (parent_window));
|
||||||
gtk_window_set_transient_for (GTK_WINDOW (editor->window),
|
gtk_window_set_transient_for (GTK_WINDOW (editor),
|
||||||
parent_window);
|
parent_window);
|
||||||
}
|
}
|
||||||
if (ap)
|
if (ap)
|
||||||
|
@ -835,13 +814,13 @@ net_connection_editor_new (GtkWindow *parent_window,
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
net_connection_editor_present (NetConnectionEditor *editor)
|
net_connection_editor_run (NetConnectionEditor *editor)
|
||||||
{
|
{
|
||||||
if (!editor_is_initialized (editor)) {
|
if (!editor_is_initialized (editor)) {
|
||||||
editor->show_when_initialized = TRUE;
|
editor->show_when_initialized = TRUE;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
gtk_window_present (GTK_WINDOW (editor->window));
|
gtk_window_present (GTK_WINDOW (editor));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -886,6 +865,6 @@ void
|
||||||
net_connection_editor_set_title (NetConnectionEditor *editor,
|
net_connection_editor_set_title (NetConnectionEditor *editor,
|
||||||
const gchar *title)
|
const gchar *title)
|
||||||
{
|
{
|
||||||
gtk_window_set_title (GTK_WINDOW (editor->window), title);
|
gtk_window_set_title (GTK_WINDOW (editor), title);
|
||||||
editor->title_set = TRUE;
|
editor->title_set = TRUE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,7 +41,7 @@ typedef struct _NetConnectionEditorClass NetConnectionEditorClass;
|
||||||
|
|
||||||
struct _NetConnectionEditor
|
struct _NetConnectionEditor
|
||||||
{
|
{
|
||||||
GObject parent;
|
GtkDialog parent;
|
||||||
|
|
||||||
GtkWidget *parent_window;
|
GtkWidget *parent_window;
|
||||||
NMClient *client;
|
NMClient *client;
|
||||||
|
@ -53,8 +53,11 @@ struct _NetConnectionEditor
|
||||||
gboolean is_changed;
|
gboolean is_changed;
|
||||||
NMAccessPoint *ap;
|
NMAccessPoint *ap;
|
||||||
|
|
||||||
GtkBuilder *builder;
|
GtkButton *cancel_button;
|
||||||
GtkWidget *window;
|
GtkButton *apply_button;
|
||||||
|
GtkNotebook *notebook;
|
||||||
|
GtkFrame *add_connection_frame;
|
||||||
|
GtkNotebook *toplevel_notebook;
|
||||||
|
|
||||||
GSList *initializing_pages;
|
GSList *initializing_pages;
|
||||||
GSList *pages;
|
GSList *pages;
|
||||||
|
@ -68,7 +71,7 @@ struct _NetConnectionEditor
|
||||||
|
|
||||||
struct _NetConnectionEditorClass
|
struct _NetConnectionEditorClass
|
||||||
{
|
{
|
||||||
GObjectClass parent_class;
|
GtkDialogClass parent_class;
|
||||||
|
|
||||||
void (*done) (NetConnectionEditor *details, gboolean success);
|
void (*done) (NetConnectionEditor *details, gboolean success);
|
||||||
};
|
};
|
||||||
|
@ -82,7 +85,6 @@ NetConnectionEditor *net_connection_editor_new (GtkWindow *parent_wi
|
||||||
void net_connection_editor_set_title (NetConnectionEditor *editor,
|
void net_connection_editor_set_title (NetConnectionEditor *editor,
|
||||||
const gchar *title);
|
const gchar *title);
|
||||||
void net_connection_editor_run (NetConnectionEditor *editor);
|
void net_connection_editor_run (NetConnectionEditor *editor);
|
||||||
void net_connection_editor_present (NetConnectionEditor *editor);
|
|
||||||
void net_connection_editor_forget (NetConnectionEditor *editor);
|
void net_connection_editor_forget (NetConnectionEditor *editor);
|
||||||
void net_connection_editor_reset (NetConnectionEditor *editor);
|
void net_connection_editor_reset (NetConnectionEditor *editor);
|
||||||
|
|
||||||
|
|
|
@ -247,7 +247,6 @@ editor_done (NetConnectionEditor *editor,
|
||||||
gboolean success,
|
gboolean success,
|
||||||
NetDeviceEthernet *device)
|
NetDeviceEthernet *device)
|
||||||
{
|
{
|
||||||
g_object_unref (editor);
|
|
||||||
device_ethernet_refresh_ui (device);
|
device_ethernet_refresh_ui (device);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1557,14 +1557,6 @@ ap_sort (gconstpointer a, gconstpointer b, gpointer data)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
editor_done (NetConnectionEditor *editor,
|
|
||||||
gboolean success,
|
|
||||||
NetDeviceWifi *device_wifi)
|
|
||||||
{
|
|
||||||
g_object_unref (editor);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
show_details_for_row (NetDeviceWifi *device_wifi, CcWifiConnectionRow *row, CcWifiConnectionList *list)
|
show_details_for_row (NetDeviceWifi *device_wifi, CcWifiConnectionRow *row, CcWifiConnectionList *list)
|
||||||
{
|
{
|
||||||
|
@ -1583,7 +1575,6 @@ show_details_for_row (NetDeviceWifi *device_wifi, CcWifiConnectionRow *row, CcWi
|
||||||
device = net_device_get_nm_device (NET_DEVICE (device_wifi));
|
device = net_device_get_nm_device (NET_DEVICE (device_wifi));
|
||||||
client = net_object_get_client (NET_OBJECT (device_wifi));
|
client = net_object_get_client (NET_OBJECT (device_wifi));
|
||||||
editor = net_connection_editor_new (GTK_WINDOW (window), connection, device, ap, client);
|
editor = net_connection_editor_new (GTK_WINDOW (window), connection, device, ap, client);
|
||||||
g_signal_connect (editor, "done", G_CALLBACK (editor_done), device_wifi);
|
|
||||||
net_connection_editor_run (editor);
|
net_connection_editor_run (editor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -270,7 +270,6 @@ editor_done (NetConnectionEditor *editor,
|
||||||
gboolean success,
|
gboolean success,
|
||||||
NetVpn *vpn)
|
NetVpn *vpn)
|
||||||
{
|
{
|
||||||
g_object_unref (editor);
|
|
||||||
net_object_refresh (NET_OBJECT (vpn));
|
net_object_refresh (NET_OBJECT (vpn));
|
||||||
g_object_unref (vpn);
|
g_object_unref (vpn);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue