[Xfce4-commits] <postler:master> Implement selecting of folders in a Bureau
Christian Dywan
noreply at xfce.org
Tue Jan 4 05:52:04 CET 2011
Updating branch refs/heads/master
to 9a2e625095aa339145bcdd9df70c7da3d0a77a72 (commit)
from 42dc217c98393c41a83e60b764a02f1e37c60b19 (commit)
commit 9a2e625095aa339145bcdd9df70c7da3d0a77a72
Author: Christian Dywan <christian at twotoasts.de>
Date: Sun Jan 2 20:13:58 2011 +0100
Implement selecting of folders in a Bureau
A folder name can be passed as a string to a bureau, which
is forwarded to the running app if needed.
This is used by the indicators to select folders and to
open additional windows.
postler/postler-app.vala | 11 +++++++++
postler/postler-bureau.vala | 2 +-
postler/postler-folders.vala | 47 ++++++++++++++++++++++++++++++-----------
postler/postler-reader.vala | 11 +++++++++-
postler/postler-service.vala | 3 +-
5 files changed, 58 insertions(+), 16 deletions(-)
diff --git a/postler/postler-app.vala b/postler/postler-app.vala
index d7073f3..5503b0b 100644
--- a/postler/postler-app.vala
+++ b/postler/postler-app.vala
@@ -47,14 +47,25 @@ namespace Postler {
}
public class Postler.App : Unique.App {
+ Bureau? bureau = null;
+
public static string argv0 { get; set; }
public App () {
GLib.Object (name: "org.elementary.PostlerApp", startup_id: null);
}
+ public new void watch_window (Bureau bureau) {
+ this.bureau = bureau;
+ }
+
public override Unique.Response message_received (int command,
Unique.MessageData data, uint timestamp) {
+ if (command == Unique.Command.ACTIVATE) {
+ return_val_if_fail (bureau != null, Unique.Response.INVALID);
+ bureau.present ();
+ bureau.folders.select_folder (data.get_text ());
+ }
return Unique.Response.OK;
}
diff --git a/postler/postler-bureau.vala b/postler/postler-bureau.vala
index 7edace6..346099c 100644
--- a/postler/postler-bureau.vala
+++ b/postler/postler-bureau.vala
@@ -20,7 +20,7 @@ public class Postler.Bureau : Gtk.Window {
Gtk.Toolbar toolbar;
Gtk.Entry search;
Gtk.Toolbar search_options;
- Postler.Folders folders;
+ public Postler.Folders folders;
Gtk.ProgressBar progressbar;
Gtk.Label statuslabel;
public Postler.Messages messages;
diff --git a/postler/postler-folders.vala b/postler/postler-folders.vala
index eb7c5d4..d0551be 100644
--- a/postler/postler-folders.vala
+++ b/postler/postler-folders.vala
@@ -321,7 +321,26 @@ public class Postler.Folders : Gtk.TreeView {
return false;
}
- void select_folder (Gtk.TreeIter iter)
+ public bool select_folder (string folder, Gtk.TreeIter? parent_iter=null)
+ requires (messages != null) {
+ Gtk.TreeIter iter;
+ if (!store.iter_children (out iter, parent_iter))
+ return false;
+ do {
+ string name;
+ store.get (iter, Columns.NAME, out name);
+ if (name == folder) {
+ get_selection ().select_iter (iter);
+ display_folder_iter (iter);
+ return true;
+ }
+ if (select_folder (folder, iter))
+ return true;
+ } while (store.iter_next (ref iter));
+ return false;
+ }
+
+ void display_folder_iter (Gtk.TreeIter iter)
requires (messages != null) {
string location;
AccountInfo account_info;
@@ -447,16 +466,18 @@ public class Postler.Folders : Gtk.TreeView {
Gtk.MenuItem menuitem;
menuitem = new Gtk.MenuItem.with_mnemonic (_("Open in New _Window"));
menuitem.activate.connect ((menuitem) => {
- Gtk.TreeIter iter;
- if (get_selection ().get_selected (null, out iter)) {
- string? location;
- AccountInfo account_info;
- store.get (iter, Columns.LOCATION, out location,
- Columns.INFO, out account_info);
- var bureau = new Bureau ();
- bureau.messages.populate (location, account_info);
- bureau.messages.grab_focus ();
- bureau.show ();
+ Gtk.TreeIter iter;
+ if (get_selection ().get_selected (null, out iter)) {
+ string? location;
+ AccountInfo account_info;
+ store.get (iter, Columns.LOCATION, out location,
+ Columns.INFO, out account_info);
+ var bureau = new Bureau ();
+ GLib.Idle.add (() => {
+ bureau.folders.select_folder (account_info.name);
+ return false;
+ });
+ bureau.show ();
}
});
menu.append (menuitem);
@@ -570,7 +591,7 @@ public class Postler.Folders : Gtk.TreeView {
GLib.Signal.emit_by_name (this, "popup-menu", &handled);
}
else
- select_folder (iter);
+ display_folder_iter (iter);
}
return base.button_release_event (event);
}
@@ -578,7 +599,7 @@ public class Postler.Folders : Gtk.TreeView {
public override void row_activated (Gtk.TreePath path, Gtk.TreeViewColumn column) {
Gtk.TreeIter iter;
if (store.get_iter (out iter, path)) {
- select_folder (iter);
+ display_folder_iter (iter);
}
}
}
diff --git a/postler/postler-reader.vala b/postler/postler-reader.vala
index 0b0792d..8c67255 100644
--- a/postler/postler-reader.vala
+++ b/postler/postler-reader.vala
@@ -179,7 +179,10 @@ public class Postler.Reader {
var app = new Postler.App ();
if (app.is_running) {
- var response = app.send_message (Unique.Command.ACTIVATE, null);
+ Unique.MessageData data = new Unique.MessageData ();
+ if (filenames != null && filenames[0] != null)
+ data.set_text (filenames[0], filenames[0].length);
+ var response = app.send_message (Unique.Command.ACTIVATE, data);
if (response == Unique.Response.OK)
return 0;
GLib.error (_("Failed to activate running instance"));
@@ -188,6 +191,12 @@ public class Postler.Reader {
var bureau = new Postler.Bureau ();
bureau.destroy.connect (Gtk.main_quit);
bureau.show ();
+ if (filenames != null && filenames[0] != null) {
+ GLib.Idle.add (() => {
+ bureau.folders.select_folder (filenames[0]);
+ return false;
+ });
+ }
app.watch_window (bureau);
Gtk.main ();
return 0;
diff --git a/postler/postler-service.vala b/postler/postler-service.vala
index 0d74b8e..1bbcec8 100644
--- a/postler/postler-service.vala
+++ b/postler/postler-service.vala
@@ -25,7 +25,8 @@ namespace Postler {
var item = new Indicate.Indicator.with_server (indicator);
item.set_property ("name", info.name);
item.user_display.connect ((item) => {
- Postler.App.spawn_module ("bureau");
+ string name = item.get_property ("name");
+ Postler.App.spawn_module ("bureau", name);
});
item.emit_show ();
items.append (item);
More information about the Xfce4-commits
mailing list