[virt-tools-list] [PATCH virt-viewer 04/10] virt-viewer-vm-connection: Use GtkHeaderBar
Eduardo Lima (Etrunko)
etrunko at redhat.com
Thu Feb 9 19:22:45 UTC 2017
Here we moved the connect button to the header bar. Unfortunately, I
could not find a "connect-symbolic" icon to be used here, so I ended up
with the stock icon.
Signed-off-by: Eduardo Lima (Etrunko) <etrunko at redhat.com>
---
src/resources/ui/virt-viewer-vm-connection.ui | 83 +++++++++------------------
src/virt-viewer-vm-connection.c | 15 ++++-
2 files changed, 40 insertions(+), 58 deletions(-)
diff --git a/src/resources/ui/virt-viewer-vm-connection.ui b/src/resources/ui/virt-viewer-vm-connection.ui
index f190c92..cb58701 100644
--- a/src/resources/ui/virt-viewer-vm-connection.ui
+++ b/src/resources/ui/virt-viewer-vm-connection.ui
@@ -1,6 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.16.1 -->
+<!-- Generated with glade 3.20.0 -->
<interface>
+ <requires lib="gtk+" version="3.12"/>
+ <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">Choose a virtual machine</property>
+ <property name="show_close_button">True</property>
+ <property name="decoration_layout">menu:close</property>
+ <child>
+ <object class="GtkButton" id="button-connect">
+ <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="GtkDialog" id="vm-connection-dialog">
<property name="can_focus">False</property>
<property name="border_width">5</property>
@@ -19,36 +45,6 @@
<object class="GtkButtonBox" id="dialog-action_area1">
<property name="can_focus">False</property>
<property name="layout_style">end</property>
- <child>
- <object class="GtkButton" id="button-cancel">
- <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">False</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkButton" id="button-connect">
- <property name="label" translatable="yes">C_onnect</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="can_default">True</property>
- <property name="has_default">True</property>
- <property name="receives_default">True</property>
- <property name="use_underline">True</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
- </child>
</object>
<packing>
<property name="expand">False</property>
@@ -86,32 +82,7 @@
<property name="position">1</property>
</packing>
</child>
- <child>
- <object class="GtkLabel" id="label">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="xalign">0</property>
- <property name="yalign">0</property>
- <property name="xpad">4</property>
- <property name="label" translatable="yes">Available virtual machines</property>
- <property name="ellipsize">end</property>
- <property name="width_chars">26</property>
- <attributes>
- <attribute name="weight" value="bold"/>
- </attributes>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="pack_type">end</property>
- <property name="position">2</property>
- </packing>
- </child>
</object>
</child>
- <action-widgets>
- <action-widget response="-6">button-cancel</action-widget>
- <action-widget response="-3">button-connect</action-widget>
- </action-widgets>
</object>
</interface>
diff --git a/src/virt-viewer-vm-connection.c b/src/virt-viewer-vm-connection.c
index ebaa92b..0363b84 100644
--- a/src/virt-viewer-vm-connection.c
+++ b/src/virt-viewer-vm-connection.c
@@ -32,7 +32,7 @@ treeview_row_activated_cb(GtkTreeView *treeview G_GNUC_UNUSED,
GtkTreeViewColumn *col G_GNUC_UNUSED,
gpointer userdata)
{
- gtk_widget_activate(GTK_WIDGET(userdata));
+ gtk_button_clicked(GTK_BUTTON(userdata));
}
static void
@@ -42,13 +42,20 @@ treeselection_changed_cb(GtkTreeSelection *selection, gpointer userdata)
gtk_tree_selection_count_selected_rows(selection) == 1);
}
+static void
+button_connect_clicked_cb(GtkButton *button G_GNUC_UNUSED,
+ GtkDialog *dialog)
+{
+ gtk_dialog_response(dialog, GTK_RESPONSE_ACCEPT);
+}
+
gchar*
virt_viewer_vm_connection_choose_name_dialog(GtkWindow *main_window,
GtkTreeModel *model,
GError **error)
{
GtkBuilder *vm_connection;
- GtkWidget *dialog;
+ GtkWidget *dialog, *headerbar;
GtkButton *button_connect;
GtkTreeView *treeview;
GtkTreeSelection *selection;
@@ -69,12 +76,16 @@ virt_viewer_vm_connection_choose_name_dialog(GtkWindow *main_window,
g_return_val_if_fail(vm_connection != NULL, NULL);
dialog = GTK_WIDGET(gtk_builder_get_object(vm_connection, "vm-connection-dialog"));
+ headerbar = GTK_WIDGET(gtk_builder_get_object(vm_connection, "headerbar"));
+ gtk_window_set_titlebar(GTK_WINDOW(dialog), headerbar);
gtk_window_set_transient_for(GTK_WINDOW(dialog), main_window);
button_connect = GTK_BUTTON(gtk_builder_get_object(vm_connection, "button-connect"));
treeview = GTK_TREE_VIEW(gtk_builder_get_object(vm_connection, "treeview"));
selection = GTK_TREE_SELECTION(gtk_builder_get_object(vm_connection, "treeview-selection"));
gtk_tree_view_set_model(treeview, model);
+ g_signal_connect(button_connect, "clicked",
+ G_CALLBACK(button_connect_clicked_cb), dialog);
g_signal_connect(treeview, "row-activated",
G_CALLBACK(treeview_row_activated_cb), button_connect);
g_signal_connect(selection, "changed",
--
2.9.3
More information about the virt-tools-list
mailing list