From: Alexander Mikhaylenko 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 @@ - - Select page or search in the outline - - - Select page - - - - - start - - - - - win.toggle-edit-annots - Annotate the document + + True + slide-right - - document-edit-symbolic - 1 - true - - - - - Annotate document + + horizontal + 6 + + + Select page or search in the outline + + + Select page + + + + + start + + + + + win.toggle-edit-annots + Annotate the document + + + document-edit-symbolic + 1 + true + + + + + Annotate document + + + + + start + + - - start - @@ -103,11 +115,17 @@ - - - - - Set zoom level + + True + slide-left + + + + + + Set zoom level + +