Save size and panel position with a delay of 5 seconds
This commit is contained in:
parent
cf9ec7755f
commit
2323c57d7e
1 changed files with 33 additions and 8 deletions
|
@ -65,6 +65,9 @@ struct _MidoriBrowser
|
||||||
GtkWidget* progressbar;
|
GtkWidget* progressbar;
|
||||||
gchar* statusbar_text;
|
gchar* statusbar_text;
|
||||||
|
|
||||||
|
guint alloc_timeout;
|
||||||
|
guint panel_timeout;
|
||||||
|
|
||||||
MidoriWebSettings* settings;
|
MidoriWebSettings* settings;
|
||||||
KatzeArray* proxy_array;
|
KatzeArray* proxy_array;
|
||||||
KatzeArray* bookmarks;
|
KatzeArray* bookmarks;
|
||||||
|
@ -3066,13 +3069,24 @@ _action_panel_activate (GtkToggleAction* action,
|
||||||
sokoke_widget_set_visible (browser->panel, active);
|
sokoke_widget_set_visible (browser->panel, active);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
midori_browser_panel_timeout (GtkWidget* hpaned)
|
||||||
|
{
|
||||||
|
gboolean position = gtk_paned_get_position (GTK_PANED (hpaned));
|
||||||
|
MidoriBrowser* browser = MIDORI_BROWSER (gtk_widget_get_toplevel (hpaned));
|
||||||
|
g_object_set (browser->settings, "last-panel-position", position, NULL);
|
||||||
|
browser->panel_timeout = 0;
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
midori_panel_notify_position_cb (GObject* object,
|
midori_panel_notify_position_cb (GObject* hpaned,
|
||||||
GParamSpec* arg1,
|
GParamSpec* pspec,
|
||||||
MidoriBrowser* browser)
|
MidoriBrowser* browser)
|
||||||
{
|
{
|
||||||
gboolean position = gtk_paned_get_position (GTK_PANED (object));
|
if (!browser->panel_timeout)
|
||||||
g_object_set (browser->settings, "last-panel-position", position, NULL);
|
browser->panel_timeout = g_timeout_add_full (G_PRIORITY_LOW, 5000,
|
||||||
|
(GSourceFunc)midori_browser_panel_timeout, hpaned, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
@ -3469,6 +3483,16 @@ midori_browser_window_state_event_cb (MidoriBrowser* browser,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
midori_browser_alloc_timeout (MidoriBrowser* browser)
|
||||||
|
{
|
||||||
|
g_object_set (browser->settings,
|
||||||
|
"last-window-width", GTK_WIDGET (browser)->allocation.width,
|
||||||
|
"last-window-height", GTK_WIDGET (browser)->allocation.height, NULL);
|
||||||
|
browser->alloc_timeout = 0;
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
midori_browser_size_allocate_cb (MidoriBrowser* browser,
|
midori_browser_size_allocate_cb (MidoriBrowser* browser,
|
||||||
GtkAllocation* allocation)
|
GtkAllocation* allocation)
|
||||||
|
@ -3478,11 +3502,12 @@ midori_browser_size_allocate_cb (MidoriBrowser* browser,
|
||||||
if (GTK_WIDGET_REALIZED (widget))
|
if (GTK_WIDGET_REALIZED (widget))
|
||||||
{
|
{
|
||||||
GdkWindowState state = gdk_window_get_state (widget->window);
|
GdkWindowState state = gdk_window_get_state (widget->window);
|
||||||
if (!(state & (GDK_WINDOW_STATE_MAXIMIZED | GDK_WINDOW_STATE_FULLSCREEN)))
|
if (!(state &
|
||||||
|
(GDK_WINDOW_STATE_MAXIMIZED | GDK_WINDOW_STATE_FULLSCREEN))
|
||||||
|
&& !browser->alloc_timeout)
|
||||||
{
|
{
|
||||||
g_object_set (browser->settings,
|
browser->alloc_timeout = g_timeout_add_full (G_PRIORITY_LOW, 5000,
|
||||||
"last-window-width", allocation->width,
|
(GSourceFunc)midori_browser_alloc_timeout, browser, NULL);
|
||||||
"last-window-height", allocation->height, NULL);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue