[evince] shell: make zoom-menu internal to EvZoomAction



commit b4711a0eb92ba815c82a58ade25eb8325299d726
Author: Pablo Correa Gómez <ablocorrea hotmail com>
Date:   Thu Mar 31 23:31:27 2022 +0200

    shell: make zoom-menu internal to EvZoomAction
    
    The menu actually belongs to EvZoomAction and EvToolbar has no
    reason to manipulate it. This allows to remove the "menu"
    property for EvZoomAction, which is unneeded, as nothing external
    to EvZoomAction ever requests or uses the said menu
    
    Co-authored-by: Qiu Wenbo <qiuwenbo kylinos com cn>

 shell/ev-toolbar.c          |  3 +--
 shell/ev-zoom-action.c      | 20 ++------------------
 shell/ev-zoom-action.h      |  3 +--
 shell/evince-menus.ui       | 23 -----------------------
 shell/evince-zoom-action.ui | 22 ++++++++++++++++++++++
 5 files changed, 26 insertions(+), 45 deletions(-)
---
diff --git a/shell/ev-toolbar.c b/shell/ev-toolbar.c
index 8bbeb5a69..61398b05a 100644
--- a/shell/ev-toolbar.c
+++ b/shell/ev-toolbar.c
@@ -250,8 +250,7 @@ ev_toolbar_constructed (GObject *object)
                           ev_toolbar);
 
         /* Zoom selector */
-        vbox = ev_zoom_action_new (ev_window_get_document_model (priv->window),
-                                   G_MENU (gtk_builder_get_object (builder, "zoom-menu")));
+        vbox = ev_zoom_action_new (ev_window_get_document_model (priv->window));
         priv->zoom_action = vbox;
         atk_object_set_name (gtk_widget_get_accessible (vbox), _("Set zoom level"));
         g_signal_connect (vbox, "activated",
diff --git a/shell/ev-zoom-action.c b/shell/ev-zoom-action.c
index cd7bffb87..e19fceb5c 100644
--- a/shell/ev-zoom-action.c
+++ b/shell/ev-zoom-action.c
@@ -34,7 +34,6 @@ enum
         PROP_0,
 
         PROP_DOCUMENT_MODEL,
-        PROP_MENU
 };
 
 enum {
@@ -271,7 +270,6 @@ ev_zoom_action_finalize (GObject *object)
                                               (gpointer)&priv->model);
         }
 
-        g_clear_object (&priv->menu);
         g_clear_object (&priv->zoom_free_section);
 
         G_OBJECT_CLASS (ev_zoom_action_parent_class)->finalize (object);
@@ -290,9 +288,6 @@ ev_zoom_action_set_property (GObject      *object,
         case PROP_DOCUMENT_MODEL:
                 priv->model = g_value_get_object (value);
                 break;
-        case PROP_MENU:
-                priv->menu = g_value_dup_object (value);
-                break;
         default:
                 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
         }
@@ -358,6 +353,7 @@ ev_zoom_action_class_init (EvZoomActionClass *klass)
                                                       EvZoomAction,
                                                       entry);
        gtk_widget_class_bind_template_child_private (widget_class, EvZoomAction, popup);
+       gtk_widget_class_bind_template_child_private (widget_class, EvZoomAction, menu);
        gtk_widget_class_bind_template_callback (widget_class, entry_icon_press_cb);
        gtk_widget_class_bind_template_callback (widget_class, entry_activated_cb);
        gtk_widget_class_bind_template_callback (widget_class, focus_out_cb);
@@ -371,15 +367,6 @@ ev_zoom_action_class_init (EvZoomActionClass *klass)
                                                               G_PARAM_WRITABLE |
                                                               G_PARAM_CONSTRUCT_ONLY |
                                                               G_PARAM_STATIC_STRINGS));
-        g_object_class_install_property (object_class,
-                                         PROP_MENU,
-                                         g_param_spec_object ("menu",
-                                                              "Menu",
-                                                              "The zoom popup menu",
-                                                              G_TYPE_MENU,
-                                                              G_PARAM_WRITABLE |
-                                                              G_PARAM_CONSTRUCT_ONLY |
-                                                              G_PARAM_STATIC_STRINGS));
 
         signals[ACTIVATED] =
                 g_signal_new ("activated",
@@ -405,14 +392,11 @@ ev_zoom_action_init (EvZoomAction *zoom_action)
 }
 
 GtkWidget *
-ev_zoom_action_new (EvDocumentModel *model,
-                    GMenu           *menu)
+ev_zoom_action_new (EvDocumentModel *model)
 {
         g_return_val_if_fail (EV_IS_DOCUMENT_MODEL (model), NULL);
-        g_return_val_if_fail (G_IS_MENU (menu), NULL);
 
         return GTK_WIDGET (g_object_new (EV_TYPE_ZOOM_ACTION,
                                          "document-model", model,
-                                         "menu", menu,
                                          NULL));
 }
diff --git a/shell/ev-zoom-action.h b/shell/ev-zoom-action.h
index 8502a994b..01aca3a75 100644
--- a/shell/ev-zoom-action.h
+++ b/shell/ev-zoom-action.h
@@ -46,7 +46,6 @@ struct _EvZoomActionClass {
 
 GType      ev_zoom_action_get_type        (void);
 
-GtkWidget *ev_zoom_action_new             (EvDocumentModel *model,
-                                           GMenu           *menu);
+GtkWidget *ev_zoom_action_new             (EvDocumentModel *model);
 
 G_END_DECLS
diff --git a/shell/evince-menus.ui b/shell/evince-menus.ui
index 35b8c28f4..42d450c4a 100644
--- a/shell/evince-menus.ui
+++ b/shell/evince-menus.ui
@@ -121,28 +121,6 @@
     </section>
   </menu>
 
-  <menu id="zoom-menu">
-    <section>
-      <item>
-        <attribute name="label" translatable="yes">Fit Pa_ge</attribute>
-        <attribute name="action">win.sizing-mode</attribute>
-        <attribute name="target">fit-page</attribute>
-      </item>
-      <item>
-        <attribute name="label" translatable="yes">Fit _Width</attribute>
-        <attribute name="action">win.sizing-mode</attribute>
-        <attribute name="target">fit-width</attribute>
-      </item>
-      <item>
-        <attribute name="label" translatable="yes">_Automatic</attribute>
-        <attribute name="action">win.sizing-mode</attribute>
-        <attribute name="target">automatic</attribute>
-      </item>
-    </section>
-    <section>
-    </section>
-  </menu>
-
   <menu id="view-popup-menu">
     <section>
       <item>
@@ -333,4 +311,3 @@
     </section>
   </menu>
 </interface>
-
diff --git a/shell/evince-zoom-action.ui b/shell/evince-zoom-action.ui
index be8f190aa..bbf9d0d26 100644
--- a/shell/evince-zoom-action.ui
+++ b/shell/evince-zoom-action.ui
@@ -23,4 +23,26 @@
     <property name="position">3</property>
     <property name="relative-to">entry</property>
   </object>
+
+  <menu id="menu">
+    <section>
+      <item>
+        <attribute name="label" translatable="yes">Fit Pa_ge</attribute>
+        <attribute name="action">win.sizing-mode</attribute>
+        <attribute name="target">fit-page</attribute>
+      </item>
+      <item>
+        <attribute name="label" translatable="yes">Fit _Width</attribute>
+        <attribute name="action">win.sizing-mode</attribute>
+        <attribute name="target">fit-width</attribute>
+      </item>
+      <item>
+        <attribute name="label" translatable="yes">_Automatic</attribute>
+        <attribute name="action">win.sizing-mode</attribute>
+        <attribute name="target">automatic</attribute>
+      </item>
+    </section>
+    <section>
+    </section>
+  </menu>
 </interface>


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