[virt-tools-list] [PATCH virt-viewer v2 12/12] iso-dialog: Use header bar for buttons
Eduardo Lima (Etrunko)
etrunko at redhat.com
Fri Jul 22 13:19:03 UTC 2016
It seems to give more modern look to the dialog, but it requires Gtk+
3.12, thus I will am keeping this commit separated.
Signed-off-by: Eduardo Lima (Etrunko) <etrunko at redhat.com>
---
configure.ac | 4 ++--
src/remote-viewer-iso-list-dialog.c | 33 ++++++++++++++++++++++++++++-----
2 files changed, 30 insertions(+), 7 deletions(-)
diff --git a/configure.ac b/configure.ac
index 7c437a3..7682f42 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 7fe032b..c6fb5d8 100644
--- a/src/remote-viewer-iso-list-dialog.c
+++ b/src/remote-viewer-iso-list-dialog.c
@@ -34,6 +34,7 @@ G_DEFINE_TYPE(RemoteViewerISOListDialog, remote_viewer_iso_list_dialog, GTK_TYPE
struct _RemoteViewerISOListDialogPrivate
{
+ GtkHeaderBar *header_bar;
GtkListStore *list_store;
GtkWidget *stack;
GtkWidget *treeview;
@@ -88,6 +89,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;
@@ -102,6 +116,9 @@ remote_viewer_iso_list_dialog_foreach(char *name, RemoteViewerISOListDialog *sel
ISO_NAME, name,
FONT_WEIGHT, weight, -1);
+ if (active)
+ remote_viewer_iso_list_dialog_set_subtitle(self, current_iso);
+
free(current_iso);
}
@@ -134,6 +151,7 @@ remote_viewer_iso_list_dialog_response(GtkDialog *dialog,
if (response_id != GTK_RESPONSE_NONE)
return;
+ remote_viewer_iso_list_dialog_set_subtitle(self, NULL);
gtk_stack_set_visible_child_full(GTK_STACK(priv->stack), "status",
GTK_STACK_TRANSITION_TYPE_SLIDE_LEFT);
gtk_dialog_set_response_sensitive(GTK_DIALOG(self), GTK_RESPONSE_NONE, FALSE);
@@ -171,9 +189,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->stack = GTK_WIDGET(gtk_builder_get_object(builder, "stack"));
gtk_box_pack_start(GTK_BOX(content), priv->stack, TRUE, TRUE, 0);
@@ -184,12 +206,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);
}
@@ -229,6 +250,7 @@ ovirt_foreign_menu_notify_file(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->treeview, TRUE);
@@ -259,6 +281,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,
NULL);
self = REMOTE_VIEWER_ISO_LIST_DIALOG(dialog);
--
2.7.4
More information about the virt-tools-list
mailing list