Merge lp:~trojan295/scratch/bugfix1329550 into lp:~elementary-apps/scratch/scratch

Proposed by Damian Czaja
Status: Merged
Merged at revision: 1470
Proposed branch: lp:~trojan295/scratch/bugfix1329550
Merge into: lp:~elementary-apps/scratch/scratch
Diff against target: 198 lines (+29/-39)
4 files modified
data/scratch-text-editor.desktop (+4/-0)
src/MainWindow.vala (+4/-3)
src/Scratch.vala (+20/-36)
src/config.vala.cmake (+1/-0)
To merge this branch: bzr merge lp:~trojan295/scratch/bugfix1329550
Reviewer Review Type Date Requested Status
elementary Apps team Pending
Review via email: mp+241317@code.launchpad.net

Description of the change

Moved the About dialog to quicklist.

There were some problems with Scratch. The argument '--about' was unknown, even through class ScratchApp inherited from Granite.Application. I found out, that in the main() function, there was some custom argument parsing and it caused, that '--about' was not recognized. I deleted there some code and now it works. The '--version' parameter is handled in the 'command_line' function.
To be honest, I'm not sure what for was that code in the main(). I cannot recognize any difference after removing it. Someone has to check that.

To post a comment you must log in.
Revision history for this message
Cody Garver (codygarver) wrote :

I am not qualified to review this code changes but I can tell you that you need to add "About Scratch" as a string so it's present in the translation domain.

Like this: http://bazaar.launchpad.net/~elementary-apps/snap-elementary/snap/view/head:/src/Snap.vala#L35

Revision history for this message
Damian Czaja (trojan295) wrote :

So I don't have to edit any .pot file, only add this const string? In Scratch it looks like the strings are defined in config.vala.cmake, so I have to add this there?

lp:~trojan295/scratch/bugfix1329550 updated
1408. By Damian Czaja

Added string constant for translation

