Implement Fullscreen mode
A new menuitem toggles Fullscreen mode, which means that the menubar is hidden, the window is maximized and window manager decoration is removed. A new button appears in the navibar which reverts this process. Fullscreen relies entirely on the window manager, which has the advantage that window manager keybindings have the same effect as activating the Fullscreen menuitem. At the same time this means that Fullscreen won't work at all without it.
This commit is contained in:
parent
184b54e311
commit
1522f47002
5 changed files with 59 additions and 4 deletions
|
@ -290,6 +290,15 @@ void on_action_source_view_activate(GtkAction* action, CBrowser* browser)
|
||||||
g_free(source);*/
|
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)
|
void on_action_back_activate(GtkAction* action, CBrowser* browser)
|
||||||
{
|
{
|
||||||
webkit_web_view_go_back(WEBKIT_WEB_VIEW(get_nth_webView(-1, 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);
|
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
|
static void on_window_size_allocate(GtkWidget* widget, GtkAllocation* allocation
|
||||||
, CBrowser* browser)
|
, CBrowser* browser)
|
||||||
{
|
{
|
||||||
if(GTK_WIDGET_REALIZED(widget))
|
if(GTK_WIDGET_REALIZED(widget))
|
||||||
{
|
{
|
||||||
if(!(gdk_window_get_state(widget->window)
|
GdkWindowState state = gdk_window_get_state(widget->window);
|
||||||
& (GDK_WINDOW_STATE_MAXIMIZED | GDK_WINDOW_STATE_FULLSCREEN)))
|
if(!(state & (GDK_WINDOW_STATE_MAXIMIZED | GDK_WINDOW_STATE_FULLSCREEN)))
|
||||||
{
|
{
|
||||||
config->winWidth = allocation->width;
|
config->winWidth = allocation->width;
|
||||||
config->winHeight = allocation->height;
|
config->winHeight = allocation->height;
|
||||||
|
@ -1180,6 +1211,8 @@ CBrowser* browser_new(CBrowser* oldBrowser)
|
||||||
|
|
||||||
// Setup the window metrics
|
// Setup the window metrics
|
||||||
browser->window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
|
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));
|
GdkScreen* screen = gtk_window_get_screen(GTK_WINDOW(browser->window));
|
||||||
const gint defaultWidth = (gint)gdk_screen_get_width(screen) / 1.7;
|
const gint defaultWidth = (gint)gdk_screen_get_width(screen) / 1.7;
|
||||||
const gint defaultHeight = (gint)gdk_screen_get_height(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_toolbar_insert(GTK_TOOLBAR(browser->navibar)
|
||||||
, GTK_TOOL_ITEM(browser->closedTabs), -1);
|
, GTK_TOOL_ITEM(browser->closedTabs), -1);
|
||||||
sokoke_container_show_children(GTK_CONTAINER(browser->navibar));
|
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);
|
action_set_active("ToolbarNavigation", config->toolbarNavigation, browser);
|
||||||
|
|
||||||
// Bookmarkbar
|
// Bookmarkbar
|
||||||
|
@ -1605,6 +1645,7 @@ CBrowser* browser_new(CBrowser* oldBrowser)
|
||||||
browser->location = oldBrowser->location;
|
browser->location = oldBrowser->location;
|
||||||
browser->webSearch = oldBrowser->webSearch;
|
browser->webSearch = oldBrowser->webSearch;
|
||||||
browser->closedTabs = oldBrowser->closedTabs;
|
browser->closedTabs = oldBrowser->closedTabs;
|
||||||
|
browser->fullscreen = oldBrowser->fullscreen;
|
||||||
browser->bookmarkbar = oldBrowser->bookmarkbar;
|
browser->bookmarkbar = oldBrowser->bookmarkbar;
|
||||||
browser->panels = oldBrowser->panels;
|
browser->panels = oldBrowser->panels;
|
||||||
browser->panels_notebook = oldBrowser->panels_notebook;
|
browser->panels_notebook = oldBrowser->panels_notebook;
|
||||||
|
|
|
@ -39,6 +39,7 @@ typedef struct _CBrowser
|
||||||
GtkWidget* location;
|
GtkWidget* location;
|
||||||
GtkWidget* webSearch;
|
GtkWidget* webSearch;
|
||||||
GtkWidget* closedTabs;
|
GtkWidget* closedTabs;
|
||||||
|
GtkWidget* fullscreen;
|
||||||
GtkWidget* bookmarkbar;
|
GtkWidget* bookmarkbar;
|
||||||
// panels
|
// panels
|
||||||
GtkWidget* panels;
|
GtkWidget* panels;
|
||||||
|
@ -160,6 +161,9 @@ on_action_zoom_normal_activate(GtkAction*, CBrowser*);
|
||||||
void
|
void
|
||||||
on_action_source_view_activate(GtkAction*, CBrowser*);
|
on_action_source_view_activate(GtkAction*, CBrowser*);
|
||||||
|
|
||||||
|
void
|
||||||
|
on_action_fullscreen_activate(GtkAction*, CBrowser*);
|
||||||
|
|
||||||
void
|
void
|
||||||
on_action_back_activate(GtkAction*, CBrowser*);
|
on_action_back_activate(GtkAction*, CBrowser*);
|
||||||
|
|
||||||
|
@ -364,6 +368,9 @@ static const GtkActionEntry entries[] = {
|
||||||
{ "Properties", GTK_STOCK_PROPERTIES
|
{ "Properties", GTK_STOCK_PROPERTIES
|
||||||
, NULL, ""
|
, NULL, ""
|
||||||
, "hm?", NULL/*G_CALLBACK(on_action_properties_activate)*/ },
|
, "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" },
|
{ "Go", NULL, "_Go" },
|
||||||
{ "Back", GTK_STOCK_GO_BACK
|
{ "Back", GTK_STOCK_GO_BACK
|
||||||
|
|
|
@ -81,5 +81,9 @@ KatzeXbelItem* tabtrash;
|
||||||
#if !GTK_CHECK_VERSION(2, 10, 0)
|
#if !GTK_CHECK_VERSION(2, 10, 0)
|
||||||
#define GTK_STOCK_SELECT_ALL "gtk-select-all"
|
#define GTK_STOCK_SELECT_ALL "gtk-select-all"
|
||||||
#endif
|
#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__ */
|
#endif /* !__GLOBAL_H__ */
|
||||||
|
|
|
@ -59,6 +59,10 @@ static void stock_items_init(void)
|
||||||
#if !GTK_CHECK_VERSION(2, 10, 0)
|
#if !GTK_CHECK_VERSION(2, 10, 0)
|
||||||
{ GTK_STOCK_SELECT_ALL, "Select _All", 0, 0, (gchar*)"gtk20" },
|
{ GTK_STOCK_SELECT_ALL, "Select _All", 0, 0, (gchar*)"gtk20" },
|
||||||
#endif
|
#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();
|
GtkIconFactory* factory = gtk_icon_factory_new();
|
||||||
guint i;
|
guint i;
|
||||||
|
|
3
src/ui.h
3
src/ui.h
|
@ -91,9 +91,8 @@ static const gchar* ui_markup =
|
||||||
"<menuitem action='ZoomOut'/>"
|
"<menuitem action='ZoomOut'/>"
|
||||||
"<menuitem action='ZoomNormal'/>"
|
"<menuitem action='ZoomNormal'/>"
|
||||||
"<separator/>"
|
"<separator/>"
|
||||||
"<menuitem action='BackgroundImage'/>"
|
|
||||||
"<menuitem action='SourceView'/>"
|
"<menuitem action='SourceView'/>"
|
||||||
"<menuitem action='Properties'/>"
|
"<menuitem action='Fullscreen'/>"
|
||||||
"</menu>"
|
"</menu>"
|
||||||
"<menu action='Go'>"
|
"<menu action='Go'>"
|
||||||
"<menuitem action='Back'/>"
|
"<menuitem action='Back'/>"
|
||||||
|
|
Loading…
Reference in a new issue