]> saetta.ns0.it Git - solipa/libsolipa/commitdiff
Aggiunte le proprietà with-label e with-percentage.
authorAndrea Zagli <a.zagli@comune.scandicci.fi.it>
Thu, 16 Jun 2011 15:31:57 +0000 (17:31 +0200)
committerAndrea Zagli <a.zagli@comune.scandicci.fi.it>
Thu, 16 Jun 2011 15:31:57 +0000 (17:31 +0200)
Aggiunte le funzioni di distruzione dell'oggetto.

data/libsolipa/gui/libsolipa.ui
src/progresswindow.c

index c5ddddeae087b5b69ce438b3bbfa9b1f640b9d07..b74b61dd8994a1958b3bd817483467ca223692a1 100644 (file)
         <child>
           <object class="GtkLabel" id="label13">
             <property name="visible">True</property>
+            <property name="no_show_all">True</property>
             <property name="label" translatable="yes">label</property>
           </object>
           <packing>
             <property name="visible">True</property>
           </object>
           <packing>
-            <property name="expand">False</property>
             <property name="position">1</property>
           </packing>
         </child>
index 178048a4cd621387095b35c233d236ee80133960..bb8ce298f68a0559e7788df50aa8d0cc39b6f5b7 100644 (file)
@@ -27,6 +27,8 @@ enum
        PROP_0,
        PROP_TITLE,
        PROP_LABEL,
+       PROP_WITH_LABEL,
+       PROP_WITH_PERCENTAGE,
        PROP_WITH_CANCEL_BUTTON
 };
 
@@ -45,6 +47,9 @@ static void solipa_progress_window_get_property (GObject *object,
 static void solipa_progress_window_on_cancel_clicked (GtkButton *button,
                                               gpointer user_data);
 
+static void solipa_progress_window_dispose (GObject *gobject);
+static void solipa_progress_window_finalize (GObject *gobject);
+
 #define SOLIPA_PROGRESS_WINDOW_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TYPE_SOLIPA_PROGRESS_WINDOW, SolipaProgressWindowPrivate))
 
 typedef struct _SolipaProgressWindowPrivate SolipaProgressWindowPrivate;
@@ -56,6 +61,8 @@ struct _SolipaProgressWindowPrivate
                GtkWidget *label;
                GtkWidget *progress;
                GtkWidget *btn_cancel;
+
+               gboolean with_percentage;
        };
 
 G_DEFINE_TYPE (SolipaProgressWindow, solipa_progress_window, G_TYPE_OBJECT)
@@ -67,6 +74,8 @@ solipa_progress_window_class_init (SolipaProgressWindowClass *klass)
 
        object_class->set_property = solipa_progress_window_set_property;
        object_class->get_property = solipa_progress_window_get_property;
+       object_class->dispose = solipa_progress_window_dispose;
+       object_class->finalize = solipa_progress_window_finalize;
 
        g_object_class_install_property (object_class, PROP_TITLE,
                                         g_param_spec_string ("title",
@@ -82,6 +91,20 @@ solipa_progress_window_class_init (SolipaProgressWindowClass *klass)
                                                              "",
                                                              G_PARAM_READWRITE));
 
