Commit 35d83903 authored by Jesse van den Kieboom's avatar Jesse van den Kieboom

Bind fullscreen mode to window state

parent 34a8c1b6
......@@ -97,8 +97,6 @@ _gedit_cmd_view_toggle_fullscreen_mode (GSimpleAction *action,
{
_gedit_window_unfullscreen (window);
}
g_simple_action_set_state (action, state);
}
void
......@@ -106,16 +104,7 @@ _gedit_cmd_view_leave_fullscreen_mode (GSimpleAction *action,
GVariant *parameter,
gpointer user_data)
{
GeditWindow *window = GEDIT_WINDOW (user_data);
GAction *fullscreen_action;
_gedit_window_unfullscreen (window);
fullscreen_action = g_action_map_lookup_action (G_ACTION_MAP (window),
"fullscreen");
g_simple_action_set_state (G_SIMPLE_ACTION (fullscreen_action),
g_variant_new_boolean (FALSE));
_gedit_window_unfullscreen (GEDIT_WINDOW (user_data));
}
static void
......
......@@ -250,6 +250,44 @@ gedit_window_finalize (GObject *object)
G_OBJECT_CLASS (gedit_window_parent_class)->finalize (object);
}
static void
update_fullscreen (GeditWindow *window,
gboolean is_fullscreen)
{
GAction *fullscreen_action;
_gedit_multi_notebook_set_show_tabs (window->priv->multi_notebook, !is_fullscreen);
if (is_fullscreen)
{
gtk_widget_hide (window->priv->statusbar);
}
else
{
if (g_settings_get_boolean (window->priv->ui_settings, "statusbar-visible"))
{
gtk_widget_show (window->priv->statusbar);
}
}
#ifndef OS_OSX
if (is_fullscreen)
{
gtk_widget_show_all (window->priv->fullscreen_eventbox);
}
else
{
gtk_widget_hide (window->priv->fullscreen_eventbox);
}
#endif
fullscreen_action = g_action_map_lookup_action (G_ACTION_MAP (window),
"fullscreen");
g_simple_action_set_state (G_SIMPLE_ACTION (fullscreen_action),
g_variant_new_boolean (is_fullscreen));
}
static gboolean
gedit_window_window_state_event (GtkWidget *widget,
GdkEventWindowState *event)
......@@ -261,6 +299,11 @@ gedit_window_window_state_event (GtkWidget *widget,
g_settings_set_int (window->priv->window_settings, GEDIT_SETTINGS_WINDOW_STATE,
window->priv->window_state);
if ((event->changed_mask & GDK_WINDOW_STATE_FULLSCREEN) != 0)
{
update_fullscreen (window, (event->new_window_state & GDK_WINDOW_STATE_FULLSCREEN) != 0);
}
return GTK_WIDGET_CLASS (gedit_window_parent_class)->window_state_event (widget, event);
}
......@@ -3447,10 +3490,6 @@ _gedit_window_fullscreen (GeditWindow *window)
/* Go to fullscreen mode and hide bars */
gtk_window_fullscreen (GTK_WINDOW (&window->window));
_gedit_multi_notebook_set_show_tabs (window->priv->multi_notebook, FALSE);
gtk_widget_hide (window->priv->statusbar);
gtk_widget_show_all (window->priv->fullscreen_eventbox);
}
void
......@@ -3463,14 +3502,6 @@ _gedit_window_unfullscreen (GeditWindow *window)
/* Unfullscreen and show bars */
gtk_window_unfullscreen (GTK_WINDOW (&window->window));
_gedit_multi_notebook_set_show_tabs (window->priv->multi_notebook, TRUE);
if (g_settings_get_boolean (window->priv->ui_settings, "statusbar-visible"))
{
gtk_widget_show (window->priv->statusbar);
}
gtk_widget_hide (window->priv->fullscreen_eventbox);
}
gboolean
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment