Remember the last window state, ie. whether Midori was maximized or minimized
This commit is contained in:
parent
b89fbb98f2
commit
89a205bd59
3 changed files with 83 additions and 1 deletions
|
@ -3436,6 +3436,15 @@ static void
|
||||||
midori_browser_window_state_event_cb (MidoriBrowser* browser,
|
midori_browser_window_state_event_cb (MidoriBrowser* browser,
|
||||||
GdkEventWindowState* event)
|
GdkEventWindowState* event)
|
||||||
{
|
{
|
||||||
|
MidoriWindowState window_state = MIDORI_WINDOW_NORMAL;
|
||||||
|
if (event->new_window_state & GDK_WINDOW_STATE_ICONIFIED)
|
||||||
|
window_state = MIDORI_WINDOW_MINIMIZED;
|
||||||
|
else if (event->new_window_state & GDK_WINDOW_STATE_MAXIMIZED)
|
||||||
|
window_state = MIDORI_WINDOW_MAXIMIZED;
|
||||||
|
else if (event->new_window_state & GDK_WINDOW_STATE_FULLSCREEN)
|
||||||
|
window_state = MIDORI_WINDOW_FULLSCREEN;
|
||||||
|
g_object_set (browser->settings, "last-window-state", window_state, NULL);
|
||||||
|
|
||||||
if (event->changed_mask & GDK_WINDOW_STATE_FULLSCREEN)
|
if (event->changed_mask & GDK_WINDOW_STATE_FULLSCREEN)
|
||||||
{
|
{
|
||||||
if (event->new_window_state & GDK_WINDOW_STATE_FULLSCREEN)
|
if (event->new_window_state & GDK_WINDOW_STATE_FULLSCREEN)
|
||||||
|
@ -4379,6 +4388,7 @@ _midori_browser_update_settings (MidoriBrowser* browser)
|
||||||
{
|
{
|
||||||
gboolean remember_last_window_size;
|
gboolean remember_last_window_size;
|
||||||
gint last_window_width, last_window_height;
|
gint last_window_width, last_window_height;
|
||||||
|
MidoriWindowState last_window_state;
|
||||||
gboolean compact_sidepanel;
|
gboolean compact_sidepanel;
|
||||||
gint last_panel_position, last_panel_page;
|
gint last_panel_position, last_panel_page;
|
||||||
gboolean show_menubar, show_navigationbar, show_bookmarkbar;
|
gboolean show_menubar, show_navigationbar, show_bookmarkbar;
|
||||||
|
@ -4395,6 +4405,7 @@ _midori_browser_update_settings (MidoriBrowser* browser)
|
||||||
"remember-last-window-size", &remember_last_window_size,
|
"remember-last-window-size", &remember_last_window_size,
|
||||||
"last-window-width", &last_window_width,
|
"last-window-width", &last_window_width,
|
||||||
"last-window-height", &last_window_height,
|
"last-window-height", &last_window_height,
|
||||||
|
"last-window-state", &last_window_state,
|
||||||
"compact-sidepanel", &compact_sidepanel,
|
"compact-sidepanel", &compact_sidepanel,
|
||||||
"last-panel-position", &last_panel_position,
|
"last-panel-position", &last_panel_position,
|
||||||
"last-panel-page", &last_panel_page,
|
"last-panel-page", &last_panel_page,
|
||||||
|
@ -4421,6 +4432,20 @@ _midori_browser_update_settings (MidoriBrowser* browser)
|
||||||
else
|
else
|
||||||
gtk_window_set_default_size (GTK_WINDOW (browser),
|
gtk_window_set_default_size (GTK_WINDOW (browser),
|
||||||
default_width, default_height);
|
default_width, default_height);
|
||||||
|
switch (last_window_state)
|
||||||
|
{
|
||||||
|
case MIDORI_WINDOW_MINIMIZED:
|
||||||
|
gtk_window_iconify (GTK_WINDOW (browser));
|
||||||
|
break;
|
||||||
|
case MIDORI_WINDOW_MAXIMIZED:
|
||||||
|
gtk_window_maximize (GTK_WINDOW (browser));
|
||||||
|
break;
|
||||||
|
case MIDORI_WINDOW_FULLSCREEN:
|
||||||
|
gtk_window_fullscreen (GTK_WINDOW (browser));
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
;/* Do nothing. */
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_midori_browser_set_toolbar_style (browser, toolbar_style);
|
_midori_browser_set_toolbar_style (browser, toolbar_style);
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
Copyright (C) 2008 Christian Dywan <christian@twotoasts.de>
|
Copyright (C) 2008-2009 Christian Dywan <christian@twotoasts.de>
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
This library is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the GNU Lesser General Public
|
modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -27,6 +27,7 @@ struct _MidoriWebSettings
|
||||||
gboolean remember_last_window_size;
|
gboolean remember_last_window_size;
|
||||||
gint last_window_width;
|
gint last_window_width;
|
||||||
gint last_window_height;
|
gint last_window_height;
|
||||||
|
MidoriWindowState last_window_state;
|
||||||
gint last_panel_position;
|
gint last_panel_position;
|
||||||
gint last_panel_page;
|
gint last_panel_page;
|
||||||
gint last_web_search;
|
gint last_web_search;
|
||||||
|
@ -89,6 +90,7 @@ enum
|
||||||
PROP_REMEMBER_LAST_WINDOW_SIZE,
|
PROP_REMEMBER_LAST_WINDOW_SIZE,
|
||||||
PROP_LAST_WINDOW_WIDTH,
|
PROP_LAST_WINDOW_WIDTH,
|
||||||
PROP_LAST_WINDOW_HEIGHT,
|
PROP_LAST_WINDOW_HEIGHT,
|
||||||
|
PROP_LAST_WINDOW_STATE,
|
||||||
PROP_LAST_PANEL_POSITION,
|
PROP_LAST_PANEL_POSITION,
|
||||||
PROP_LAST_PANEL_PAGE,
|
PROP_LAST_PANEL_PAGE,
|
||||||
PROP_LAST_WEB_SEARCH,
|
PROP_LAST_WEB_SEARCH,
|
||||||
|
@ -139,6 +141,24 @@ enum
|
||||||
PROP_CACHE_SIZE
|
PROP_CACHE_SIZE
|
||||||
};
|
};
|
||||||
|
|
||||||
|
GType
|
||||||
|
midori_window_state_get_type (void)
|
||||||
|
{
|
||||||
|
static GType type = 0;
|
||||||
|
if (!type)
|
||||||
|
{
|
||||||
|
static const GEnumValue values[] = {
|
||||||
|
{ MIDORI_WINDOW_NORMAL, "MIDORI_WINDOW_NORMAL", "Normal" },
|
||||||
|
{ MIDORI_WINDOW_MINIMIZED, "MIDORI_WINDOW_MINIMIZED", "Minimized" },
|
||||||
|
{ MIDORI_WINDOW_MAXIMIZED, "MIDORI_WINDOW_MAXIMIZED", "Maximized" },
|
||||||
|
{ MIDORI_WINDOW_FULLSCREEN, "MIDORI_WINDOW_FULLSCREEN", "Fullscreen" },
|
||||||
|
{ 0, NULL, NULL }
|
||||||
|
};
|
||||||
|
type = g_enum_register_static ("MidoriWindowState", values);
|
||||||
|
}
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
GType
|
GType
|
||||||
midori_startup_get_type (void)
|
midori_startup_get_type (void)
|
||||||
{
|
{
|
||||||
|
@ -303,6 +323,23 @@ midori_web_settings_class_init (MidoriWebSettingsClass* class)
|
||||||
0, G_MAXINT, 0,
|
0, G_MAXINT, 0,
|
||||||
flags));
|
flags));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* MidoriWebSettings:last-window-state:
|
||||||
|
*
|
||||||
|
* The last saved window state.
|
||||||
|
*
|
||||||
|
* Since: 0.1.3
|
||||||
|
*/
|
||||||
|
g_object_class_install_property (gobject_class,
|
||||||
|
PROP_LAST_WINDOW_STATE,
|
||||||
|
g_param_spec_enum (
|
||||||
|
"last-window-state",
|
||||||
|
"Last window state",
|
||||||
|
"The last saved window state",
|
||||||
|
MIDORI_TYPE_WINDOW_STATE,
|
||||||
|
MIDORI_WINDOW_NORMAL,
|
||||||
|
flags));
|
||||||
|
|
||||||
g_object_class_install_property (gobject_class,
|
g_object_class_install_property (gobject_class,
|
||||||
PROP_LAST_PANEL_POSITION,
|
PROP_LAST_PANEL_POSITION,
|
||||||
g_param_spec_int (
|
g_param_spec_int (
|
||||||
|
@ -887,6 +924,9 @@ midori_web_settings_set_property (GObject* object,
|
||||||
case PROP_LAST_WINDOW_HEIGHT:
|
case PROP_LAST_WINDOW_HEIGHT:
|
||||||
web_settings->last_window_height = g_value_get_int (value);
|
web_settings->last_window_height = g_value_get_int (value);
|
||||||
break;
|
break;
|
||||||
|
case PROP_LAST_WINDOW_STATE:
|
||||||
|
web_settings->last_window_state = g_value_get_enum (value);
|
||||||
|
break;
|
||||||
case PROP_LAST_PANEL_POSITION:
|
case PROP_LAST_PANEL_POSITION:
|
||||||
web_settings->last_panel_position = g_value_get_int (value);
|
web_settings->last_panel_position = g_value_get_int (value);
|
||||||
break;
|
break;
|
||||||
|
@ -1062,6 +1102,9 @@ midori_web_settings_get_property (GObject* object,
|
||||||
case PROP_LAST_WINDOW_HEIGHT:
|
case PROP_LAST_WINDOW_HEIGHT:
|
||||||
g_value_set_int (value, web_settings->last_window_height);
|
g_value_set_int (value, web_settings->last_window_height);
|
||||||
break;
|
break;
|
||||||
|
case PROP_LAST_WINDOW_STATE:
|
||||||
|
g_value_set_enum (value, web_settings->last_window_state);
|
||||||
|
break;
|
||||||
case PROP_LAST_PANEL_POSITION:
|
case PROP_LAST_PANEL_POSITION:
|
||||||
g_value_set_int (value, web_settings->last_panel_position);
|
g_value_set_int (value, web_settings->last_panel_position);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -34,6 +34,20 @@ G_BEGIN_DECLS
|
||||||
typedef struct _MidoriWebSettings MidoriWebSettings;
|
typedef struct _MidoriWebSettings MidoriWebSettings;
|
||||||
typedef struct _MidoriWebSettingsClass MidoriWebSettingsClass;
|
typedef struct _MidoriWebSettingsClass MidoriWebSettingsClass;
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
MIDORI_WINDOW_NORMAL,
|
||||||
|
MIDORI_WINDOW_MINIMIZED,
|
||||||
|
MIDORI_WINDOW_MAXIMIZED,
|
||||||
|
MIDORI_WINDOW_FULLSCREEN,
|
||||||
|
} MidoriWindowState;
|
||||||
|
|
||||||
|
GType
|
||||||
|
midori_window_state_get_type (void) G_GNUC_CONST;
|
||||||
|
|
||||||
|
#define MIDORI_TYPE_WINDOW_STATE \
|
||||||
|
(midori_startup_get_type ())
|
||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
MIDORI_STARTUP_BLANK_PAGE,
|
MIDORI_STARTUP_BLANK_PAGE,
|
||||||
|
|
Loading…
Reference in a new issue