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

Proposed by Cris Dywan
Status: Merged
Approved by: Cris Dywan
Approved revision: 6182
Merged at revision: 6322
Proposed branch: lp:~kalikiana/midori/dialoglauncher
Merge into: lp:midori
Diff against target: 174 lines (+53/-33)
3 files modified
extensions/apps.vala (+17/-9)
midori/midori-browser.c (+32/-21)
midori/midori-extension.c (+4/-3)
To merge this branch: bzr merge lp:~kalikiana/midori/dialoglauncher
Reviewer Review Type Date Requested Status
André Stösel Approve
Review via email: mp+166327@code.launchpad.net

Commit message

Replace 'Run as app' in bookmark dialog with 'Create launcher'

Description of the change

Replace 'Run as app' in bookmark dialog with 'Create launcher'

To post a comment you must log in.
Revision history for this message
Cris Dywan (kalikiana) wrote :

Let's introduce a trigger mechanism instead of hard-coding it. We whitelist extensions that are allowed to be automatically through a button or menu item. In this case the bookmark dialog requests a trigger (the same mechanism will be usable for the toolbar context menu). The extension registers the trigger in extension_init.

Revision history for this message
Cris Dywan (kalikiana) wrote :

I gave this more thought. I'm now concerned that a trigger has to both activate an extension and call the action. And the browser needs to get a hold of the label which is tricky since it cannot get a MidoriApp easily.

I'd prefer to consider apps as a stock extension for now. For consistency I'm really eager to solve the UI bit but as it seems the triggers won't be ready for a while.

Revision history for this message
André Stösel (ivaldi) wrote :

Looks good!

review: Approve
Revision history for this message
RabbitBot (rabbitbot-a) wrote :

Attempt to merge into lp:midori failed due to conflicts:

text conflict in extensions/apps.vala

lp:~kalikiana/midori/dialoglauncher updated
6182. By Cris Dywan

