Merge lp:~artem-anufrij/webby-browser/save-main-window-settings into lp:webby-browser

Proposed by Artem Anufrij on 2015-10-16
Status: Merged
Approved by: Erasmo Marín on 2015-10-22
Approved revision: 16
Merged at revision: 16
Proposed branch: lp:~artem-anufrij/webby-browser/save-main-window-settings
Merge into: lp:webby-browser
Diff against target: 311 lines (+132/-49)
7 files modified
CMakeLists.txt (+6/-6)
org.pantheon.Webby.gschema.xml (+0/-24)
po/webby.pot (+49/-19)
schemas/CMakeLists.txt (+5/-0)
schemas/org.pantheon.Webby.gschema.xml (+24/-0)
src/AppWindow.vala (+25/-0)
src/Settings.vala (+23/-0)
To merge this branch: bzr merge lp:~artem-anufrij/webby-browser/save-main-window-settings
Reviewer Review Type Date Requested Status
Erasmo Marín 2015-10-16 Approve on 2015-10-22
Review via email: mp+274792@code.launchpad.net

Commit message

Store size and state of main window.

New pot-file.

Description of the change

Store size and state of main window.

New pot-file.

To post a comment you must log in.
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'CMakeLists.txt'
2--- CMakeLists.txt 2015-10-13 20:25:00 +0000
3+++ CMakeLists.txt 2015-10-16 21:44:55 +0000
4@@ -115,12 +115,18 @@
5 src/DesktopFile.vala
6 src/InfoDialog.vala
7 src/Launcher.vala
8+ src/Settings.vala
9 src/UrlEntry.vala
10 src/WebApp.vala
11 src/WebBar.vala
12 src/Webby.vala
13 src/WebAppWindow.vala)
14
15+#
16+# schema
17+#
18+add_subdirectory (schemas)
19+
20
21 include(ValaPrecompile)
22 vala_precompile(VALA_C ${SRC_FILES} PACKAGES ${PKG_DEPS}
23@@ -139,9 +145,3 @@
24 add_executable(webby ${VALA_C})
25 target_link_libraries(webby ${SQLITE_LIBRARIES} ${CLUTTERGTK_LIBRARIES} -lm)
26 install(TARGETS webby RUNTIME DESTINATION bin)
27-
28-#
29-# GSettings Schema
30-#
31-include(GSettings)
32-add_schema("org.pantheon.Webby.gschema.xml")
33
34=== removed file 'org.pantheon.Webby.gschema.xml'
35--- org.pantheon.Webby.gschema.xml 2015-02-24 05:12:05 +0000
36+++ org.pantheon.Webby.gschema.xml 1970-01-01 00:00:00 +0000
37@@ -1,24 +0,0 @@
38-<schemalist>
39- <enum id="org.pantheon.webby.SavedState.window-state">
40- <value nick="Normal" value="0" />
41- <value nick="Maximized" value="1" />
42- <value nick="Fullscreen" value="2" />
43- </enum>
44- <schema path="/org/pantheon/webby/saved-state/" id="org.pantheon.webby.SavedState" gettext-domain="webby">
45- <key name="window-width" type="i">
46- <default>800</default>
47- <summary>The saved width of the window.</summary>
48- <description>The saved width of the window.</description>
49- </key>
50- <key name="window-height" type="i">
51- <default>650</default>
52- <summary>The saved height of the window.</summary>
53- <description>The saved height of the window.</description>
54- </key>
55- <key name="window-state" enum="org.pantheon.webby.SavedState.window-state">
56- <default>"Normal"</default>
57- <summary>The saved state of the window.</summary>
58- <description>The saved state of the window.</description>
59- </key>
60- </schema>
61-</schemalist>
62
63=== modified file 'po/webby.pot'
64--- po/webby.pot 2015-03-24 00:20:49 +0000
65+++ po/webby.pot 2015-10-16 21:44:55 +0000
66@@ -1,72 +1,102 @@
67+# SOME DESCRIPTIVE TITLE.
68+# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
69+# This file is distributed under the same license as the PACKAGE package.
70+# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
71+#
72 #, fuzzy
73 msgid ""
74 msgstr ""
75 "Project-Id-Version: PACKAGE VERSION\n"
76 "Report-Msgid-Bugs-To: \n"
77-"POT-Creation-Date: 2015-02-26 23:57-0300\n"
78+"POT-Creation-Date: 2015-10-16 23:42+0200\n"
79 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
80 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
81 "Language-Team: LANGUAGE <LL@li.org>\n"
82+"Language: \n"
83 "MIME-Version: 1.0\n"
84-"Content-Type: text/plain; charset=UTF-8\n"
85+"Content-Type: text/plain; charset=CHARSET\n"
86 "Content-Transfer-Encoding: 8bit\n"
87-"X-Launchpad-Export-Date: 2015-03-24 00:16+0000\n"
88-"X-Generator: Launchpad (build 17413)\n"
89-"Language: \n"
90-
91-msgid "Remove Application"
92-msgstr ""
93-
94+
95+#: /home/artem/Launchpad/webby-browser/po/../src/InfoDialog.vala:16
96 msgid "Accept"
97 msgstr ""
98
99+#: /home/artem/Launchpad/webby-browser/po/../src/AppWindow.vala:70
100+msgid "Applications"
101+msgstr ""
102+
103+#: /home/artem/Launchpad/webby-browser/po/../src/AppWindow.vala:76
104+msgid "Add a new Web App"
105+msgstr ""
106+
107+#: /home/artem/Launchpad/webby-browser/po/../src/AppWindow.vala:79
108+msgid "No Web Apps Availible"
109+msgstr ""
110+
111+#: /home/artem/Launchpad/webby-browser/po/../src/AppWindow.vala:79
112+msgid "Create a new Webby Web App."
113+msgstr ""
114+
115+#: /home/artem/Launchpad/webby-browser/po/../src/AppWindow.vala:80
116+msgid "Create App"
117+msgstr ""
118+
119+#: /home/artem/Launchpad/webby-browser/po/../src/AppWindow.vala:80
120+msgid "Create a new Webby web app."
121+msgstr ""
122+
123+#: /home/artem/Launchpad/webby-browser/po/../src/Assistant.vala:45
124 msgid "Create a new web app with webby"
125 msgstr ""
126
127+#: /home/artem/Launchpad/webby-browser/po/../src/Assistant.vala:53
128 msgid "Application name"
129 msgstr ""
130
131+#: /home/artem/Launchpad/webby-browser/po/../src/Assistant.vala:56
132 msgid "http://myapp.domain"
133 msgstr ""
134
135+#: /home/artem/Launchpad/webby-browser/po/../src/Assistant.vala:66
136 msgid "theme icon name"
137 msgstr ""
138
139+#: /home/artem/Launchpad/webby-browser/po/../src/Assistant.vala:68
140 msgid "or"
141 msgstr ""
142
143+#: /home/artem/Launchpad/webby-browser/po/../src/Assistant.vala:69
144 msgid "Set from file..."
145 msgstr ""
146
147+#: /home/artem/Launchpad/webby-browser/po/../src/Assistant.vala:85
148 msgid "Save cookies"
149 msgstr ""
150
151+#: /home/artem/Launchpad/webby-browser/po/../src/Assistant.vala:87
152 msgid "Save login information"
153 msgstr ""
154
155-msgid "Create app"
156+#: /home/artem/Launchpad/webby-browser/po/../src/Assistant.vala:110
157+msgid "Save app"
158 msgstr ""
159
160+#: /home/artem/Launchpad/webby-browser/po/../src/Assistant.vala:132
161 msgid "url must start with http:// or https://"
162 msgstr ""
163
164+#: /home/artem/Launchpad/webby-browser/po/../src/Assistant.vala:145
165 msgid "App already exist"
166 msgstr ""
167
168+#: /home/artem/Launchpad/webby-browser/po/../src/Assistant.vala:198
169 msgid "Images"
170 msgstr ""
171
172+#: /home/artem/Launchpad/webby-browser/po/../src/Assistant.vala:210
173 msgid "Cancel"
174 msgstr ""
175
176+#: /home/artem/Launchpad/webby-browser/po/../src/Assistant.vala:211
177 msgid "Open"
178 msgstr ""
179-
180-msgid "App created"
181-msgstr ""
182-
183-msgid "The application shortcut was successfully created"
184-msgstr ""
185-
186-msgid "Applications"
187-msgstr ""
188
189=== added directory 'schemas'
190=== added file 'schemas/CMakeLists.txt'
191--- schemas/CMakeLists.txt 1970-01-01 00:00:00 +0000
192+++ schemas/CMakeLists.txt 2015-10-16 21:44:55 +0000
193@@ -0,0 +1,5 @@
194+#
195+# GSettings Schema
196+#
197+include(GSettings)
198+add_schema(org.pantheon.Webby.gschema.xml)
199
200=== added file 'schemas/org.pantheon.Webby.gschema.xml'
201--- schemas/org.pantheon.Webby.gschema.xml 1970-01-01 00:00:00 +0000
202+++ schemas/org.pantheon.Webby.gschema.xml 2015-10-16 21:44:55 +0000
203@@ -0,0 +1,24 @@
204+<schemalist>
205+ <enum id="org.pantheon.webby.SavedState.window-state">
206+ <value nick="Normal" value="0" />
207+ <value nick="Maximized" value="1" />
208+ <value nick="Fullscreen" value="2" />
209+ </enum>
210+ <schema path="/org/pantheon/webby/saved-state/" id="org.pantheon.webby.SavedState" gettext-domain="webby">
211+ <key name="window-width" type="i">
212+ <default>800</default>
213+ <summary>The saved width of the window.</summary>
214+ <description>The saved width of the window.</description>
215+ </key>
216+ <key name="window-height" type="i">
217+ <default>650</default>
218+ <summary>The saved height of the window.</summary>
219+ <description>The saved height of the window.</description>
220+ </key>
221+ <key name="window-state" enum="org.pantheon.webby.SavedState.window-state">
222+ <default>"Normal"</default>
223+ <summary>The saved state of the window.</summary>
224+ <description>The saved state of the window.</description>
225+ </key>
226+ </schema>
227+</schemalist>
228
229=== modified file 'src/AppWindow.vala'
230--- src/AppWindow.vala 2015-10-16 13:27:38 +0000
231+++ src/AppWindow.vala 2015-10-16 21:44:55 +0000
232@@ -1,5 +1,7 @@
233 public class AppWindow : Granite.Application {
234
235+ private Settings settings;
236+
237 public Gtk.Window mainwindow;
238
239 private Gtk.Stack stack;
240@@ -52,6 +54,8 @@
241 return;
242 }
243
244+ settings = Settings.get_default ();
245+
246 mainwindow = new Gtk.Window ();
247
248 mainwindow.set_default_size (700, 500);
249@@ -129,8 +133,14 @@
250 show_assistant ();
251 });
252
253+ mainwindow.delete_event.connect (() => {
254+ this.store_settings ();
255+ return false;
256+ });
257+
258 mainwindow.destroy.connect (Gtk.main_quit);
259
260+ this.restore_settings ();
261 mainwindow.show_all ();
262
263 if (apps_view.has_items)
264@@ -172,4 +182,19 @@
265 //fix ugly border at the bottom of headerbar
266 mainwindow.queue_draw ();
267 }
268+
269+ private void restore_settings () {
270+ this.mainwindow.set_default_size (settings.window_width, settings.window_height);
271+
272+ if (settings.window_state == Settings.WindowState.MAXIMIZED)
273+ this.mainwindow.maximize ();
274+ }
275+
276+ private void store_settings () {
277+ settings.window_state = (this.mainwindow.is_maximized ? Settings.WindowState.MAXIMIZED: Settings.WindowState.NORMAL);
278+ if (settings.window_state == Settings.WindowState.NORMAL) {
279+ settings.window_height = this.mainwindow.get_allocated_height ();
280+ settings.window_width = this.mainwindow.get_allocated_width ();
281+ }
282+ }
283 }
284
285=== added file 'src/Settings.vala'
286--- src/Settings.vala 1970-01-01 00:00:00 +0000
287+++ src/Settings.vala 2015-10-16 21:44:55 +0000
288@@ -0,0 +1,23 @@
289+public class Settings : Granite.Services.Settings {
290+
291+ private static Settings settings;
292+ public static Settings get_default () {
293+ if (settings == null)
294+ settings = new Settings ();
295+
296+ return settings;
297+ }
298+ public int window_width { get; set; }
299+ public int window_height { get; set; }
300+ public WindowState window_state { get; set; }
301+
302+ private Settings () {
303+ base ("org.pantheon.webby.SavedState");
304+ }
305+
306+ public enum WindowState {
307+ NORMAL,
308+ MAXIMIZED,
309+ FULLSCREEN
310+ }
311+}

Subscribers

People subscribed via source and target branches

to all changes: