phosh-arch/evince-mobile/0002-toolbar-Allow-hiding-zoom-annotation-and-page-widgets.patch
2024-08-13 08:17:11 -07:00

197 lines
8.7 KiB
Diff

From: Alexander Mikhaylenko <alexm@gnome.org>
Date: Thu, 15 Apr 2021 12:28:10 +0500
Subject: toolbar: Allow hiding zoom, annotation and page widgets
This will be useful to make it adaptive.
---
shell/ev-toolbar.c | 32 +++++++++++++++----
shell/ev-toolbar.h | 2 ++
shell/evince-toolbar.ui | 84 ++++++++++++++++++++++++++++++-------------------
3 files changed, 79 insertions(+), 39 deletions(-)
diff --git a/shell/ev-toolbar.c b/shell/ev-toolbar.c
index 6c5521f..83ba22a 100644
--- a/shell/ev-toolbar.c
+++ b/shell/ev-toolbar.c
@@ -51,6 +51,8 @@ typedef struct {
GtkWidget *zoom_action;
GtkWidget *find_button;
GtkWidget *action_menu_button;
+ GtkWidget *zoom_revealer;
+ GtkWidget *page_annots_revealer;
EvToolbarMode toolbar_mode;
} EvToolbarPrivate;
@@ -141,6 +143,8 @@ ev_toolbar_class_init (EvToolbarClass *klass)
gtk_widget_class_bind_template_child_private (widget_class, EvToolbar, action_menu_button);
gtk_widget_class_bind_template_child_private (widget_class, EvToolbar, find_button);
gtk_widget_class_bind_template_child_private (widget_class, EvToolbar, zoom_action);
+ gtk_widget_class_bind_template_child_private (widget_class, EvToolbar, page_annots_revealer);
+ gtk_widget_class_bind_template_child_private (widget_class, EvToolbar, zoom_revealer);
gtk_widget_class_bind_template_callback (widget_class, ev_toolbar_find_button_sensitive_changed);
gtk_widget_class_bind_template_callback (widget_class, ev_toolbar_zoom_selector_activated);
@@ -235,19 +239,17 @@ ev_toolbar_set_mode (EvToolbar *ev_toolbar,
case EV_TOOLBAR_MODE_FULLSCREEN:
gtk_widget_show (priv->sidebar_button);
gtk_widget_show (priv->action_menu_button);
- gtk_widget_show (priv->zoom_action);
- gtk_widget_show (priv->page_selector);
+ gtk_widget_show (priv->zoom_revealer);
+ gtk_widget_show (priv->page_annots_revealer);
gtk_widget_show (priv->find_button);
- gtk_widget_show (priv->annots_button);
gtk_widget_hide (priv->open_button);
break;
case EV_TOOLBAR_MODE_RECENT_VIEW:
gtk_widget_hide (priv->sidebar_button);
gtk_widget_hide (priv->action_menu_button);
- gtk_widget_hide (priv->zoom_action);
- gtk_widget_hide (priv->page_selector);
+ gtk_widget_hide (priv->zoom_revealer);
+ gtk_widget_hide (priv->page_annots_revealer);
gtk_widget_hide (priv->find_button);
- gtk_widget_hide (priv->annots_button);
gtk_widget_show (priv->open_button);
break;
}
@@ -278,3 +280,21 @@ ev_toolbar_set_sidebar_visible (EvToolbar *ev_toolbar,
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->sidebar_button), visible);
}
+
+void
+ev_toolbar_set_mobile (EvToolbar *ev_toolbar,
+ gboolean mobile)
+{
+ EvToolbarPrivate *priv;
+
+ g_return_if_fail (EV_IS_TOOLBAR (ev_toolbar));
+
+ priv = GET_PRIVATE (ev_toolbar);
+ mobile = !!mobile;
+
+ gtk_revealer_set_reveal_child (GTK_REVEALER (priv->zoom_revealer), !mobile);
+ gtk_revealer_set_reveal_child (GTK_REVEALER (priv->page_annots_revealer), !mobile);
+
+ if (mobile)
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->annots_button), FALSE);
+}
diff --git a/shell/ev-toolbar.h b/shell/ev-toolbar.h
index 1b15e80..1c1f0a2 100644
--- a/shell/ev-toolbar.h
+++ b/shell/ev-toolbar.h
@@ -60,5 +60,7 @@ EvToolbarMode ev_toolbar_get_mode (EvToolbar *ev_toolbar);
void ev_toolbar_set_sidebar_visible (EvToolbar *ev_toolbar,
gboolean visible);
+void ev_toolbar_set_mobile (EvToolbar *ev_toolbar,
+ gboolean mobile);
G_END_DECLS
diff --git a/shell/evince-toolbar.ui b/shell/evince-toolbar.ui
index 4add3ec..f35b961 100644
--- a/shell/evince-toolbar.ui
+++ b/shell/evince-toolbar.ui
@@ -31,38 +31,50 @@
</packing>
</child>
<child>
- <object class="EvPageActionWidget" id="page_selector">
- <property name="tooltip-text" translatable="yes">Select page or search in the outline</property>
- <child internal-child="accessible">
- <object class="AtkObject">
- <property name="AtkObject::accessible-name" translatable="yes">Select page</property>
- </object>
- </child>
- </object>
- <packing>
- <property name="pack-type">start</property>
- </packing>
- </child>
- <child>
- <object class="GtkToggleButton" id="annots_button">
- <property name="action-name">win.toggle-edit-annots</property>
- <property name="tooltip-text" translatable="yes">Annotate the document</property>
+ <object class="GtkRevealer" id="page_annots_revealer">
+ <property name="reveal-child">True</property>
+ <property name="transition-type">slide-right</property>
<child>
- <object class="GtkImage">
- <property name="icon-name">document-edit-symbolic</property>
- <property name="icon-size">1</property>
- <property name="visible">true</property>
- </object>
- </child>
- <child internal-child="accessible">
- <object class="AtkObject">
- <property name="AtkObject::accessible-name" translatable="yes">Annotate document</property>
+ <object class="GtkBox">
+ <property name="orientation">horizontal</property>
+ <property name="spacing">6</property>
+ <child>
+ <object class="EvPageActionWidget" id="page_selector">
+ <property name="tooltip-text" translatable="yes">Select page or search in the outline</property>
+ <child internal-child="accessible">
+ <object class="AtkObject">
+ <property name="AtkObject::accessible-name" translatable="yes">Select page</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="pack-type">start</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkToggleButton" id="annots_button">
+ <property name="action-name">win.toggle-edit-annots</property>
+ <property name="tooltip-text" translatable="yes">Annotate the document</property>
+ <child>
+ <object class="GtkImage">
+ <property name="icon-name">document-edit-symbolic</property>
+ <property name="icon-size">1</property>
+ <property name="visible">true</property>
+ </object>
+ </child>
+ <child internal-child="accessible">
+ <object class="AtkObject">
+ <property name="AtkObject::accessible-name" translatable="yes">Annotate document</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="pack-type">start</property>
+ </packing>
+ </child>
</object>
</child>
</object>
- <packing>
- <property name="pack-type">start</property>
- </packing>
</child>
<child>
<object class="GtkMenuButton" id="action_menu_button">
@@ -103,11 +115,17 @@
</packing>
</child>
<child>
- <object class="EvZoomAction" id="zoom_action">
- <signal name="activated" handler="ev_toolbar_zoom_selector_activated"/>
- <child internal-child="accessible">
- <object class="AtkObject">
- <property name="AtkObject::accessible-name" translatable="yes">Set zoom level</property>
+ <object class="GtkRevealer" id="zoom_revealer">
+ <property name="reveal-child">True</property>
+ <property name="transition-type">slide-left</property>
+ <child>
+ <object class="EvZoomAction" id="zoom_action">
+ <signal name="activated" handler="ev_toolbar_zoom_selector_activated"/>
+ <child internal-child="accessible">
+ <object class="AtkObject">
+ <property name="AtkObject::accessible-name" translatable="yes">Set zoom level</property>
+ </object>
+ </child>
</object>
</child>
</object>