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
1=== added file 'extensions/domain-keys.vala'
2--- extensions/domain-keys.vala 1970-01-01 00:00:00 +0000
3+++ extensions/domain-keys.vala 2014-03-02 18:28:29 +0000
4@@ -0,0 +1,76 @@
5+/*
6+ Copyright (C) 2014 James Axl <bilimish@yandex.ru>
7+
8+ This library is free software; you can redistribute it and/or
9+ modify it under the terms of the GNU Lesser General Public
10+ License as published by the Free Software Foundation; either
11+ version 2.1 of the License, or (at your option) any later version.
12+
13+ See the file COPYING for the full license text.
14+*/
15+
16+namespace DomainHotkeys {
17+ class Manager : Midori.Extension {
18+ internal Manager () {
19+ GLib.Object (name: _("Domain Hotkeys"),
20+ description: _("Add www. and .com/.country_domain and proceed with Ctrl+Enter/Ctrl+Shift"),
21+ version: "0.1" + Midori.VERSION_SUFFIX,
22+ authors: "James Axl <bilimish@yandex.ru>");
23+ activate.connect (this.activated);
24+ deactivate.connect (this.deactivated);
25+ }
26+
27+ bool key_press_event (Midori.LocationAction action, Gdk.EventKey event_key) {
28+ if (event_key.keyval == Gdk.Key.Return) {
29+ if ((bool)(event_key.state & Gdk.ModifierType.CONTROL_MASK)) {
30+ submit_uri(action);
31+ return true;
32+ } else if((bool)(event_key.state & Gdk.ModifierType.SHIFT_MASK)) {
33+ submit_uri(action, true);
34+ return true;
35+ }
36+ }
37+ return false;
38+ }
39+
40+ void submit_uri(Midori.LocationAction action, bool locale = false) {
41+ var url = action.get_text ();
42+ if (locale){
43+ var domain = C_("Domain", ".com");
44+ url = "www." + url + domain;
45+ } else {
46+ url = "www." + url + ".com";
47+ }
48+ action.submit_uri(url, false);
49+ }
50+
51+ void browser_added (Midori.Browser browser) {
52+ var action_group = browser.get_action_group ();
53+ var action = action_group.get_action ("Location") as Midori.LocationAction;
54+ action.key_press_event.connect (key_press_event);
55+ }
56+
57+ void activated (Midori.App app) {
58+ foreach (var browser in app.get_browsers ())
59+ browser_added (browser);
60+ app.add_browser.connect (browser_added);
61+ }
62+
63+ void browser_removed (Midori.Browser browser) {
64+ var action_group = browser.get_action_group ();
65+ var action = action_group.get_action ("Location") as Midori.LocationAction;
66+ action.key_press_event.disconnect (key_press_event);
67+ }
68+
69+ void deactivated () {
70+ var app = get_app ();
71+ app.add_browser.disconnect (browser_added);
72+ foreach (var browser in app.get_browsers ())
73+ browser_removed (browser);
74+ }
75+ }
76+}
77+
78+public Midori.Extension extension_init () {
79+ return new DomainHotkeys.Manager ();
80+}
81
82=== modified file 'midori/marshal.list'
83--- midori/marshal.list 2013-12-26 17:29:08 +0000
84+++ midori/marshal.list 2014-03-02 18:28:29 +0000
85@@ -1,3 +1,4 @@
86+BOOLEAN:POINTER
87 BOOLEAN:OBJECT
88 BOOLEAN:OBJECT,OBJECT
89 BOOLEAN:OBJECT,OBJECT,POINTER
90
91=== modified file 'midori/midori-locationaction.c'
92--- midori/midori-locationaction.c 2014-02-11 23:01:05 +0000
93+++ midori/midori-locationaction.c 2014-03-02 18:28:29 +0000
94@@ -69,6 +69,7 @@
95 SECONDARY_ICON_RELEASED,
96 RESET_URI,
97 SUBMIT_URI,
98+ KEY_PRESS_EVENT,
99 LAST_SIGNAL
100 };
101
102@@ -176,6 +177,23 @@
103 G_TYPE_STRING,
104 G_TYPE_BOOLEAN);
105
106+ /**
107+ * MidoriLocationAction:key-press-event:
108+ *
109+ * A key (combination) was pressed in an entry of the action.
110+ *
111+ * Since 0.5.8
112+ */
113+ signals[KEY_PRESS_EVENT] = g_signal_new ("key-press-event",
114+ G_TYPE_FROM_CLASS (class),
115+ (GSignalFlags) (G_SIGNAL_RUN_LAST),
116+ 0,
117+ 0,
118+ NULL,
119+ midori_cclosure_marshal_BOOLEAN__POINTER,
120+ G_TYPE_BOOLEAN, 1,
121+ GDK_TYPE_EVENT);
122+
123 gobject_class = G_OBJECT_CLASS (class);
124 gobject_class->finalize = midori_location_action_finalize;
125 gobject_class->set_property = midori_location_action_set_property;
126@@ -1025,6 +1043,11 @@
127 GdkEventKey* event,
128 GtkAction* action)
129 {
130+ gboolean handled = FALSE;
131+ g_signal_emit (action, signals[KEY_PRESS_EVENT], 0, event, &handled);
132+ if (handled)
133+ return TRUE;
134+
135 GtkWidget* widget = GTK_WIDGET (entry);
136 MidoriLocationAction* location_action = MIDORI_LOCATION_ACTION (action);
137 const gchar* text;
138@@ -1068,8 +1091,10 @@
139 }
140
141 if (is_enter && (text = gtk_entry_get_text (entry)) && *text)
142+ {
143 g_signal_emit (action, signals[SUBMIT_URI], 0, text,
144 MIDORI_MOD_NEW_TAB (event->state));
145+ }
146 break;
147 case GDK_KEY_Escape:
148 {
149
150=== modified file 'midori/midori.vapi'
151--- midori/midori.vapi 2014-02-22 14:06:19 +0000
152+++ midori/midori.vapi 2014-03-02 18:28:29 +0000
153@@ -218,6 +218,15 @@
154 public class LocationAction : Gtk.Action {
155 public static string render_uri ([CCode (array_length = false)] string[] keys, string uri_escaped);
156 public static string render_title ([CCode (array_length = false)] string[] keys, string title);
157+
158+ public double progress { get; set; }
159+ public string secondary_icon { get; set; }
160+
161+ public unowned string get_text ();
162+ public void set_text (string text);
163+
164+ public signal void submit_uri (string uri, bool new_tab);
165+ public signal bool key_press_event (Gdk.EventKey event);
166 }
167
168 [CCode (cheader_filename = "midori/midori.h")]
169
170=== modified file 'po/POTFILES.in'
171--- po/POTFILES.in 2014-02-21 20:28:57 +0000
172+++ po/POTFILES.in 2014-03-02 18:28:29 +0000
173@@ -102,3 +102,4 @@
174 extensions/adblock/config.vala
175 extensions/adblock/updater.vala
176 extensions/adblock/element.vala
177+extensions/domain-keys.vala

Subscribers

People subscribed via source and target branches

to all changes: