[Xfce4-commits] <postler:master> Implement the basics of a PostlerComposer
Christian Dywan
noreply at xfce.org
Sun May 30 22:22:03 CEST 2010
Updating branch refs/heads/master
to b82590bc597767f1d45d54497e59d60b530bbb6c (commit)
from 2f6f43232eb739d1ccb4c78f58c4bdb6bca62fd4 (commit)
commit b82590bc597767f1d45d54497e59d60b530bbb6c
Author: Christian Dywan <christian at twotoasts.de>
Date: Sun May 30 21:11:17 2010 +0200
Implement the basics of a PostlerComposer
postler/postler-composer.vala | 170 +++++++++++++++++++++++++++++++++++++++++
postler/postler-reader.vala | 15 +++-
2 files changed, 183 insertions(+), 2 deletions(-)
diff --git a/postler/postler-composer.vala b/postler/postler-composer.vala
new file mode 100644
index 0000000..fb7d4d2
--- /dev/null
+++ b/postler/postler-composer.vala
@@ -0,0 +1,170 @@
+/*
+ Copyright (C) 2010 Christian Dywan <christian at twotoasts.de>
+
+ This library 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.
+
+ See the file COPYING for the full license text.
+*/
+
+const string GETTEXT_PACKAGE_COMPOSER = Config.GETTEXT_PACKAGE;
+
+public class Postler.Composer : Gtk.Window {
+ Gtk.UIManager ui;
+ Gtk.ActionGroup actions;
+
+ Gtk.VBox shelf;
+ Gtk.Toolbar toolbar;
+ Postler.Content content;
+
+ const string ui_markup = """
+ <ui>
+ <menubar>
+ <menu action="Mail">
+ <menuitem action="MessageSend"/>
+ <separator/>
+ <menuitem action="MessageSave"/>
+ <separator/>
+ <menuitem action="FileAttach"/>
+ <separator/>
+ <menuitem action="Close"/>
+ </menu>
+ <menu action="Edit">
+ <menuitem action="InsertEmoticonGrin"/>
+ <menuitem action="InsertEmoticonWink"/>
+ <menuitem action="InsertEmoticonSad"/>
+ <separator/>
+ <menuitem action="AddressBook"/>
+ <separator/>
+ <menuitem action="Preferences"/>
+ </menu>
+ </menubar>
+ <toolbar>
+ <toolitem action="MessageSend"/>
+ <toolitem action="MessageSave"/>
+ <separator/>
+ <toolitem action="FileAttach"/>
+ <separator/>
+ <toolitem action="AddressBook"/>
+ <toolitem action="Preferences"/>
+ <separator expand="true"/>
+ <toolitem action="InsertEmoticonGrin"/>
+ <toolitem action="InsertEmoticonWink"/>
+ <toolitem action="InsertEmoticonSad"/>
+ </toolbar>
+ </ui>
+ """;
+
+ void action_mail_send () {
+ /* TODO */
+ }
+
+ void action_preferences () {
+ /* TODO */
+ }
+
+ void action_close () {
+ destroy ();
+ }
+
+ const Gtk.ActionEntry[] action_entries = {
+ { "Mail", null, N_("_Mail") },
+ { "MessageSend", STOCK_MAIL_SEND, null, "<Ctrl>Return",
+ N_("Send the message"), action_mail_send },
+ { "MessageSave", Gtk.STOCK_SAVE, N_("Save as _Draft"), "<Ctrl>s",
+ N_("Save message as draft"), null },
+ { "FileAttach", STOCK_MAIL_ATTACHMENT, N_("_Attach File"), "",
+ N_("Attach a file to the message"), null },
+ { "Close", Gtk.STOCK_CLOSE, null, "<Ctrl>w",
+ N_("Close the window"), action_close },
+ { "Edit", null, N_("_Edit") },
+ { "AddressBook", STOCK_ADDRESSBOOK, null, "<Ctrl><Shift>a",
+ N_("Open the addressbook"), null },
+ { "Preferences", Gtk.STOCK_PREFERENCES, null, "<Ctrl><Alt>p",
+ N_("Configure the application preferences"), action_preferences },
+ { "InsertEmoticonGrin", STOCK_FACE_GRIN, N_("Insert _Grinning Face"), "",
+ N_("Insert a grinning face"), null },
+ { "InsertEmoticonWink", STOCK_FACE_WINK, N_("Insert _Winking Face"), "",
+ N_("Insert a winking face"), null },
+ { "InsertEmoticonSad", STOCK_FACE_SAD, N_("Insert _Sad Face"), "",
+ N_("Insert a sad face"), null }
+ };
+
+ public Composer () {
+ GLib.Object (icon_name: STOCK_MAIL_MESSAGE_NEW,
+ title: GLib.Environment.get_application_name ());
+
+ var screen = get_screen ();
+ double window_width = screen.get_width () / 1.7;
+ double window_height = screen.get_height () / 1.7;
+ set_default_size ((int)window_width, (int)window_height);
+
+ ui = new Gtk.UIManager ();
+ actions = new Gtk.ActionGroup ("Composer");
+ actions.set_translation_domain (Config.GETTEXT_PACKAGE);
+ actions.add_actions (action_entries, this);
+ ui.insert_action_group (actions, 0);
+ try {
+ ui.add_ui_from_string (ui_markup, -1);
+ add_accel_group (ui.get_accel_group ());
+ }
+ catch (Error error) {
+ GLib.error (_("Failed to create window: %s"), error.message);
+ }
+
+ shelf = new Gtk.VBox (false, 0);
+ add (shelf);
+ var menubar = ui.get_widget ("/menubar");
+ /* The menubar is nice for globalmenu, but otherwise redundant */
+ menubar.set_no_show_all (true);
+ shelf.pack_start (menubar, false, false, 0);
+ toolbar = ui.get_widget ("/toolbar") as Gtk.Toolbar;
+ actions.get_action ("MessageSend").is_important = true;
+ shelf.pack_start (toolbar, false, false, 0);
+ var sizegroup = new Gtk.SizeGroup (Gtk.SizeGroupMode.HORIZONTAL);
+ var box = new Gtk.HBox (false, 0);
+ shelf.pack_start (box, false, false, 4);
+ var label = new Gtk.Label.with_mnemonic (_("_From:"));
+ box.pack_start (label, false, false, 4);
+ sizegroup.add_widget (label);
+ var entry_from = new Gtk.Entry ();
+ box.pack_start (entry_from, true, true, 4);
+ box = new Gtk.HBox (false, 0);
+ shelf.pack_start (box, false, false, 4);
+ label = new Gtk.Label.with_mnemonic (_("_To:"));
+ box.pack_start (label, false, false, 4);
+ sizegroup.add_widget (label);
+ var entry_to = new Gtk.Entry ();
+ box.pack_start (entry_to, true, true, 4);
+ box = new Gtk.HBox (false, 0);
+ shelf.pack_start (box, false, false, 4);
+ label = new Gtk.Label.with_mnemonic (_("_Copy:"));
+ box.pack_start (label, false, false, 4);
+ sizegroup.add_widget (label);
+ var entry_copy = new Gtk.Entry ();
+ box.pack_start (entry_copy, true, true, 4);
+ box = new Gtk.HBox (false, 0);
+ shelf.pack_start (box, false, false, 4);
+ label = new Gtk.Label.with_mnemonic (_("_Subject:"));
+ box.pack_start (label, false, false, 4);
+ sizegroup.add_widget (label);
+ var entry_subject = new Gtk.Entry ();
+ box.pack_start (entry_subject, true, true, 4);
+ content = new Postler.Content ();
+ var scrolled = new Postler.ScrolledWindow (content);
+ shelf.pack_start (scrolled, true, true, 0);
+ shelf.show_all ();
+
+ entry_from.grab_focus ();
+
+ content.editable = true;
+ var settings = content.settings;
+ if (settings.get_class ().find_property ("enable-spell-checking") != null)
+ settings.set ("enable-spell-checking", true, null);
+ content.clear ();
+ }
+}
+
+
diff --git a/postler/postler-reader.vala b/postler/postler-reader.vala
index b85547f..c8fd800 100644
--- a/postler/postler-reader.vala
+++ b/postler/postler-reader.vala
@@ -61,7 +61,7 @@ public class Postler.Reader {
string title = null;
/* TODO: Implement "tray" */
- /* TODO: Implement "compose", "reply", "reply-all", "forward" */
+ /* TODO: Implement "reply", "reply-all", "forward" */
if (module == "content" || module == "source") {
instance = new Postler.Content ();
icon_name = "emblem-mail" /* FIXME */;
@@ -74,9 +74,20 @@ public class Postler.Reader {
title = content.subject;
}
}
+ else if (module == "compose") {
+ instance = new Postler.Composer ();
+ if (filenames != null && filenames[0] != null) {
+ Postler.Composer composer = (Postler.Composer)instance;
+ /* FIXME: add addresses or files */
+ }
+ instance.destroy.connect (Gtk.main_quit);
+ instance.show ();
+ Gtk.main ();
+ return 0;
+ }
else
GLib.error ("Unknown module \"%s\". Valid modules are: %s",
- module, "content source");
+ module, "content source compose");
/* FIXME: Escape to close window */
var window = new Gtk.Window (Gtk.WindowType.TOPLEVEL);
More information about the Xfce4-commits
mailing list