[evince/wip/recent-view: 1/4] ev-recent-view-toolbar: Implement a different toolbar for recent view



commit 13ece3be90395b565b919c455b67d3f84c70ac59
Author: Aakash Goenka <aakash goenka gmail com>
Date:   Sun May 4 08:33:05 2014 -0700

    ev-recent-view-toolbar: Implement a different toolbar for recent view
    
    Added a new EvRecentViewToolbar which is displayed while in
    recent view, instead of the full regular toolbar.

 shell/Makefile.am              |    4 +-
 shell/ev-recent-view-toolbar.c |  155 ++++++++++++++++++++++++++++++++++++++++
 shell/ev-recent-view-toolbar.h |   58 +++++++++++++++
 3 files changed, 216 insertions(+), 1 deletions(-)
---
diff --git a/shell/Makefile.am b/shell/Makefile.am
index a038281..e79eaae 100644
--- a/shell/Makefile.am
+++ b/shell/Makefile.am
@@ -48,7 +48,9 @@ evince_SOURCES=                               \
        ev-open-recent-action.c         \
        ev-open-recent-action.h         \
        ev-recent-view.c                \
-       ev-recent-view.h                \
+       ev-recent-view.h                \
+       ev-recent-view-toolbar.c        \
+       ev-recent-view-toolbar.h        \
        ev-toolbar.c                    \
        ev-toolbar.h                    \
        ev-toolbar-main.c               \
diff --git a/shell/ev-recent-view-toolbar.c b/shell/ev-recent-view-toolbar.c
new file mode 100644
index 0000000..a2cdfc3
--- /dev/null
+++ b/shell/ev-recent-view-toolbar.c
@@ -0,0 +1,155 @@
+/* ev-recent-view.c
+ *  this file is part of evince, a gnome document viewer
+ *
+ * Copyright (C) 2012 Carlos Garcia Campos <carlosgc gnome org>
+ * Copyright (C) 2013 Aakash Goenka <aakash goenka gmail com>
+ * Copyright (C) 2014 Germán Poo-Caamaño <gpoo gnome org>
+ *
+ * Evince is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Evince is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "ev-toolbar.h"
+#include "ev-recent-view-toolbar.h"
+#include <math.h>
+
+enum
+{
+       PROP_0,
+       PROP_WINDOW
+};
+
+struct _EvRecentViewToolbarPrivate {
+       EvWindow *window;
+};
+
+G_DEFINE_TYPE (EvRecentViewToolbar, ev_recent_view_toolbar, EV_TYPE_TOOLBAR)
+
+static void
+ev_recent_view_toolbar_set_property (GObject      *object,
+                                    guint         prop_id,
+                                    const GValue *value,
+                                    GParamSpec   *pspec)
+{
+        EvRecentViewToolbar *ev_toolbar = EV_RECENT_VIEW_TOOLBAR (object);
+
+        switch (prop_id) {
+        case PROP_WINDOW:
+                ev_toolbar->priv->window = g_value_get_object (value);
+                break;
+        default:
+                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+        }
+}
+
+static void
+keep_active_button_cb (GtkToggleButton *button,
+                      gpointer         data)
+{
+       gtk_toggle_button_set_active (button, TRUE);
+}
+
+static void
+ev_recent_view_toolbar_constructed (GObject *object)
+{
+       EvRecentViewToolbar *ev_recent_view_toolbar = EV_RECENT_VIEW_TOOLBAR (object);
+       GtkActionGroup   *action_group;
+       GtkWidget        *tool_item;
+       GtkAction        *action;
+       GtkWidget        *button;
+        gboolean        rtl;
+
+       G_OBJECT_CLASS (ev_recent_view_toolbar_parent_class)->constructed (object);
+
+        rtl = gtk_widget_get_direction (GTK_WIDGET (ev_recent_view_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_recent_view_toolbar)),
+                                    GTK_STYLE_CLASS_MENUBAR);
+
+       action_group = ev_window_get_recent_view_toolbar_action_group (ev_recent_view_toolbar->priv->window);
+
+       /* View of recent items */
+       action = gtk_action_group_get_action (action_group, "RecentViewHide");
+       button = ev_toolbar_create_toggle_button (EV_TOOLBAR (ev_recent_view_toolbar), action);
+       gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
+       tool_item = GTK_WIDGET (gtk_tool_item_new ());
+        if (rtl)
+                gtk_widget_set_margin_left (tool_item, 12);
+        else
+                gtk_widget_set_margin_right (tool_item, 12);
+       gtk_container_add (GTK_CONTAINER (tool_item), button);
+       gtk_widget_show (button);
+       gtk_container_add (GTK_CONTAINER (ev_recent_view_toolbar), tool_item);
+       g_signal_connect (button, "toggled",
+                         G_CALLBACK (keep_active_button_cb), NULL);
+       gtk_widget_show (tool_item);
+
+       /* Button for file open dialog */
+       action = gtk_action_group_get_action (action_group, "ToolbarOpenDocument");
+       button = ev_toolbar_create_button (EV_TOOLBAR (ev_recent_view_toolbar), action);
+       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_recent_view_toolbar), tool_item);
+       gtk_widget_show (tool_item);
+
+       /* Separator */
+       tool_item = GTK_WIDGET (gtk_tool_item_new ());
+       gtk_tool_item_set_expand (GTK_TOOL_ITEM (tool_item), TRUE);
+       gtk_container_add (GTK_CONTAINER (ev_recent_view_toolbar), tool_item);
+       gtk_widget_show (tool_item);
+}
+
+static void
+ev_recent_view_toolbar_class_init (EvRecentViewToolbarClass *klass)
+{
+       GObjectClass *g_object_class = G_OBJECT_CLASS (klass);
+
+       g_object_class->set_property = ev_recent_view_toolbar_set_property;
+       g_object_class->constructed = ev_recent_view_toolbar_constructed;
+
+       g_object_class_install_property (g_object_class,
+                                        PROP_WINDOW,
+                                        g_param_spec_object ("window",
+                                        "Window",
+                                        "The evince window",
+                                        EV_TYPE_WINDOW,
+                                        G_PARAM_WRITABLE |
+                                        G_PARAM_CONSTRUCT_ONLY |
+                                        G_PARAM_STATIC_STRINGS));
+
+       g_type_class_add_private (g_object_class, sizeof (EvRecentViewToolbarPrivate));
+}
+
+static void
+ev_recent_view_toolbar_init (EvRecentViewToolbar *ev_recent_view_toolbar)
+{
+       ev_recent_view_toolbar->priv = G_TYPE_INSTANCE_GET_PRIVATE (ev_recent_view_toolbar, 
EV_TYPE_RECENT_VIEW_TOOLBAR, EvRecentViewToolbarPrivate);
+}
+
+GtkWidget *
+ev_recent_view_toolbar_new (EvWindow *window)
+{
+       g_return_val_if_fail (EV_IS_WINDOW (window), NULL);
+
+       return GTK_WIDGET (g_object_new (EV_TYPE_RECENT_VIEW_TOOLBAR,
+                                        "window", window,
+                                        NULL));
+}
diff --git a/shell/ev-recent-view-toolbar.h b/shell/ev-recent-view-toolbar.h
new file mode 100644
index 0000000..54a1db0
--- /dev/null
+++ b/shell/ev-recent-view-toolbar.h
@@ -0,0 +1,58 @@
+/* ev-recent-view-toolbar.h
+ *  this file is part of evince, a gnome document viewer
+ *
+ * Copyright (C) 2012 Carlos Garcia Campos <carlosgc gnome org>
+ * Copyright (C) 2013 Aakash Goenka <aakash goenka gmail com>
+ * Copyright (C) 2014 Germán Poo-Caamaño <gpoo gnome org>
+ *
+ * Evince is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Evince is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#ifndef __EV_RECENT_VIEW_TOOLBAR_H__
+#define __EV_RECENT_VIEW_TOOLBAR_H__
+
+#include <gtk/gtk.h>
+#include "ev-window.h"
+#include "ev-toolbar.h"
+
+G_BEGIN_DECLS
+
+#define EV_TYPE_RECENT_VIEW_TOOLBAR              (ev_recent_view_toolbar_get_type())
+#define EV_RECENT_VIEW_TOOLBAR(object)           (G_TYPE_CHECK_INSTANCE_CAST((object), 
EV_TYPE_RECENT_VIEW_TOOLBAR, EvRecentViewToolbar))
+#define EV_IS_RECENT_VIEW_TOOLBAR(object)        (G_TYPE_CHECK_INSTANCE_TYPE((object), 
EV_TYPE_RECENT_VIEW_TOOLBAR))
+#define EV_RECENT_VIEW_TOOLBAR_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST((klass), 
EV_TYPE_RECENT_VIEW_TOOLBAR, EvRecentViewToolbarClass))
+#define EV_IS_RECENT_VIEW_TOOLBAR_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE((klass), 
EV_TYPE_RECENT_VIEW_TOOLBAR))
+#define EV_RECENT_VIEW_TOOLBAR_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS((object), 
EV_TYPE_RECENT_VIEW_TOOLBAR, EvRecentViewToolbarClass))
+
+typedef struct _EvRecentViewToolbar        EvRecentViewToolbar;
+typedef struct _EvRecentViewToolbarClass   EvRecentViewToolbarClass;
+typedef struct _EvRecentViewToolbarPrivate EvRecentViewToolbarPrivate;
+
+struct _EvRecentViewToolbar {
+       EvToolbar base_instance;
+
+       EvRecentViewToolbarPrivate *priv;
+};
+
+struct _EvRecentViewToolbarClass {
+       EvToolbarClass base_class;
+};
+
+GType      ev_recent_view_toolbar_get_type (void);
+GtkWidget *ev_recent_view_toolbar_new      (EvWindow *window);
+
+G_END_DECLS
+
+#endif /* __EV_RECENT_VIEW_TOOLBAR_H__ */


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