[epiphany] page-menu: Replace GtkEntry with GtkButton to display the zoom level



commit fac3c8f8f6da41672e625d5b1b9f18dd4d315da0
Author: Iulian Radu <iulian radu67 gmail com>
Date:   Tue Sep 27 15:24:30 2016 +0300

    page-menu: Replace GtkEntry with GtkButton to display the zoom level
    
    Also, it is now possible to click on the button to reset the zoom
    level to its default value.

 src/ephy-header-bar.c                  |    1 +
 src/ephy-window.c                      |   22 +++-------------------
 src/resources/gtk/page-menu-popover.ui |    7 +++++--
 3 files changed, 9 insertions(+), 21 deletions(-)
---
diff --git a/src/ephy-header-bar.c b/src/ephy-header-bar.c
index 5d0bcde..cf2b38e 100644
--- a/src/ephy-header-bar.c
+++ b/src/ephy-header-bar.c
@@ -646,6 +646,7 @@ ephy_header_bar_constructed (GObject *object)
   g_type_ensure (G_TYPE_THEMED_ICON);
   builder = gtk_builder_new_from_resource ("/org/gnome/epiphany/gtk/page-menu-popover.ui");
   page_menu_popover = GTK_WIDGET (gtk_builder_get_object (builder, "page-menu-popover"));
+  g_object_set_data (G_OBJECT (page_menu_popover), "zoom-level-button", gtk_builder_get_object (builder, 
"zoom-level"));
   gtk_menu_button_set_popover (GTK_MENU_BUTTON (button), page_menu_popover);
   g_object_unref (builder);
 
diff --git a/src/ephy-window.c b/src/ephy-window.c
index 3d22656..a2cadb2 100644
--- a/src/ephy-window.c
+++ b/src/ephy-window.c
@@ -1014,9 +1014,7 @@ sync_tab_zoom (WebKitWebView *web_view, GParamSpec *pspec, EphyWindow *window)
   double zoom;
   GtkWidget *page_menu_button;
   GtkPopover *page_menu_popover;
-  GtkWidget *widget;
-  GtkWidget *zoom_level_entry;
-  GList *children;
+  GtkWidget *zoom_level_button;
   char *zoom_level_text;
 
   if (window->closing)
@@ -1024,26 +1022,12 @@ sync_tab_zoom (WebKitWebView *web_view, GParamSpec *pspec, EphyWindow *window)
 
   zoom = webkit_web_view_get_zoom_level (web_view);
 
-  /* Update the zoom level entry in the page menu popover:
-   * - obtain the popover from the page menu button
-   * - obtain the box (the first child of the popover)
-   * - obtain the "zoom box" (the first child of the box above)
-   * - obtain the GtkEntry which is the second child of the zoom box
-   */
   page_menu_button = ephy_header_bar_get_page_menu_button (EPHY_HEADER_BAR (window->header_bar));
   page_menu_popover = gtk_menu_button_get_popover (GTK_MENU_BUTTON (page_menu_button));
-  children = gtk_container_get_children (GTK_CONTAINER (page_menu_popover));
-  widget = g_list_nth_data (children, 0);
-  g_assert (GTK_IS_BOX (widget));
-  children = gtk_container_get_children (GTK_CONTAINER (widget));
-  widget = g_list_nth_data (children, 0);
-  g_assert (GTK_IS_BOX (widget));
-  children = gtk_container_get_children (GTK_CONTAINER (widget));
-  zoom_level_entry = g_list_nth_data (children, 1);
-  g_assert (GTK_IS_ENTRY (zoom_level_entry));
+  zoom_level_button = g_object_get_data (G_OBJECT (page_menu_popover), "zoom-level-button");
 
   zoom_level_text = g_strdup_printf ("%.0lf%%", zoom * 100);
-  gtk_entry_set_text (GTK_ENTRY (zoom_level_entry), zoom_level_text);
+  gtk_button_set_label (GTK_BUTTON (zoom_level_button), zoom_level_text);
   g_free (zoom_level_text);
 
   if (zoom >= ZOOM_MAXIMAL) {
diff --git a/src/resources/gtk/page-menu-popover.ui b/src/resources/gtk/page-menu-popover.ui
index 5968690..284d202 100644
--- a/src/resources/gtk/page-menu-popover.ui
+++ b/src/resources/gtk/page-menu-popover.ui
@@ -32,9 +32,12 @@
               </packing>
             </child>
             <child>
-              <object class="GtkEntry" id="zoom-level">
+              <object class="GtkModelButton" id="zoom-level">
+                <property name="text">100%</property>
+                <property name="action-name">win.zoom-normal</property>
+                <property name="iconic">True</property>
                 <property name="xalign">0.5</property>
-                <property name="sensitive">False</property>
+                <property name="centered">True</property>
                 <property name="visible">True</property>
               </object>
               <packing>


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