Revision history for this message
Cameron Norman (cameronnemo) :

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'data/scratch-text-editor.desktop'
--- data/scratch-text-editor.desktop 2014-04-12 23:26:29 +0000
+++ data/scratch-text-editor.desktop 2014-11-12 11:20:30 +0000
@@ -10,6 +10,7 @@
10Keywords=Notepad;IDE;Plain10Keywords=Notepad;IDE;Plain
11MimeType=text/plain;11MimeType=text/plain;
12StartupNotify=true12StartupNotify=true
13Actions=AboutDialog;
1314
14X-Ayatana-Desktop-Shortcuts=NewWindow;NewDocument15X-Ayatana-Desktop-Shortcuts=NewWindow;NewDocument
1516
@@ -25,3 +26,6 @@
25Exec=scratch-text-editor --new-window26Exec=scratch-text-editor --new-window
26TargetEnvironment=Unity27TargetEnvironment=Unity
2728
29[Desktop Action AboutDialog]
30Exec=scratch-text-editor --about
31Name=About Scratch
2832
=== modified file 'src/MainWindow.vala'
--- src/MainWindow.vala 2014-11-02 11:16:30 +0000
+++ src/MainWindow.vala 2014-11-12 11:20:30 +0000
@@ -157,7 +157,7 @@
157 this.toolbar.show_close_button = true;157 this.toolbar.show_close_button = true;
158 this.set_titlebar (this.toolbar);158 this.set_titlebar (this.toolbar);
159 toolbar.menu = ui.get_widget ("ui/AppMenu") as Gtk.Menu;159 toolbar.menu = ui.get_widget ("ui/AppMenu") as Gtk.Menu;
160 var app_menu = (app as Granite.Application).create_appmenu (toolbar.menu);160 var app_menu = new Granite.Widgets.AppMenu (toolbar.menu);
161 toolbar.pack_end (app_menu);161 toolbar.pack_end (app_menu);
162162
163 // SearchManager163 // SearchManager
@@ -335,7 +335,7 @@
335 // Get current document335 // Get current document
336 public Scratch.Services.Document? get_current_document () {336 public Scratch.Services.Document? get_current_document () {
337 Scratch.Services.Document? doc = null;337 Scratch.Services.Document? doc = null;
338 338
339 var view = this.get_current_view ();339 var view = this.get_current_view ();
340 if (view != null)340 if (view != null)
341 doc = view.get_current_document ();341 doc = view.get_current_document ();
@@ -897,4 +897,5 @@
897 action_fullscreen }897 action_fullscreen }
898 };898 };
899 }899 }
900}
901\ No newline at end of file900\ No newline at end of file
901}
902
902903
=== modified file 'src/Scratch.vala'
--- src/Scratch.vala 2014-10-27 22:56:33 +0000
+++ src/Scratch.vala 2014-11-12 11:20:30 +0000
@@ -23,12 +23,12 @@
23using Granite.Services;23using Granite.Services;
2424
25namespace Scratch {25namespace Scratch {
26 26
27 // Settings27 // Settings
28 public SavedState saved_state;28 public SavedState saved_state;
29 public Settings settings;29 public Settings settings;
30 public ServicesSettings services;30 public ServicesSettings services;
31 31
32 public class ScratchApp : Granite.Application {32 public class ScratchApp : Granite.Application {
3333
34 private GLib.List <MainWindow> windows;34 private GLib.List <MainWindow> windows;
@@ -42,7 +42,7 @@
42 private static bool print_version = false;42 private static bool print_version = false;
43 private static bool create_new_tab = false;43 private static bool create_new_tab = false;
44 private static bool create_new_window = false;44 private static bool create_new_window = false;
45 45
46 construct {46 construct {
47 flags |= ApplicationFlags.HANDLES_OPEN;47 flags |= ApplicationFlags.HANDLES_OPEN;
48 flags |= ApplicationFlags.HANDLES_COMMAND_LINE;48 flags |= ApplicationFlags.HANDLES_COMMAND_LINE;
@@ -93,7 +93,7 @@
93 settings = new Settings ();93 settings = new Settings ();
94 services = new ServicesSettings ();94 services = new ServicesSettings ();
95 windows = new GLib.List <MainWindow> ();95 windows = new GLib.List <MainWindow> ();
96 96
97 // Init data home folder for unsaved text files97 // Init data home folder for unsaved text files
98 _data_home_folder_unsaved = Environment.get_user_data_dir () + "/" + exec_name + "/unsaved/";98 _data_home_folder_unsaved = Environment.get_user_data_dir () + "/" + exec_name + "/unsaved/";
99 }99 }
@@ -126,6 +126,12 @@
126 return Posix.EXIT_FAILURE;126 return Posix.EXIT_FAILURE;
127 }127 }
128128
129 if (print_version) {
130 stdout.printf ("Scratch Text Editor %s\n", Constants.VERSION);
131 stdout.printf ("Copyright 2011-2014 Scratch Text Editor Developers.\n");
132 return Posix.EXIT_SUCCESS;
133 }
134
129 // Create (or show) the first window135 // Create (or show) the first window
130 activate ();136 activate ();
131137
@@ -143,7 +149,7 @@
143 }149 }
144150
145 // Set Current Directory151 // Set Current Directory
146 Environment.set_current_dir (_cwd); 152 Environment.set_current_dir (_cwd);
147153
148 // Open all files given as arguments154 // Open all files given as arguments
149 if (unclaimed_args > 0) {155 if (unclaimed_args > 0) {
@@ -168,9 +174,9 @@
168 // Restore opened documents174 // Restore opened documents
169 if (settings.show_at_start == "last-tabs") {175 if (settings.show_at_start == "last-tabs") {
170 window.start_loading ();176 window.start_loading ();
171 177
172 string[] uris = settings.schema.get_strv ("opened-files");178 string[] uris = settings.schema.get_strv ("opened-files");
173 179
174 foreach (string uri in uris) {180 foreach (string uri in uris) {
175 if (uri != "") {181 if (uri != "") {
176 var file = File.new_for_uri (uri);182 var file = File.new_for_uri (uri);
@@ -187,7 +193,7 @@
187 }193 }
188194
189 }195 }
190 196
191 protected override void open (File[] files, string hint) {197 protected override void open (File[] files, string hint) {
192 // Add a view if there aren't and get the current DocumentView198 // Add a view if there aren't and get the current DocumentView
193 Scratch.Widgets.DocumentView? view = null;199 Scratch.Widgets.DocumentView? view = null;
@@ -197,7 +203,7 @@
197 view = window.add_view ();203 view = window.add_view ();
198 else204 else
199 view = window.get_current_view ();205 view = window.get_current_view ();
200 206
201 for (int i = 0; i < files.length; i++) {207 for (int i = 0; i < files.length; i++) {
202 // Check if the given path is a directory208 // Check if the given path is a directory
203 try {209 try {
@@ -233,44 +239,22 @@
233 windows.remove (window as MainWindow);239 windows.remove (window as MainWindow);
234 base.window_removed (window);240 base.window_removed (window);
235 }241 }
236 242
237 static const OptionEntry[] entries = {243 static const OptionEntry[] entries = {
238 { "new-tab", 't', 0, OptionArg.NONE, out create_new_tab, N_("New Tab"), null },244 { "new-tab", 't', 0, OptionArg.NONE, out create_new_tab, N_("New Tab"), null },
239 { "new-window", 'n', 0, OptionArg.NONE, out create_new_window, N_("New Window"), null },245 { "new-window", 'n', 0, OptionArg.NONE, out create_new_window, N_("New Window"), null },
240 { "version", 'v', 0, OptionArg.NONE, out print_version, N_("Print version info and exit"), null },246 { "version", 'v', 0, OptionArg.NONE, out print_version, N_("Print version info and exit"), null },
241 { "set", 's', 0, OptionArg.STRING, ref _app_cmd_name, N_("Set of plugins"), "" },247 { "set", 's', 0, OptionArg.STRING, ref _app_cmd_name, N_("Set of plugins"), "" },
242 { "cwd", 'c', 0, OptionArg.STRING, ref _cwd, N_("Current working directory"), "" }, 248 { "cwd", 'c', 0, OptionArg.STRING, ref _cwd, N_("Current working directory"), "" },
243 { null }249 { null }
244 };250 };
245251
246 public static int main (string[] args) {252 public static int main (string[] args) {
247 _app_cmd_name = "Scratch";253 _app_cmd_name = "Scratch";
248254
249 var context = new OptionContext ("File");
250 context.add_main_entries (entries, Constants.GETTEXT_PACKAGE);
251 context.add_group (Gtk.get_option_group (true));
252
253 string[] args_primary_instance = args;
254 args_primary_instance += "-c";
255 args_primary_instance += Environment.get_current_dir ();
256
257 try {
258 context.parse (ref args);
259 } catch(Error e) {
260 print (e.message + "\n");
261
262 return Posix.EXIT_FAILURE;
263 }
264
265 if (print_version) {
266 stdout.printf ("Scratch Text Editor %s\n", Constants.VERSION);
267 stdout.printf ("Copyright 2011-2014 Scratch Text Editor Developers.\n");
268
269 return Posix.EXIT_SUCCESS;
270 }
271
272 ScratchApp app = ScratchApp.instance;255 ScratchApp app = ScratchApp.instance;
273 return app.run (args_primary_instance);256 return app.run (args);
274 }257 }
275 }258 }
276}
277\ No newline at end of file259\ No newline at end of file
260}
261
278262
=== modified file 'src/config.vala.cmake'
--- src/config.vala.cmake 2013-05-09 08:49:17 +0000
+++ src/config.vala.cmake 2014-11-12 11:20:30 +0000
@@ -16,4 +16,5 @@
16 public const string GENERIC = N_("Text Editor");16 public const string GENERIC = N_("Text Editor");
17 public const string NEW_DOCUMENT = N_("New Document");17 public const string NEW_DOCUMENT = N_("New Document");
18 public const string NEW_WINDOW = N_("New Window");18 public const string NEW_WINDOW = N_("New Window");
19 public const string ABOUT_SCRATCH = N_("About Scratch");
19}20}

Subscribers

People subscribed via source and target branches