Merge lp:~midori/midori/domainKeys into lp:midori

Proposed by axlrose112
Status: Merged
Approved by: Cris Dywan
Approved revision: 6566
Merged at revision: 6580
Proposed branch: lp:~midori/midori/domainKeys
Merge into: lp:midori
Diff against target: 177 lines (+112/-0)
5 files modified
extensions/domain-keys.vala (+76/-0)
midori/marshal.list (+1/-0)
midori/midori-locationaction.c (+25/-0)
midori/midori.vapi (+9/-0)
po/POTFILES.in (+1/-0)
To merge this branch: bzr merge lp:~midori/midori/domainKeys
Reviewer Review Type Date Requested Status
Cris Dywan Approve
Paweł Forysiuk Needs Fixing
Review via email: mp+208931@code.launchpad.net

Commit message

Implement ctrl+enter extension

To post a comment you must log in.
Revision history for this message
Paweł Forysiuk (tuxator) wrote :

Imho ctrl+enter should only do www. + word + .com

If you wanna support different suffix i would suggest using different key combo maybe
alt + enter.

I would just read that custom suffix from user config, defaulting to .org, with a little note to user that he may change it to domain suffix of his country.
For both default setting and gui you can look at external download extension.

Renaming variables was nice, would just revert the domain thingy from it cause it would change the default behaviour from what i gather.

review: Needs Fixing
Revision history for this message
axlrose112 (axlrose112) wrote :

ahh ok, i will improve it then, thank you

lp:~midori/midori/domainKeys updated
6566. By axlrose112

Add www. and .com/.country_domain and proceed with Ctrl+Enter/Ctrl+Shift

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

