[Xfce4-commits] <postler:master> Insert smileys from a popup menu
Christian Dywan
noreply at xfce.org
Fri Jan 14 23:32:01 CET 2011
Updating branch refs/heads/master
to d13d60da7ec49da88c71f9b9dc42d880ab35eab5 (commit)
from 5fc54e4326ef3f5fdd78734e136548691de52081 (commit)
commit d13d60da7ec49da88c71f9b9dc42d880ab35eab5
Author: Sergio Spinatelli <spinatelli.sergio at gmail.com>
Date: Fri Jan 14 23:22:52 2011 +0100
Insert smileys from a popup menu
Fixes: https://bugs.launchpad.net/postler/+bug/690509
postler/postler-composer.vala | 49 ++++++++++++++++++++++++++++++++++++++--
1 files changed, 46 insertions(+), 3 deletions(-)
diff --git a/postler/postler-composer.vala b/postler/postler-composer.vala
index a009ece..c029d6f 100644
--- a/postler/postler-composer.vala
+++ b/postler/postler-composer.vala
@@ -60,10 +60,12 @@ public class Postler.Composer : Gtk.Window {
<toolitem action="AddressBook"/>
<separator expand="true"/>
<toolitem action="Quote"/>
- <toolitem action="InsertEmoticonSmileBig"/>
- <toolitem action="InsertEmoticonWink"/>
- <toolitem action="InsertEmoticonSad"/>
</toolbar>
+ <popup name="emoticons">
+ <menuitem action="InsertEmoticonSmileBig"/>
+ <menuitem action="InsertEmoticonWink"/>
+ <menuitem action="InsertEmoticonSad"/>
+ </popup>
</ui>
""";
@@ -328,6 +330,36 @@ public class Postler.Composer : Gtk.Window {
if (attachments.length == 0)
att_view.visible = false;
}
+
+ void action_emoticons (Gtk.Action action) {
+ var menu = ui.get_widget ("/emoticons") as Gtk.Menu;
+ if (menu.get_attach_widget () == null) {
+ var proxy = action.get_proxies ().nth_data (0);
+ menu.attach_to_widget (proxy, (widget, menu) => { });
+ }
+ menu.popup (null, null, button_menu_position, 1,
+ Gtk.get_current_event_time ());
+ menu.select_first (true);
+ menu.deactivate.connect (( menu_shell ) => {
+ (menu.attach_widget as Gtk.ToggleToolButton).active = false;
+ });
+ }
+
+ /* FIXME: Share this function */
+ void button_menu_position (Gtk.Menu menu, ref int x, ref int y, ref bool push_in) {
+ /* Position the menu right below the widget */
+ var widget = menu.get_attach_widget ();
+ Gtk.Allocation allocation = widget.allocation;
+ int widget_x, widget_y;
+ widget.window.get_position (out widget_x, out widget_y);
+ Gtk.Requisition requisition;
+ widget.size_request (out requisition);
+ int widget_height = requisition.height;
+ x = widget_x + allocation.x;
+ y = widget_y + allocation.y + widget_height;
+ push_in = true;
+ }
+
void action_insert_emoticon (Gtk.Action action) {
unowned string name = action.name;
string emoticon;
@@ -361,6 +393,7 @@ public class Postler.Composer : Gtk.Window {
N_("Open the addressbook"), action_address_book },
{ "Quote", Gtk.STOCK_INDENT, N_("_Quote the selected text"), "",
N_("Mark the selected text as a quote"), action_quote },
+ { "Emoticons", STOCK_FACE_SMILE_BIG, N_("Insert _Smiley"), "", null, action_emoticons },
{ "InsertEmoticonSmileBig", STOCK_FACE_SMILE_BIG, N_("Insert Big _Smile"), "",
N_("Insert a grinning face"), action_insert_emoticon },
{ "InsertEmoticonWink", STOCK_FACE_WINK, N_("Insert _Winking"), "",
@@ -446,6 +479,16 @@ public class Postler.Composer : Gtk.Window {
shelf.pack_start (menubar, false, false, 0);
toolbar = ui.get_widget ("/toolbar") as Gtk.Toolbar;
actions.get_action ("MessageSend").is_important = true;
+
+ var toolitem = new Gtk.ToggleToolButton.from_stock (STOCK_FACE_SMILE_BIG);
+ toolitem.label = _("Insert Smiley");
+ toolitem.tooltip_text = _("Insert a Smiley into the message");
+ actions.get_action ("Emoticons").connect_proxy (toolitem);
+ (toolitem as Gtk.ToggleToolButton).clicked.connect ((widget) => {
+ action_emoticons (actions.get_action ("Emoticons"));
+ });
+ toolbar.insert (toolitem, -1);
+
shelf.pack_start (toolbar, false, false, 0);
var sizegroup = new Gtk.SizeGroup (Gtk.SizeGroupMode.HORIZONTAL);
var box = new Gtk.HBox (false, 0);
More information about the Xfce4-commits
mailing list