Merge lp:~kalikiana/midori/apps into lp:midori

Proposed by Cris Dywan
Status: Merged
Approved by: André Stösel
Approved revision: 6196
Merged at revision: 6195
Proposed branch: lp:~kalikiana/midori/apps
Merge into: lp:midori
Diff against target: 116 lines (+59/-7)
2 files modified
extensions/apps.vala (+57/-5)
midori/midori-download.vala (+2/-2)
To merge this branch: bzr merge lp:~kalikiana/midori/apps
Reviewer Review Type Date Requested Status
André Stösel Approve
Review via email: mp+167179@code.launchpad.net

Commit message

Clean launcher filenames, double-click to open and delete button

Description of the change

Clean launcher filenames, double-click to open and delete button

To post a comment you must log in.
Revision history for this message
André Stösel (ivaldi) wrote :

A function to change the label of a profile would be nice too.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'extensions/apps.vala'
--- extensions/apps.vala 2013-05-31 11:58:17 +0000
+++ extensions/apps.vala 2013-06-03 23:33:29 +0000
@@ -22,9 +22,9 @@
2222
23 internal static async void create (string prefix, GLib.File folder, string uri, string title, Gtk.Widget proxy) {23 internal static async void create (string prefix, GLib.File folder, string uri, string title, Gtk.Widget proxy) {
24 /* Strip LRE leading character and / */24 /* Strip LRE leading character and / */
25 string filename = title.delimit ("‪/", ' ').strip() + ".desktop";
26 string exec = prefix + uri;25 string exec = prefix + uri;
27 string name = title;26 string name = title.delimit ("‪/", ' ').strip();
27 string filename = Midori.Download.clean_filename (name) + ".desktop";
28 // TODO: Midori.Paths.get_icon save to png28 // TODO: Midori.Paths.get_icon save to png
29 string icon_name = Midori.Stock.WEB_BROWSER;29 string icon_name = Midori.Stock.WEB_BROWSER;
30 string contents = """30 string contents = """
@@ -45,9 +45,6 @@
45 var browser = proxy.get_toplevel () as Midori.Browser;45 var browser = proxy.get_toplevel () as Midori.Browser;
46 browser.send_notification (_("Launcher created"),46 browser.send_notification (_("Launcher created"),
47 _("You can now run <b>%s</b> from your launcher or menu").printf (name));47 _("You can now run <b>%s</b> from your launcher or menu").printf (name));
48 /* TODO: Use infobar; currently hits gtk_widget_get_realized: assertion `GTK_IS_WIDGET (widget)' failed
49 (browser.tab as Midori.View).add_info_bar (Gtk.MessageType.INFO,
50 _("You can now run <b>%s</b> from your launcher or menu").printf (name), null, null, null); */
51 }48 }
52 catch (Error error) {49 catch (Error error) {
53 var browser = proxy.get_toplevel () as Midori.Browser;50 var browser = proxy.get_toplevel () as Midori.Browser;
@@ -128,6 +125,46 @@
128 return toolbar;125 return toolbar;
129 }126 }
130127
128 void row_activated (Gtk.TreePath path, Gtk.TreeViewColumn column) {
129 Gtk.TreeIter iter;
130 if (store.get_iter (out iter, path)) {
131 Launcher launcher;
132 store.get (iter, 0, out launcher);
133 try {
134 GLib.Process.spawn_command_line_async (launcher.exec);
135 }
136 catch (Error error) {
137 var browser = get_toplevel () as Midori.Browser;
138 browser.send_notification (_("Error launching"), error.message);
139 }
140 }
141 }
142
143 bool button_released (Gdk.EventButton event) {
144 Gtk.TreePath? path;
145 Gtk.TreeViewColumn column;
146 if (treeview.get_path_at_pos ((int)event.x, (int)event.y, out path, out column, null, null)) {
147 if (path != null) {
148 if (column == treeview.get_column (2)) {
149 Gtk.TreeIter iter;
150 if (store.get_iter (out iter, path)) {
151 Launcher launcher;
152 store.get (iter, 0, out launcher);
153 try {
154 launcher.file.trash (null);
155 store.remove (iter);
156 }
157 catch (Error error) {
158 GLib.critical (error.message);
159 }
160 return true;
161 }
162 }
163 }
164 }
165 return false;
166 }
167
131 public Sidebar (Katze.Array array, GLib.File app_folder) {168 public Sidebar (Katze.Array array, GLib.File app_folder) {
132 Gtk.TreeViewColumn column;169 Gtk.TreeViewColumn column;
133170
@@ -151,6 +188,14 @@
151 column.set_cell_data_func (renderer_text, on_render_text);188 column.set_cell_data_func (renderer_text, on_render_text);
152 treeview.append_column (column);189 treeview.append_column (column);
153190
191 column = new Gtk.TreeViewColumn ();
192 Gtk.CellRendererPixbuf renderer_button = new Gtk.CellRendererPixbuf ();
193 column.pack_start (renderer_button, false);
194 column.set_cell_data_func (renderer_button, on_render_button);
195 treeview.append_column (column);
196
197 treeview.row_activated.connect (row_activated);
198 treeview.button_release_event.connect (button_released);
154 treeview.show ();199 treeview.show ();
155 pack_start (treeview, true, true, 0);200 pack_start (treeview, true, true, 0);
156201
@@ -203,6 +248,13 @@
203 launcher.name, launcher.uri),248 launcher.name, launcher.uri),
204 "ellipsize", Pango.EllipsizeMode.END);249 "ellipsize", Pango.EllipsizeMode.END);
205 }250 }
251
252 void on_render_button (Gtk.CellLayout column, Gtk.CellRenderer renderer,
253 Gtk.TreeModel model, Gtk.TreeIter iter) {
254
255 renderer.set ("stock-id", Gtk.STOCK_DELETE,
256 "stock-size", Gtk.IconSize.MENU);
257 }
206 }258 }
207259
208 private class Manager : Midori.Extension {260 private class Manager : Midori.Extension {
209261
=== modified file 'midori/midori-download.vala'
--- midori/midori-download.vala 2013-05-19 09:43:05 +0000
+++ midori/midori-download.vala 2013-06-03 23:33:29 +0000
@@ -244,9 +244,9 @@
244244
245 public string clean_filename (string filename) {245 public string clean_filename (string filename) {
246 #if HAVE_WIN32246 #if HAVE_WIN32
247 return filename.delimit ("/\\<>:\"|?*", '_');247 return filename.delimit ("/\\<>:\"|?* ", '_');
248 #else248 #else
249 return filename.delimit ("/", '_');249 return filename.delimit ("/ ", '_');
250 #endif250 #endif
251 }251 }
252252

Subscribers

People subscribed via source and target branches

to all changes: