summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlos Soriano <csoriano@gnome.org>2015-02-05 15:25:51 +0100
committerCarlos Soriano <csoriano@gnome.org>2015-02-11 13:07:48 +0100
commit2b09a6f2e396f6505ef5a3988994694dc9d25cf0 (patch)
treeb11386165c8fa1ce50a05da573b16e3349d527df
parentacb1bc1b621cdd40dade116c48776373d10d4392 (diff)
downloadnautilus-2b09a6f2e396f6505ef5a3988994694dc9d25cf0.tar.gz
nautilus-progress-info-widget: Use GtkBuilder for the UI
As always, it's better to use GtkBuilder definition files for the UI. Also improve the looks using a round button and symbolic icons.
-rw-r--r--src/Adwaita.css5
-rw-r--r--src/nautilus-progress-info-widget.c105
-rw-r--r--src/nautilus-progress-info-widget.h4
-rw-r--r--src/nautilus-progress-info-widget.xml87
-rw-r--r--src/nautilus.gresource.xml1
5 files changed, 126 insertions, 76 deletions
diff --git a/src/Adwaita.css b/src/Adwaita.css
index ba7719620..e8020c7d2 100644
--- a/src/Adwaita.css
+++ b/src/Adwaita.css
@@ -33,6 +33,11 @@
color: @theme_unfocused_selected_fg_color;
}
+.nautilus-circular-button {
+ border-radius: 20px;
+ outline-radius: 20px;
+}
+
/* Floating status bar */
.floating-bar {
padding: 2px;
diff --git a/src/nautilus-progress-info-widget.c b/src/nautilus-progress-info-widget.c
index 491ac8ba7..86b34fdab 100644
--- a/src/nautilus-progress-info-widget.c
+++ b/src/nautilus-progress-info-widget.c
@@ -25,13 +25,13 @@
#include <config.h>
#include "nautilus-progress-info-widget.h"
-
-struct _NautilusProgressInfoWidgetPriv {
+struct _NautilusProgressInfoWidgetPrivate {
NautilusProgressInfo *info;
GtkWidget *status; /* GtkLabel */
GtkWidget *details; /* GtkLabel */
GtkWidget *progress_bar;
+ GtkWidget *cancel;
};
enum {
@@ -41,8 +41,8 @@ enum {
static GParamSpec *properties[NUM_PROPERTIES] = { NULL };
-G_DEFINE_TYPE (NautilusProgressInfoWidget, nautilus_progress_info_widget,
- GTK_TYPE_BOX);
+G_DEFINE_TYPE_WITH_PRIVATE (NautilusProgressInfoWidget, nautilus_progress_info_widget,
+ GTK_TYPE_BOX);
static void
info_finished (NautilusProgressInfoWidget *self)
@@ -89,68 +89,21 @@ cancel_clicked (GtkWidget *button,
}
static void
-nautilus_progress_info_widget_constructed (GObject *obj)
+nautilus_progress_info_widget_dispose (GObject *obj)
{
- GtkWidget *label, *progress_bar, *hbox, *box, *button, *image;
NautilusProgressInfoWidget *self = NAUTILUS_PROGRESS_INFO_WIDGET (obj);
- G_OBJECT_CLASS (nautilus_progress_info_widget_parent_class)->constructed (obj);
-
- label = gtk_label_new ("status");
- gtk_widget_set_size_request (label, 500, -1);
- gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
- gtk_label_set_line_wrap_mode (GTK_LABEL (label), PANGO_WRAP_WORD_CHAR);
- gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
- gtk_box_pack_start (GTK_BOX (self),
- label,
- TRUE, FALSE,
- 0);
- self->priv->status = label;
-
- hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 10);
-
- progress_bar = gtk_progress_bar_new ();
- self->priv->progress_bar = progress_bar;
- gtk_progress_bar_set_pulse_step (GTK_PROGRESS_BAR (progress_bar), 0.05);
- box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
- gtk_box_pack_start(GTK_BOX (box),
- progress_bar,
- TRUE, FALSE,
- 0);
- gtk_box_pack_start(GTK_BOX (hbox),
- box,
- TRUE, TRUE,
- 0);
-
- image = gtk_image_new_from_icon_name ("gtk-cancel",
- GTK_ICON_SIZE_BUTTON);
- button = gtk_button_new ();
- gtk_container_add (GTK_CONTAINER (button), image);
- gtk_box_pack_start (GTK_BOX (hbox),
- button,
- FALSE,FALSE,
- 0);
- g_signal_connect (button, "clicked",
- G_CALLBACK (cancel_clicked), self);
+ g_clear_object (&self->priv->info);
- gtk_box_pack_start (GTK_BOX (self),
- hbox,
- FALSE,FALSE,
- 0);
-
- label = gtk_label_new ("details");
- gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
- gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
- gtk_box_pack_start (GTK_BOX (self),
- label,
- TRUE, FALSE,
- 0);
- self->priv->details = label;
-
- gtk_widget_show_all (GTK_WIDGET (self));
+ G_OBJECT_CLASS (nautilus_progress_info_widget_parent_class)->dispose (obj);
+}
- update_data (self);
- update_progress (self);
+static void
+nautilus_progress_info_widget_constructed (GObject *obj)
+{
+ NautilusProgressInfoWidget *self = NAUTILUS_PROGRESS_INFO_WIDGET (obj);
+
+ G_OBJECT_CLASS (nautilus_progress_info_widget_parent_class)->constructed (obj);
g_signal_connect_swapped (self->priv->info,
"changed",
@@ -161,16 +114,9 @@ nautilus_progress_info_widget_constructed (GObject *obj)
g_signal_connect_swapped (self->priv->info,
"finished",
G_CALLBACK (info_finished), self);
-}
-static void
-nautilus_progress_info_widget_dispose (GObject *obj)
-{
- NautilusProgressInfoWidget *self = NAUTILUS_PROGRESS_INFO_WIDGET (obj);
-
- g_clear_object (&self->priv->info);
-
- G_OBJECT_CLASS (nautilus_progress_info_widget_parent_class)->dispose (obj);
+ update_data (self);
+ update_progress (self);
}
static void
@@ -194,17 +140,22 @@ nautilus_progress_info_widget_set_property (GObject *object,
static void
nautilus_progress_info_widget_init (NautilusProgressInfoWidget *self)
{
- self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, NAUTILUS_TYPE_PROGRESS_INFO_WIDGET,
- NautilusProgressInfoWidgetPriv);
+ self->priv = nautilus_progress_info_widget_get_instance_private (self);
+
+ gtk_widget_init_template (GTK_WIDGET (self));
+
+ g_signal_connect (self->priv->cancel, "clicked",
+ G_CALLBACK (cancel_clicked), self);
-
}
static void
nautilus_progress_info_widget_class_init (NautilusProgressInfoWidgetClass *klass)
{
GObjectClass *oclass;
+ GtkWidgetClass *widget_class;
+ widget_class = GTK_WIDGET_CLASS (klass);
oclass = G_OBJECT_CLASS (klass);
oclass->set_property = nautilus_progress_info_widget_set_property;
oclass->constructed = nautilus_progress_info_widget_constructed;
@@ -220,7 +171,13 @@ nautilus_progress_info_widget_class_init (NautilusProgressInfoWidgetClass *klass
g_object_class_install_properties (oclass, NUM_PROPERTIES, properties);
- g_type_class_add_private (klass, sizeof (NautilusProgressInfoWidgetPriv));
+ gtk_widget_class_set_template_from_resource (widget_class,
+ "/org/gnome/nautilus/nautilus-progress-info-widget.xml");
+
+ gtk_widget_class_bind_template_child_private (widget_class, NautilusProgressInfoWidget, status);
+ gtk_widget_class_bind_template_child_private (widget_class, NautilusProgressInfoWidget, details);
+ gtk_widget_class_bind_template_child_private (widget_class, NautilusProgressInfoWidget, progress_bar);
+ gtk_widget_class_bind_template_child_private (widget_class, NautilusProgressInfoWidget, cancel);
}
GtkWidget *
diff --git a/src/nautilus-progress-info-widget.h b/src/nautilus-progress-info-widget.h
index 38915d136..5bb40c9fe 100644
--- a/src/nautilus-progress-info-widget.h
+++ b/src/nautilus-progress-info-widget.h
@@ -41,13 +41,13 @@
#define NAUTILUS_PROGRESS_INFO_WIDGET_GET_CLASS(obj) \
(G_TYPE_INSTANCE_GET_CLASS ((obj), NAUTILUS_TYPE_PROGRESS_INFO_WIDGET, NautilusProgressInfoWidgetClass))
-typedef struct _NautilusProgressInfoWidgetPriv NautilusProgressInfoWidgetPriv;
+typedef struct _NautilusProgressInfoWidgetPrivate NautilusProgressInfoWidgetPrivate;
typedef struct {
GtkBox parent;
/* private */
- NautilusProgressInfoWidgetPriv *priv;
+ NautilusProgressInfoWidgetPrivate *priv;
} NautilusProgressInfoWidget;
typedef struct {
diff --git a/src/nautilus-progress-info-widget.xml b/src/nautilus-progress-info-widget.xml
new file mode 100644
index 000000000..fa645eff4
--- /dev/null
+++ b/src/nautilus-progress-info-widget.xml
@@ -0,0 +1,87 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <template class="NautilusProgressInfoWidget" parent="GtkBox">
+ <property name="visible">True</property>
+ <property name="margin">5</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <object class="GtkLabel" id="status">
+ <property name="label">status</property>
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ <property name="width-request">400</property>
+ <property name="wrap">True</property>
+ <property name="wrap-mode">word-char</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkBox" id="box2">
+ <property name="visible">True</property>
+ <child>
+ <object class="GtkProgressBar" id="progress_bar">
+ <property name="visible">True</property>
+ <property name="valign">center</property>
+ <property name="pulse-step">0.05</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="cancel">
+ <property name="visible">True</property>
+ <property name="receives_default">True</property>
+ <property name="margin_start">20</property>
+ <style>
+ <class name="image-button"/>
+ <class name="nautilus-circular-button"/>
+ </style>
+ <child>
+ <object class="GtkImage" id="cancel_icon">
+ <property name="visible">True</property>
+ <property name="icon-name">window-close-symbolic</property>
+ <property name="icon-size">1</property>
+ </object>
+ </child>
+ </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>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="details">
+ <property name="label">details</property>
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">label</property>
+ <property name="ellipsize">end</property>
+ <property name="xalign">0</property>
+ <property name="wrap">True</property>
+ <property name="wrap-mode">word-char</property>
+ <style>
+ <class name="dim-label"/>
+ </style>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ </template>
+</interface>
diff --git a/src/nautilus.gresource.xml b/src/nautilus.gresource.xml
index ff0a1cac4..1bdb66ca4 100644
--- a/src/nautilus.gresource.xml
+++ b/src/nautilus.gresource.xml
@@ -8,6 +8,7 @@
<file>nautilus-toolbar-view-menu.xml</file>
<file>nautilus-toolbar-action-menu.xml</file>
<file>nautilus-view-context-menus.xml</file>
+ <file>nautilus-progress-info-widget.xml</file>
<file alias="icons/thumbnail_frame.png">../icons/thumbnail_frame.png</file>
<file alias="icons/filmholes.png">../icons/filmholes.png</file>
<file alias="icons/knob.png">../icons/knob.png</file>