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
1=== modified file 'data/scratch-text-editor.desktop'
2--- data/scratch-text-editor.desktop 2014-04-12 23:26:29 +0000
3+++ data/scratch-text-editor.desktop 2014-11-12 11:20:30 +0000
4@@ -10,6 +10,7 @@
5 Keywords=Notepad;IDE;Plain
6 MimeType=text/plain;
7 StartupNotify=true
8+Actions=AboutDialog;
9
10 X-Ayatana-Desktop-Shortcuts=NewWindow;NewDocument
11
12@@ -25,3 +26,6 @@
13 Exec=scratch-text-editor --new-window
14 TargetEnvironment=Unity
15
16+[Desktop Action AboutDialog]
17+Exec=scratch-text-editor --about
18+Name=About Scratch
19
20=== modified file 'src/MainWindow.vala'
21--- src/MainWindow.vala 2014-11-02 11:16:30 +0000
22+++ src/MainWindow.vala 2014-11-12 11:20:30 +0000
23@@ -157,7 +157,7 @@
24 this.toolbar.show_close_button = true;
25 this.set_titlebar (this.toolbar);
26 toolbar.menu = ui.get_widget ("ui/AppMenu") as Gtk.Menu;
27- var app_menu = (app as Granite.Application).create_appmenu (toolbar.menu);
28+ var app_menu = new Granite.Widgets.AppMenu (toolbar.menu);
29 toolbar.pack_end (app_menu);
30
31 // SearchManager
32@@ -335,7 +335,7 @@
33 // Get current document
34 public Scratch.Services.Document? get_current_document () {
35 Scratch.Services.Document? doc = null;
36-
37+
38 var view = this.get_current_view ();
39 if (view != null)
40 doc = view.get_current_document ();
41@@ -897,4 +897,5 @@
42 action_fullscreen }
43 };
44 }
45-}
46\ No newline at end of file
47+}
48+
49
50=== modified file 'src/Scratch.vala'
51--- src/Scratch.vala 2014-10-27 22:56:33 +0000
52+++ src/Scratch.vala 2014-11-12 11:20:30 +0000
53@@ -23,12 +23,12 @@
54 using Granite.Services;
55
56 namespace Scratch {
57-
58+
59 // Settings
60 public SavedState saved_state;
61 public Settings settings;
62 public ServicesSettings services;
63-
64+
65 public class ScratchApp : Granite.Application {
66
67 private GLib.List <MainWindow> windows;
68@@ -42,7 +42,7 @@
69 private static bool print_version = false;
70 private static bool create_new_tab = false;
71 private static bool create_new_window = false;
72-
73+
74 construct {
75 flags |= ApplicationFlags.HANDLES_OPEN;
76 flags |= ApplicationFlags.HANDLES_COMMAND_LINE;
77@@ -93,7 +93,7 @@
78 settings = new Settings ();
79 services = new ServicesSettings ();
80 windows = new GLib.List <MainWindow> ();
81-
82+
83 // Init data home folder for unsaved text files
84 _data_home_folder_unsaved = Environment.get_user_data_dir () + "/" + exec_name + "/unsaved/";
85 }
86@@ -126,6 +126,12 @@
87 return Posix.EXIT_FAILURE;
88 }
89
90+ if (print_version) {
91+ stdout.printf ("Scratch Text Editor %s\n", Constants.VERSION);
92+ stdout.printf ("Copyright 2011-2014 Scratch Text Editor Developers.\n");
93+ return Posix.EXIT_SUCCESS;
94+ }
95+
96 // Create (or show) the first window
97 activate ();
98
99@@ -143,7 +149,7 @@
100 }
101
102 // Set Current Directory
103- Environment.set_current_dir (_cwd);
104+ Environment.set_current_dir (_cwd);
105
106 // Open all files given as arguments
107 if (unclaimed_args > 0) {
108@@ -168,9 +174,9 @@
109 // Restore opened documents
110 if (settings.show_at_start == "last-tabs") {
111 window.start_loading ();
112-
113+
114 string[] uris = settings.schema.get_strv ("opened-files");
115-
116+
117 foreach (string uri in uris) {
118 if (uri != "") {
119 var file = File.new_for_uri (uri);
120@@ -187,7 +193,7 @@
121 }
122
123 }
124-
125+
126 protected override void open (File[] files, string hint) {
127 // Add a view if there aren't and get the current DocumentView
128 Scratch.Widgets.DocumentView? view = null;
129@@ -197,7 +203,7 @@
130 view = window.add_view ();
131 else
132 view = window.get_current_view ();
133-
134+
135 for (int i = 0; i < files.length; i++) {
136 // Check if the given path is a directory
137 try {
138@@ -233,44 +239,22 @@
139 windows.remove (window as MainWindow);
140 base.window_removed (window);
141 }
142-
143+
144 static const OptionEntry[] entries = {
145 { "new-tab", 't', 0, OptionArg.NONE, out create_new_tab, N_("New Tab"), null },
146 { "new-window", 'n', 0, OptionArg.NONE, out create_new_window, N_("New Window"), null },
147 { "version", 'v', 0, OptionArg.NONE, out print_version, N_("Print version info and exit"), null },
148 { "set", 's', 0, OptionArg.STRING, ref _app_cmd_name, N_("Set of plugins"), "" },
149- { "cwd", 'c', 0, OptionArg.STRING, ref _cwd, N_("Current working directory"), "" },
150+ { "cwd", 'c', 0, OptionArg.STRING, ref _cwd, N_("Current working directory"), "" },
151 { null }
152 };
153
154 public static int main (string[] args) {
155 _app_cmd_name = "Scratch";
156
157- var context = new OptionContext ("File");
158- context.add_main_entries (entries, Constants.GETTEXT_PACKAGE);
159- context.add_group (Gtk.get_option_group (true));
160-
161- string[] args_primary_instance = args;
162- args_primary_instance += "-c";
163- args_primary_instance += Environment.get_current_dir ();
164-
165- try {
166- context.parse (ref args);
167- } catch(Error e) {
168- print (e.message + "\n");
169-
170- return Posix.EXIT_FAILURE;
171- }
172-
173- if (print_version) {
174- stdout.printf ("Scratch Text Editor %s\n", Constants.VERSION);
175- stdout.printf ("Copyright 2011-2014 Scratch Text Editor Developers.\n");
176-
177- return Posix.EXIT_SUCCESS;
178- }
179-
180 ScratchApp app = ScratchApp.instance;
181- return app.run (args_primary_instance);
182+ return app.run (args);
183 }
184 }
185-}
186\ No newline at end of file
187+}
188+
189
190=== modified file 'src/config.vala.cmake'
191--- src/config.vala.cmake 2013-05-09 08:49:17 +0000
192+++ src/config.vala.cmake 2014-11-12 11:20:30 +0000
193@@ -16,4 +16,5 @@
194 public const string GENERIC = N_("Text Editor");
195 public const string NEW_DOCUMENT = N_("New Document");
196 public const string NEW_WINDOW = N_("New Window");
197+ public const string ABOUT_SCRATCH = N_("About Scratch");
198 }

Subscribers

People subscribed via source and target branches