Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions src/Application.vala
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ public class Mail.Application : Gtk.Application {
public const string ACTION_GROUP_PREFIX = "app";
public const string ACTION_PREFIX = ACTION_GROUP_PREFIX + ".";

public const string ACTION_ACCOUNT_SETTINGS = "account-settings";
public const string ACTION_LOAD_IMAGES = "always-load-remote-images";
public const string ACTION_MANAGE_SIGNATURES = "manage-signatures";

public static GLib.Settings settings;
Expand Down Expand Up @@ -133,6 +135,30 @@ public class Mail.Application : Gtk.Application {
transient_for = active_window
};
});

var account_settings_action = new SimpleAction (ACTION_ACCOUNT_SETTINGS, null);
account_settings_action.activate.connect (() => {
try {
Gtk.show_uri_on_window (active_window, "settings://accounts/online", Gtk.get_current_event_time ());
} catch (Error e) {
var dialog = new Granite.MessageDialog (
_("Unable to open System Settings"),
_("Open System Settings manually or install Evolution to set up online accounts."),
new ThemedIcon ("preferences-system")
) {
badge_icon = new ThemedIcon ("dialog-warning"),
modal = true,
transient_for = active_window,
};
dialog.response.connect (dialog.destroy);
dialog.present ();
}
});

var load_images_action = settings.create_action (ACTION_LOAD_IMAGES);

add_action (account_settings_action);
add_action (load_images_action);
add_action (manage_signatures_action);

new InboxMonitor ().start.begin ();
Expand Down
59 changes: 9 additions & 50 deletions src/FolderList/FolderList.vala
Original file line number Diff line number Diff line change
Expand Up @@ -47,40 +47,19 @@ public class Mail.FolderList : Gtk.Box {
child = source_list
};

var load_images_menuitem = new Granite.SwitchModelButton (_("Always Show Remote Images"));
var dialogs_section = new Menu ();
dialogs_section.append (_("Edit Signatures…"), Application.ACTION_PREFIX + Application.ACTION_MANAGE_SIGNATURES);
dialogs_section.append (_("Account Settings…"), Application.ACTION_PREFIX + Application.ACTION_ACCOUNT_SETTINGS);

var manage_signatures_menuitem = new Gtk.ModelButton () {
text = _("Edit Signatures…"),
action_name = Application.ACTION_PREFIX + Application.ACTION_MANAGE_SIGNATURES,
};

var account_settings_menuitem = new Gtk.ModelButton () {
text = _("Account Settings…")
};

var app_menu_separator = new Gtk.Separator (HORIZONTAL) {
margin_bottom = 3,
margin_top = 3
};

var app_menu_box = new Gtk.Box (VERTICAL, 0) {
margin_bottom = 3,
margin_top = 3
};
app_menu_box.add (load_images_menuitem);
app_menu_box.add (app_menu_separator);
app_menu_box.add (manage_signatures_menuitem);
app_menu_box.add (account_settings_menuitem);
app_menu_box.show_all ();

var app_menu_popover = new Gtk.Popover (null) {
child = app_menu_box
};
var menu_model = new Menu ();
menu_model.append (_("Always Show Remote Images"), Application.ACTION_PREFIX + Application.ACTION_LOAD_IMAGES);
menu_model.append_section (null, dialogs_section);

var app_menu = new Gtk.MenuButton () {
image = new Gtk.Image.from_icon_name ("open-menu-symbolic", Gtk.IconSize.SMALL_TOOLBAR),
popover = app_menu_popover,
tooltip_text = _("Menu")
menu_model = menu_model,
tooltip_text = _("Menu"),
use_popover = false
};

var action_bar = new Gtk.ActionBar ();
Expand Down Expand Up @@ -119,26 +98,6 @@ public class Mail.FolderList : Gtk.Box {
settings.set ("selected-folder", "(ss)", "GROUPED", item.name);
}
});

settings.bind ("always-load-remote-images", load_images_menuitem, "active", SettingsBindFlags.DEFAULT);

account_settings_menuitem.clicked.connect (() => {
try {
Gtk.show_uri_on_window ((Gtk.Window) get_toplevel (), "settings://accounts/online", Gtk.get_current_event_time ());
} catch (Error e) {
var dialog = new Granite.MessageDialog (
_("Unable to open System Settings"),
_("Open System Settings manually or install Evolution to set up online accounts."),
new ThemedIcon ("preferences-system")
) {
badge_icon = new ThemedIcon ("dialog-warning"),
modal = true,
transient_for = (Gtk.Window) get_toplevel ()
};
dialog.response.connect (dialog.destroy);
dialog.present ();
}
});
}

private void add_account (Mail.Backend.Account account) {
Expand Down
Loading