[gnome-boxes] wizard-window: API to show file chooser widget
- From: Zeeshan Ali Khattak <zeeshanak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-boxes] wizard-window: API to show file chooser widget
- Date: Wed, 10 Dec 2014 00:01:33 +0000 (UTC)
commit 90f263657f65754f2c71324ccbc0e1045b8e08b9
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date: Wed Dec 3 17:31:11 2014 +0000
wizard-window: API to show file chooser widget
Add a view and API to show file chooser to user.
https://bugzilla.gnome.org/show_bug.cgi?id=741046
data/ui/wizard-window.ui | 12 ++++++++++++
src/wizard-window.vala | 25 ++++++++++++++++++++++++-
2 files changed, 36 insertions(+), 1 deletions(-)
---
diff --git a/data/ui/wizard-window.ui b/data/ui/wizard-window.ui
index 76c7e76..6fec5ba 100644
--- a/data/ui/wizard-window.ui
+++ b/data/ui/wizard-window.ui
@@ -71,6 +71,18 @@
</packing>
</child>
+ <child>
+ <object class="GtkFileChooserWidget" id="file_chooser">
+ <property name="visible">True</property>
+ <property name="show-hidden">False</property>
+ <property name="local-only">False</property>
+ </object>
+
+ <packing>
+ <property name="name">file_chooser</property>
+ </packing>
+ </child>
+
</object>
</child>
diff --git a/src/wizard-window.vala b/src/wizard-window.vala
index 4e16798..0c8035b 100644
--- a/src/wizard-window.vala
+++ b/src/wizard-window.vala
@@ -4,11 +4,14 @@ using Gtk;
private enum Boxes.WizardWindowPage {
MAIN,
CUSTOMIZATION,
+ FILE_CHOOSER,
}
[GtkTemplate (ui = "/org/gnome/Boxes/ui/wizard-window.ui")]
private class Boxes.WizardWindow : Gtk.Window, Boxes.UI {
- public const string[] page_names = { "main", "customization" };
+ public const string[] page_names = { "main", "customization", "file_chooser" };
+
+ public delegate void FileChosenFunc (string uri);
public UIState previous_ui_state { get; protected set; }
public UIState ui_state { get; protected set; }
@@ -40,6 +43,8 @@ private class Boxes.WizardWindow : Gtk.Window, Boxes.UI {
[GtkChild]
public Gtk.Grid customization_grid;
[GtkChild]
+ public Gtk.FileChooserWidget file_chooser;
+ [GtkChild]
public WizardToolbar topbar;
[GtkChild]
public Notificationbar notificationbar;
@@ -50,6 +55,12 @@ private class Boxes.WizardWindow : Gtk.Window, Boxes.UI {
wizard.setup_ui (app_window, this);
topbar.setup_ui (this);
+ // FIXME: Can we do this from UI file somehow? Would be nice, if so
+ file_chooser.filter = new Gtk.FileFilter ();
+ file_chooser.filter.add_mime_type ("application/x-cd-image");
+ foreach (var extension in InstalledMedia.supported_extensions)
+ file_chooser.filter.add_pattern ("*" + extension);
+
set_transient_for (app_window);
notify["ui-state"].connect (ui_state_changed);
@@ -91,6 +102,18 @@ private class Boxes.WizardWindow : Gtk.Window, Boxes.UI {
page = WizardWindowPage.CUSTOMIZATION;
}
+ public void show_file_chooser (owned FileChosenFunc file_chosen_func) {
+ ulong activated_id = 0;
+ activated_id = file_chooser.file_activated.connect (() => {
+ var uri = file_chooser.get_uri ();
+ file_chosen_func (uri);
+ file_chooser.disconnect (activated_id);
+
+ page = WizardWindowPage.MAIN;
+ });
+ page = WizardWindowPage.FILE_CHOOSER;
+ }
+
private void ui_state_changed () {
wizard.set_state (ui_state);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]