+       g_object_class_install_property (object_class, PROP_WITH_LABEL,
+                                        g_param_spec_boolean ("with-label",
+                                                              "With label",
+                                                              "With label",
+                                                              TRUE,
+                                                              G_PARAM_READWRITE));
+
+       g_object_class_install_property (object_class, PROP_WITH_PERCENTAGE,
+                                        g_param_spec_boolean ("with-percentage",
+                                                              "With percentage",
+                                                              "With percentage",
+                                                              FALSE,
+                                                              G_PARAM_READWRITE));
+
        g_object_class_install_property (object_class, PROP_WITH_CANCEL_BUTTON,
                                         g_param_spec_boolean ("with-cancel-button",
                                                               "With cancel button",
@@ -111,6 +134,8 @@ static void
 solipa_progress_window_init (SolipaProgressWindow *solipa_progress_window)
 {
        SolipaProgressWindowPrivate *priv = SOLIPA_PROGRESS_WINDOW_GET_PRIVATE (solipa_progress_window);
+
+       priv->with_percentage = FALSE;
 }
 
 /**
@@ -160,8 +185,9 @@ SolipaProgressWindow
        priv->dialog = GTK_WIDGET (gtk_builder_get_object (builder, "w_progress"));
        priv->label = GTK_WIDGET (gtk_builder_get_object (builder, "label13"));
        priv->progress = GTK_WIDGET (gtk_builder_get_object (builder, "progressbar1"));
+       priv->btn_cancel = GTK_WIDGET (gtk_builder_get_object (builder, "button8"));
 
-       g_signal_connect (gtk_builder_get_object (builder, "button8"), "clicked",
+       g_signal_connect (G_OBJECT (priv->btn_cancel), "clicked",
                          G_CALLBACK (solipa_progress_window_on_cancel_clicked), (gpointer)solipa_progress_window);
 
        return solipa_progress_window;
@@ -200,16 +226,22 @@ solipa_progress_window_pulse (SolipaProgressWindow *progressw)
        SolipaProgressWindowPrivate *priv = SOLIPA_PROGRESS_WINDOW_GET_PRIVATE (progressw);
 
        gtk_progress_bar_pulse (GTK_PROGRESS_BAR (priv->progress));
+       gtk_progress_bar_set_text (GTK_PROGRESS_BAR (priv->progress), "");
 }
 
 void
 solipa_progress_window_set_fraction (SolipaProgressWindow *progressw, gdouble fraction)
 {
+       gchar *text;
+
        g_return_if_fail (IS_SOLIPA_PROGRESS_WINDOW (progressw));
 
        SolipaProgressWindowPrivate *priv = SOLIPA_PROGRESS_WINDOW_GET_PRIVATE (progressw);
 
        gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (priv->progress), fraction);
+       text = g_strdup_printf ("%.2f%%", fraction * 100.0);
+       gtk_progress_bar_set_text (GTK_PROGRESS_BAR (priv->progress), text);
+       g_free (text);
 }
 
 /* PRIVATE */
@@ -232,6 +264,14 @@ solipa_progress_window_set_property (GObject *object,
                                gtk_label_set_text (GTK_LABEL (priv->label), g_strstrip (g_value_dup_string (value)));
                                break;
 
+                       case PROP_WITH_LABEL:
+                               gtk_widget_set_visible (priv->label, g_value_get_boolean (value));
+                               break;
+
+                       case PROP_WITH_PERCENTAGE:
+                               priv->with_percentage = g_value_get_boolean (value);
+                               break;
+
                        case PROP_WITH_CANCEL_BUTTON:
                                gtk_widget_set_visible (priv->btn_cancel, g_value_get_boolean (value));
                                break;
@@ -261,6 +301,14 @@ solipa_progress_window_get_property (GObject *object,
                                g_value_set_string (value, gtk_label_get_text (GTK_LABEL (priv->label)));
                                break;
 
+                       case PROP_WITH_LABEL:
+                               g_value_set_boolean (value, gtk_widget_get_visible (priv->label));
+                               break;
+
+                       case PROP_WITH_PERCENTAGE:
+                               g_value_set_boolean (value, priv->with_percentage);
+                               break;
+
                        case PROP_WITH_CANCEL_BUTTON:
                                g_value_set_boolean (value, gtk_widget_get_visible (priv->btn_cancel));
                                break;
@@ -291,4 +339,30 @@ solipa_progress_window_on_cancel_clicked (GtkButton *button,
                        gtk_widget_destroy (priv->dialog);
                        g_object_unref (user_data);
                }
+}
+
+static void
+solipa_progress_window_dispose (GObject *gobject)
+{
+       SolipaProgressWindow *solipa_progress_window = (SolipaProgressWindow *)gobject;
+       SolipaProgressWindowPrivate *priv = SOLIPA_PROGRESS_WINDOW_GET_PRIVATE (solipa_progress_window);
+
+       if (priv->dialog != NULL)
+               {
+                       gtk_widget_destroy (priv->dialog);
+                       priv->dialog = NULL;
+               }
+
+       GObjectClass *parent_class = g_type_class_peek_parent (G_OBJECT_GET_CLASS (gobject));
+       parent_class->dispose (gobject);
+}
+
+static void
+solipa_progress_window_finalize (GObject *gobject)
+{
+       SolipaProgressWindow *solipa_progress_window = (SolipaProgressWindow *)gobject;
+       SolipaProgressWindowPrivate *priv = SOLIPA_PROGRESS_WINDOW_GET_PRIVATE (solipa_progress_window);
+
+       GObjectClass *parent_class = g_type_class_peek_parent (G_OBJECT_GET_CLASS (gobject));
+       parent_class->finalize (gobject);
 }
\ No newline at end of file