[gnome-boxes] properties-window: API to show file chooser widget
- From: Zeeshan Ali Khattak <zeeshanak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-boxes] properties-window: API to show file chooser widget
- Date: Fri, 5 Dec 2014 22:00:12 +0000 (UTC)
commit 2681d1bcda27c39bab7d4f09e9ae397764da74ef
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date: Wed Dec 3 17:31:11 2014 +0000
properties-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=741047
data/ui/properties-window.ui | 14 ++++++++++++++
src/properties-window.vala | 25 +++++++++++++++++++++++--
2 files changed, 37 insertions(+), 2 deletions(-)
---
diff --git a/data/ui/properties-window.ui b/data/ui/properties-window.ui
index 3ca6de7..7cd1aa0 100644
--- a/data/ui/properties-window.ui
+++ b/data/ui/properties-window.ui
@@ -15,6 +15,8 @@
| |-> properties = new Boxes.Properties ();
| |
| |-> troubleshoot_log = new Boxes.TroubleshootLog ();
+ | |
+ | |-> file_chooser = new Gtk.FileChooserWidget ();
|
|-> topbar = new Boxes.PropertiesToolbar (); // as titlebar
-->
@@ -63,6 +65,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">True</property>
+ </object>
+
+ <packing>
+ <property name="name">file_chooser</property>
+ </packing>
+ </child>
+
</object>
</child>
diff --git a/src/properties-window.vala b/src/properties-window.vala
index fa7142e..5a889d0 100644
--- a/src/properties-window.vala
+++ b/src/properties-window.vala
@@ -3,12 +3,15 @@ using Gtk;
private enum Boxes.PropsWindowPage {
MAIN,
- TROUBLESHOOTING_LOG
+ TROUBLESHOOTING_LOG,
+ FILE_CHOOSER,
}
[GtkTemplate (ui = "/org/gnome/Boxes/ui/properties-window.ui")]
private class Boxes.PropertiesWindow: Gtk.Window, Boxes.UI {
- public const string[] page_names = { "main", "troubleshoot_log" };
+ public const string[] page_names = { "main", "troubleshoot_log", "file_chooser" };
+
+ public delegate void FileChosenFunc (string path);
public UIState previous_ui_state { get; protected set; }
public UIState ui_state { get; protected set; }
@@ -31,6 +34,8 @@ private class Boxes.PropertiesWindow: Gtk.Window, Boxes.UI {
[GtkChild]
public TroubleshootLog troubleshoot_log;
[GtkChild]
+ public Gtk.FileChooserWidget file_chooser;
+ [GtkChild]
public PropertiesToolbar topbar;
[GtkChild]
public Notificationbar notificationbar;
@@ -43,6 +48,10 @@ private class Boxes.PropertiesWindow: Gtk.Window, Boxes.UI {
properties.setup_ui (app_window, this);
topbar.setup_ui (app_window, 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");
+
set_transient_for (app_window);
notify["ui-state"].connect (ui_state_changed);
@@ -53,6 +62,18 @@ private class Boxes.PropertiesWindow: Gtk.Window, Boxes.UI {
page = PropsWindowPage.TROUBLESHOOTING_LOG;
}
+ public void show_file_chooser (owned FileChosenFunc file_chosen_func) {
+ ulong activated_id = 0;
+ activated_id = file_chooser.file_activated.connect (() => {
+ var path = file_chooser.get_filename ();
+ file_chosen_func (path);
+ file_chooser.disconnect (activated_id);
+
+ page = PropsWindowPage.MAIN;
+ });
+ page = PropsWindowPage.FILE_CHOOSER;
+ }
+
public void copy_troubleshoot_log_to_clipboard () {
var log = troubleshoot_log.view.buffer.text;
var clipboard = Gtk.Clipboard.get_for_display (get_display (), Gdk.SELECTION_CLIPBOARD);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]