[evince] Revert "shell: Use a GtkHeaderBar instead of a GtkToolbar and window decorations"



commit 48ef49533e76cdb924309905e93c41e776b8e8d0
Author: Carlos Garcia Campos <carlosgc gnome org>
Date:   Sat May 10 12:00:10 2014 +0200

    Revert "shell: Use a GtkHeaderBar instead of a GtkToolbar and window decorations"
    
    This reverts commit c9127524e1409d582f038439e9143695d1fadc0d.
    
    It broke the fullscreen mode.

 libmisc/ev-page-action-widget.c |   23 +-----------
 shell/ev-toolbar.c              |   77 +++++++++++++++++++++++----------------
 shell/ev-toolbar.h              |    4 +-
 shell/ev-window.c               |    7 +++-
 4 files changed, 55 insertions(+), 56 deletions(-)
---
diff --git a/libmisc/ev-page-action-widget.c b/libmisc/ev-page-action-widget.c
index 5eb5039..6b88635 100644
--- a/libmisc/ev-page-action-widget.c
+++ b/libmisc/ev-page-action-widget.c
@@ -319,30 +319,11 @@ ev_page_action_widget_finalize (GObject *object)
 }
 
 static void
-ev_page_action_widget_get_preferred_width (GtkWidget *widget,
-                                           gint      *minimum_width,
-                                           gint      *natural_width)
+ev_page_action_widget_class_init (EvPageActionWidgetClass *class)
 {
-        GtkWidget *child;
-
-        *minimum_width = *natural_width = 0;
-
-        child = gtk_bin_get_child (GTK_BIN (widget));
-        if (!child || !gtk_widget_get_visible (child))
-                return;
-
-        gtk_widget_get_preferred_width (child, minimum_width, natural_width);
-        *natural_width = *minimum_width;
-}
-
-static void
-ev_page_action_widget_class_init (EvPageActionWidgetClass *klass)
-{
-       GObjectClass *object_class = G_OBJECT_CLASS (klass);
-        GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+       GObjectClass *object_class = G_OBJECT_CLASS (class);
 
        object_class->finalize = ev_page_action_widget_finalize;
-        widget_class->get_preferred_width = ev_page_action_widget_get_preferred_width;
 
        widget_signals[WIDGET_ACTIVATE_LINK] =
                g_signal_new ("activate_link",
diff --git a/shell/ev-toolbar.c b/shell/ev-toolbar.c
index 48b4280..f9f87e6 100644
--- a/shell/ev-toolbar.c
+++ b/shell/ev-toolbar.c
@@ -44,7 +44,7 @@ struct _EvToolbarPrivate {
         GtkWidget *action_menu_button;
 };
 
-G_DEFINE_TYPE (EvToolbar, ev_toolbar, GTK_TYPE_HEADER_BAR)
+G_DEFINE_TYPE (EvToolbar, ev_toolbar, GTK_TYPE_TOOLBAR)
 
 static void
 ev_toolbar_set_property (GObject      *object,
@@ -124,7 +124,7 @@ ev_toolbar_create_button_group (EvToolbar *ev_toolbar)
         GtkStyleContext *style_context;
         GtkWidget *box;
 
-        box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
+        box = gtk_box_new (gtk_orientable_get_orientation (GTK_ORIENTABLE (ev_toolbar)), 0);
 
         style_context = gtk_widget_get_style_context (box);
         gtk_style_context_add_class (style_context, GTK_STYLE_CLASS_RAISED);
@@ -150,6 +150,11 @@ ev_toolbar_constructed (GObject *object)
 
         rtl = gtk_widget_get_direction (GTK_WIDGET (ev_toolbar)) == GTK_TEXT_DIR_RTL;
 
+        /* Set the MENUBAR style class so it's possible to drag the app
+         * using the toolbar. */
+        gtk_style_context_add_class (gtk_widget_get_style_context (GTK_WIDGET (ev_toolbar)),
+                                     GTK_STYLE_CLASS_MENUBAR);
+
         action_group = ev_window_get_main_action_group (ev_toolbar->priv->window);
         ui_manager = ev_window_get_ui_manager (ev_toolbar->priv->window);
 
@@ -168,33 +173,33 @@ ev_toolbar_constructed (GObject *object)
 
         tool_item = GTK_WIDGET (gtk_tool_item_new ());
         if (rtl)
-                gtk_widget_set_margin_left (tool_item, 6);
+                gtk_widget_set_margin_left (tool_item, 12);
         else
-                gtk_widget_set_margin_right (tool_item, 6);
+                gtk_widget_set_margin_right (tool_item, 12);
         gtk_container_add (GTK_CONTAINER (tool_item), hbox);
         gtk_widget_show (hbox);
 
-        gtk_header_bar_pack_start (GTK_HEADER_BAR (ev_toolbar), tool_item);
+        gtk_container_add (GTK_CONTAINER (ev_toolbar), tool_item);
         gtk_widget_show (tool_item);
 
         /* Page selector */
         action = gtk_action_group_get_action (action_group, "PageSelector");
         tool_item = gtk_action_create_tool_item (action);
         if (rtl)
-                gtk_widget_set_margin_left (tool_item, 6);
+                gtk_widget_set_margin_left (tool_item, 12);
         else
-                gtk_widget_set_margin_right (tool_item, 6);
-        gtk_header_bar_pack_start (GTK_HEADER_BAR (ev_toolbar), tool_item);
+                gtk_widget_set_margin_right (tool_item, 12);
+        gtk_container_add (GTK_CONTAINER (ev_toolbar), tool_item);
         gtk_widget_show (tool_item);
 
         /* History */
         action = gtk_action_group_get_action (action_group, "History");
         tool_item = gtk_action_create_tool_item (action);
         if (rtl)
-                gtk_widget_set_margin_left (tool_item, 6);
+                gtk_widget_set_margin_left (tool_item, 12);
         else
-                gtk_widget_set_margin_right (tool_item, 6);
-        gtk_header_bar_pack_start (GTK_HEADER_BAR (ev_toolbar), tool_item);
+                gtk_widget_set_margin_right (tool_item, 12);
+        gtk_container_add (GTK_CONTAINER (ev_toolbar), tool_item);
         gtk_widget_show (tool_item);
 
         /* Find */
@@ -204,23 +209,26 @@ ev_toolbar_constructed (GObject *object)
         gtk_container_add (GTK_CONTAINER (tool_item), button);
         gtk_widget_show (button);
         if (rtl)
-                gtk_widget_set_margin_left (tool_item, 6);
+                gtk_widget_set_margin_left (tool_item, 12);
         else
-                gtk_widget_set_margin_right (tool_item, 6);
-        gtk_header_bar_pack_start (GTK_HEADER_BAR (ev_toolbar), tool_item);
+                gtk_widget_set_margin_right (tool_item, 12);
+        gtk_container_add (GTK_CONTAINER (ev_toolbar), tool_item);
         gtk_widget_show (tool_item);
 
-        /* Action Menu */
-        menu = gtk_ui_manager_get_widget (ui_manager, "/ActionMenu");
-        button = ev_toolbar_create_menu_button (ev_toolbar, "emblem-system-symbolic",
-                                                menu, GTK_ALIGN_END);
-        gtk_widget_set_tooltip_text (button, _("File options"));
-        ev_toolbar->priv->action_menu_button = button;
+        /* Separator */
         tool_item = GTK_WIDGET (gtk_tool_item_new ());
-        gtk_container_add (GTK_CONTAINER (tool_item), button);
-        gtk_widget_show (button);
+        gtk_tool_item_set_expand (GTK_TOOL_ITEM (tool_item), TRUE);
+        gtk_container_add (GTK_CONTAINER (ev_toolbar), tool_item);
+        gtk_widget_show (tool_item);
 
-        gtk_header_bar_pack_end (GTK_HEADER_BAR (ev_toolbar), tool_item);
+        /* Zoom selector */
+        action = gtk_action_group_get_action (action_group, "ViewZoom");
+        tool_item = gtk_action_create_tool_item (action);
+        if (rtl)
+                gtk_widget_set_margin_left (tool_item, 12);
+        else
+                gtk_widget_set_margin_right (tool_item, 12);
+        gtk_container_add (GTK_CONTAINER (ev_toolbar), tool_item);
         gtk_widget_show (tool_item);
 
         /* View Menu */
@@ -232,18 +240,25 @@ ev_toolbar_constructed (GObject *object)
         tool_item = GTK_WIDGET (gtk_tool_item_new ());
         gtk_container_add (GTK_CONTAINER (tool_item), button);
         gtk_widget_show (button);
-
-        gtk_header_bar_pack_end (GTK_HEADER_BAR (ev_toolbar), tool_item);
-        gtk_widget_show (tool_item);
-
-        /* Zoom selector */
-        action = gtk_action_group_get_action (action_group, "ViewZoom");
-        tool_item = gtk_action_create_tool_item (action);
         if (rtl)
                 gtk_widget_set_margin_left (tool_item, 6);
         else
                 gtk_widget_set_margin_right (tool_item, 6);
-        gtk_header_bar_pack_end (GTK_HEADER_BAR (ev_toolbar), tool_item);
+
+        gtk_container_add (GTK_CONTAINER (ev_toolbar), tool_item);
+        gtk_widget_show (tool_item);
+
+        /* Action Menu */
+        menu = gtk_ui_manager_get_widget (ui_manager, "/ActionMenu");
+        button = ev_toolbar_create_menu_button (ev_toolbar, "emblem-system-symbolic",
+                                                menu, GTK_ALIGN_END);
+        gtk_widget_set_tooltip_text (button, _("File options"));
+        ev_toolbar->priv->action_menu_button = button;
+        tool_item = GTK_WIDGET (gtk_tool_item_new ());
+        gtk_container_add (GTK_CONTAINER (tool_item), button);
+        gtk_widget_show (button);
+
+        gtk_container_add (GTK_CONTAINER (ev_toolbar), tool_item);
         gtk_widget_show (tool_item);
 }
 
diff --git a/shell/ev-toolbar.h b/shell/ev-toolbar.h
index 7b79725..0c54932 100644
--- a/shell/ev-toolbar.h
+++ b/shell/ev-toolbar.h
@@ -38,13 +38,13 @@ typedef struct _EvToolbarClass   EvToolbarClass;
 typedef struct _EvToolbarPrivate EvToolbarPrivate;
 
 struct _EvToolbar {
-        GtkHeaderBar base_instance;
+        GtkToolbar base_instance;
 
         EvToolbarPrivate *priv;
 };
 
 struct _EvToolbarClass {
-        GtkHeaderBarClass base_class;
+        GtkToolbarClass base_class;
 };
 
 GType      ev_toolbar_get_type           (void);
diff --git a/shell/ev-window.c b/shell/ev-window.c
index 9d74bdb..174284a 100644
--- a/shell/ev-window.c
+++ b/shell/ev-window.c
@@ -7357,8 +7357,11 @@ ev_window_init (EvWindow *ev_window)
 
        ev_window->priv->toolbar = ev_toolbar_new (ev_window);
        gtk_widget_set_no_show_all (ev_window->priv->toolbar, TRUE);
-       gtk_header_bar_set_show_close_button (GTK_HEADER_BAR (ev_window->priv->toolbar), TRUE);
-       gtk_window_set_titlebar (GTK_WINDOW (ev_window), ev_window->priv->toolbar);
+       gtk_widget_set_halign (ev_window->priv->toolbar, GTK_ALIGN_FILL);
+       gtk_widget_set_valign (ev_window->priv->toolbar, GTK_ALIGN_START);
+       gtk_box_pack_start (GTK_BOX (ev_window->priv->main_box),
+                           ev_window->priv->toolbar,
+                           FALSE, TRUE, 0);
        gtk_widget_show (ev_window->priv->toolbar);
 
        /* Find Bar */


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