Nice!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== added file 'extensions/domain-keys.vala'
--- extensions/domain-keys.vala 1970-01-01 00:00:00 +0000
+++ extensions/domain-keys.vala 2014-03-02 18:28:29 +0000
@@ -0,0 +1,76 @@
1/*
2 Copyright (C) 2014 James Axl <bilimish@yandex.ru>
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 See the file COPYING for the full license text.
10*/
11
12namespace DomainHotkeys {
13 class Manager : Midori.Extension {
14 internal Manager () {
15 GLib.Object (name: _("Domain Hotkeys"),
16 description: _("Add www. and .com/.country_domain and proceed with Ctrl+Enter/Ctrl+Shift"),
17 version: "0.1" + Midori.VERSION_SUFFIX,
18 authors: "James Axl <bilimish@yandex.ru>");
19 activate.connect (this.activated);
20 deactivate.connect (this.deactivated);
21 }
22
23 bool key_press_event (Midori.LocationAction action, Gdk.EventKey event_key) {
24 if (event_key.keyval == Gdk.Key.Return) {
25 if ((bool)(event_key.state & Gdk.ModifierType.CONTROL_MASK)) {
26 submit_uri(action);
27 return true;
28 } else if((bool)(event_key.state & Gdk.ModifierType.SHIFT_MASK)) {
29 submit_uri(action, true);
30 return true;
31 }
32 }
33 return false;
34 }
35
36 void submit_uri(Midori.LocationAction action, bool locale = false) {
37 var url = action.get_text ();
38 if (locale){
39 var domain = C_("Domain", ".com");
40 url = "www." + url + domain;
41 } else {
42 url = "www." + url + ".com";
43 }
44 action.submit_uri(url, false);
45 }
46
47 void browser_added (Midori.Browser browser) {
48 var action_group = browser.get_action_group ();
49 var action = action_group.get_action ("Location") as Midori.LocationAction;
50 action.key_press_event.connect (key_press_event);
51 }
52
53 void activated (Midori.App app) {
54 foreach (var browser in app.get_browsers ())
55 browser_added (browser);
56 app.add_browser.connect (browser_added);
57 }
58
59 void browser_removed (Midori.Browser browser) {
60 var action_group = browser.get_action_group ();
61 var action = action_group.get_action ("Location") as Midori.LocationAction;
62 action.key_press_event.disconnect (key_press_event);
63 }
64
65 void deactivated () {
66 var app = get_app ();
67 app.add_browser.disconnect (browser_added);
68 foreach (var browser in app.get_browsers ())
69 browser_removed (browser);
70 }
71 }
72}
73
74public Midori.Extension extension_init () {
75 return new DomainHotkeys.Manager ();
76}
077
=== modified file 'midori/marshal.list'
--- midori/marshal.list 2013-12-26 17:29:08 +0000
+++ midori/marshal.list 2014-03-02 18:28:29 +0000
@@ -1,3 +1,4 @@
1BOOLEAN:POINTER
1BOOLEAN:OBJECT2BOOLEAN:OBJECT
2BOOLEAN:OBJECT,OBJECT3BOOLEAN:OBJECT,OBJECT
3BOOLEAN:OBJECT,OBJECT,POINTER4BOOLEAN:OBJECT,OBJECT,POINTER
45
=== modified file 'midori/midori-locationaction.c'
--- midori/midori-locationaction.c 2014-02-11 23:01:05 +0000
+++ midori/midori-locationaction.c 2014-03-02 18:28:29 +0000
@@ -69,6 +69,7 @@
69 SECONDARY_ICON_RELEASED,69 SECONDARY_ICON_RELEASED,
70 RESET_URI,70 RESET_URI,
71 SUBMIT_URI,71 SUBMIT_URI,
72 KEY_PRESS_EVENT,
72 LAST_SIGNAL73 LAST_SIGNAL
73};74};
7475
@@ -176,6 +177,23 @@
176 G_TYPE_STRING,177 G_TYPE_STRING,
177 G_TYPE_BOOLEAN);178 G_TYPE_BOOLEAN);
178179
180 /**
181 * MidoriLocationAction:key-press-event:
182 *
183 * A key (combination) was pressed in an entry of the action.
184 *
185 * Since 0.5.8
186 */
187 signals[KEY_PRESS_EVENT] = g_signal_new ("key-press-event",
188 G_TYPE_FROM_CLASS (class),
189 (GSignalFlags) (G_SIGNAL_RUN_LAST),
190 0,
191 0,
192 NULL,
193 midori_cclosure_marshal_BOOLEAN__POINTER,
194 G_TYPE_BOOLEAN, 1,
195 GDK_TYPE_EVENT);
196
179 gobject_class = G_OBJECT_CLASS (class);197 gobject_class = G_OBJECT_CLASS (class);
180 gobject_class->finalize = midori_location_action_finalize;198 gobject_class->finalize = midori_location_action_finalize;
181 gobject_class->set_property = midori_location_action_set_property;199 gobject_class->set_property = midori_location_action_set_property;
@@ -1025,6 +1043,11 @@
1025 GdkEventKey* event,1043 GdkEventKey* event,
1026 GtkAction* action)1044 GtkAction* action)
1027{1045{
1046 gboolean handled = FALSE;
1047 g_signal_emit (action, signals[KEY_PRESS_EVENT], 0, event, &handled);
1048 if (handled)
1049 return TRUE;
1050
1028 GtkWidget* widget = GTK_WIDGET (entry);1051 GtkWidget* widget = GTK_WIDGET (entry);
1029 MidoriLocationAction* location_action = MIDORI_LOCATION_ACTION (action);1052 MidoriLocationAction* location_action = MIDORI_LOCATION_ACTION (action);
1030 const gchar* text;1053 const gchar* text;
@@ -1068,8 +1091,10 @@
1068 }1091 }
10691092
1070 if (is_enter && (text = gtk_entry_get_text (entry)) && *text)1093 if (is_enter && (text = gtk_entry_get_text (entry)) && *text)
1094 {
1071 g_signal_emit (action, signals[SUBMIT_URI], 0, text,1095 g_signal_emit (action, signals[SUBMIT_URI], 0, text,
1072 MIDORI_MOD_NEW_TAB (event->state));1096 MIDORI_MOD_NEW_TAB (event->state));
1097 }
1073 break;1098 break;
1074 case GDK_KEY_Escape:1099 case GDK_KEY_Escape:
1075 {1100 {
10761101
=== modified file 'midori/midori.vapi'
--- midori/midori.vapi 2014-02-22 14:06:19 +0000
+++ midori/midori.vapi 2014-03-02 18:28:29 +0000
@@ -218,6 +218,15 @@
218 public class LocationAction : Gtk.Action {218 public class LocationAction : Gtk.Action {
219 public static string render_uri ([CCode (array_length = false)] string[] keys, string uri_escaped);219 public static string render_uri ([CCode (array_length = false)] string[] keys, string uri_escaped);
220 public static string render_title ([CCode (array_length = false)] string[] keys, string title);220 public static string render_title ([CCode (array_length = false)] string[] keys, string title);
221
222 public double progress { get; set; }
223 public string secondary_icon { get; set; }
224
225 public unowned string get_text ();
226 public void set_text (string text);
227
228 public signal void submit_uri (string uri, bool new_tab);
229 public signal bool key_press_event (Gdk.EventKey event);
221 }230 }
222231
223 [CCode (cheader_filename = "midori/midori.h")]232 [CCode (cheader_filename = "midori/midori.h")]
224233
=== modified file 'po/POTFILES.in'
--- po/POTFILES.in 2014-02-21 20:28:57 +0000
+++ po/POTFILES.in 2014-03-02 18:28:29 +0000
@@ -102,3 +102,4 @@
102extensions/adblock/config.vala102extensions/adblock/config.vala
103extensions/adblock/updater.vala103extensions/adblock/updater.vala
104extensions/adblock/element.vala104extensions/adblock/element.vala
105extensions/domain-keys.vala

Subscribers

People subscribed via source and target branches

to all changes: