[epiphany] Remove use of stock items in floating status bar



commit c92b52c38495c79add07bd91bcf181beae80d20f
Author: William Jon McCann <william jon mccann gmail com>
Date:   Tue Dec 31 13:31:45 2013 -0500

    Remove use of stock items in floating status bar
    
    By syncing widget from nautilus
    
    https://bugzilla.gnome.org/show_bug.cgi?id=721285

 embed/ephy-embed.c                  |    4 +-
 lib/widgets/nautilus-floating-bar.c |  134 ++++++++++++++++++++++++++---------
 lib/widgets/nautilus-floating-bar.h |   12 +++-
 3 files changed, 111 insertions(+), 39 deletions(-)
---
diff --git a/embed/ephy-embed.c b/embed/ephy-embed.c
index 4446f35..d943f93 100644
--- a/embed/ephy-embed.c
+++ b/embed/ephy-embed.c
@@ -153,7 +153,7 @@ ephy_embed_set_statusbar_label (EphyEmbed *embed, const char *label)
 {
   EphyEmbedPrivate *priv = embed->priv;
 
-  nautilus_floating_bar_set_label (NAUTILUS_FLOATING_BAR (priv->floating_bar), label);
+  nautilus_floating_bar_set_primary_label (NAUTILUS_FLOATING_BAR (priv->floating_bar), label);
 
   if (label == NULL || label[0] == '\0') {
     gtk_widget_hide (priv->floating_bar);
@@ -712,7 +712,7 @@ ephy_embed_constructed (GObject *object)
   ephy_embed_set_fullscreen_message (embed, FALSE);
 
   /* statusbar is hidden by default */
-  priv->floating_bar = nautilus_floating_bar_new (NULL, FALSE);
+  priv->floating_bar = nautilus_floating_bar_new (NULL, NULL, FALSE);
   gtk_widget_set_halign (priv->floating_bar, GTK_ALIGN_START);
   gtk_widget_set_valign (priv->floating_bar, GTK_ALIGN_END);
   gtk_widget_set_no_show_all (priv->floating_bar, TRUE);
diff --git a/lib/widgets/nautilus-floating-bar.c b/lib/widgets/nautilus-floating-bar.c
index 101827a..40090f1 100644
--- a/lib/widgets/nautilus-floating-bar.c
+++ b/lib/widgets/nautilus-floating-bar.c
@@ -25,19 +25,24 @@
 
 #include <config.h>
 
+#include <string.h>
+
 #include "nautilus-floating-bar.h"
 
 struct _NautilusFloatingBarDetails {
-       gchar *label;
+       gchar *primary_label;
+       gchar *details_label;
 
-       GtkWidget *label_widget;
+       GtkWidget *primary_label_widget;
+       GtkWidget *details_label_widget;
        GtkWidget *spinner;
        gboolean show_spinner;
        gboolean is_interactive;
 };
 
 enum {
-       PROP_LABEL = 1,
+       PROP_PRIMARY_LABEL = 1,
+       PROP_DETAILS_LABEL,
        PROP_SHOW_SPINNER,
        NUM_PROPERTIES
 };
@@ -70,7 +75,8 @@ nautilus_floating_bar_finalize (GObject *obj)
 {
        NautilusFloatingBar *self = NAUTILUS_FLOATING_BAR (obj);
 
-       g_free (self->priv->label);
+       g_free (self->priv->primary_label);
+       g_free (self->priv->details_label);
 
        G_OBJECT_CLASS (nautilus_floating_bar_parent_class)->finalize (obj);
 }
@@ -84,8 +90,11 @@ nautilus_floating_bar_get_property (GObject *object,
        NautilusFloatingBar *self = NAUTILUS_FLOATING_BAR (object);
 
        switch (property_id) {
-       case PROP_LABEL:
-               g_value_set_string (value, self->priv->label);
+       case PROP_PRIMARY_LABEL:
+               g_value_set_string (value, self->priv->primary_label);
+               break;
+       case PROP_DETAILS_LABEL:
+               g_value_set_string (value, self->priv->details_label);
                break;
        case PROP_SHOW_SPINNER:
                g_value_set_boolean (value, self->priv->show_spinner);
@@ -105,8 +114,11 @@ nautilus_floating_bar_set_property (GObject *object,
        NautilusFloatingBar *self = NAUTILUS_FLOATING_BAR (object);
 
        switch (property_id) {
-       case PROP_LABEL:
-               nautilus_floating_bar_set_label (self, g_value_get_string (value));
+       case PROP_PRIMARY_LABEL:
+               nautilus_floating_bar_set_primary_label (self, g_value_get_string (value));
+               break;
+       case PROP_DETAILS_LABEL:
+               nautilus_floating_bar_set_details_label (self, g_value_get_string (value));
                break;
        case PROP_SHOW_SPINNER:
                nautilus_floating_bar_set_show_spinner (self, g_value_get_boolean (value));
@@ -118,9 +130,22 @@ nautilus_floating_bar_set_property (GObject *object,
 }
 
 static void
-update_label (NautilusFloatingBar *self)
+update_labels (NautilusFloatingBar *self)
 {
-       gtk_label_set_text (GTK_LABEL (self->priv->label_widget), self->priv->label);
+       gboolean primary_visible, details_visible;
+
+       primary_visible = (self->priv->primary_label != NULL) &&
+               (strlen (self->priv->primary_label) > 0);
+       details_visible = (self->priv->details_label != NULL) &&
+               (strlen (self->priv->details_label) > 0);
+
+       gtk_label_set_text (GTK_LABEL (self->priv->primary_label_widget),
+                           self->priv->primary_label);
+       gtk_widget_set_visible (self->priv->primary_label_widget, primary_visible);
+
+       gtk_label_set_text (GTK_LABEL (self->priv->details_label_widget),
+                           self->priv->details_label);
+       gtk_widget_set_visible (self->priv->details_label_widget, details_visible);
 }
 
 static gboolean
@@ -218,7 +243,7 @@ static void
 nautilus_floating_bar_constructed (GObject *obj)
 {
        NautilusFloatingBar *self = NAUTILUS_FLOATING_BAR (obj);
-       GtkWidget *w, *box;
+       GtkWidget *w, *box, *labels_box;
 
        G_OBJECT_CLASS (nautilus_floating_bar_parent_class)->constructed (obj);
 
@@ -232,17 +257,27 @@ nautilus_floating_bar_constructed (GObject *obj)
        gtk_widget_set_size_request (w, 16, 16);
        gtk_widget_set_margin_left (w, 8);
 
-       w = gtk_label_new (NULL);
-       gtk_label_set_ellipsize (GTK_LABEL (w), PANGO_ELLIPSIZE_MIDDLE);
-       gtk_box_pack_start (GTK_BOX (box), w, FALSE, FALSE, 0);
-       g_object_set (w,
+       labels_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
+       gtk_box_pack_start (GTK_BOX (box), labels_box, TRUE, TRUE, 0);
+       g_object_set (labels_box,
                      "margin-top", 2,
                      "margin-bottom", 2,
-                     "margin-start", 12,
-                     "margin-end", 12,
-                     "max-width-chars", 60,
+                     "margin-left", 12,
+                     "margin-right", 12,
                      NULL);
-       self->priv->label_widget = w;
+       gtk_widget_show (labels_box);
+
+       w = gtk_label_new (NULL);
+       gtk_label_set_ellipsize (GTK_LABEL (w), PANGO_ELLIPSIZE_MIDDLE);
+       gtk_label_set_single_line_mode (GTK_LABEL (w), TRUE);
+       gtk_container_add (GTK_CONTAINER (labels_box), w);
+       self->priv->primary_label_widget = w;
+       gtk_widget_show (w);
+
+       w = gtk_label_new (NULL);
+       gtk_label_set_single_line_mode (GTK_LABEL (w), TRUE);
+       gtk_container_add (GTK_CONTAINER (labels_box), w);
+       self->priv->details_label_widget = w;
        gtk_widget_show (w);
 }
 
@@ -274,10 +309,16 @@ nautilus_floating_bar_class_init (NautilusFloatingBarClass *klass)
        wclass->hide = nautilus_floating_bar_hide;
        wclass->parent_set = nautilus_floating_bar_parent_set;
 
-       properties[PROP_LABEL] =
-               g_param_spec_string ("label",
-                                    "Bar's label",
-                                    "Label displayed by the bar",
+       properties[PROP_PRIMARY_LABEL] =
+               g_param_spec_string ("primary-label",
+                                    "Bar's primary label",
+                                    "Primary label displayed by the bar",
+                                    NULL,
+                                    G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS);
+       properties[PROP_DETAILS_LABEL] =
+               g_param_spec_string ("details-label",
+                                    "Bar's details label",
+                                    "Details label displayed by the bar",
                                     NULL,
                                     G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS);
        properties[PROP_SHOW_SPINNER] =
@@ -301,20 +342,43 @@ nautilus_floating_bar_class_init (NautilusFloatingBarClass *klass)
 }
 
 void
-nautilus_floating_bar_set_label (NautilusFloatingBar *self,
-                                const gchar *label)
+nautilus_floating_bar_set_primary_label (NautilusFloatingBar *self,
+                                        const gchar *label)
+{
+       if (g_strcmp0 (self->priv->primary_label, label) != 0) {
+               g_free (self->priv->primary_label);
+               self->priv->primary_label = g_strdup (label);
+
+               g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_PRIMARY_LABEL]);
+
+               update_labels (self);
+       }
+}
+
+void
+nautilus_floating_bar_set_details_label (NautilusFloatingBar *self,
+                                        const gchar *label)
 {
-       if (g_strcmp0 (self->priv->label, label) != 0) {
-               g_free (self->priv->label);
-               self->priv->label = g_strdup (label);
+       if (g_strcmp0 (self->priv->details_label, label) != 0) {
+               g_free (self->priv->details_label);
+               self->priv->details_label = g_strdup (label);
 
-               g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_LABEL]);
+               g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_DETAILS_LABEL]);
 
-               update_label (self);
+               update_labels (self);
        }
 }
 
 void
+nautilus_floating_bar_set_labels (NautilusFloatingBar *self,
+                                 const gchar *primary_label,
+                                 const gchar *details_label)
+{
+       nautilus_floating_bar_set_primary_label (self, primary_label);
+       nautilus_floating_bar_set_details_label (self, details_label);
+}
+
+void
 nautilus_floating_bar_set_show_spinner (NautilusFloatingBar *self,
                                        gboolean show_spinner)
 {
@@ -328,11 +392,13 @@ nautilus_floating_bar_set_show_spinner (NautilusFloatingBar *self,
 }
 
 GtkWidget *
-nautilus_floating_bar_new (const gchar *label,
+nautilus_floating_bar_new (const gchar *primary_label,
+                          const gchar *details_label,
                           gboolean show_spinner)
 {
        return g_object_new (NAUTILUS_TYPE_FLOATING_BAR,
-                            "label", label,
+                            "primary-label", primary_label,
+                            "details-label", details_label,
                             "show-spinner", show_spinner,
                             "orientation", GTK_ORIENTATION_HORIZONTAL,
                             "spacing", 8,
@@ -341,12 +407,12 @@ nautilus_floating_bar_new (const gchar *label,
 
 void
 nautilus_floating_bar_add_action (NautilusFloatingBar *self,
-                                 const gchar *stock_id,
+                                 const gchar *icon_name,
                                  gint action_id)
 {
        GtkWidget *w, *button;
 
-       w = gtk_image_new_from_stock (stock_id, GTK_ICON_SIZE_MENU);
+       w = gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_MENU);
        gtk_widget_show (w);
 
        button = gtk_button_new ();
diff --git a/lib/widgets/nautilus-floating-bar.h b/lib/widgets/nautilus-floating-bar.h
index 03ea0f9..ba31ac5 100644
--- a/lib/widgets/nautilus-floating-bar.h
+++ b/lib/widgets/nautilus-floating-bar.h
@@ -58,16 +58,22 @@ struct _NautilusFloatingBarClass {
 /* GObject */
 GType       nautilus_floating_bar_get_type  (void);
 
-GtkWidget * nautilus_floating_bar_new              (const gchar *label,
+GtkWidget * nautilus_floating_bar_new              (const gchar *primary_label,
+                                                   const gchar *details_label,
                                                    gboolean show_spinner);
 
-void        nautilus_floating_bar_set_label        (NautilusFloatingBar *self,
+void       nautilus_floating_bar_set_primary_label (NautilusFloatingBar *self,
                                                    const gchar *label);
+void       nautilus_floating_bar_set_details_label (NautilusFloatingBar *self,
+                                                   const gchar *label);
+void        nautilus_floating_bar_set_labels        (NautilusFloatingBar *self,
+                                                    const gchar *primary,
+                                                    const gchar *detail);
 void        nautilus_floating_bar_set_show_spinner (NautilusFloatingBar *self,
                                                    gboolean show_spinner);
 
 void        nautilus_floating_bar_add_action       (NautilusFloatingBar *self,
-                                                   const gchar *stock_id,
+                                                   const gchar *icon_name,
                                                    gint action_id);
 void        nautilus_floating_bar_cleanup_actions  (NautilusFloatingBar *self);
 


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