[nautilus] progress-info: change icon when operation is finished



commit 05d02cea4ab52d30fa42cc2925f7a41cfc15d5cd
Author: Paolo Borelli <pborelli gnome org>
Date:   Mon Jan 18 19:10:37 2016 +0100

    progress-info: change icon when operation is finished
    
    When the operation is finished turn the icon into a "check" icon.

 src/nautilus-progress-info-widget.c               |   34 +++++++++++++--------
 src/resources/ui/nautilus-progress-info-widget.ui |   19 ++++++-----
 2 files changed, 31 insertions(+), 22 deletions(-)
---
diff --git a/src/nautilus-progress-info-widget.c b/src/nautilus-progress-info-widget.c
index e1c71ac..9edb1c0 100644
--- a/src/nautilus-progress-info-widget.c
+++ b/src/nautilus-progress-info-widget.c
@@ -31,7 +31,8 @@ struct _NautilusProgressInfoWidgetPrivate {
        GtkWidget *status; /* GtkLabel */
        GtkWidget *details; /* GtkLabel */
        GtkWidget *progress_bar;
-       GtkWidget *cancel;
+       GtkWidget *button;
+       GtkWidget *done_image;
 };
 
 enum {
@@ -47,13 +48,14 @@ G_DEFINE_TYPE_WITH_PRIVATE (NautilusProgressInfoWidget, nautilus_progress_info_w
 static void
 info_finished (NautilusProgressInfoWidget *self)
 {
-       gtk_widget_set_sensitive (self->priv->cancel, FALSE);
+       gtk_button_set_image (GTK_BUTTON (self->priv->button), self->priv->done_image);
+       gtk_widget_set_sensitive (self->priv->button, FALSE);
 }
 
 static void
 info_cancelled (NautilusProgressInfoWidget *self)
 {
-       gtk_widget_set_sensitive (self->priv->cancel, FALSE);
+       gtk_widget_set_sensitive (self->priv->button, FALSE);
 }
 
 static void
@@ -87,10 +89,12 @@ update_progress (NautilusProgressInfoWidget *self)
 }
 
 static void
-cancel_clicked (GtkWidget *button,
+button_clicked (GtkWidget *button,
                NautilusProgressInfoWidget *self)
 {
-       nautilus_progress_info_cancel (self->priv->info);
+       if (!nautilus_progress_info_get_is_finished (self->priv->info)) {
+               nautilus_progress_info_cancel (self->priv->info);
+       }
 }
 
 static void
@@ -155,9 +159,8 @@ nautilus_progress_info_widget_init (NautilusProgressInfoWidget *self)
 
        gtk_widget_init_template (GTK_WIDGET (self));
 
-       g_signal_connect (self->priv->cancel, "clicked",
-                         G_CALLBACK (cancel_clicked), self);
-
+       g_signal_connect (self->priv->button, "clicked",
+                         G_CALLBACK (button_clicked), self);
 }
 
 static void
@@ -188,7 +191,8 @@ nautilus_progress_info_widget_class_init (NautilusProgressInfoWidgetClass *klass
        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);
+       gtk_widget_class_bind_template_child_private (widget_class, NautilusProgressInfoWidget, button);
+       gtk_widget_class_bind_template_child_private (widget_class, NautilusProgressInfoWidget, done_image);
 }
 
 GtkWidget *
@@ -200,9 +204,13 @@ nautilus_progress_info_widget_new (NautilusProgressInfo *info)
                             "info", info,
                             NULL);
 
-        gtk_widget_set_sensitive (self->priv->cancel,
-                                  !nautilus_progress_info_get_is_finished (self->priv->info) &&
-                                  !nautilus_progress_info_get_is_cancelled (self->priv->info));
+       if (nautilus_progress_info_get_is_finished (self->priv->info)) {
+               gtk_button_set_image (GTK_BUTTON (self->priv->button), self->priv->done_image);
+       }
+
+       gtk_widget_set_sensitive (self->priv->button,
+                                 !nautilus_progress_info_get_is_finished (self->priv->info) &&
+                                 !nautilus_progress_info_get_is_cancelled (self->priv->info));
 
-        return GTK_WIDGET (self);
+       return GTK_WIDGET (self);
 }
diff --git a/src/resources/ui/nautilus-progress-info-widget.ui 
b/src/resources/ui/nautilus-progress-info-widget.ui
index 3aee042..2cc80c1 100644
--- a/src/resources/ui/nautilus-progress-info-widget.ui
+++ b/src/resources/ui/nautilus-progress-info-widget.ui
@@ -33,22 +33,15 @@
       </packing>
     </child>
     <child>
-      <object class="GtkButton" id="cancel">
+      <object class="GtkButton" id="button">
         <property name="visible">True</property>
         <property name="receives_default">True</property>
         <property name="margin_start">20</property>
         <property name="valign">center</property>
+        <property name="image">cancel_image</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="height">3</property>
@@ -75,4 +68,12 @@
       </packing>
     </child>
   </template>
+  <object class="GtkImage" id="cancel_image">
+    <property name="visible">True</property>
+    <property name="icon_name">window-close-symbolic</property>
+  </object>
+  <object class="GtkImage" id="done_image">
+    <property name="visible">True</property>
+    <property name="icon_name">object-select-symbolic</property>
+  </object>
 </interface>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]