[epiphany/wip/exalm/entry: 1/4] Revert "Replace custom url progress bar with built in version of GtkEntry"



commit 3fc9df2ebbb5e39862625cc6c6cb741bc4e98b58
Author: Alexander Mikhaylenko <exalm7659 gmail com>
Date:   Mon Sep 3 18:54:18 2018 +0500

    Revert "Replace custom url progress bar with built in version of GtkEntry"
    
    This reverts commit 17cd06fc53e477460b47a10d399955df6fe55a9b.

 lib/widgets/ephy-location-entry.c | 37 +++++++++++++++++++++----------------
 1 file changed, 21 insertions(+), 16 deletions(-)
---
diff --git a/lib/widgets/ephy-location-entry.c b/lib/widgets/ephy-location-entry.c
index 81d92693a..684f214a2 100644
--- a/lib/widgets/ephy-location-entry.c
+++ b/lib/widgets/ephy-location-entry.c
@@ -57,6 +57,7 @@ struct _EphyLocationEntry {
   GtkOverlay parent_instance;
 
   GtkWidget *url_entry;
+  GtkWidget *progress_bar;
   GtkWidget *bookmark;
   GtkWidget *bookmark_event_box;
   GtkWidget *reader_mode;
@@ -791,17 +792,7 @@ button_box_size_allocated_cb (GtkWidget    *widget,
   GtkCssProvider *css_provider = gtk_css_provider_new();
   gchar *css;
 
-  /* We are using the CSS provider here to solve UI displaying issues:
-   *  - padding-right is used to prevent text below the icons on the right side
-   *    of the entry (removing the icon button box width (allocation width)
-   *    including border spacing 5).
-   *  - progress margin-right is used to allow progress bar below icons on the
-   *    right side.
-   */
-  css = g_strdup_printf (".url_entry { padding-right: %dpx; }"\
-                         ".url_entry progress { margin-right: -%dpx; }",
-                         allocation->width + 5,
-                         allocation->width);
+  css = g_strdup_printf (".url_entry { padding-right: %dpx; }", allocation->width + 5);
   gtk_css_provider_load_from_data (css_provider, css, -1, NULL);
 
   gtk_style_context_add_provider_for_screen (gdk_screen_get_default (),
@@ -828,6 +819,14 @@ ephy_location_entry_construct_contents (EphyLocationEntry *entry)
   gtk_widget_show (entry->url_entry);
   gtk_overlay_add_overlay (GTK_OVERLAY (entry), entry->url_entry);
 
+  /* Progress bar */
+  entry->progress_bar = gtk_progress_bar_new ();
+  gtk_style_context_add_class (gtk_widget_get_style_context (entry->progress_bar), "url_progress");
+  gtk_widget_set_halign (entry->progress_bar, GTK_ALIGN_FILL);
+  gtk_widget_set_valign (entry->progress_bar, GTK_ALIGN_END);
+  gtk_widget_show (entry->progress_bar);
+  gtk_overlay_add_overlay (GTK_OVERLAY (entry), entry->progress_bar);
+
   /* Button Box */
   button_box = gtk_button_box_new (GTK_ORIENTATION_HORIZONTAL);
   gtk_box_set_homogeneous (GTK_BOX (button_box), FALSE);
@@ -1428,7 +1427,8 @@ progress_hide (gpointer user_data)
 {
   EphyLocationEntry *entry = EPHY_LOCATION_ENTRY (user_data);
 
-  gtk_entry_set_progress_fraction (GTK_ENTRY (entry->url_entry), 0);
+  gtk_widget_hide (entry->progress_bar);
+  gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (entry->progress_bar), 0);
 
   if (entry->progress_timeout) {
     g_source_remove (entry->progress_timeout);
@@ -1447,7 +1447,7 @@ ephy_location_entry_set_fraction_internal (gpointer user_data)
   gdouble current;
 
   entry->progress_timeout = 0;
-  current = gtk_entry_get_progress_fraction (GTK_ENTRY (entry->url_entry));
+  current = gtk_progress_bar_get_fraction (GTK_PROGRESS_BAR (entry->progress_bar));
 
   if ((entry->progress_fraction - current) > 0.5 || entry->progress_fraction == 1.0)
     ms = 10;
@@ -1456,10 +1456,12 @@ ephy_location_entry_set_fraction_internal (gpointer user_data)
 
   progress = current + 0.025;
   if (progress < entry->progress_fraction) {
-    gtk_entry_set_progress_fraction (GTK_ENTRY (entry->url_entry), progress);
+    gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (entry->progress_bar),
+                                   progress);
     entry->progress_timeout = g_timeout_add (ms, ephy_location_entry_set_fraction_internal, entry);
   } else {
-    gtk_entry_set_progress_fraction (GTK_ENTRY (entry->url_entry), entry->progress_fraction);
+    gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (entry->progress_bar),
+                                   entry->progress_fraction);
     if (entry->progress_fraction == 1.0)
       entry->progress_timeout = g_timeout_add (500, progress_hide, entry);
   }
@@ -1478,10 +1480,13 @@ ephy_location_entry_set_progress (EphyLocationEntry *entry,
  }
 
   if (!loading) {
-    gtk_entry_set_progress_fraction (GTK_ENTRY (entry->url_entry), 0);
+    gtk_widget_hide (entry->progress_bar);
     return;
   }
 
+  if (!gtk_widget_is_visible (entry->progress_bar))
+    gtk_widget_show (entry->progress_bar);
+
   entry->progress_fraction = fraction;
   ephy_location_entry_set_fraction_internal (entry);
 }


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