[gnome-boxes] searchbar: Drop use of AppWindow singleton
- From: Zeeshan Ali Khattak <zeeshanak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-boxes] searchbar: Drop use of AppWindow singleton
- Date: Fri, 8 Aug 2014 16:23:19 +0000 (UTC)
commit 464fd4764e1b022fc99b587cff54609dcf53aeba
Author: Adrien Plazas <kekun plazas laposte net>
Date: Fri Jul 18 09:39:19 2014 +0200
searchbar: Drop use of AppWindow singleton
Instead of using the AppWindow singleton, Searchbar now has its own
reference to AppWindow that it receives through a parameter to setup_ui().
This is needed to drop the use of AppWindow singleton and therefore to
make multiple windows possible.
https://bugzilla.gnome.org/show_bug.cgi?id=732098
src/app-window.vala | 1 +
src/searchbar.vala | 18 ++++++++++++------
2 files changed, 13 insertions(+), 6 deletions(-)
---
diff --git a/src/app-window.vala b/src/app-window.vala
index f0730fc..62317db 100644
--- a/src/app-window.vala
+++ b/src/app-window.vala
@@ -110,6 +110,7 @@ private class Boxes.AppWindow: Gtk.ApplicationWindow, Boxes.UI {
display_page.setup_ui (this);
view.setup_ui (this);
selectionbar.setup_ui (this);
+ searchbar.setup_ui (this);
notificationbar.searchbar = searchbar;
}
diff --git a/src/searchbar.vala b/src/searchbar.vala
index 12ffb3d..b6ac6a6 100644
--- a/src/searchbar.vala
+++ b/src/searchbar.vala
@@ -5,14 +5,16 @@ private class Boxes.Searchbar: Gtk.SearchBar {
public bool enable_key_handler {
set {
if (value)
- GLib.SignalHandler.unblock (App.window, key_handler_id);
+ GLib.SignalHandler.unblock (window, key_handler_id);
else
- GLib.SignalHandler.block (App.window, key_handler_id);
+ GLib.SignalHandler.block (window, key_handler_id);
}
}
[GtkChild]
private Gtk.SearchEntry entry;
+ private AppWindow window;
+
private ulong key_handler_id;
construct {
@@ -21,15 +23,19 @@ private class Boxes.Searchbar: Gtk.SearchBar {
App.app.call_when_ready (on_app_ready);
}
+ public void setup_ui (AppWindow window) {
+ this.window = window;
+ }
+
[GtkCallback]
private void on_search_changed () {
App.app.filter.text = text;
- App.window.view.refilter ();
+ window.view.refilter ();
}
[GtkCallback]
private void on_search_activated () {
- App.window.view.activate_first_item ();
+ window.view.activate_first_item ();
}
[GtkCallback]
@@ -44,11 +50,11 @@ private class Boxes.Searchbar: Gtk.SearchBar {
}
private void on_app_ready () {
- key_handler_id = App.window.key_press_event.connect (on_app_key_pressed);
+ key_handler_id = window.key_press_event.connect (on_app_key_pressed);
}
private bool on_app_key_pressed (Gtk.Widget widget, Gdk.EventKey event) {
- if (App.window.ui_state != UIState.COLLECTION)
+ if (window.ui_state != UIState.COLLECTION)
return false;
return handle_event ((Gdk.Event) event);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]