[virt-tools-list] [PATCH virt-viewer 4/4] iso-dialog: Use header bar for buttons
Eduardo Lima (Etrunko)
etrunko at redhat.com
Mon Jan 23 19:28:16 UTC 2017
It seems to give more modern look to the dialog, but it requires Gtk+
3.12, thus I will am keeping this commit separated.
On the glade UI file, we get rid of the GtkAlignment object that was
used to put some space between the tree view and dialog buttons. The
"Select ISO" label is gone too.
Signed-off-by: Eduardo Lima (Etrunko) <etrunko at redhat.com>
---
configure.ac | 4 +-
src/remote-viewer-iso-list-dialog.c | 31 +++++++++--
src/resources/ui/remote-viewer-iso-list.ui | 87 +++++++++++-------------------
3 files changed, 60 insertions(+), 62 deletions(-)
diff --git a/configure.ac b/configure.ac
index c611d70..ce71349 100644
--- a/configure.ac
+++ b/configure.ac
@@ -17,8 +17,8 @@ GLIB2_REQUIRED="2.38"
GLIB2_ENCODED_VERSION="GLIB_VERSION_2_38"
# Keep these two definitions in agreement.
-GTK_REQUIRED="3.10"
-GTK_ENCODED_VERSION="GDK_VERSION_3_10"
+GTK_REQUIRED="3.12"
+GTK_ENCODED_VERSION="GDK_VERSION_3_12"
LIBXML2_REQUIRED="2.6.0"
LIBVIRT_REQUIRED="0.10.0"
diff --git a/src/remote-viewer-iso-list-dialog.c b/src/remote-viewer-iso-list-dialog.c
index e27e5fc..b788262 100644
--- a/src/remote-viewer-iso-list-dialog.c
+++ b/src/remote-viewer-iso-list-dialog.c
@@ -36,6 +36,7 @@ G_DEFINE_TYPE(RemoteViewerISOListDialog, remote_viewer_iso_list_dialog, GTK_TYPE
struct _RemoteViewerISOListDialogPrivate
{
+ GtkHeaderBar *header_bar;
GtkListStore *list_store;
GtkWidget *status;
GtkWidget *spinner;
@@ -118,6 +119,19 @@ remote_viewer_iso_list_dialog_show_files(RemoteViewerISOListDialog *self)
}
static void
+remote_viewer_iso_list_dialog_set_subtitle(RemoteViewerISOListDialog *self, const char *iso_name)
+{
+ RemoteViewerISOListDialogPrivate *priv = self->priv;
+ gchar *subtitle = NULL;
+
+ if (iso_name && strlen(iso_name) != 0)
+ subtitle = g_strdup_printf(_("Current: %s"), iso_name);
+
+ gtk_header_bar_set_subtitle(priv->header_bar, subtitle);
+ g_free(subtitle);
+}
+
+static void
remote_viewer_iso_list_dialog_foreach(char *name, RemoteViewerISOListDialog *self)
{
RemoteViewerISOListDialogPrivate *priv = self->priv;
@@ -137,6 +151,7 @@ remote_viewer_iso_list_dialog_foreach(char *name, RemoteViewerISOListDialog *sel
gtk_tree_view_set_cursor(GTK_TREE_VIEW(priv->tree_view), path, NULL, FALSE);
gtk_tree_view_scroll_to_cell(GTK_TREE_VIEW(priv->tree_view), path, NULL, TRUE, 0.5, 0.5);
gtk_tree_path_free(path);
+ remote_viewer_iso_list_dialog_set_subtitle(self, current_iso);
}
g_free(current_iso);
@@ -195,6 +210,7 @@ remote_viewer_iso_list_dialog_response(GtkDialog *dialog,
gtk_spinner_start(GTK_SPINNER(priv->spinner));
gtk_label_set_markup(GTK_LABEL(priv->status), _("<b>Loading...</b>"));
+ remote_viewer_iso_list_dialog_set_subtitle(self, NULL);
gtk_stack_set_visible_child_full(GTK_STACK(priv->stack), "status",
GTK_STACK_TRANSITION_TYPE_NONE);
gtk_dialog_set_response_sensitive(GTK_DIALOG(self), GTK_RESPONSE_NONE, FALSE);
@@ -248,9 +264,13 @@ remote_viewer_iso_list_dialog_init(RemoteViewerISOListDialog *self)
RemoteViewerISOListDialogPrivate *priv = self->priv = DIALOG_PRIVATE(self);
GtkBuilder *builder = virt_viewer_util_load_ui("remote-viewer-iso-list.ui");
GtkCellRendererToggle *cell_renderer;
+ GtkWidget *button, *image;
gtk_builder_connect_signals(builder, self);
+ priv->header_bar = GTK_HEADER_BAR(gtk_dialog_get_header_bar(GTK_DIALOG(self)));
+ gtk_header_bar_set_has_subtitle(priv->header_bar, TRUE);
+
priv->status = GTK_WIDGET(gtk_builder_get_object(builder, "status"));
priv->spinner = GTK_WIDGET(gtk_builder_get_object(builder, "spinner"));
priv->stack = GTK_WIDGET(gtk_builder_get_object(builder, "stack"));
@@ -264,12 +284,11 @@ remote_viewer_iso_list_dialog_init(RemoteViewerISOListDialog *self)
g_object_unref(builder);
- gtk_dialog_add_buttons(GTK_DIALOG(self),
- _("Refresh"), GTK_RESPONSE_NONE,
- _("Close"), GTK_RESPONSE_CLOSE,
- NULL);
+ button = gtk_dialog_add_button(GTK_DIALOG(self), "", GTK_RESPONSE_NONE);
+ image = gtk_image_new_from_icon_name("view-refresh-symbolic", GTK_ICON_SIZE_BUTTON);
+ gtk_button_set_image(GTK_BUTTON(button), image);
+ gtk_button_set_always_show_image(GTK_BUTTON(button), TRUE);
- gtk_dialog_set_default_response(GTK_DIALOG(self), GTK_RESPONSE_CLOSE);
gtk_dialog_set_response_sensitive(GTK_DIALOG(self), GTK_RESPONSE_NONE, FALSE);
g_signal_connect(self, "response", G_CALLBACK(remote_viewer_iso_list_dialog_response), NULL);
}
@@ -337,6 +356,7 @@ ovirt_foreign_menu_iso_name_changed(OvirtForeignMenu *foreign_menu,
g_free(name);
} while (gtk_tree_model_iter_next(model, &iter));
+ remote_viewer_iso_list_dialog_set_subtitle(self, current_iso);
gtk_dialog_set_response_sensitive(GTK_DIALOG(self), GTK_RESPONSE_NONE, TRUE);
gtk_widget_set_sensitive(priv->tree_view, TRUE);
g_free(current_iso);
@@ -356,6 +376,7 @@ remote_viewer_iso_list_dialog_new(GtkWindow *parent, GObject *foreign_menu)
"border-width", 18,
"default-width", 400,
"default-height", 300,
+ "use-header-bar", TRUE,
"foreign-menu", foreign_menu,
NULL);
diff --git a/src/resources/ui/remote-viewer-iso-list.ui b/src/resources/ui/remote-viewer-iso-list.ui
index ab1bdc4..b385527 100644
--- a/src/resources/ui/remote-viewer-iso-list.ui
+++ b/src/resources/ui/remote-viewer-iso-list.ui
@@ -72,70 +72,47 @@
<property name="orientation">vertical</property>
<property name="spacing">6</property>
<child>
- <object class="GtkLabel">
+ <object class="GtkScrolledWindow">
<property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label" translatable="yes">Select ISO</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="GtkAlignment" id="alignment">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="bottom_padding">6</property>
+ <property name="can_focus">True</property>
+ <property name="shadow_type">in</property>
<child>
- <object class="GtkScrolledWindow">
+ <object class="GtkTreeView" id="view">
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="shadow_type">in</property>
+ <property name="model">liststore</property>
+ <property name="headers_visible">False</property>
+ <property name="rules_hint">True</property>
+ <property name="search_column">1</property>
+ <property name="enable_grid_lines">horizontal</property>
+ <signal name="row-activated" handler="remote_viewer_iso_list_dialog_row_activated" swapped="no"/>
+ <child internal-child="selection">
+ <object class="GtkTreeSelection" id="treeview-selection"/>
+ </child>
<child>
- <object class="GtkTreeView" id="view">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="model">liststore</property>
- <property name="headers_visible">False</property>
- <property name="rules_hint">True</property>
- <property name="search_column">1</property>
- <property name="enable_grid_lines">horizontal</property>
- <signal name="row-activated" handler="remote_viewer_iso_list_dialog_row_activated" swapped="no"/>
- <child internal-child="selection">
- <object class="GtkTreeSelection" id="treeview-selection"/>
- </child>
+ <object class="GtkTreeViewColumn" id="selected_column">
+ <property name="sizing">autosize</property>
+ <property name="title" translatable="yes">Selected</property>
<child>
- <object class="GtkTreeViewColumn" id="selected_column">
- <property name="sizing">autosize</property>
- <property name="title" translatable="yes">Selected</property>
- <child>
- <object class="GtkCellRendererToggle" id="cellrenderertoggle">
- <signal name="toggled" handler="remote_viewer_iso_list_dialog_toggled" swapped="no"/>
- </object>
- <attributes>
- <attribute name="active">0</attribute>
- </attributes>
- </child>
+ <object class="GtkCellRendererToggle" id="cellrenderertoggle">
+ <signal name="toggled" handler="remote_viewer_iso_list_dialog_toggled" swapped="no"/>
</object>
+ <attributes>
+ <attribute name="active">0</attribute>
+ </attributes>
</child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkTreeViewColumn" id="name_column">
+ <property name="title" translatable="yes">Name</property>
+ <property name="expand">True</property>
<child>
- <object class="GtkTreeViewColumn" id="name_column">
- <property name="title" translatable="yes">Name</property>
- <property name="expand">True</property>
- <child>
- <object class="GtkCellRendererText" id="cellrenderertext"/>
- <attributes>
- <attribute name="text">1</attribute>
- <attribute name="weight">2</attribute>
- </attributes>
- </child>
- </object>
+ <object class="GtkCellRendererText" id="cellrenderertext"/>
+ <attributes>
+ <attribute name="text">1</attribute>
+ <attribute name="weight">2</attribute>
+ </attributes>
</child>
</object>
</child>
--
2.9.3
More information about the virt-tools-list
mailing list