[Xfce4-commits] <postler:master> Simplify 'Use as' menu code and add stock icons
Christian Dywan
noreply at xfce.org
Sat Dec 18 00:06:02 CET 2010
Updating branch refs/heads/master
to e75ac4adcb36e883c66b90ed0abbc023b5cef3a7 (commit)
from c2d0c2699cc4bce89b7ad70a8e2e1db4e350fae7 (commit)
commit e75ac4adcb36e883c66b90ed0abbc023b5cef3a7
Author: Christian Dywan <christian at twotoasts.de>
Date: Fri Dec 17 23:52:52 2010 +0100
Simplify 'Use as' menu code and add stock icons
postler/postler-accounts.vala | 10 +++++-
postler/postler-folders.vala | 63 ++++++++--------------------------------
2 files changed, 21 insertions(+), 52 deletions(-)
diff --git a/postler/postler-accounts.vala b/postler/postler-accounts.vala
index 26f6b62..e6b9711 100644
--- a/postler/postler-accounts.vala
+++ b/postler/postler-accounts.vala
@@ -24,7 +24,13 @@ namespace Postler {
TRASH,
ARCHIVE,
JUNK,
- MAX
+ MAX;
+ public string get_stock_id () {
+ return localized_folders [this].stock_id;
+ }
+ public string get_label () {
+ return _(localized_folders [this].label);
+ }
}
public struct MailFolder {
public string? role;
@@ -56,7 +62,7 @@ namespace Postler {
/* The length values must be in the array to work around Vala mistakenly
optimizing the value away when using arrays indirectly with MailFolder */
const MailFolder[] localized_folders = {
- { "INBOX", null, null, null, 0 },
+ { "INBOX", STOCK_INBOX, N_("Inbox"), null, 0 },
{ "Sent", STOCK_SENT_MAIL, N_("Sent"), sent_folders, sent_folders.length },
{ "Drafts", null, N_("Drafts"), drafts_folders, drafts_folders.length },
{ "Queue", STOCK_OUTBOX, N_("Outbox"), queue_folders, queue_folders.length },
diff --git a/postler/postler-folders.vala b/postler/postler-folders.vala
index 20994f1..5fa2036 100644
--- a/postler/postler-folders.vala
+++ b/postler/postler-folders.vala
@@ -436,58 +436,21 @@ public class Postler.Folders : Gtk.TreeView {
menuitem = new Gtk.MenuItem.with_mnemonic (_("_Use as..."));
var use_as_menu = new Gtk.Menu ();
- var use_folder_item = new Gtk.MenuItem.with_label (_("INBOX"));
- use_folder_item.activate.connect ((use_folder_item) => {
- Gtk.TreeIter iter;
- if (get_selection ().get_selected (null, out iter))
- use_folder (iter, FolderType.INBOX);
- });
- use_as_menu.append (use_folder_item);
- use_folder_item = new Gtk.MenuItem.with_label (_("Sent"));
- use_folder_item.activate.connect ((use_folder_item) => {
- Gtk.TreeIter iter;
- if (get_selection ().get_selected (null, out iter))
- use_folder (iter, FolderType.SENT);
- });
- use_as_menu.append (use_folder_item);
- use_folder_item = new Gtk.MenuItem.with_label (_("Drafts"));
- use_folder_item.activate.connect ((use_folder_item) => {
- Gtk.TreeIter iter;
- if (get_selection ().get_selected (null, out iter))
- use_folder (iter, FolderType.DRAFTS);
- });
- use_as_menu.append (use_folder_item);
- use_folder_item = new Gtk.MenuItem.with_label (_("Queue"));
- use_folder_item.activate.connect ((use_folder_item) => {
- Gtk.TreeIter iter;
- if (get_selection ().get_selected (null, out iter))
- use_folder (iter, FolderType.QUEUE);
- });
- use_as_menu.append (use_folder_item);
- use_folder_item = new Gtk.MenuItem.with_label (_("Trash"));
- use_folder_item.activate.connect ((use_folder_item) => {
- Gtk.TreeIter iter;
- if (get_selection ().get_selected (null, out iter))
- use_folder (iter, FolderType.TRASH);
- });
- use_as_menu.append (use_folder_item);
- use_folder_item = new Gtk.MenuItem.with_label (_("Archive"));
- use_folder_item.activate.connect ((use_folder_item) => {
- Gtk.TreeIter iter;
- if (get_selection ().get_selected (null, out iter))
- use_folder (iter, FolderType.ARCHIVE);
- });
- use_as_menu.append (use_folder_item);
- use_folder_item = new Gtk.MenuItem.with_label (_("Junk"));
- use_folder_item.activate.connect ((use_folder_item) => {
- Gtk.TreeIter iter;
- if (get_selection ().get_selected (null, out iter))
- use_folder (iter, FolderType.JUNK);
- });
- use_as_menu.append (use_folder_item);
+ for (int i = 0; i < FolderType.MAX; i++) {
+ var type = (FolderType)i;
+ var folder_item = new Gtk.ImageMenuItem.from_stock (
+ type.get_stock_id () ?? Gtk.STOCK_DIRECTORY, null);
+ folder_item.label = type.get_label ();
+ use_as_menu.append (folder_item);
+ folder_item.activate.connect ((folder_item) => {
+ Gtk.TreeIter iter;
+ if (get_selection ().get_selected (null, out iter))
+ use_folder (iter, type);
+ });
+ }
menuitem.submenu = use_as_menu;
menu.append (menuitem);
-
+
bool is_account = false;
Gtk.TreeIter selected_iter;
if (get_selection ().get_selected (null, out selected_iter)) {
More information about the Xfce4-commits
mailing list