[gnome-latex: 60/205] Improve first unmaximisation if key window_maximized=true
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-latex: 60/205] Improve first unmaximisation if key window_maximized=true
- Date: Fri, 14 Dec 2018 10:51:55 +0000 (UTC)
commit a584e0f0b42ad7898325c2f57751a6ff3e5e8fe5
Author: Sébastien Wilmet <sebastien wilmet gmail com>
Date: Sat Sep 12 23:54:31 2009 +0200
Improve first unmaximisation if key window_maximized=true
Unmaximize window will really decrease the size of the window.
Without that, the size keep unchanged...
src/callbacks.c | 35 +++++++++++++++++++++++++++++++++++
src/callbacks.h | 2 ++
src/main.c | 8 ++++++++
src/prefs.c | 11 -----------
4 files changed, 45 insertions(+), 11 deletions(-)
---
diff --git a/src/callbacks.c b/src/callbacks.c
index 25f845a..02328b4 100644
--- a/src/callbacks.c
+++ b/src/callbacks.c
@@ -859,6 +859,41 @@ cb_show_symbol_tables (GtkToggleAction *toggle_action, gpointer user_data)
gtk_widget_hide (latexila.symbols->vbox);
}
+gboolean
+cb_window_unmaximized (GtkWidget *widget, GdkEventWindowState *event,
+ gpointer user_data)
+{
+ // TODO is there an easier way to do that?
+ // TODO disconnect the signal instead of using a static bool?
+
+ static gboolean first_time = TRUE;
+
+ if (! first_time)
+ return FALSE;
+
+ if (event->changed_mask & GDK_WINDOW_STATE_MAXIMIZED)
+ {
+ if (! (event->new_window_state & GDK_WINDOW_STATE_MAXIMIZED)
+ && first_time)
+ {
+ // For the first unmaximisation, decrease a little the size of the
+ // window. Without that, the window would keep the same size.
+
+ gint width = latexila.prefs->window_width;
+ gint height = latexila.prefs->window_height;
+ width -= width / 10;
+ height -= height / 10;
+ gtk_window_resize (latexila.main_window, width, height);
+
+ first_time = FALSE;
+ return TRUE;
+ }
+ }
+
+ // let the event propagate further
+ return FALSE;
+}
+
void
open_new_document (const gchar *filename, const gchar *uri)
{
diff --git a/src/callbacks.h b/src/callbacks.h
index c86b99e..a5f1e10 100644
--- a/src/callbacks.h
+++ b/src/callbacks.h
@@ -66,6 +66,8 @@ void cb_font_set (GtkFontButton *font_button, gpointer user_data);
void cb_category_symbols_selected (GtkIconView *icon_view, gpointer user_data);
void cb_symbol_selected (GtkIconView *icon_view, gpointer user_data);
void cb_show_symbol_tables (GtkToggleAction *toggle_action, gpointer user_data);
+gboolean cb_window_unmaximized (GtkWidget *widget, GdkEventWindowState *event,
+ gpointer user_data);
void open_new_document (const gchar *filename, const gchar *uri);
diff --git a/src/main.c b/src/main.c
index 247e570..2df05f0 100644
--- a/src/main.c
+++ b/src/main.c
@@ -150,8 +150,16 @@ main (int argc, char *argv[])
gtk_window_set_default_size (GTK_WINDOW (window),
latexila.prefs->window_width, latexila.prefs->window_height);
if (latexila.prefs->window_maximised)
+ {
gtk_window_maximize (GTK_WINDOW (window));
+ // For the first unmaximisation, decrease a little the size of the
+ // window. Without that, the window would keep the same size.
+ g_signal_connect (G_OBJECT (window), "window-state-event",
+ G_CALLBACK (cb_window_unmaximized), NULL);
+ }
+
+
/* menubar and toolbar */
GtkWidget *main_vbox = gtk_vbox_new (FALSE, 0);
gtk_container_add (GTK_CONTAINER (window), main_vbox);
diff --git a/src/prefs.c b/src/prefs.c
index c6a4ea9..3fac2b1 100644
--- a/src/prefs.c
+++ b/src/prefs.c
@@ -208,17 +208,6 @@ save_preferences (preferences_t *prefs)
gint window_width, window_height;
gtk_window_get_size (latexila.main_window, &window_width, &window_height);
-
- /* generate bugs with the panes positions
- // if the window is maximised, store sizes that are a bit smaller, else
- // making window non-maximised will have no effect
- if (window_maximised)
- {
- window_width -= window_width / 10;
- window_height -= window_height / 10;
- }
- */
-
g_key_file_set_integer (key_file, PROGRAM_NAME, "window_width",
window_width);
g_key_file_set_integer (key_file, PROGRAM_NAME, "window_height",
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]