[PATCH] add fullscreen mode

=3D?UTF-8?q?Guido=3D20G=3DC3=3DBCnther?=3D agx at sigxcpu.org
Sun Oct 4 15:05:03 UTC 2009


---
 debian/patches/fullscreen.patch |  465 +++++++++++++++++++++++++++++++++=
++++++
 debian/patches/series           |    1 +
 2 files changed, 466 insertions(+), 0 deletions(-)
 create mode 100644 debian/patches/fullscreen.patch

diff --git a/debian/patches/fullscreen.patch b/debian/patches/fullscreen.=
patch
new file mode 100644
index 0000000..7e7f59a
--- /dev/null
+++ b/debian/patches/fullscreen.patch
@@ -0,0 +1,465 @@
+From c84586837b65e318b3cfd3c7b0e676282255acc5 Mon Sep 17 00:00:00 2001
+From: Fr=E9d=E9ric P=E9ters <fpeters at 0d.be>
+Date: Sun, 04 Oct 2009 13:50:26 +0000
+Subject: Fullscreen mode (GNOME bug 544388)
+
+---
+diff --git a/data/ui/window.ui b/data/ui/window.ui
+index 0df53ce..3018b54 100644
+--- a/data/ui/window.ui
++++ b/data/ui/window.ui
+@@ -23,6 +23,8 @@
+       <menuitem action=3D"ZoomIn"/>
+       <menuitem action=3D"ZoomOut"/>
+       <menuitem action=3D"ZoomDefault"/>
++      <separator/>
++      <menuitem name=3D"ViewFullscreenMenu" action=3D"ViewFullscreen"/>
+     </menu>
+     <menu action=3D"GoMenu">
+       <menuitem action=3D"Back"/>
+@@ -43,4 +45,15 @@
+     <toolitem action=3D"ZoomOut"/>
+     <toolitem action=3D"ZoomIn"/>
+   </toolbar>
++
++  <toolbar name=3D"FullscreenToolBar">
++    <toolitem action=3D"Back"/>
++    <toolitem action=3D"Forward"/>
++    <separator/>
++    <toolitem action=3D"ZoomOut"/>
++    <toolitem action=3D"ZoomIn"/>
++    <separator expand=3D"true"/>
++    <toolitem action=3D"LeaveFullscreen"/>
++  </toolbar>
++
+ </ui>
+diff --git a/src/dh-window.c b/src/dh-window.c
+index 495af29..0e55717 100644
+--- a/src/dh-window.c
++++ b/src/dh-window.c
+@@ -18,6 +18,13 @@
+  * Boston, MA 02111-1307, USA.
+  */
+=20
++/*
++ * Fullscreen mode code adapted from gedit
++ *  Copyright (C) 1998, 1999 Alex Roberts, Evan Lawrence
++ *  Copyright (C) 2000, 2001 Chema Celorio, Paolo Maggi
++ *  Copyright (C) 2002-2005 Paolo Maggi
++ */
++
+ #include "config.h"
+ #include <string.h>
+ #include <glib/gi18n-lib.h>
+@@ -39,6 +46,8 @@
+ #include "eggfindbar.h"
+ #include "ige-conf.h"
+=20
++#define FULLSCREEN_ANIMATION_SPEED 4
++
+ struct _DhWindowPriv {
+         DhBase         *base;
+=20
+@@ -53,6 +62,10 @@ struct _DhWindowPriv {
+         GtkWidget      *vbox;
+         GtkWidget      *findbar;
+=20
++        GtkWidget      *fullscreen_controls;
++        guint           fullscreen_animation_timeout_id;
++        gboolean        fullscreen_animation_enter;
++
+         GtkUIManager   *manager;
+         GtkActionGroup *action_group;
+=20
+@@ -107,9 +120,6 @@ static void           window_tree_link_selected_cb  =
 (GObject         *ignored,
+ static void           window_search_link_selected_cb (GObject         *=
ignored,
+                                                       DhLink          *=
link,
+                                                       DhWindow        *=
window);
+-static void           window_manager_add_widget      (GtkUIManager    *=
manager,
+-                                                      GtkWidget       *=
widget,
+-                                                      DhWindow        *=
window);
+ static void           window_check_history           (DhWindow        *=
window,
+                                                       WebKitWebView   *=
web_view);
+ static void           window_web_view_tab_accel_cb   (GtkAccelGroup   *=
accel_group,
+@@ -369,6 +379,276 @@ window_activate_zoom_default (GtkAction *action,
+         window_update_zoom_actions_sensitiveness (window);
+ }
+=20
++static gboolean
++run_fullscreen_animation (gpointer data)
++{
++	DhWindow *window =3D DH_WINDOW (data);
++	GdkScreen *screen;
++	GdkRectangle fs_rect;
++	gint x, y;
++=09
++	screen =3D gtk_window_get_screen (GTK_WINDOW (window));
++	gdk_screen_get_monitor_geometry (screen,
++					 gdk_screen_get_monitor_at_window (screen,
++									   gtk_widget_get_window (GTK_WIDGET (window))),
++					 &fs_rect);
++					=20
++	gtk_window_get_position (GTK_WINDOW (window->priv->fullscreen_controls=
),
++				 &x, &y);
++=09
++	if (window->priv->fullscreen_animation_enter)
++	{
++		if (y =3D=3D fs_rect.y)
++		{
++			window->priv->fullscreen_animation_timeout_id =3D 0;
++			return FALSE;
++		}
++		else
++		{
++			gtk_window_move (GTK_WINDOW (window->priv->fullscreen_controls),
++					 x, y + 1);
++			return TRUE;
++		}
++	}
++	else
++	{
++		gint w, h;
++=09
++		gtk_window_get_size (GTK_WINDOW (window->priv->fullscreen_controls),
++				     &w, &h);
++=09
++		if (y =3D=3D fs_rect.y - h + 1)
++		{
++			window->priv->fullscreen_animation_timeout_id =3D 0;
++			return FALSE;
++		}
++		else
++		{
++			gtk_window_move (GTK_WINDOW (window->priv->fullscreen_controls),
++					 x, y - 1);
++			return TRUE;
++		}
++	}
++}
++
++static void
++show_hide_fullscreen_toolbar (DhWindow *window,
++                              gboolean     show,
++                              gint         height)
++{
++        GtkSettings *settings;
++        gboolean enable_animations;
++
++        settings =3D gtk_widget_get_settings (GTK_WIDGET (window));
++        g_object_get (G_OBJECT (settings),
++                      "gtk-enable-animations",
++                      &enable_animations,
++                      NULL);
++
++        if (enable_animations)
++        {
++                window->priv->fullscreen_animation_enter =3D show;
++
++                if (window->priv->fullscreen_animation_timeout_id =3D=3D=
 0)
++                {
++                        window->priv->fullscreen_animation_timeout_id =3D
++                                g_timeout_add (FULLSCREEN_ANIMATION_SPE=
ED,
++                                               (GSourceFunc) run_fullsc=
reen_animation,
++                                               window);
++                }
++        }
++        else
++        {
++                GdkRectangle fs_rect;
++                GdkScreen *screen;
++
++                screen =3D gtk_window_get_screen (GTK_WINDOW (window));
++                gdk_screen_get_monitor_geometry (screen,
++                                                 gdk_screen_get_monitor=
_at_window (screen,
++                                                                       =
            gtk_widget_get_window (GTK_WIDGET (window))),
++                                                 &fs_rect);
++
++                if (show)
++                        gtk_window_move (GTK_WINDOW (window->priv->full=
screen_controls),
++                                 fs_rect.x, fs_rect.y);
++                else
++                        gtk_window_move (GTK_WINDOW (window->priv->full=
screen_controls),
++                                         fs_rect.x, fs_rect.y - height =
+ 1);
++        }
++
++}
++
++
++static gboolean
++on_fullscreen_controls_enter_notify_event (GtkWidget        *widget,
++                                           GdkEventCrossing *event,
++                                           DhWindow      *window)
++{
++        show_hide_fullscreen_toolbar (window, TRUE, 0);
++
++        return FALSE;
++}
++
++static gboolean
++on_fullscreen_controls_leave_notify_event (GtkWidget        *widget,
++                                           GdkEventCrossing *event,
++                                           DhWindow      *window)
++{
++        GdkDisplay *display;
++        GdkScreen *screen;
++        gint w, h;
++        gint x, y;
++
++        display =3D gdk_display_get_default ();
++        screen =3D gtk_window_get_screen (GTK_WINDOW (window));
++
++        gtk_window_get_size (GTK_WINDOW (window->priv->fullscreen_contr=
ols), &w, &h);
++        gdk_display_get_pointer (display, &screen, &x, &y, NULL);
++
++        /* gtk seems to emit leave notify when clicking on tool items,
++         * work around it by checking the coordinates
++         */
++        if (y >=3D h)
++        {
++                show_hide_fullscreen_toolbar (window, FALSE, h);
++        }
++
++        return FALSE;
++}
++
++static gboolean
++window_is_fullscreen (DhWindow *window)
++{
++        GdkWindowState  state;
++
++        g_return_val_if_fail (DH_IS_WINDOW (window), FALSE);
++
++#if GTK_CHECK_VERSION (2,14,0)
++        state =3D gdk_window_get_state (gtk_widget_get_window (GTK_WIDG=
ET (window)));
++#else
++        state =3D gdk_window_get_state (GTK_WIDGET (window)->window);
++#endif
++
++        return state & GDK_WINDOW_STATE_FULLSCREEN;
++}
++
++static void
++window_fullscreen_controls_build (DhWindow *window)
++{
++        GtkWidget *toolbar;
++        GtkAction *action;
++        DhWindowPriv  *priv;
++
++        priv =3D window->priv;
++        if (priv->fullscreen_controls !=3D NULL)
++                return;
++
++        priv->fullscreen_controls =3D gtk_window_new (GTK_WINDOW_POPUP)=
;
++        gtk_window_set_transient_for (GTK_WINDOW (priv->fullscreen_cont=
rols),
++                                      GTK_WINDOW (window));
++
++        toolbar =3D gtk_ui_manager_get_widget (priv->manager, "/Fullscr=
eenToolBar");
++        gtk_container_add (GTK_CONTAINER (priv->fullscreen_controls),
++                           toolbar);
++        action =3D gtk_action_group_get_action (priv->action_group,
++                                              "LeaveFullscreen");
++        g_object_set (action, "is-important", TRUE, NULL);
++
++        /* Set the toolbar style */
++        gtk_toolbar_set_style (GTK_TOOLBAR (toolbar),
++                               GTK_TOOLBAR_BOTH_HORIZ);
++
++        g_signal_connect (priv->fullscreen_controls, "enter-notify-even=
t",
++                          G_CALLBACK (on_fullscreen_controls_enter_noti=
fy_event),
++                          window);
++        g_signal_connect (priv->fullscreen_controls, "leave-notify-even=
t",
++                          G_CALLBACK (on_fullscreen_controls_leave_noti=
fy_event),
++                          window);
++}
++
++static void
++window_fullscreen_controls_show (DhWindow *window)
++{
++        GdkScreen *screen;
++        GdkRectangle fs_rect;
++        gint w, h;
++
++        screen =3D gtk_window_get_screen (GTK_WINDOW (window));
++        gdk_screen_get_monitor_geometry (screen,
++                        gdk_screen_get_monitor_at_window (
++                                screen,
++                                gtk_widget_get_window (GTK_WIDGET (wind=
ow))),
++                        &fs_rect);
++
++        gtk_window_get_size (GTK_WINDOW (window->priv->fullscreen_contr=
ols), &w, &h);
++
++        gtk_window_resize (GTK_WINDOW (window->priv->fullscreen_control=
s),
++                           fs_rect.width, h);
++
++        gtk_window_move (GTK_WINDOW (window->priv->fullscreen_controls)=
,
++                         fs_rect.x, fs_rect.y - h + 1);
++
++        gtk_widget_show_all (window->priv->fullscreen_controls);
++}
++
++static void
++window_fullscreen (DhWindow *window)
++{
++        if (window_is_fullscreen (window))
++                return;
++
++        gtk_window_fullscreen (GTK_WINDOW (window));
++        gtk_widget_hide (gtk_ui_manager_get_widget (window->priv->manag=
er, "/MenuBar"));
++        gtk_widget_hide (gtk_ui_manager_get_widget (window->priv->manag=
er, "/Toolbar"));
++
++        window_fullscreen_controls_build (window);
++        window_fullscreen_controls_show (window);
++}
++
++static void
++window_unfullscreen (DhWindow *window)
++{
++        if (! window_is_fullscreen (window))
++                return;
++
++        gtk_window_unfullscreen (GTK_WINDOW (window));
++        gtk_widget_show (gtk_ui_manager_get_widget (window->priv->manag=
er, "/MenuBar"));
++        gtk_widget_show (gtk_ui_manager_get_widget (window->priv->manag=
er, "/Toolbar"));
++
++        gtk_widget_hide (window->priv->fullscreen_controls);
++}
++
++
++static void
++window_toggle_fullscreen_mode (GtkAction *action,
++                               DhWindow  *window)
++{
++        if (window_is_fullscreen (window)) {
++                window_unfullscreen (window);
++        } else {
++                window_fullscreen (window);
++        }
++}
++
++static void
++window_leave_fullscreen_mode (GtkAction *action,
++                              DhWindow *window)
++{
++        GtkAction *view_action;
++
++        view_action =3D gtk_action_group_get_action (window->priv->acti=
on_group,
++                                                   "ViewFullscreen");
++        g_signal_handlers_block_by_func (view_action,
++                        G_CALLBACK (window_toggle_fullscreen_mode),
++                        window);
++        gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (view_action),
++                                      FALSE);
++        window_unfullscreen (window);
++        g_signal_handlers_unblock_by_func (view_action,
++                        G_CALLBACK (window_toggle_fullscreen_mode),
++                        window);
++}
++
+ static void
+ window_activate_preferences (GtkAction *action,
+                              DhWindow  *window)
+@@ -543,6 +823,18 @@ static const GtkActionEntry actions[] =3D {
+         /* About menu */
+         { "About", GTK_STOCK_ABOUT, NULL, NULL, NULL,
+           G_CALLBACK (window_activate_about) },
++
++        /* Fullscreen toolbar */
++        { "LeaveFullscreen", GTK_STOCK_LEAVE_FULLSCREEN, NULL,
++          NULL, N_("Leave fullscreen mode"),
++          G_CALLBACK (window_leave_fullscreen_mode) }
++};
++
++static const GtkToggleActionEntry always_sensitive_toggle_menu_entries[=
] =3D
++{
++        { "ViewFullscreen", GTK_STOCK_FULLSCREEN, NULL, "F11",
++          N_("Display in full screen"),
++          G_CALLBACK (window_toggle_fullscreen_mode), FALSE },
+ };
+=20
+ static const gchar* important_actions[] =3D {
+@@ -627,11 +919,6 @@ dh_window_init (DhWindow *window)
+                           G_CALLBACK (window_open_link_cb),
+                           window);
+=20
+-        g_signal_connect (priv->manager,
+-                          "add-widget",
+-                          G_CALLBACK (window_manager_add_widget),
+-                          window);
+-
+         priv->action_group =3D gtk_action_group_new ("MainWindow");
+=20
+         gtk_action_group_set_translation_domain (priv->action_group,
+@@ -641,6 +928,10 @@ dh_window_init (DhWindow *window)
+                                       actions,
+                                       G_N_ELEMENTS (actions),
+                                       window);
++        gtk_action_group_add_toggle_actions (priv->action_group,
++                                             always_sensitive_toggle_me=
nu_entries,
++                                             G_N_ELEMENTS (always_sensi=
tive_toggle_menu_entries),
++                                             window);
+=20
+         for (i =3D 0; i < G_N_ELEMENTS (important_actions); i++) {
+                 action =3D gtk_action_group_get_action (priv->action_gr=
oup,
+@@ -771,6 +1062,8 @@ window_populate (DhWindow *window)
+         GtkWidget    *book_tree_sw;
+         GNode        *contents_tree;
+         GList        *keywords;
++        GtkWidget    *menubar;
++        GtkWidget    *toolbar;
+=20
+         priv =3D window->priv;
+=20
+@@ -781,19 +1074,24 @@ window_populate (DhWindow *window)
+         g_free (path);
+         gtk_ui_manager_ensure_update (priv->manager);
+=20
++        menubar =3D gtk_ui_manager_get_widget (priv->manager, "/MenuBar=
");
++        gtk_box_pack_start (GTK_BOX (priv->menu_box), menubar,
++                            FALSE, FALSE, 0);
++        toolbar =3D gtk_ui_manager_get_widget (priv->manager, "/Toolbar=
");
++        gtk_box_pack_start (GTK_BOX (priv->menu_box), toolbar,
++                            FALSE, FALSE, 0);
++
+ #ifdef GDK_WINDOWING_QUARTZ
+         {
+                 GtkWidget       *widget;
+                 IgeMacMenuGroup *group;
+=20
+                 /* Hide toolbar labels. */
+-                widget =3D gtk_ui_manager_get_widget (priv->manager, "/=
Toolbar");
+-                gtk_toolbar_set_style (GTK_TOOLBAR (widget), GTK_TOOLBA=
R_ICONS);
++                gtk_toolbar_set_style (GTK_TOOLBAR (toolbar), GTK_TOOLB=
AR_ICONS);
+=20
+                 /* Setup menubar. */
+-                widget =3D gtk_ui_manager_get_widget (priv->manager, "/=
MenuBar");
+-                ige_mac_menu_set_menu_bar (GTK_MENU_SHELL (widget));
+-                gtk_widget_hide (widget);
++                ige_mac_menu_set_menu_bar (GTK_MENU_SHELL (menubar));
++                gtk_widget_hide (menubar);
+=20
+                 widget =3D gtk_ui_manager_get_widget (priv->manager, "/=
MenuBar/FileMenu/Quit");
+                 ige_mac_menu_set_quit_menu_item (GTK_MENU_ITEM (widget)=
);
+@@ -1046,21 +1344,6 @@ window_search_link_selected_cb (GObject  *ignored=
,
+ }
+=20
+ static void
+-window_manager_add_widget (GtkUIManager *manager,
+-                           GtkWidget    *widget,
+-                           DhWindow     *window)
+-{
+-        DhWindowPriv *priv;
+-
+-        priv =3D window->priv;
+-
+-        gtk_box_pack_start (GTK_BOX (priv->menu_box), widget,
+-                            FALSE, FALSE, 0);
+-
+-        gtk_widget_show (widget);
+-}
+-
+-static void
+ window_check_history (DhWindow      *window,
+                       WebKitWebView *web_view)
+ {
+--
+cgit v0.8.2
diff --git a/debian/patches/series b/debian/patches/series
index 14c6926..3ab9497 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1 +1,2 @@
 00install-devhelp-el.patch
+fullscreen.patch
--=20
1.6.4.3


--gKMricLos+KVdGMg--






More information about the pkg-gnome-maintainers mailing list