[gnome-boxes] selectionbar: Add 'Open in new windows' button
- From: Zeeshan Ali Khattak <zeeshanak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-boxes] selectionbar: Add 'Open in new windows' button
- Date: Sat, 16 Aug 2014 15:47:10 +0000 (UTC)
commit b0e2fc3fb0c4afa8739d877345db7ad7a4da4560
Author: Adrien Plazas <kekun plazas laposte net>
Date: Tue Aug 12 08:38:31 2014 +0200
selectionbar: Add 'Open in new windows' button
This is needed to make multiple windows possible.
https://bugzilla.gnome.org/show_bug.cgi?id=734486
data/ui/selectionbar.ui | 17 +++++++++++++++++
src/app.vala | 22 ++++++++++++++++++++++
src/selectionbar.vala | 19 +++++++++++++++++++
3 files changed, 58 insertions(+), 0 deletions(-)
---
diff --git a/data/ui/selectionbar.ui b/data/ui/selectionbar.ui
index 48b506d..0583012 100644
--- a/data/ui/selectionbar.ui
+++ b/data/ui/selectionbar.ui
@@ -52,6 +52,23 @@
</packing>
</child>
+ <!-- Open in new windows button -->
+ <child>
+ <object class="GtkButton" id="open_btn">
+ <property name="visible">True</property>
+ <property name="valign">center</property>
+ <property name="use-underline">True</property>
+ <signal name="clicked" handler="on_open_btn_clicked"/>
+ <style>
+ <class name="text-button"/>
+ </style>
+ </object>
+
+ <packing>
+ <property name="pack-type">start</property>
+ </packing>
+ </child>
+
<!-- Remove button -->
<child>
<object class="GtkButton" id="remove_btn">
diff --git a/src/app.vala b/src/app.vala
index 2917865..63575f8 100644
--- a/src/app.vala
+++ b/src/app.vala
@@ -311,6 +311,28 @@ private class Boxes.App: Gtk.Application {
return false;
}
+ public void open_selected_items_in_new_window () {
+ var selected_items = main_window.view.get_selected_items ();
+
+ main_window.selection_mode = false;
+
+ foreach (var item in selected_items) {
+ if (item is Machine)
+ open_in_new_window (item as Machine);
+ }
+ }
+
+ private void open_in_new_window (Machine machine) {
+ if (machine.window != main_window) {
+ machine.window.present ();
+
+ return;
+ }
+
+ var window = add_new_window ();
+ window.connect_to (machine);
+ }
+
public void delete_machine (Machine machine, bool by_user = true) {
machine.delete (by_user); // Will also delete associated storage volume if by_user is 'true'
collection.remove_item (machine);
diff --git a/src/selectionbar.vala b/src/selectionbar.vala
index e979067..0187ab9 100644
--- a/src/selectionbar.vala
+++ b/src/selectionbar.vala
@@ -11,6 +11,8 @@ private class Boxes.Selectionbar: Gtk.Revealer {
private Gtk.Button remove_btn;
[GtkChild]
private Gtk.Button properties_btn;
+ [GtkChild]
+ private Gtk.Button open_btn;
private AppWindow window;
@@ -20,6 +22,7 @@ private class Boxes.Selectionbar: Gtk.Revealer {
update_properties_btn ();
update_pause_btn ();
update_delete_btn ();
+ update_open_btn ();
});
}
@@ -67,6 +70,11 @@ private class Boxes.Selectionbar: Gtk.Revealer {
}
[GtkCallback]
+ private void on_open_btn_clicked () {
+ App.app.open_selected_items_in_new_window ();
+ }
+
+ [GtkCallback]
private void on_remove_btn_clicked () {
App.app.remove_selected_items ();
}
@@ -148,4 +156,15 @@ private class Boxes.Selectionbar: Gtk.Revealer {
remove_btn.sensitive = sensitive;
}
+
+ private void update_open_btn () {
+ var items = App.app.selected_items.length ();
+
+ open_btn.sensitive = items > 0;
+ // Translators: This is a button to open box(es) in new window(s)
+ if (items == 0)
+ open_btn.label = _("_Open in new window");
+ else
+ open_btn.label = ngettext ("_Open in new window", "_Open in %d new windows", items).printf
(items);
+ }
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]