Commit da9a427b7c7950f66d8c10af2e14c4d6a4585512
1 parent
ea07200f
Exists in
master
and in
4 other branches
Creating gsettings path for window state and saving size and state to
it.
Showing
7 changed files
with
339 additions
and
122 deletions
Show diff stats
Makefile.in
@@ -44,6 +44,10 @@ SOURCES= \ | @@ -44,6 +44,10 @@ SOURCES= \ | ||
44 | $(wildcard src/main/@OSNAME@/*.c) \ | 44 | $(wildcard src/main/@OSNAME@/*.c) \ |
45 | $(wildcard src/main/@OSNAME@/*.rc) | 45 | $(wildcard src/main/@OSNAME@/*.rc) |
46 | 46 | ||
47 | +SCHEMAS= \ | ||
48 | + $(wildcard schemas/@OSNAME@/*.gschema.xml) \ | ||
49 | + $(wildcard schemas/common/*.gschema.xml) | ||
50 | + | ||
47 | #---[ Tools ]---------------------------------------------------------------------------- | 51 | #---[ Tools ]---------------------------------------------------------------------------- |
48 | 52 | ||
49 | CC=@CC@ | 53 | CC=@CC@ |
@@ -75,6 +79,7 @@ sysconfdir=@sysconfdir@ | @@ -75,6 +79,7 @@ sysconfdir=@sysconfdir@ | ||
75 | BASEDIR=@BASEDIR@ | 79 | BASEDIR=@BASEDIR@ |
76 | 80 | ||
77 | POTDIR=$(BASEDIR)/.pot | 81 | POTDIR=$(BASEDIR)/.pot |
82 | +POTDIR=$(BASEDIR)/.schemas | ||
78 | 83 | ||
79 | OBJDIR=$(BASEDIR)/.obj/$(PACKAGE_NAME) | 84 | OBJDIR=$(BASEDIR)/.obj/$(PACKAGE_NAME) |
80 | OBJDBG=$(OBJDIR)/Debug | 85 | OBJDBG=$(OBJDIR)/Debug |
@@ -134,11 +139,11 @@ $(OBJDBG)/%.o: \ | @@ -134,11 +139,11 @@ $(OBJDBG)/%.o: \ | ||
134 | @$(WINDRES) $< -O coff -o $@ | 139 | @$(WINDRES) $< -O coff -o $@ |
135 | 140 | ||
136 | gschemas.compiled: \ | 141 | gschemas.compiled: \ |
137 | - schemas/@OSNAME@/*.gschema.xml | 142 | + $(foreach SCHEMA, $(notdir $(SCHEMAS)), $(OBJDIR)/schemas/$(SCHEMA)) |
138 | 143 | ||
139 | @glib-compile-schemas \ | 144 | @glib-compile-schemas \ |
140 | --targetdir=$(@D) \ | 145 | --targetdir=$(@D) \ |
141 | - $(BASEDIR)/schemas/@OSNAME@ | 146 | + $(OBJDIR)/schemas |
142 | 147 | ||
143 | #---[ Release Rules ]-------------------------------------------------------------------- | 148 | #---[ Release Rules ]-------------------------------------------------------------------- |
144 | 149 | ||
@@ -184,6 +189,18 @@ $(POTDIR)/$(PACKAGE_NAME)/%.pot: \ | @@ -184,6 +189,18 @@ $(POTDIR)/$(PACKAGE_NAME)/%.pot: \ | ||
184 | @touch $@ | 189 | @touch $@ |
185 | 190 | ||
186 | 191 | ||
192 | +$(OBJDIR)/schemas/%.xml:\ | ||
193 | + schemas/@OSNAME@/%.xml | ||
194 | + | ||
195 | + @$(MKDIR) $(@D) | ||
196 | + @cp "$^" "$@" | ||
197 | + | ||
198 | +$(OBJDIR)/schemas/%.xml:\ | ||
199 | + schemas/common/%.xml | ||
200 | + | ||
201 | + @$(MKDIR) $(@D) | ||
202 | + @cp "$^" "$@" | ||
203 | + | ||
187 | install-%: \ | 204 | install-%: \ |
188 | %/Makefile | 205 | %/Makefile |
189 | 206 | ||
@@ -299,12 +316,14 @@ clean: \ | @@ -299,12 +316,14 @@ clean: \ | ||
299 | cleanDebug: | 316 | cleanDebug: |
300 | 317 | ||
301 | @rm -fr $(OBJDBG) | 318 | @rm -fr $(OBJDBG) |
319 | + @rm -fr $(OBJDIR)/schemas | ||
302 | @rm -fr $(BINDBG) | 320 | @rm -fr $(BINDBG) |
303 | @rm -f gschemas.compiled | 321 | @rm -f gschemas.compiled |
304 | 322 | ||
305 | cleanRelease: | 323 | cleanRelease: |
306 | 324 | ||
307 | @rm -fr $(OBJRLS) | 325 | @rm -fr $(OBJRLS) |
326 | + @rm -fr $(OBJDIR)/schemas | ||
308 | @rm -fr $(BINRLS) | 327 | @rm -fr $(BINRLS) |
309 | @rm -fr $(POTDIR) | 328 | @rm -fr $(POTDIR) |
310 | 329 |
configure.ac
@@ -97,6 +97,8 @@ dnl INSTALL_PACKAGES="linux-lib ${INSTALL_PACKAGES}" | @@ -97,6 +97,8 @@ dnl INSTALL_PACKAGES="linux-lib ${INSTALL_PACKAGES}" | ||
97 | 97 | ||
98 | esac | 98 | esac |
99 | 99 | ||
100 | +AC_CONFIG_FILES(schemas/common/window.gschema.xml) | ||
101 | + | ||
100 | AC_SUBST(OSNAME,$app_cv_osname) | 102 | AC_SUBST(OSNAME,$app_cv_osname) |
101 | AC_SUBST(LIBS) | 103 | AC_SUBST(LIBS) |
102 | AC_SUBST(LOGDIR) | 104 | AC_SUBST(LOGDIR) |
schemas/Makefile.in
@@ -55,6 +55,10 @@ install: | @@ -55,6 +55,10 @@ install: | ||
55 | @$(MKDIR) $(DESTDIR)/$(schemadir) | 55 | @$(MKDIR) $(DESTDIR)/$(schemadir) |
56 | @$(INSTALL_DATA) \ | 56 | @$(INSTALL_DATA) \ |
57 | $(BASEDIR)/schemas/@OSNAME@/application.gschema.xml \ | 57 | $(BASEDIR)/schemas/@OSNAME@/application.gschema.xml \ |
58 | - $(DESTDIR)/$(schemadir)/$(PRODUCT_NAME).gschema.xml | 58 | + $(DESTDIR)/$(schemadir)/$(PRODUCT_NAME)-application.gschema.xml |
59 | + | ||
60 | + @$(INSTALL_DATA) \ | ||
61 | + $(BASEDIR)/schemas/common/window.gschema.xml \ | ||
62 | + $(DESTDIR)/$(schemadir)/$(PRODUCT_NAME)-window.gschema.xml | ||
59 | 63 | ||
60 | 64 |
@@ -0,0 +1,103 @@ | @@ -0,0 +1,103 @@ | ||
1 | +<?xml version="1.0" encoding="UTF-8"?> | ||
2 | +<!-- | ||
3 | + | ||
4 | + Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 | ||
5 | + (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a | ||
6 | + aplicativos mainframe. Registro no INPI sob o nome G3270. | ||
7 | + | ||
8 | + Copyright (C) <2008> <Banco do Brasil S.A.> | ||
9 | + | ||
10 | + Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob | ||
11 | + os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela | ||
12 | + Free Software Foundation. | ||
13 | + | ||
14 | + Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER | ||
15 | + GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO | ||
16 | + A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para | ||
17 | + obter mais detalhes. | ||
18 | + | ||
19 | + Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este | ||
20 | + programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin | ||
21 | + St, Fifth Floor, Boston, MA 02110-1301 USA | ||
22 | + | ||
23 | + | ||
24 | + Contatos: | ||
25 | + | ||
26 | + perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | ||
27 | + erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) | ||
28 | + | ||
29 | +--> | ||
30 | + | ||
31 | +<schemalist> | ||
32 | + | ||
33 | + <schema id="br.com.bb.@PACKAGE_NAME@.window"> | ||
34 | + | ||
35 | + <key name="width" type="i"> | ||
36 | + <default>-1</default> | ||
37 | + <summary>The window width.</summary> | ||
38 | + <description></description> | ||
39 | + </key> | ||
40 | + | ||
41 | + <key name="height" type="i"> | ||
42 | + <default>-1</default> | ||
43 | + <summary>The window height.</summary> | ||
44 | + <description></description> | ||
45 | + </key> | ||
46 | + | ||
47 | + <key name="is-maximized" type="b"> | ||
48 | + <default>false</default> | ||
49 | + <summary>Is the window maximized?</summary> | ||
50 | + <description></description> | ||
51 | + </key> | ||
52 | + | ||
53 | + <key name="is-fullscreen" type="b"> | ||
54 | + <default>false</default> | ||
55 | + <summary>Is the window in full screen mode?</summary> | ||
56 | + <description></description> | ||
57 | + </key> | ||
58 | + | ||
59 | + <key name="has-subtitle" type="b"> | ||
60 | + <default>true</default> | ||
61 | + <summary>Enable top window subtitle</summary> | ||
62 | + <description>If TRUE, reserve space for a subtitle, even if none is currently set.</description> | ||
63 | + </key> | ||
64 | + | ||
65 | + <key name="toolbar-visible" type="b"> | ||
66 | + <default>true</default> | ||
67 | + <summary>The toolbar visible state</summary> | ||
68 | + <description></description> | ||
69 | + </key> | ||
70 | + | ||
71 | + <key name="menubar-visible" type="b"> | ||
72 | + <default>true</default> | ||
73 | + <summary>The menubar visible state</summary> | ||
74 | + <description></description> | ||
75 | + </key> | ||
76 | + | ||
77 | + <key name="toolbar-style" type="i"> | ||
78 | + <default>-1</default> | ||
79 | + <summary>How to draw the toolbar.</summary> | ||
80 | + <description></description> | ||
81 | + </key> | ||
82 | + | ||
83 | + <key name="toolbar-icon-size" type="i"> | ||
84 | + <default>0</default> | ||
85 | + <summary>The size of the icons in a toolbar</summary> | ||
86 | + <description></description> | ||
87 | + </key> | ||
88 | + | ||
89 | + <key name="toolbar-action-names" type="s"> | ||
90 | + <default>'win.copy,win.paste,win.select-all,separator,win.connect,win.disconnect,separator,win.session.properties,win.file.transfer,win.print,win.close'</default> | ||
91 | + <summary>The toolbar action list</summary> | ||
92 | + <description></description> | ||
93 | + </key> | ||
94 | + | ||
95 | + <key name="header-action-names" type="s"> | ||
96 | + <default>'win.disconnect,win.reconnect,win.file.transfer,win.print:menu.open-menu'</default> | ||
97 | + <summary>The actions in the header bar</summary> | ||
98 | + <description></description> | ||
99 | + </key> | ||
100 | + | ||
101 | + </schema> | ||
102 | + | ||
103 | +</schemalist> |
schemas/linux/application.gschema.xml.in
@@ -38,48 +38,6 @@ | @@ -38,48 +38,6 @@ | ||
38 | <description>The ID of the current user interface style</description> | 38 | <description>The ID of the current user interface style</description> |
39 | </key> | 39 | </key> |
40 | 40 | ||
41 | - <key name="has-subtitle" type="b"> | ||
42 | - <default>true</default> | ||
43 | - <summary>Enable top window subtitle</summary> | ||
44 | - <description>If TRUE, reserve space for a subtitle, even if none is currently set.</description> | ||
45 | - </key> | ||
46 | - | ||
47 | - <key name="toolbar-style" type="i"> | ||
48 | - <default>-1</default> | ||
49 | - <summary>How to draw the toolbar.</summary> | ||
50 | - <description></description> | ||
51 | - </key> | ||
52 | - | ||
53 | - <key name="toolbar-icon-size" type="i"> | ||
54 | - <default>0</default> | ||
55 | - <summary>The size of the icons in a toolbar</summary> | ||
56 | - <description></description> | ||
57 | - </key> | ||
58 | - | ||
59 | - <key name="toolbar-visible" type="b"> | ||
60 | - <default>true</default> | ||
61 | - <summary>The toolbar visible state</summary> | ||
62 | - <description></description> | ||
63 | - </key> | ||
64 | - | ||
65 | - <key name="menubar-visible" type="b"> | ||
66 | - <default>true</default> | ||
67 | - <summary>The menubar visible state</summary> | ||
68 | - <description></description> | ||
69 | - </key> | ||
70 | - | ||
71 | - <key name="toolbar-action-names" type="s"> | ||
72 | - <default>'win.copy,win.paste,win.select-all,separator,win.connect,win.disconnect,separator,win.session.properties,win.file.transfer,win.print,app.quit'</default> | ||
73 | - <summary>The toolbar action list</summary> | ||
74 | - <description></description> | ||
75 | - </key> | ||
76 | - | ||
77 | - <key name="header-action-names" type="s"> | ||
78 | - <default>'win.disconnect,win.reconnect,win.file.transfer,win.print:menu.open-menu'</default> | ||
79 | - <summary>The actions in the header bar</summary> | ||
80 | - <description></description> | ||
81 | - </key> | ||
82 | - | ||
83 | </schema> | 41 | </schema> |
84 | 42 | ||
85 | </schemalist> | 43 | </schemalist> |
src/objects/window/private.h
@@ -65,6 +65,13 @@ | @@ -65,6 +65,13 @@ | ||
65 | GtkNotebook * notebook; | 65 | GtkNotebook * notebook; |
66 | GtkToolbar * toolbar; | 66 | GtkToolbar * toolbar; |
67 | 67 | ||
68 | + struct { | ||
69 | + int width; ///< @brief Window width. | ||
70 | + int height; ///< @brief Window height. | ||
71 | + int is_maximized : 1; ///< @brief Non zero if window is maximized. | ||
72 | + int is_fullscreen : 1; ///< @brief Non zero if window is fullscreen. | ||
73 | + } state; | ||
74 | + | ||
68 | GtkWidget * popups[PW3270_APP_WINDOW_POPUP_COUNT]; | 75 | GtkWidget * popups[PW3270_APP_WINDOW_POPUP_COUNT]; |
69 | 76 | ||
70 | }; | 77 | }; |
src/objects/window/window.c
@@ -35,6 +35,7 @@ | @@ -35,6 +35,7 @@ | ||
35 | 35 | ||
36 | static void get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec); | 36 | static void get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec); |
37 | static void set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec); | 37 | static void set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec); |
38 | + static GSettings *pw3270_application_window_settings_new(void); | ||
38 | 39 | ||
39 | G_DEFINE_TYPE(pw3270ApplicationWindow, pw3270ApplicationWindow, GTK_TYPE_APPLICATION_WINDOW); | 40 | G_DEFINE_TYPE(pw3270ApplicationWindow, pw3270ApplicationWindow, GTK_TYPE_APPLICATION_WINDOW); |
40 | 41 | ||
@@ -60,29 +61,105 @@ | @@ -60,29 +61,105 @@ | ||
60 | } | 61 | } |
61 | } | 62 | } |
62 | 63 | ||
64 | + { | ||
65 | + g_autoptr(GSettings) settings = pw3270_application_window_settings_new(); | ||
66 | + | ||
67 | + g_settings_set_int(settings, "width", window->state.width); | ||
68 | + g_settings_set_int(settings, "height", window->state.height); | ||
69 | + g_settings_set_boolean(settings, "is-maximized", window->state.is_maximized); | ||
70 | + g_settings_set_boolean(settings, "is-fullscreen", window->state.is_fullscreen); | ||
71 | + } | ||
72 | + | ||
63 | GTK_WIDGET_CLASS(pw3270ApplicationWindow_parent_class)->destroy(widget); | 73 | GTK_WIDGET_CLASS(pw3270ApplicationWindow_parent_class)->destroy(widget); |
64 | 74 | ||
65 | } | 75 | } |
66 | 76 | ||
67 | - static void pw3270ApplicationWindow_class_init(pw3270ApplicationWindowClass *klass) { | 77 | + static void size_allocate(GtkWidget *widget, GtkAllocation *allocation) { |
78 | + | ||
79 | + // https://developer.gnome.org/SaveWindowState/ | ||
80 | + GTK_WIDGET_CLASS(pw3270ApplicationWindow_parent_class)->size_allocate(widget, allocation); | ||
68 | 81 | ||
69 | - GTK_WIDGET_CLASS(klass)->destroy = destroy; | 82 | + pw3270ApplicationWindow * window = PW3270_APPLICATION_WINDOW(widget); |
83 | + | ||
84 | + if(!(window->state.is_maximized || window->state.is_fullscreen)) { | ||
85 | + gtk_window_get_size(GTK_WINDOW (widget), &window->state.width, &window->state.height); | ||
86 | + } | ||
70 | 87 | ||
71 | - GObjectClass *object_class = G_OBJECT_CLASS(klass); | 88 | + } |
72 | 89 | ||
73 | - object_class->set_property = set_property; | ||
74 | - object_class->get_property = get_property; | 90 | + static gboolean window_state_event(GtkWidget *widget, GdkEventWindowState *event) { |
75 | 91 | ||
76 | - g_object_class_install_property( | ||
77 | - object_class, | ||
78 | - PROP_ACTION_NAMES, | ||
79 | - g_param_spec_string ("action-names", | ||
80 | - N_("Action Names"), | ||
81 | - N_("The name of the actions in the header bar"), | ||
82 | - NULL, | ||
83 | - G_PARAM_WRITABLE|G_PARAM_READABLE) | ||
84 | - ); | 92 | + // https://developer.gnome.org/SaveWindowState/ |
93 | + gboolean res = GDK_EVENT_PROPAGATE; | ||
85 | 94 | ||
95 | + if(GTK_WIDGET_CLASS(pw3270ApplicationWindow_parent_class)->window_state_event != NULL) { | ||
96 | + res = GTK_WIDGET_CLASS(pw3270ApplicationWindow_parent_class)->window_state_event(widget, event); | ||
97 | + } | ||
98 | + | ||
99 | + { | ||
100 | + pw3270ApplicationWindow * window = PW3270_APPLICATION_WINDOW(widget); | ||
101 | + | ||
102 | + window->state.is_maximized = (event->new_window_state & GDK_WINDOW_STATE_MAXIMIZED) == 0 ? 0 : 1; | ||
103 | + window->state.is_fullscreen = (event->new_window_state & GDK_WINDOW_STATE_FULLSCREEN) == 0 ? 0 : 1; | ||
104 | + } | ||
105 | + | ||
106 | + return res; | ||
107 | + } | ||
108 | + | ||
109 | + static void constructed(GObject *object) { | ||
110 | + | ||
111 | + // https://developer.gnome.org/SaveWindowState/ | ||
112 | + | ||
113 | + pw3270ApplicationWindow * window = PW3270_APPLICATION_WINDOW(object); | ||
114 | + | ||
115 | + g_autoptr(GSettings) settings = pw3270_application_window_settings_new(); | ||
116 | + if(settings) { | ||
117 | + | ||
118 | + // https://developer.gnome.org/SaveWindowState/ | ||
119 | + window->state.width = g_settings_get_int (settings, "width"); | ||
120 | + window->state.height = g_settings_get_int (settings, "height"); | ||
121 | + window->state.is_maximized = g_settings_get_boolean (settings, "is-maximized") ? 1 : 0; | ||
122 | + window->state.is_fullscreen = g_settings_get_boolean (settings, "is-fullscreen") ? 1 : 0; | ||
123 | + | ||
124 | + } | ||
125 | + | ||
126 | + gtk_window_set_default_size(GTK_WINDOW (object), window->state.width, window->state.height); | ||
127 | + | ||
128 | + if(window->state.is_maximized) | ||
129 | + gtk_window_maximize(GTK_WINDOW(object)); | ||
130 | + | ||
131 | + if(window->state.is_fullscreen) | ||
132 | + gtk_window_fullscreen(GTK_WINDOW (object)); | ||
133 | + | ||
134 | + G_OBJECT_CLASS (pw3270ApplicationWindow_parent_class)->constructed (object); | ||
135 | + } | ||
136 | + | ||
137 | + static void pw3270ApplicationWindow_class_init(pw3270ApplicationWindowClass *klass) { | ||
138 | + | ||
139 | + { | ||
140 | + GtkWidgetClass *widget = GTK_WIDGET_CLASS(klass); | ||
141 | + widget->destroy = destroy; | ||
142 | + widget->window_state_event = window_state_event; | ||
143 | + widget->size_allocate = size_allocate; | ||
144 | + } | ||
145 | + | ||
146 | + { | ||
147 | + GObjectClass *object_class = G_OBJECT_CLASS(klass); | ||
148 | + | ||
149 | + object_class->set_property = set_property; | ||
150 | + object_class->get_property = get_property; | ||
151 | + object_class->constructed = constructed; | ||
152 | + | ||
153 | + g_object_class_install_property( | ||
154 | + object_class, | ||
155 | + PROP_ACTION_NAMES, | ||
156 | + g_param_spec_string ("action-names", | ||
157 | + N_("Action Names"), | ||
158 | + N_("The name of the actions in the header bar"), | ||
159 | + NULL, | ||
160 | + G_PARAM_WRITABLE|G_PARAM_READABLE) | ||
161 | + ); | ||
162 | + } | ||
86 | 163 | ||
87 | } | 164 | } |
88 | 165 | ||
@@ -104,6 +181,13 @@ | @@ -104,6 +181,13 @@ | ||
104 | 181 | ||
105 | static void pw3270ApplicationWindow_init(pw3270ApplicationWindow *widget) { | 182 | static void pw3270ApplicationWindow_init(pw3270ApplicationWindow *widget) { |
106 | 183 | ||
184 | + // Setup defaults | ||
185 | + widget->state.width = 800; | ||
186 | + widget->state.height = 500; | ||
187 | + widget->state.is_maximized = 0; | ||
188 | + widget->state.is_fullscreen = 0; | ||
189 | + | ||
190 | + // Create contents | ||
107 | GtkBox * vBox = GTK_BOX(gtk_box_new(GTK_ORIENTATION_VERTICAL,0)); | 191 | GtkBox * vBox = GTK_BOX(gtk_box_new(GTK_ORIENTATION_VERTICAL,0)); |
108 | 192 | ||
109 | widget->notebook = GTK_NOTEBOOK(gtk_notebook_new()); | 193 | widget->notebook = GTK_NOTEBOOK(gtk_notebook_new()); |
@@ -224,8 +308,6 @@ | @@ -224,8 +308,6 @@ | ||
224 | 308 | ||
225 | size_t ix; | 309 | size_t ix; |
226 | 310 | ||
227 | - g_autoptr(GSettings) settings = pw3270_application_get_settings(G_APPLICATION(application)); | ||
228 | - | ||
229 | g_return_val_if_fail(GTK_IS_APPLICATION(application), NULL); | 311 | g_return_val_if_fail(GTK_IS_APPLICATION(application), NULL); |
230 | pw3270ApplicationWindow * window = | 312 | pw3270ApplicationWindow * window = |
231 | g_object_new( | 313 | g_object_new( |
@@ -259,88 +341,88 @@ | @@ -259,88 +341,88 @@ | ||
259 | 341 | ||
260 | } | 342 | } |
261 | 343 | ||
262 | - if(pw3270_application_get_ui_style(G_APPLICATION(application)) == PW3270_UI_STYLE_GNOME) { | 344 | + // Setup and show main window |
345 | + { | ||
346 | + g_autoptr(GSettings) settings = pw3270_application_window_settings_new(); | ||
347 | + | ||
348 | + if(pw3270_application_get_ui_style(G_APPLICATION(application)) == PW3270_UI_STYLE_GNOME) { | ||
349 | + | ||
350 | + // Create header bar | ||
351 | + | ||
352 | + GtkHeaderBar * header = GTK_HEADER_BAR(gtk_header_bar_new()); | ||
353 | + gtk_window_set_titlebar(GTK_WINDOW(window), GTK_WIDGET(header)); | ||
354 | + gtk_header_bar_set_show_close_button(header,TRUE); | ||
263 | 355 | ||
264 | - // Create header bar | 356 | + gtk_header_bar_set_title(header,title); |
357 | + g_settings_bind( | ||
358 | + settings, | ||
359 | + "has-subtitle", | ||
360 | + header, | ||
361 | + "has-subtitle", | ||
362 | + G_SETTINGS_BIND_DEFAULT | ||
363 | + ); | ||
265 | 364 | ||
266 | - GtkHeaderBar * header = GTK_HEADER_BAR(gtk_header_bar_new()); | ||
267 | - gtk_window_set_titlebar(GTK_WINDOW(window), GTK_WIDGET(header)); | ||
268 | - gtk_header_bar_set_show_close_button(header,TRUE); | 365 | + // Show the new header |
366 | + gtk_widget_show_all(GTK_WIDGET(header)); | ||
367 | + | ||
368 | + g_settings_bind( | ||
369 | + settings, | ||
370 | + "header-action-names", | ||
371 | + window, | ||
372 | + "action-names", | ||
373 | + G_SETTINGS_BIND_DEFAULT | ||
374 | + ); | ||
375 | + | ||
376 | + } else { | ||
377 | + | ||
378 | + gtk_window_set_title(GTK_WINDOW(window), title); | ||
379 | + | ||
380 | + } | ||
269 | 381 | ||
270 | - gtk_header_bar_set_title(header,title); | ||
271 | g_settings_bind( | 382 | g_settings_bind( |
272 | settings, | 383 | settings, |
273 | - "has-subtitle", | ||
274 | - header, | ||
275 | - "has-subtitle", | 384 | + "menubar-visible", |
385 | + window, | ||
386 | + "show-menubar", | ||
276 | G_SETTINGS_BIND_DEFAULT | 387 | G_SETTINGS_BIND_DEFAULT |
277 | ); | 388 | ); |
278 | 389 | ||
279 | - // Show the new header | ||
280 | - gtk_widget_show_all(GTK_WIDGET(header)); | ||
281 | - | ||
282 | - // g_autofree gchar * header_actions = g_settings_get_string(settings, "header-action-names"); | ||
283 | - // pw3270_window_set_header_action_names(GTK_WIDGET(window), header_actions); | 390 | + g_settings_bind( |
391 | + settings, | ||
392 | + "toolbar-visible", | ||
393 | + window->toolbar, | ||
394 | + "visible", | ||
395 | + G_SETTINGS_BIND_DEFAULT | ||
396 | + ); | ||
284 | 397 | ||
285 | g_settings_bind( | 398 | g_settings_bind( |
286 | settings, | 399 | settings, |
287 | - "header-action-names", | ||
288 | - window, | 400 | + "toolbar-action-names", |
401 | + window->toolbar, | ||
289 | "action-names", | 402 | "action-names", |
290 | G_SETTINGS_BIND_DEFAULT | 403 | G_SETTINGS_BIND_DEFAULT |
291 | ); | 404 | ); |
292 | 405 | ||
293 | - } else { | 406 | + g_settings_bind( |
407 | + settings, | ||
408 | + "toolbar-style", | ||
409 | + window->toolbar, | ||
410 | + "style", | ||
411 | + G_SETTINGS_BIND_DEFAULT | ||
412 | + ); | ||
294 | 413 | ||
295 | - gtk_window_set_title(GTK_WINDOW(window), title); | 414 | + g_settings_bind( |
415 | + settings, | ||
416 | + "toolbar-icon-size", | ||
417 | + window->toolbar, | ||
418 | + "icon-size", | ||
419 | + G_SETTINGS_BIND_DEFAULT | ||
420 | + ); | ||
296 | 421 | ||
297 | } | 422 | } |
298 | 423 | ||
299 | - // Setup and show main window | ||
300 | - g_settings_bind( | ||
301 | - settings, | ||
302 | - "menubar-visible", | ||
303 | - window, | ||
304 | - "show-menubar", | ||
305 | - G_SETTINGS_BIND_DEFAULT | ||
306 | - ); | ||
307 | - | ||
308 | - g_settings_bind( | ||
309 | - settings, | ||
310 | - "toolbar-visible", | ||
311 | - window->toolbar, | ||
312 | - "visible", | ||
313 | - G_SETTINGS_BIND_DEFAULT | ||
314 | - ); | ||
315 | - | ||
316 | - g_settings_bind( | ||
317 | - settings, | ||
318 | - "toolbar-action-names", | ||
319 | - window->toolbar, | ||
320 | - "action-names", | ||
321 | - G_SETTINGS_BIND_DEFAULT | ||
322 | - ); | ||
323 | - | ||
324 | - g_settings_bind( | ||
325 | - settings, | ||
326 | - "toolbar-style", | ||
327 | - window->toolbar, | ||
328 | - "style", | ||
329 | - G_SETTINGS_BIND_DEFAULT | ||
330 | - ); | ||
331 | - | ||
332 | - g_settings_bind( | ||
333 | - settings, | ||
334 | - "toolbar-icon-size", | ||
335 | - window->toolbar, | ||
336 | - "icon-size", | ||
337 | - G_SETTINGS_BIND_DEFAULT | ||
338 | - ); | ||
339 | - | ||
340 | - | ||
341 | // Setup default position and size | 424 | // Setup default position and size |
342 | gtk_window_set_position(GTK_WINDOW(window),GTK_WIN_POS_CENTER); | 425 | gtk_window_set_position(GTK_WINDOW(window),GTK_WIN_POS_CENTER); |
343 | - gtk_window_set_default_size (GTK_WINDOW (window), 800, 500); | ||
344 | 426 | ||
345 | // Create terminal widget | 427 | // Create terminal widget |
346 | GtkWidget * terminal = pw3270_application_window_new_tab(GTK_WIDGET(window), session_file); | 428 | GtkWidget * terminal = pw3270_application_window_new_tab(GTK_WIDGET(window), session_file); |
@@ -456,3 +538,45 @@ | @@ -456,3 +538,45 @@ | ||
456 | g_strfreev(actions); | 538 | g_strfreev(actions); |
457 | 539 | ||
458 | } | 540 | } |
541 | + | ||
542 | + GSettings *pw3270_application_window_settings_new() { | ||
543 | + | ||
544 | + // Get settings | ||
545 | + g_autofree gchar * path = g_strconcat("/apps/" PACKAGE_NAME "/", g_get_application_name(), "/window/",NULL); | ||
546 | + debug("path=%s",path); | ||
547 | + | ||
548 | +#ifdef DEBUG | ||
549 | + | ||
550 | + GError * error = NULL; | ||
551 | + GSettingsSchemaSource * source = | ||
552 | + g_settings_schema_source_new_from_directory( | ||
553 | + ".", | ||
554 | + NULL, | ||
555 | + TRUE, | ||
556 | + &error | ||
557 | + ); | ||
558 | + | ||
559 | + g_assert_no_error(error); | ||
560 | + | ||
561 | + GSettingsSchema * schema = | ||
562 | + g_settings_schema_source_lookup( | ||
563 | + source, | ||
564 | + "br.com.bb." PACKAGE_NAME ".window", | ||
565 | + TRUE); | ||
566 | + | ||
567 | + debug("schema %s=%p path=%s","br.com.bb." PACKAGE_NAME ".window",schema,path); | ||
568 | + | ||
569 | + GSettings * settings = g_settings_new_full(schema, NULL, path); | ||
570 | + | ||
571 | + g_settings_schema_source_unref(source); | ||
572 | + | ||
573 | +#else | ||
574 | + | ||
575 | + GSettings * settings = g_settings_new_with_path("br.com.bb." PACKAGE_NAME, path); | ||
576 | + | ||
577 | +#endif // DEBUG | ||
578 | + | ||
579 | + return settings; | ||
580 | + | ||
581 | + } | ||
582 | + |