[virt-tools-list] [PATCH virt-viewer 05/10] remote-viewer-connect: Use GtkHeaderBar
Eduardo Lima (Etrunko)
etrunko at redhat.com
Thu Feb 9 19:22:46 UTC 2017
Just like the virt-viewer-connect dialog, the connect button has been
moved to the header bar. Additionally, the example text is now presented
as the subtitle.
Signed-off-by: Eduardo Lima (Etrunko) <etrunko at redhat.com>
---
src/remote-viewer-connect.c | 20 +---
src/resources/ui/remote-viewer-connect.ui | 173 +++++++++---------------------
2 files changed, 54 insertions(+), 139 deletions(-)
diff --git a/src/remote-viewer-connect.c b/src/remote-viewer-connect.c
index 2fbc5ff..f3ac468 100644
--- a/src/remote-viewer-connect.c
+++ b/src/remote-viewer-connect.c
@@ -152,15 +152,6 @@ recent_item_activated_dialog_cb(GtkRecentChooser *chooser G_GNUC_UNUSED, gpointe
shutdown_loop(ci->loop);
}
-static void
-make_label_small(GtkLabel* label)
-{
- PangoAttrList* attributes = pango_attr_list_new();
- pango_attr_list_insert(attributes, pango_attr_scale_new(0.9));
- gtk_label_set_attributes(label, attributes);
- pango_attr_list_unref(attributes);
-}
-
/**
* remote_viewer_connect_dialog
*
@@ -174,7 +165,7 @@ make_label_small(GtkLabel* label)
gboolean
remote_viewer_connect_dialog(gchar **uri)
{
- GtkWidget *window, *label, *entry, *recent, *connect_button, *cancel_button;
+ GtkWidget *window, *header, *entry, *recent, *connect_button;
GtkRecentFilter *rfilter;
GtkBuilder *builder;
gboolean active;
@@ -192,13 +183,11 @@ remote_viewer_connect_dialog(gchar **uri)
g_return_val_if_fail(builder != NULL, GTK_RESPONSE_NONE);
window = GTK_WIDGET(gtk_builder_get_object(builder, "remote-viewer-connection-window"));
+ header = GTK_WIDGET(gtk_builder_get_object(builder, "headerbar"));
+ gtk_window_set_titlebar(GTK_WINDOW(window), header);
connect_button = GTK_WIDGET(gtk_builder_get_object(builder, "connect-button"));
- cancel_button = GTK_WIDGET(gtk_builder_get_object(builder, "cancel-button"));
- label = GTK_WIDGET(gtk_builder_get_object(builder, "example-label"));
entry = ci.entry = GTK_WIDGET(gtk_builder_get_object(builder, "connection-address-entry"));
- make_label_small(GTK_LABEL(label));
-
active = (gtk_entry_get_text_length(GTK_ENTRY(ci.entry)) > 0);
gtk_widget_set_sensitive(GTK_WIDGET(connect_button), active);
@@ -216,9 +205,6 @@ remote_viewer_connect_dialog(gchar **uri)
g_signal_connect(connect_button, "clicked",
G_CALLBACK(connect_button_clicked_cb), &ci);
- /* make sure that user_data is passed as first parameter */
- g_signal_connect_swapped(cancel_button, "clicked",
- G_CALLBACK(window_deleted_cb), &ci);
g_signal_connect_swapped(window, "delete-event",
G_CALLBACK(window_deleted_cb), &ci);
diff --git a/src/resources/ui/remote-viewer-connect.ui b/src/resources/ui/remote-viewer-connect.ui
index 308d121..89d17fd 100644
--- a/src/resources/ui/remote-viewer-connect.ui
+++ b/src/resources/ui/remote-viewer-connect.ui
@@ -1,63 +1,48 @@
<?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.18.3 -->
+<!-- Generated with glade 3.20.0 -->
<interface>
+ <requires lib="gtk+" version="3.20"/>
+ <object class="GtkImage" id="image1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="stock">gtk-connect</property>
+ </object>
+ <object class="GtkHeaderBar" id="headerbar">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="title">Connection Details</property>
+ <property name="subtitle">For example, spice://foo.example.org:5900</property>
+ <property name="show_close_button">True</property>
+ <property name="decoration_layout">menu:close</property>
+ <child>
+ <object class="GtkButton" id="connect-button">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="tooltip_text" translatable="yes">Connect</property>
+ <property name="image">image1</property>
+ <property name="always_show_image">True</property>
+ </object>
+ <packing>
+ <property name="pack_type">end</property>
+ </packing>
+ </child>
+ </object>
<object class="GtkWindow" id="remote-viewer-connection-window">
+ <property name="name">12</property>
<property name="can_focus">False</property>
- <property name="title" translatable="yes">Connection details</property>
+ <property name="border_width">12</property>
+ <property name="icon_name">remote-viewer</property>
<child>
- <object class="GtkVBox" id="main-box">
+ <object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="border_width">10</property>
- <property name="spacing">20</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">6</property>
<child>
- <object class="GtkVBox" id="connection-address-box">
+ <object class="GtkEntry" id="connection-address-entry">
<property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="spacing">6</property>
- <child>
- <object class="GtkLabel" id="connection-address-label">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="xalign">0</property>
- <property name="label" translatable="yes">Connection _Address</property>
- <property name="use_underline">True</property>
- <property name="mnemonic_widget">connection-address-entry</property>
- <attributes>
- <attribute name="weight" value="bold"/>
- </attributes>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkEntry" id="connection-address-entry">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="example-label">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="xalign">0</property>
- <property name="sensitive">False</property>
- <property name="label" translatable="yes">For example, spice://foo.example.org:5900</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">2</property>
- </packing>
- </child>
+ <property name="can_focus">True</property>
</object>
<packing>
<property name="expand">False</property>
@@ -66,88 +51,32 @@
</packing>
</child>
<child>
- <object class="GtkVBox" id="recent-chooser-box">
+ <object class="GtkLabel" id="recent-chooser-label">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="spacing">6</property>
- <child>
- <object class="GtkLabel" id="recent-chooser-label">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label" translatable="yes">Recent connections</property>
- <property name="xalign">0</property>
- <attributes>
- <attribute name="weight" value="bold"/>
- </attributes>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkRecentChooserWidget" id="recent-chooser">
- <property name="can_focus">False</property>
- <property name="limit">20</property>
- <property name="local_only">False</property>
- <property name="show_icons">False</property>
- <property name="sort_type">mru</property>
- </object>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
- </child>
+ <property name="label" translatable="yes">Recent connections</property>
+ <property name="xalign">0</property>
+ <attributes>
+ <attribute name="weight" value="bold"/>
+ </attributes>
</object>
<packing>
- <property name="expand">True</property>
+ <property name="expand">False</property>
<property name="fill">True</property>
- <property name="position">2</property>
+ <property name="position">1</property>
</packing>
</child>
<child>
- <object class="GtkHButtonBox" id="button-box">
- <property name="visible">True</property>
+ <object class="GtkRecentChooserWidget" id="recent-chooser">
<property name="can_focus">False</property>
- <property name="resize_mode">immediate</property>
- <property name="spacing">6</property>
- <property name="layout_style">end</property>
- <child>
- <object class="GtkButton" id="cancel-button">
- <property name="label" translatable="yes">_Cancel</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <property name="use_underline">True</property>
- </object>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkButton" id="connect-button">
- <property name="label" translatable="yes">C_onnect</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <property name="use_underline">True</property>
- </object>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
- </child>
+ <property name="local_only">False</property>
+ <property name="show_icons">False</property>
+ <property name="sort_type">mru</property>
</object>
<packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="pack_type">end</property>
- <property name="position">3</property>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">2</property>
</packing>
</child>
</object>
--
2.9.3
More information about the virt-tools-list
mailing list