From 0a7d34595cc5790aa402406dee275c8d2cda396c Mon Sep 17 00:00:00 2001 From: Chris Cromer Date: Sun, 23 Dec 2018 19:24:09 -0300 Subject: [PATCH] handle settings for window size --- ... => cl.cromer.ubb.sernatur.db.gschema.xml} | 9 +-- .../cl.cromer.ubb.sernatur.window.gschema.xml | 25 +++++++ data/gschema/meson.build | 3 +- data/ui/sernatur.window.ui | 3 +- po/POTFILES | 3 +- po/es.po | 66 +++++++++++-------- po/sernatur.pot | 61 ++++++++++------- src/sernatur-window.vala | 22 +++++-- src/sernatur.vala | 9 ++- 9 files changed, 131 insertions(+), 70 deletions(-) rename data/gschema/{cl.cromer.ubb.sernatur.gschema.xml => cl.cromer.ubb.sernatur.db.gschema.xml} (79%) create mode 100644 data/gschema/cl.cromer.ubb.sernatur.window.gschema.xml diff --git a/data/gschema/cl.cromer.ubb.sernatur.gschema.xml b/data/gschema/cl.cromer.ubb.sernatur.db.gschema.xml similarity index 79% rename from data/gschema/cl.cromer.ubb.sernatur.gschema.xml rename to data/gschema/cl.cromer.ubb.sernatur.db.gschema.xml index f8b4dc3..f31f5d6 100644 --- a/data/gschema/cl.cromer.ubb.sernatur.gschema.xml +++ b/data/gschema/cl.cromer.ubb.sernatur.db.gschema.xml @@ -1,5 +1,5 @@ - + "localhost" Host to connect to @@ -49,12 +49,5 @@ Password to use - - false - Should the program open maximized or not - - Should the program open maximized or not - - diff --git a/data/gschema/cl.cromer.ubb.sernatur.window.gschema.xml b/data/gschema/cl.cromer.ubb.sernatur.window.gschema.xml new file mode 100644 index 0000000..f693864 --- /dev/null +++ b/data/gschema/cl.cromer.ubb.sernatur.window.gschema.xml @@ -0,0 +1,25 @@ + + + + false + Should the program open maximized or not + + Should the program open maximized or not + + + + 640 + Window width + + Window width + + + + 480 + Window height + + Window height + + + + diff --git a/data/gschema/meson.build b/data/gschema/meson.build index b4d2538..60f75b0 100644 --- a/data/gschema/meson.build +++ b/data/gschema/meson.build @@ -1 +1,2 @@ -install_data('cl.cromer.ubb.sernatur.gschema.xml', install_dir: join_paths(get_option('prefix'), get_option('datadir'), 'glib-2.0', 'schemas')) +install_data('cl.cromer.ubb.sernatur.db.gschema.xml', install_dir: join_paths(get_option('prefix'), get_option('datadir'), 'glib-2.0', 'schemas')) +install_data('cl.cromer.ubb.sernatur.window.gschema.xml', install_dir: join_paths(get_option('prefix'), get_option('datadir'), 'glib-2.0', 'schemas')) diff --git a/data/ui/sernatur.window.ui b/data/ui/sernatur.window.ui index 8c4e5e9..37be7a9 100644 --- a/data/ui/sernatur.window.ui +++ b/data/ui/sernatur.window.ui @@ -21,7 +21,8 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND SERNATUR sernatur False - + + diff --git a/po/POTFILES b/po/POTFILES index 165e401..c967683 100644 --- a/po/POTFILES +++ b/po/POTFILES @@ -1,4 +1,5 @@ src/sernatur.vala src/sernatur-window.vala data/ui/sernatur.window.ui -data/gschema/cl.cromer.ubb.sernatur.gschema.xml +data/gschema/cl.cromer.ubb.sernatur.db.gschema.xml +data/gschema/cl.cromer.ubb.sernatur.window.gschema.xml diff --git a/po/es.po b/po/es.po index e4d190d..5b8823a 100644 --- a/po/es.po +++ b/po/es.po @@ -7,8 +7,8 @@ msgid "" msgstr "" "Project-Id-Version: sernatur\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2018-12-23 16:09-0300\n" -"PO-Revision-Date: 2018-12-23 16:10-0300\n" +"POT-Creation-Date: 2018-12-23 19:19-0300\n" +"PO-Revision-Date: 2018-12-23 19:21-0300\n" "Last-Translator: Chris Cromer \n" "Language-Team: none\n" "Language: es\n" @@ -18,73 +18,81 @@ msgstr "" "Plural-Forms: nplurals=2; plural=(n != 1);\n" "X-Generator: Poedit 2.0.6\n" -#: src/sernatur-window.vala:63 +#: src/sernatur.vala:54 +#, c-format +msgid "Could not load application icon: %s\n" +msgstr "No se puede cargar el icono de la aplicación: %s\n" + +#: src/sernatur-window.vala:97 msgid "Error" msgstr "Error" -#: src/sernatur-window.vala:91 +#: src/sernatur-window.vala:125 msgid "Server version:" msgstr "Versión del servidor:" -#: data/ui/sernatur.window.ui:40 +#: data/ui/sernatur.window.ui:42 msgid "_File" msgstr "" -#: data/ui/sernatur.window.ui:105 +#: data/ui/sernatur.window.ui:107 msgid "_Edit" msgstr "" -#: data/ui/sernatur.window.ui:155 +#: data/ui/sernatur.window.ui:157 msgid "_View" msgstr "" -#: data/ui/sernatur.window.ui:163 +#: data/ui/sernatur.window.ui:165 msgid "_Help" msgstr "" -#: data/gschema/cl.cromer.ubb.sernatur.gschema.xml:5 -#: data/gschema/cl.cromer.ubb.sernatur.gschema.xml:6 +#: data/gschema/cl.cromer.ubb.sernatur.db.gschema.xml:5 +#: data/gschema/cl.cromer.ubb.sernatur.db.gschema.xml:6 msgid "Host to connect to" msgstr "Servidor a conectar" -#: data/gschema/cl.cromer.ubb.sernatur.gschema.xml:12 -#: data/gschema/cl.cromer.ubb.sernatur.gschema.xml:13 +#: data/gschema/cl.cromer.ubb.sernatur.db.gschema.xml:12 +#: data/gschema/cl.cromer.ubb.sernatur.db.gschema.xml:13 msgid "Port number to use" msgstr "Número de puerto a usar" -#: data/gschema/cl.cromer.ubb.sernatur.gschema.xml:19 -#: data/gschema/cl.cromer.ubb.sernatur.gschema.xml:20 +#: data/gschema/cl.cromer.ubb.sernatur.db.gschema.xml:19 +#: data/gschema/cl.cromer.ubb.sernatur.db.gschema.xml:20 msgid "Options to use" msgstr "Opciones a usar" -#: data/gschema/cl.cromer.ubb.sernatur.gschema.xml:26 -#: data/gschema/cl.cromer.ubb.sernatur.gschema.xml:27 +#: data/gschema/cl.cromer.ubb.sernatur.db.gschema.xml:26 +#: data/gschema/cl.cromer.ubb.sernatur.db.gschema.xml:27 msgid "tty to send debug info (ignored)" msgstr "tty para enviar datos de depuración (ignorado)" -#: data/gschema/cl.cromer.ubb.sernatur.gschema.xml:33 -#: data/gschema/cl.cromer.ubb.sernatur.gschema.xml:34 +#: data/gschema/cl.cromer.ubb.sernatur.db.gschema.xml:33 +#: data/gschema/cl.cromer.ubb.sernatur.db.gschema.xml:34 msgid "Database to use" msgstr "Base de dato a usar" -#: data/gschema/cl.cromer.ubb.sernatur.gschema.xml:40 -#: data/gschema/cl.cromer.ubb.sernatur.gschema.xml:41 +#: data/gschema/cl.cromer.ubb.sernatur.db.gschema.xml:40 +#: data/gschema/cl.cromer.ubb.sernatur.db.gschema.xml:41 msgid "Username to use" msgstr "Nombre de usuario a usar" -#: data/gschema/cl.cromer.ubb.sernatur.gschema.xml:47 -#: data/gschema/cl.cromer.ubb.sernatur.gschema.xml:48 +#: data/gschema/cl.cromer.ubb.sernatur.db.gschema.xml:47 +#: data/gschema/cl.cromer.ubb.sernatur.db.gschema.xml:48 msgid "Password to use" msgstr "Contraseña a usar" -#: data/gschema/cl.cromer.ubb.sernatur.gschema.xml:54 -#: data/gschema/cl.cromer.ubb.sernatur.gschema.xml:55 +#: data/gschema/cl.cromer.ubb.sernatur.window.gschema.xml:5 +#: data/gschema/cl.cromer.ubb.sernatur.window.gschema.xml:6 msgid "Should the program open maximized or not" msgstr "Si el programa debe abrir maximizado ó no" -#, fuzzy -#~ msgid "The file '%s' doesn't exist.\n" -#~ msgstr "El archivo '%s' no existe.\n" +#: data/gschema/cl.cromer.ubb.sernatur.window.gschema.xml:12 +#: data/gschema/cl.cromer.ubb.sernatur.window.gschema.xml:13 +msgid "Window width" +msgstr "El ancho de la ventana" -#~ msgid "Connection failed" -#~ msgstr "Conexión falló" +#: data/gschema/cl.cromer.ubb.sernatur.window.gschema.xml:19 +#: data/gschema/cl.cromer.ubb.sernatur.window.gschema.xml:20 +msgid "Window height" +msgstr "La altura de la venta" diff --git a/po/sernatur.pot b/po/sernatur.pot index ae7751f..a60617b 100644 --- a/po/sernatur.pot +++ b/po/sernatur.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: sernatur\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2018-12-23 16:09-0300\n" +"POT-Creation-Date: 2018-12-23 19:19-0300\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -17,66 +17,81 @@ msgstr "" "Content-Type: text/plain; charset=CHARSET\n" "Content-Transfer-Encoding: 8bit\n" -#: src/sernatur-window.vala:63 +#: src/sernatur.vala:54 +#, c-format +msgid "Could not load application icon: %s\n" +msgstr "" + +#: src/sernatur-window.vala:97 msgid "Error" msgstr "" -#: src/sernatur-window.vala:91 +#: src/sernatur-window.vala:125 msgid "Server version:" msgstr "" -#: data/ui/sernatur.window.ui:40 +#: data/ui/sernatur.window.ui:42 msgid "_File" msgstr "" -#: data/ui/sernatur.window.ui:105 +#: data/ui/sernatur.window.ui:107 msgid "_Edit" msgstr "" -#: data/ui/sernatur.window.ui:155 +#: data/ui/sernatur.window.ui:157 msgid "_View" msgstr "" -#: data/ui/sernatur.window.ui:163 +#: data/ui/sernatur.window.ui:165 msgid "_Help" msgstr "" -#: data/gschema/cl.cromer.ubb.sernatur.gschema.xml:5 -#: data/gschema/cl.cromer.ubb.sernatur.gschema.xml:6 +#: data/gschema/cl.cromer.ubb.sernatur.db.gschema.xml:5 +#: data/gschema/cl.cromer.ubb.sernatur.db.gschema.xml:6 msgid "Host to connect to" msgstr "" -#: data/gschema/cl.cromer.ubb.sernatur.gschema.xml:12 -#: data/gschema/cl.cromer.ubb.sernatur.gschema.xml:13 +#: data/gschema/cl.cromer.ubb.sernatur.db.gschema.xml:12 +#: data/gschema/cl.cromer.ubb.sernatur.db.gschema.xml:13 msgid "Port number to use" msgstr "" -#: data/gschema/cl.cromer.ubb.sernatur.gschema.xml:19 -#: data/gschema/cl.cromer.ubb.sernatur.gschema.xml:20 +#: data/gschema/cl.cromer.ubb.sernatur.db.gschema.xml:19 +#: data/gschema/cl.cromer.ubb.sernatur.db.gschema.xml:20 msgid "Options to use" msgstr "" -#: data/gschema/cl.cromer.ubb.sernatur.gschema.xml:26 -#: data/gschema/cl.cromer.ubb.sernatur.gschema.xml:27 +#: data/gschema/cl.cromer.ubb.sernatur.db.gschema.xml:26 +#: data/gschema/cl.cromer.ubb.sernatur.db.gschema.xml:27 msgid "tty to send debug info (ignored)" msgstr "" -#: data/gschema/cl.cromer.ubb.sernatur.gschema.xml:33 -#: data/gschema/cl.cromer.ubb.sernatur.gschema.xml:34 +#: data/gschema/cl.cromer.ubb.sernatur.db.gschema.xml:33 +#: data/gschema/cl.cromer.ubb.sernatur.db.gschema.xml:34 msgid "Database to use" msgstr "" -#: data/gschema/cl.cromer.ubb.sernatur.gschema.xml:40 -#: data/gschema/cl.cromer.ubb.sernatur.gschema.xml:41 +#: data/gschema/cl.cromer.ubb.sernatur.db.gschema.xml:40 +#: data/gschema/cl.cromer.ubb.sernatur.db.gschema.xml:41 msgid "Username to use" msgstr "" -#: data/gschema/cl.cromer.ubb.sernatur.gschema.xml:47 -#: data/gschema/cl.cromer.ubb.sernatur.gschema.xml:48 +#: data/gschema/cl.cromer.ubb.sernatur.db.gschema.xml:47 +#: data/gschema/cl.cromer.ubb.sernatur.db.gschema.xml:48 msgid "Password to use" msgstr "" -#: data/gschema/cl.cromer.ubb.sernatur.gschema.xml:54 -#: data/gschema/cl.cromer.ubb.sernatur.gschema.xml:55 +#: data/gschema/cl.cromer.ubb.sernatur.window.gschema.xml:5 +#: data/gschema/cl.cromer.ubb.sernatur.window.gschema.xml:6 msgid "Should the program open maximized or not" msgstr "" + +#: data/gschema/cl.cromer.ubb.sernatur.window.gschema.xml:12 +#: data/gschema/cl.cromer.ubb.sernatur.window.gschema.xml:13 +msgid "Window width" +msgstr "" + +#: data/gschema/cl.cromer.ubb.sernatur.window.gschema.xml:19 +#: data/gschema/cl.cromer.ubb.sernatur.window.gschema.xml:20 +msgid "Window height" +msgstr "" diff --git a/src/sernatur-window.vala b/src/sernatur-window.vala index 54a85be..9d0bae6 100644 --- a/src/sernatur-window.vala +++ b/src/sernatur-window.vala @@ -28,11 +28,11 @@ namespace Sernatur { * This is a callback for when the window's state changes * @param widget The widget that called this GtkCallback * @param state The event window state_handler - * @return Returns true or false + * @return Returns true if the event is handled or false if it isn't */ [GtkCallback] - private bool state_handler(Gtk.Widget widget, Gdk.EventWindowState state) { - Settings settings = new Settings ("cl.cromer.ubb.sernatur"); + private bool maximize_window(Gtk.Widget widget, Gdk.EventWindowState state) { + Settings settings = new Settings ("cl.cromer.ubb.sernatur.window"); if (state.changed_mask == Gdk.WindowState.MAXIMIZED && (state.new_window_state & Gdk.WindowState.MAXIMIZED) != 0) { // Maximized settings.set_boolean ("maximized", true); @@ -44,6 +44,20 @@ namespace Sernatur { return true; } + [GtkCallback] + private bool resize_window(Gtk.Widget widget, Gdk.Event event) { + Settings settings = new Settings ("cl.cromer.ubb.sernatur.window"); + if (event.get_event_type () == Gdk.EventType.CONFIGURE && !settings.get_boolean ("maximized")) { + if (settings.get_int ("width") != event.get_window ().get_width ()) { + settings.set_int ("width", event.get_window ().get_width ()); + } + if (settings.get_int ("height") != event.get_window ().get_height ()) { + settings.set_int ("height", event.get_window ().get_height ()); + } + } + return false; + } + /** * Initialize the main window class * @param application The application used to make the GLib object @@ -52,7 +66,7 @@ namespace Sernatur { GLib.Object (application: application); Database conn; - Settings settings = new Settings ("cl.cromer.ubb.sernatur"); + Settings settings = new Settings ("cl.cromer.ubb.sernatur.db"); string host = settings.get_string ("host"); string port = settings.get_string ("port"); string options = settings.get_string ("options"); diff --git a/src/sernatur.vala b/src/sernatur.vala index 8864d9c..c03de70 100644 --- a/src/sernatur.vala +++ b/src/sernatur.vala @@ -39,16 +39,19 @@ namespace Sernatur { */ public override void activate () { window = new MainWindow (this); - GLib.Settings settings = new GLib.Settings ("cl.cromer.ubb.sernatur"); + GLib.Settings settings = new GLib.Settings ("cl.cromer.ubb.sernatur.window"); + + window.set_default_size (settings.get_int("width"), settings.get_int("height")); + if (settings.get_boolean ("maximized")) { window.maximize (); } + try { window.icon = IconTheme.get_default ().load_icon ("sernatur", 48, 0); } - catch (Error e) { - stderr.printf ("Could not load application icon: %s\n", e.message); + stderr.printf (dgettext (null, "Could not load application icon: %s\n"), e.message); } window.present (); }