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

Proposed by Artem Anufrij
Status: Merged
Approved by: Erasmo Marín
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 Approve
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.
Revision history for this message
Erasmo Marín (erasmo-marin) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'CMakeLists.txt'
--- CMakeLists.txt 2015-10-13 20:25:00 +0000
+++ CMakeLists.txt 2015-10-16 21:44:55 +0000
@@ -115,12 +115,18 @@
115 src/DesktopFile.vala115 src/DesktopFile.vala
116 src/InfoDialog.vala116 src/InfoDialog.vala
117 src/Launcher.vala117 src/Launcher.vala
118 src/Settings.vala
118 src/UrlEntry.vala119 src/UrlEntry.vala
119 src/WebApp.vala120 src/WebApp.vala
120 src/WebBar.vala121 src/WebBar.vala
121 src/Webby.vala122 src/Webby.vala
122 src/WebAppWindow.vala)123 src/WebAppWindow.vala)
123124
125#
126# schema
127#
128add_subdirectory (schemas)
129
124130
125include(ValaPrecompile)131include(ValaPrecompile)
126vala_precompile(VALA_C ${SRC_FILES} PACKAGES ${PKG_DEPS}132vala_precompile(VALA_C ${SRC_FILES} PACKAGES ${PKG_DEPS}
@@ -139,9 +145,3 @@
139add_executable(webby ${VALA_C})145add_executable(webby ${VALA_C})
140target_link_libraries(webby ${SQLITE_LIBRARIES} ${CLUTTERGTK_LIBRARIES} -lm)146target_link_libraries(webby ${SQLITE_LIBRARIES} ${CLUTTERGTK_LIBRARIES} -lm)
141install(TARGETS webby RUNTIME DESTINATION bin)147install(TARGETS webby RUNTIME DESTINATION bin)
142
143#
144# GSettings Schema
145#
146include(GSettings)
147add_schema("org.pantheon.Webby.gschema.xml")
148148
=== removed file 'org.pantheon.Webby.gschema.xml'
--- org.pantheon.Webby.gschema.xml 2015-02-24 05:12:05 +0000
+++ org.pantheon.Webby.gschema.xml 1970-01-01 00:00:00 +0000
@@ -1,24 +0,0 @@
1<schemalist>
2 <enum id="org.pantheon.webby.SavedState.window-state">
3 <value nick="Normal" value="0" />
4 <value nick="Maximized" value="1" />
5 <value nick="Fullscreen" value="2" />
6 </enum>
7 <schema path="/org/pantheon/webby/saved-state/" id="org.pantheon.webby.SavedState" gettext-domain="webby">
8 <key name="window-width" type="i">
9 <default>800</default>
10 <summary>The saved width of the window.</summary>
11 <description>The saved width of the window.</description>
12 </key>
13 <key name="window-height" type="i">
14 <default>650</default>
15 <summary>The saved height of the window.</summary>
16 <description>The saved height of the window.</description>
17 </key>
18 <key name="window-state" enum="org.pantheon.webby.SavedState.window-state">
19 <default>"Normal"</default>
20 <summary>The saved state of the window.</summary>
21 <description>The saved state of the window.</description>
22 </key>
23 </schema>
24</schemalist>
250
=== modified file 'po/webby.pot'
--- po/webby.pot 2015-03-24 00:20:49 +0000
+++ po/webby.pot 2015-10-16 21:44:55 +0000
@@ -1,72 +1,102 @@
1# SOME DESCRIPTIVE TITLE.
2# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
3# This file is distributed under the same license as the PACKAGE package.
4# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
5#
1#, fuzzy6#, fuzzy
2msgid ""7msgid ""
3msgstr ""8msgstr ""
4"Project-Id-Version: PACKAGE VERSION\n"9"Project-Id-Version: PACKAGE VERSION\n"
5"Report-Msgid-Bugs-To: \n"10"Report-Msgid-Bugs-To: \n"
6"POT-Creation-Date: 2015-02-26 23:57-0300\n"11"POT-Creation-Date: 2015-10-16 23:42+0200\n"
7"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"12"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
8"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"13"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
9"Language-Team: LANGUAGE <LL@li.org>\n"14"Language-Team: LANGUAGE <LL@li.org>\n"
15"Language: \n"
10"MIME-Version: 1.0\n"16"MIME-Version: 1.0\n"
11"Content-Type: text/plain; charset=UTF-8\n"17"Content-Type: text/plain; charset=CHARSET\n"
12"Content-Transfer-Encoding: 8bit\n"18"Content-Transfer-Encoding: 8bit\n"
13"X-Launchpad-Export-Date: 2015-03-24 00:16+0000\n"19
14"X-Generator: Launchpad (build 17413)\n"20#: /home/artem/Launchpad/webby-browser/po/../src/InfoDialog.vala:16
15"Language: \n"
16
17msgid "Remove Application"
18msgstr ""
19
20msgid "Accept"21msgid "Accept"
21msgstr ""22msgstr ""
2223
24#: /home/artem/Launchpad/webby-browser/po/../src/AppWindow.vala:70
25msgid "Applications"
26msgstr ""
27
28#: /home/artem/Launchpad/webby-browser/po/../src/AppWindow.vala:76
29msgid "Add a new Web App"
30msgstr ""
31
32#: /home/artem/Launchpad/webby-browser/po/../src/AppWindow.vala:79
33msgid "No Web Apps Availible"
34msgstr ""
35
36#: /home/artem/Launchpad/webby-browser/po/../src/AppWindow.vala:79
37msgid "Create a new Webby Web App."
38msgstr ""
39
40#: /home/artem/Launchpad/webby-browser/po/../src/AppWindow.vala:80
41msgid "Create App"
42msgstr ""
43
44#: /home/artem/Launchpad/webby-browser/po/../src/AppWindow.vala:80
45msgid "Create a new Webby web app."
46msgstr ""
47
48#: /home/artem/Launchpad/webby-browser/po/../src/Assistant.vala:45
23msgid "Create a new web app with webby"49msgid "Create a new web app with webby"
24msgstr ""50msgstr ""
2551
52#: /home/artem/Launchpad/webby-browser/po/../src/Assistant.vala:53
26msgid "Application name"53msgid "Application name"
27msgstr ""54msgstr ""
2855
56#: /home/artem/Launchpad/webby-browser/po/../src/Assistant.vala:56
29msgid "http://myapp.domain"57msgid "http://myapp.domain"
30msgstr ""58msgstr ""
3159
60#: /home/artem/Launchpad/webby-browser/po/../src/Assistant.vala:66
32msgid "theme icon name"61msgid "theme icon name"
33msgstr ""62msgstr ""
3463
64#: /home/artem/Launchpad/webby-browser/po/../src/Assistant.vala:68
35msgid "or"65msgid "or"
36msgstr ""66msgstr ""
3767
68#: /home/artem/Launchpad/webby-browser/po/../src/Assistant.vala:69
38msgid "Set from file..."69msgid "Set from file..."
39msgstr ""70msgstr ""
4071
72#: /home/artem/Launchpad/webby-browser/po/../src/Assistant.vala:85
41msgid "Save cookies"73msgid "Save cookies"
42msgstr ""74msgstr ""
4375
76#: /home/artem/Launchpad/webby-browser/po/../src/Assistant.vala:87
44msgid "Save login information"77msgid "Save login information"
45msgstr ""78msgstr ""
4679
47msgid "Create app"80#: /home/artem/Launchpad/webby-browser/po/../src/Assistant.vala:110
81msgid "Save app"
48msgstr ""82msgstr ""
4983
84#: /home/artem/Launchpad/webby-browser/po/../src/Assistant.vala:132
50msgid "url must start with http:// or https://"85msgid "url must start with http:// or https://"
51msgstr ""86msgstr ""
5287
88#: /home/artem/Launchpad/webby-browser/po/../src/Assistant.vala:145
53msgid "App already exist"89msgid "App already exist"
54msgstr ""90msgstr ""
5591
92#: /home/artem/Launchpad/webby-browser/po/../src/Assistant.vala:198
56msgid "Images"93msgid "Images"
57msgstr ""94msgstr ""
5895
96#: /home/artem/Launchpad/webby-browser/po/../src/Assistant.vala:210
59msgid "Cancel"97msgid "Cancel"
60msgstr ""98msgstr ""
6199
100#: /home/artem/Launchpad/webby-browser/po/../src/Assistant.vala:211
62msgid "Open"101msgid "Open"
63msgstr ""102msgstr ""
64
65msgid "App created"
66msgstr ""
67
68msgid "The application shortcut was successfully created"
69msgstr ""
70
71msgid "Applications"
72msgstr ""
73103
=== added directory 'schemas'
=== added file 'schemas/CMakeLists.txt'
--- schemas/CMakeLists.txt 1970-01-01 00:00:00 +0000
+++ schemas/CMakeLists.txt 2015-10-16 21:44:55 +0000
@@ -0,0 +1,5 @@
1#
2# GSettings Schema
3#
4include(GSettings)
5add_schema(org.pantheon.Webby.gschema.xml)
06
=== added file 'schemas/org.pantheon.Webby.gschema.xml'
--- schemas/org.pantheon.Webby.gschema.xml 1970-01-01 00:00:00 +0000
+++ schemas/org.pantheon.Webby.gschema.xml 2015-10-16 21:44:55 +0000
@@ -0,0 +1,24 @@
1<schemalist>
2 <enum id="org.pantheon.webby.SavedState.window-state">
3 <value nick="Normal" value="0" />
4 <value nick="Maximized" value="1" />
5 <value nick="Fullscreen" value="2" />
6 </enum>
7 <schema path="/org/pantheon/webby/saved-state/" id="org.pantheon.webby.SavedState" gettext-domain="webby">
8 <key name="window-width" type="i">
9 <default>800</default>
10 <summary>The saved width of the window.</summary>
11 <description>The saved width of the window.</description>
12 </key>
13 <key name="window-height" type="i">
14 <default>650</default>
15 <summary>The saved height of the window.</summary>
16 <description>The saved height of the window.</description>
17 </key>
18 <key name="window-state" enum="org.pantheon.webby.SavedState.window-state">
19 <default>"Normal"</default>
20 <summary>The saved state of the window.</summary>
21 <description>The saved state of the window.</description>
22 </key>
23 </schema>
24</schemalist>
025
=== modified file 'src/AppWindow.vala'
--- src/AppWindow.vala 2015-10-16 13:27:38 +0000
+++ src/AppWindow.vala 2015-10-16 21:44:55 +0000
@@ -1,5 +1,7 @@
1public class AppWindow : Granite.Application {1public class AppWindow : Granite.Application {
22
3 private Settings settings;
4
3 public Gtk.Window mainwindow;5 public Gtk.Window mainwindow;
46
5 private Gtk.Stack stack;7 private Gtk.Stack stack;
@@ -52,6 +54,8 @@
52 return;54 return;
53 }55 }
5456
57 settings = Settings.get_default ();
58
55 mainwindow = new Gtk.Window ();59 mainwindow = new Gtk.Window ();
5660
57 mainwindow.set_default_size (700, 500);61 mainwindow.set_default_size (700, 500);
@@ -129,8 +133,14 @@
129 show_assistant ();133 show_assistant ();
130 });134 });
131135
136 mainwindow.delete_event.connect (() => {
137 this.store_settings ();
138 return false;
139 });
140
132 mainwindow.destroy.connect (Gtk.main_quit);141 mainwindow.destroy.connect (Gtk.main_quit);
133142
143 this.restore_settings ();
134 mainwindow.show_all ();144 mainwindow.show_all ();
135145
136 if (apps_view.has_items)146 if (apps_view.has_items)
@@ -172,4 +182,19 @@
172 //fix ugly border at the bottom of headerbar182 //fix ugly border at the bottom of headerbar
173 mainwindow.queue_draw ();183 mainwindow.queue_draw ();
174 }184 }
185
186 private void restore_settings () {
187 this.mainwindow.set_default_size (settings.window_width, settings.window_height);
188
189 if (settings.window_state == Settings.WindowState.MAXIMIZED)
190 this.mainwindow.maximize ();
191 }
192
193 private void store_settings () {
194 settings.window_state = (this.mainwindow.is_maximized ? Settings.WindowState.MAXIMIZED: Settings.WindowState.NORMAL);
195 if (settings.window_state == Settings.WindowState.NORMAL) {
196 settings.window_height = this.mainwindow.get_allocated_height ();
197 settings.window_width = this.mainwindow.get_allocated_width ();
198 }
199 }
175}200}
176201
=== added file 'src/Settings.vala'
--- src/Settings.vala 1970-01-01 00:00:00 +0000
+++ src/Settings.vala 2015-10-16 21:44:55 +0000
@@ -0,0 +1,23 @@
1public class Settings : Granite.Services.Settings {
2
3 private static Settings settings;
4 public static Settings get_default () {
5 if (settings == null)
6 settings = new Settings ();
7
8 return settings;
9 }
10 public int window_width { get; set; }
11 public int window_height { get; set; }
12 public WindowState window_state { get; set; }
13
14 private Settings () {
15 base ("org.pantheon.webby.SavedState");
16 }
17
18 public enum WindowState {
19 NORMAL,
20 MAXIMIZED,
21 FULLSCREEN
22 }
23}

Subscribers

People subscribed via source and target branches

to all changes: