[gnome-boxes] props-toolbar: Add 'Open' button to file chooser view
- From: Zeeshan Ali Khattak <zeeshanak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-boxes] props-toolbar: Add 'Open' button to file chooser view
- Date: Wed, 10 Dec 2014 00:26:35 +0000 (UTC)
commit a194dd690bb99c0d9e58532090d0afb05dc77724
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date: Wed Dec 10 00:24:23 2014 +0000
props-toolbar: Add 'Open' button to file chooser view
When in file chooser view, user should not only be able to activate
selected files using double-click and 'Enter' key but also by clicking
a button.
data/ui/properties-toolbar.ui | 19 +++++++++++++++++++
src/properties-toolbar.vala | 32 ++++++++++++++++++++++++++++++++
2 files changed, 51 insertions(+), 0 deletions(-)
---
diff --git a/data/ui/properties-toolbar.ui b/data/ui/properties-toolbar.ui
index c9a3540..b8d76c4 100644
--- a/data/ui/properties-toolbar.ui
+++ b/data/ui/properties-toolbar.ui
@@ -126,6 +126,25 @@
</packing>
</child>
+ <child>
+ <object class="GtkButton" id="file_chooser_open_button">
+ <property name="visible">True</property>
+ <property name="sensitive">False</property>
+ <property name="valign">center</property>
+ <property name="use-underline">True</property>
+ <property name="label" translatable="yes">_Open</property>
+ <signal name="clicked" handler="on_file_chooser_open_clicked"/>
+ <style>
+ <class name="text-button"/>
+ </style>
+
+ </object>
+
+ <packing>
+ <property name="pack-type">end</property>
+ </packing>
+ </child>
+
</object>
<packing>
diff --git a/src/properties-toolbar.vala b/src/properties-toolbar.vala
index abe017f..ab9478b 100644
--- a/src/properties-toolbar.vala
+++ b/src/properties-toolbar.vala
@@ -21,6 +21,8 @@ private class Boxes.PropertiesToolbar: Gtk.Stack {
[GtkChild]
private EditableEntry title_entry;
+ [GtkChild]
+ private Button file_chooser_open_button;
private AppWindow window;
private unowned PropertiesWindow props_window;
@@ -37,6 +39,13 @@ private class Boxes.PropertiesToolbar: Gtk.Stack {
this.window = window;
this.props_window = props_window;
+ var file_chooser = props_window.file_chooser;
+ file_chooser.selection_changed.connect (() => {
+ var path = file_chooser.get_filename ();
+
+ file_chooser_open_button.sensitive = (path != null);
+ });
+
window.notify["ui-state"].connect (ui_state_changed);
}
@@ -63,6 +72,29 @@ private class Boxes.PropertiesToolbar: Gtk.Stack {
}
[GtkCallback]
+ private void on_file_chooser_open_clicked () requires (page == PropsWindowPage.FILE_CHOOSER) {
+ var file_chooser = props_window.file_chooser;
+ var file = file_chooser.get_file ();
+ assert (file != null);
+ var file_type = file.query_file_type (FileQueryInfoFlags.NONE, null);
+
+ switch (file_type) {
+ case GLib.FileType.REGULAR:
+ case GLib.FileType.SYMBOLIC_LINK:
+ file_chooser.file_activated ();
+ break;
+
+ case GLib.FileType.DIRECTORY:
+ file_chooser.set_current_folder (file.get_path ());
+ break;
+
+ default:
+ debug ("Unknown file type selected");
+ break;
+ }
+ }
+
+ [GtkCallback]
private void on_title_entry_changed () {
window.current_item.name = title_entry.text;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]