diff --git a/src/browser.c b/src/browser.c
index 03ea2fa3..88044e39 100644
--- a/src/browser.c
+++ b/src/browser.c
@@ -290,6 +290,15 @@ void on_action_source_view_activate(GtkAction* action, CBrowser* browser)
g_free(source);*/
}
+void on_action_fullscreen_activate(GtkAction* action, CBrowser* browser)
+{
+ GdkWindowState state = gdk_window_get_state(browser->window->window);
+ if(state & GDK_WINDOW_STATE_FULLSCREEN)
+ gtk_window_unfullscreen(GTK_WINDOW(browser->window));
+ else
+ gtk_window_fullscreen(GTK_WINDOW(browser->window));
+}
+
void on_action_back_activate(GtkAction* action, CBrowser* browser)
{
webkit_web_view_go_back(WEBKIT_WEB_VIEW(get_nth_webView(-1, browser)));
@@ -1125,13 +1134,35 @@ void on_notebook_switch_page(GtkWidget* widget, GtkNotebookPage* page
update_search_engines(browser);
}
+static void on_window_state_changed(GtkWidget* widget
+ , GdkEventWindowState* event, CBrowser* browser)
+{
+ if(event->changed_mask & GDK_WINDOW_STATE_FULLSCREEN)
+ {
+ if(event->new_window_state & GDK_WINDOW_STATE_FULLSCREEN)
+ {
+ gtk_widget_hide(browser->menubar);
+ g_object_set(browser->fullscreen, "stock-id"
+ , GTK_STOCK_LEAVE_FULLSCREEN, NULL);
+ gtk_widget_show(browser->fullscreen);
+ }
+ else
+ {
+ gtk_widget_show(browser->menubar);
+ gtk_widget_hide(browser->fullscreen);
+ g_object_set(browser->fullscreen, "stock-id"
+ , GTK_STOCK_FULLSCREEN, NULL);
+ }
+ }
+}
+
static void on_window_size_allocate(GtkWidget* widget, GtkAllocation* allocation
, CBrowser* browser)
{
if(GTK_WIDGET_REALIZED(widget))
{
- if(!(gdk_window_get_state(widget->window)
- & (GDK_WINDOW_STATE_MAXIMIZED | GDK_WINDOW_STATE_FULLSCREEN)))
+ GdkWindowState state = gdk_window_get_state(widget->window);
+ if(!(state & (GDK_WINDOW_STATE_MAXIMIZED | GDK_WINDOW_STATE_FULLSCREEN)))
{
config->winWidth = allocation->width;
config->winHeight = allocation->height;
@@ -1180,6 +1211,8 @@ CBrowser* browser_new(CBrowser* oldBrowser)
// Setup the window metrics
browser->window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+ g_signal_connect(browser->window, "window-state-event"
+ , G_CALLBACK(on_window_state_changed), browser);
GdkScreen* screen = gtk_window_get_screen(GTK_WINDOW(browser->window));
const gint defaultWidth = (gint)gdk_screen_get_width(screen) / 1.7;
const gint defaultHeight = (gint)gdk_screen_get_height(screen) / 1.7;
@@ -1351,6 +1384,13 @@ CBrowser* browser_new(CBrowser* oldBrowser)
gtk_toolbar_insert(GTK_TOOLBAR(browser->navibar)
, GTK_TOOL_ITEM(browser->closedTabs), -1);
sokoke_container_show_children(GTK_CONTAINER(browser->navibar));
+ action = gtk_action_group_get_action(browser->actiongroup, "Fullscreen");
+ browser->fullscreen = gtk_action_create_tool_item(action);
+ gtk_widget_hide(browser->fullscreen);
+ g_signal_connect(browser->fullscreen, "clicked"
+ , G_CALLBACK(on_action_fullscreen_activate), browser);
+ gtk_toolbar_insert(GTK_TOOLBAR(browser->navibar)
+ , GTK_TOOL_ITEM(browser->fullscreen), -1);
action_set_active("ToolbarNavigation", config->toolbarNavigation, browser);
// Bookmarkbar
@@ -1605,6 +1645,7 @@ CBrowser* browser_new(CBrowser* oldBrowser)
browser->location = oldBrowser->location;
browser->webSearch = oldBrowser->webSearch;
browser->closedTabs = oldBrowser->closedTabs;
+ browser->fullscreen = oldBrowser->fullscreen;
browser->bookmarkbar = oldBrowser->bookmarkbar;
browser->panels = oldBrowser->panels;
browser->panels_notebook = oldBrowser->panels_notebook;
diff --git a/src/browser.h b/src/browser.h
index 3f6bc218..a3c4f3df 100644
--- a/src/browser.h
+++ b/src/browser.h
@@ -39,6 +39,7 @@ typedef struct _CBrowser
GtkWidget* location;
GtkWidget* webSearch;
GtkWidget* closedTabs;
+ GtkWidget* fullscreen;
GtkWidget* bookmarkbar;
// panels
GtkWidget* panels;
@@ -160,6 +161,9 @@ on_action_zoom_normal_activate(GtkAction*, CBrowser*);
void
on_action_source_view_activate(GtkAction*, CBrowser*);
+void
+on_action_fullscreen_activate(GtkAction*, CBrowser*);
+
void
on_action_back_activate(GtkAction*, CBrowser*);
@@ -364,6 +368,9 @@ static const GtkActionEntry entries[] = {
{ "Properties", GTK_STOCK_PROPERTIES
, NULL, ""
, "hm?", NULL/*G_CALLBACK(on_action_properties_activate)*/ },
+ { "Fullscreen", GTK_STOCK_FULLSCREEN
+ , NULL, "F11"
+ , "Toggle fullscreen view", G_CALLBACK(on_action_fullscreen_activate) },
{ "Go", NULL, "_Go" },
{ "Back", GTK_STOCK_GO_BACK
diff --git a/src/global.h b/src/global.h
index 52f283e6..de9ea3ef 100644
--- a/src/global.h
+++ b/src/global.h
@@ -81,5 +81,9 @@ KatzeXbelItem* tabtrash;
#if !GTK_CHECK_VERSION(2, 10, 0)
#define GTK_STOCK_SELECT_ALL "gtk-select-all"
#endif
+#if !GTK_CHECK_VERSION(2, 8, 0)
+#define GTK_STOCK_FULLSCREEN "gtk-fullscreen"
+#define GTK_STOCK_LEAVE_FULLSCREEN "gtk-leave-fullscreen"
+#endif
#endif /* !__GLOBAL_H__ */
diff --git a/src/main.c b/src/main.c
index c177e1cd..7fe43c20 100755
--- a/src/main.c
+++ b/src/main.c
@@ -59,6 +59,10 @@ static void stock_items_init(void)
#if !GTK_CHECK_VERSION(2, 10, 0)
{ GTK_STOCK_SELECT_ALL, "Select _All", 0, 0, (gchar*)"gtk20" },
#endif
+ #if !GTK_CHECK_VERSION(2, 8, 0)
+ { GTK_STOCK_FULLSCREEN, "_Fullscreen", 0, 0, (gchar*)"gtk20" },
+ { GTK_STOCK_FULLSCREEN, "_Leave Fullscreen", 0, 0, (gchar*)"gtk20" },
+ #endif
};
GtkIconFactory* factory = gtk_icon_factory_new();
guint i;
diff --git a/src/ui.h b/src/ui.h
index d9d350f6..787fdd41 100644
--- a/src/ui.h
+++ b/src/ui.h
@@ -91,9 +91,8 @@ static const gchar* ui_markup =
""
""
"