Added menu bar and About box. Fixed bug in ISO8601 date conversion.

This commit is contained in:
Jim Nelson 2011-05-26 18:26:36 -07:00
parent ba81ad43a4
commit 65eb370e96
4 changed files with 114 additions and 4 deletions

View file

@ -5,6 +5,34 @@
*/
public class GearyApplication : YorbaApplication {
// TODO: replace static strings with const strings when gettext is integrated properly
public const string PROGRAM_NAME = "Geary";
public static string PROGRAM_DESCRIPTION = _("Email Client");
public const string VERSION = "0.0.1";
public const string COPYRIGHT = "Copyright 2011 Yorba Foundation";
public const string WEBSITE = "http://www.yorba.org";
public static string WEBSITE_LABEL = _("Visit the Yorba web site");
public const string[] AUTHORS = {
"Jim Nelson"
};
public const string LICENSE = """
Shotwell is free software; you can redistribute it and/or modify it under the
terms of the GNU Lesser General Public License as published by the Free
Software Foundation; either version 2.1 of the License, or (at your option)
any later version.
Shotwell is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
more details.
You should have received a copy of the GNU Lesser General Public License
along with Shotwell; if not, write to the Free Software Foundation, Inc.,
51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
""";
public static GearyApplication instance {
get {
if (_instance == null)

View file

@ -5,14 +5,41 @@
*/
public class MainWindow : Gtk.Window {
private const string MAIN_MENU_XML = """
<ui>
<menubar name="MenuBar">
<menu name="FileMenu" action="FileMenu">
<menuitem name="Quit" action="FileQuit" />
</menu>
<menu name="HelpMenu" action="HelpMenu">
<menuitem name="About" action="HelpAbout" />
</menu>
</menubar>
</ui>
""";
private MessageListStore message_list_store = new MessageListStore();
private MessageListView message_list_view;
private Gtk.UIManager ui = new Gtk.UIManager();
private Geary.Engine? engine = null;
public MainWindow() {
title = GearyApplication.PROGRAM_NAME;
set_default_size(800, 600);
try {
ui.add_ui_from_string(MAIN_MENU_XML, -1);
} catch (Error err) {
error("Unable to load main menu UI: %s", err.message);
}
Gtk.ActionGroup action_group = new Gtk.ActionGroup("MainMenuActionGroup");
action_group.add_actions(create_actions(), this);
ui.insert_action_group(action_group, 0);
add_accel_group(ui.get_accel_group());
message_list_view = new MessageListView(message_list_store);
create_layout();
@ -52,12 +79,65 @@ public class MainWindow : Gtk.Window {
base.destroy();
}
private Gtk.ActionEntry[] create_actions() {
Gtk.ActionEntry[] entries = new Gtk.ActionEntry[0];
//
// File
//
Gtk.ActionEntry file_menu = { "FileMenu", null, TRANSLATABLE, null, null, null };
file_menu.label = _("_File");
entries += file_menu;
Gtk.ActionEntry quit = { "FileQuit", Gtk.Stock.QUIT, TRANSLATABLE, "<Ctrl>Q", null, on_quit };
quit.label = _("_Quit");
entries += quit;
//
// Help
//
Gtk.ActionEntry help_menu = { "HelpMenu", null, TRANSLATABLE, null, null, null };
help_menu.label = _("_Help");
entries += help_menu;
Gtk.ActionEntry about = { "HelpAbout", Gtk.Stock.ABOUT, TRANSLATABLE, null, null, on_about };
about.label = _("_About");
entries += about;
return entries;
}
private void create_layout() {
Gtk.VBox main_layout = new Gtk.VBox(false, 0);
// main menu
main_layout.pack_start(ui.get_widget("/MenuBar"), false, false, 0);
// message list
Gtk.ScrolledWindow message_list_scrolled = new Gtk.ScrolledWindow(null, null);
message_list_scrolled.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
message_list_scrolled.add_with_viewport(message_list_view);
main_layout.pack_end(message_list_scrolled, true, true, 0);
add(message_list_scrolled);
add(main_layout);
}
private void on_quit() {
GearyApplication.instance.exit();
}
private void on_about() {
Gtk.show_about_dialog(this,
"program-name", GearyApplication.PROGRAM_NAME,
"authors", GearyApplication.AUTHORS,
"copyright", GearyApplication.COPYRIGHT,
"license", GearyApplication.LICENSE,
"version", GearyApplication.VERSION,
"website", GearyApplication.WEBSITE,
"website-label", GearyApplication.WEBSITE_LABEL
);
}
}

View file

@ -5,10 +5,12 @@
*/
// TODO: This fakes internationalization support until fully integrated.
public string _(string text) {
public unowned string _(string text) {
return text;
}
public const string TRANSLATABLE = "TRANSLATABLE";
namespace Intl {
}

View file

@ -28,7 +28,7 @@ public class Geary.RFC822.Date : Geary.RFC822.MessageData, Geary.Common.MessageD
if (tm == 0)
throw new ImapError.PARSE_ERROR("Unable to parse \"%s\": not ISO-8601 date", iso8601);
value = new DateTime.from_unix_utc(tm);
value = new DateTime.from_unix_local(tm);
original = iso8601;
}