Merge lp:midori

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'extensions/apps.vala'
2--- extensions/apps.vala 2013-07-16 14:20:37 +0000
3+++ extensions/apps.vala 2013-08-06 20:23:26 +0000
4@@ -380,24 +380,26 @@
5 }
6 }
7
8- void tool_menu_populated (Midori.Browser browser, Gtk.Menu menu) {
9- var menuitem = new Gtk.MenuItem.with_mnemonic (_("Create _Launcher"));
10- menuitem.show ();
11- menu.append (menuitem);
12- menuitem.activate.connect (() => {
13+ void browser_added (Midori.Browser browser) {
14+ var accels = new Gtk.AccelGroup ();
15+ browser.add_accel_group (accels);
16+ var action_group = browser.get_action_group ();
17+
18+ var action = new Gtk.Action ("CreateLauncher", _("Create _Launcher"),
19+ _("Creates a new app for a specific site"), null);
20+ action.activate.connect (() => {
21 var view = browser.tab as Midori.View;
22 string checksum = Checksum.compute_for_string (ChecksumType.MD5, view.get_display_uri (), -1);
23 Launcher.create.begin (APP_PREFIX, app_folder.get_child (checksum),
24 view.get_display_uri (), view.get_display_title (), browser);
25 });
26- }
27+ action_group.add_action_with_accel (action, "<Ctrl><Shift>A");
28+ action.set_accel_group (accels);
29+ action.connect_accelerator ();
30
31- void browser_added (Midori.Browser browser) {
32 var viewable = new Sidebar (array, app_folder, profile_folder);
33 viewable.show ();
34 browser.panel.append_page (viewable);
35- browser.populate_tool_menu.connect (tool_menu_populated);
36- // TODO website context menu
37 widgets.append (viewable);
38 }
39
40@@ -424,6 +426,12 @@
41 app.add_browser.disconnect (browser_added);
42 foreach (var widget in widgets)
43 widget.destroy ();
44+ foreach (var browser in app.get_browsers ()) {
45+ var action_group = browser.get_action_group ();
46+ var action = action_group.get_action ("CreateLauncher");
47+ action_group.remove_action (action);
48+ }
49+
50 }
51
52 internal Manager () {
53
54=== modified file 'midori/midori-browser.c'
55--- midori/midori-browser.c 2013-08-02 12:00:42 +0000
56+++ midori/midori-browser.c 2013-08-06 20:23:26 +0000
57@@ -1070,8 +1070,19 @@
58 KatzeItem* bookmark)
59 {
60 MidoriBrowser* browser = midori_browser_get_for_widget (button);
61- gtk_widget_set_sensitive (button, FALSE);
62 midori_browser_add_speed_dial (browser);
63+ GtkWidget* dialog = gtk_widget_get_toplevel (button);
64+ gtk_dialog_response (GTK_DIALOG (dialog), GTK_RESPONSE_DELETE_EVENT);
65+}
66+
67+static void
68+midori_browser_edit_bookmark_create_launcher_cb (GtkWidget* button,
69+ KatzeItem* bookmark)
70+{
71+ GtkAction* action = g_object_get_data (G_OBJECT (button), "midori-action");
72+ gtk_action_activate (action);
73+ GtkWidget* dialog = gtk_widget_get_toplevel (button);
74+ gtk_dialog_response (GTK_DIALOG (dialog), GTK_RESPONSE_DELETE_EVENT);
75 }
76
77 /* Private function, used by MidoriBookmarks and MidoriHistory */
78@@ -1095,7 +1106,6 @@
79 GtkWidget* entry_uri;
80 GtkWidget* combo_folder;
81 GtkWidget* check_toolbar;
82- GtkWidget* check_app;
83 gboolean return_status = FALSE;
84 sqlite3* db = g_object_get_data (G_OBJECT (browser->bookmarks), "db");
85 if (!db)
86@@ -1180,15 +1190,6 @@
87 katze_item_get_meta_integer (bookmark, "parentid"));
88 gtk_box_pack_start (GTK_BOX (vbox), combo_folder, FALSE, FALSE, 0);
89
90- if (new_bookmark && !is_folder)
91- {
92- label = gtk_button_new_with_mnemonic (_("Add to _Speed Dial"));
93- g_signal_connect (label, "clicked",
94- G_CALLBACK (midori_browser_edit_bookmark_add_speed_dial_cb), bookmark);
95- return_status = TRUE;
96- gtk_dialog_add_action_widget (GTK_DIALOG (dialog), label, GTK_RESPONSE_HELP);
97- }
98-
99 hbox = gtk_hbox_new (FALSE, 6);
100 gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
101 check_toolbar = gtk_check_button_new_with_mnemonic (_("Show in Bookmarks _Bar"));
102@@ -1196,14 +1197,28 @@
103 katze_item_get_meta_boolean (bookmark, "toolbar"));
104 gtk_box_pack_start (GTK_BOX (hbox), check_toolbar, FALSE, FALSE, 0);
105
106- check_app = NULL;
107- if (!is_folder)
108+ if (new_bookmark && !is_folder)
109 {
110- check_app = gtk_check_button_new_with_mnemonic (_("Run as _web application"));
111- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check_app),
112- katze_item_get_meta_boolean (bookmark, "app"));
113- gtk_box_pack_start (GTK_BOX (hbox), check_app, FALSE, FALSE, 0);
114+ hbox = gtk_hbox_new (FALSE, 6);
115+ gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
116+
117+ label = gtk_button_new_with_mnemonic (_("Add to _Speed Dial"));
118+ g_signal_connect (label, "clicked",
119+ G_CALLBACK (midori_browser_edit_bookmark_add_speed_dial_cb), bookmark);
120+ gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
121+
122+ /* FIXME: There's no API for extending the bookmark dialog */
123+ GtkAction* action = _action_by_name (browser, "CreateLauncher");
124+ if (action != NULL)
125+ {
126+ label = gtk_button_new_with_mnemonic (gtk_action_get_label (action));
127+ g_object_set_data (G_OBJECT (label), "midori-action", action);
128+ g_signal_connect (label, "clicked",
129+ G_CALLBACK (midori_browser_edit_bookmark_create_launcher_cb), bookmark);
130+ gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
131+ }
132 }
133+
134 gtk_widget_show_all (content_area);
135
136 gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_ACCEPT);
137@@ -1216,12 +1231,8 @@
138 katze_item_set_meta_integer (bookmark, "toolbar",
139 gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (check_toolbar)));
140 if (!is_folder)
141- {
142 katze_item_set_uri (bookmark,
143 gtk_entry_get_text (GTK_ENTRY (entry_uri)));
144- katze_item_set_meta_integer (bookmark, "app",
145- gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (check_app)));
146- }
147
148 selected = midori_bookmark_folder_button_get_active (combo_folder);
149 katze_item_set_meta_integer (bookmark, "parentid", selected);
150
151=== modified file 'midori/midori-extension.c'
152--- midori/midori-extension.c 2013-05-19 09:33:02 +0000
153+++ midori/midori-extension.c 2013-08-06 20:23:26 +0000
154@@ -559,8 +559,8 @@
155 while (keys && (filename = keys[i++]))
156 midori_extension_activate_gracefully (app, extension_path, filename, activate);
157 /* FIXME need proper stock extension mechanism */
158- GObject* extension = midori_extension_activate_gracefully (app, extension_path, "libtransfers." G_MODULE_SUFFIX, activate);
159- g_assert (extension != NULL);
160+ g_assert (midori_extension_activate_gracefully (app, extension_path, "libtransfers." G_MODULE_SUFFIX, activate));
161+ g_assert (midori_extension_activate_gracefully (app, extension_path, "libapps." G_MODULE_SUFFIX, activate));
162 }
163 else
164 {
165@@ -672,7 +672,8 @@
166 if (katze_array_get_item_index (extensions, extension) >= 0)
167 return;
168 /* FIXME need proper stock extension mechanism */
169- if (!strcmp (filename, "libtransfers." G_MODULE_SUFFIX))
170+ if (!strcmp (filename, "libtransfers." G_MODULE_SUFFIX)
171+ || !strcmp (filename, "libapps." G_MODULE_SUFFIX))
172 return;
173
174 katze_array_add_item (extensions, extension);

Subscribers

People subscribed via source and target branches

to all changes: