Skip to content

Commit b66b407

Browse files
committed
working omni bar
1 parent 904f4a7 commit b66b407

File tree

3 files changed

+26
-21
lines changed

3 files changed

+26
-21
lines changed

src/config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ pub const LOCALEDIR: &str = "/app/share/locale";
44
pub const PKGDATADIR: &str = "/app/share/geopard";
55
pub const PROFILE: &str = "Devel";
66
pub const RESOURCES_FILE: &str = concat!("/app/share/geopard", "/resources.gresource");
7-
pub const VERSION: &str = "1.0.0-alpha-50a81e9";
7+
pub const VERSION: &str = "1.0.0-alpha-904f4a7";
88

99
use once_cell::sync::Lazy;
1010
use serde::{Deserialize, Serialize};

src/tab.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -629,7 +629,7 @@ impl Tab {
629629
let mut url = url.clone();
630630
url.set_query(Some(&query));
631631
text_input
632-
.activate_action("win.open-omni", Some(&url.to_string().to_variant()))
632+
.activate_action("win.open-url", Some(&url.to_string().to_variant()))
633633
.unwrap();
634634
});
635635
ctx.insert_widget(&mut iter, &text_input);

src/window.rs

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -143,24 +143,11 @@ impl Window {
143143
&*imp.style_provider.borrow(),
144144
gtk::STYLE_PROVIDER_PRIORITY_APPLICATION,
145145
);
146-
this.bind_signals();
147146
this.squeezer_changed();
148147
this.setup_actions_signals();
149148
this.open_in_new_tab(bookmarks_url().as_str());
150149
this
151150
}
152-
fn bind_signals(&self) {
153-
self.imp().tab_view.connect_selected_page_notify(
154-
clone!(@weak self as this => @default-panic, move |tab_view| {
155-
this.page_switched(tab_view);
156-
}),
157-
);
158-
self.imp().squeezer.connect_visible_child_notify(
159-
clone!(@weak self as this => @default-panic, move |_sq| {
160-
this.squeezer_changed();
161-
}),
162-
);
163-
}
164151
fn setup_actions_signals(&self) {
165152
let imp = self.imp();
166153

@@ -224,6 +211,28 @@ impl Window {
224211
None
225212
}),
226213
);
214+
215+
imp.tab_view.connect_selected_page_notify(
216+
clone!(@weak self as this => @default-panic, move |tab_view| {
217+
this.page_switched(tab_view);
218+
}),
219+
);
220+
imp.squeezer.connect_visible_child_notify(
221+
clone!(@weak self as this => @default-panic, move |_sq| {
222+
this.squeezer_changed();
223+
}),
224+
);
225+
imp.url_bar.connect_activate(
226+
clone!(@weak self as this => @default-panic, move |_sq| {
227+
this.open_omni(this.imp().url_bar.text().as_str());
228+
})
229+
);
230+
imp.small_url_bar.connect_activate(
231+
clone!(@weak self as this => @default-panic, move |_sq| {
232+
this.open_omni(this.imp().small_url_bar.text().as_str());
233+
})
234+
);
235+
227236
adw::StyleManager::default().connect_dark_notify(clone!(@weak self as this => @default-panic, move |_| {
228237
this.set_special_color_from_hash();
229238
}));
@@ -346,15 +355,11 @@ impl Window {
346355
}
347356
});
348357
}
349-
// this should also handle search requests
350358
fn open_omni(&self, v: &str) {
351-
let url = Url::parse(v);
359+
let url = Url::parse(v).or_else(|_| Url::parse(&format!("gemini://geminispace.info/search?{}", v)));
352360
match url {
353361
Ok(url) => self.current_tab().spawn_open_url(url),
354-
Err(e) => error!(
355-
"Failed to parse url (will trigger a search in the future): {:?}",
356-
e
357-
),
362+
Err(e) => error!("Failed to open from omni bar"),
358363
}
359364
}
360365
fn open_url_str(&self, v: &str) {

0 commit comments

Comments
 (0)