[Xfce4-commits] <postler:master> Change view menu button into an ordinary button
Christian Dywan
noreply at xfce.org
Fri Aug 13 02:56:02 CEST 2010
Updating branch refs/heads/master
to 15ad7bb06de1f6b120fb4123b1f8419e66ebfa4a (commit)
from 2b1a14a3704df66c12c434cc1e95ef8457bc136f (commit)
commit 15ad7bb06de1f6b120fb4123b1f8419e66ebfa4a
Author: Christian Dywan <christian at twotoasts.de>
Date: Sat Aug 7 16:01:12 2010 +0200
Change view menu button into an ordinary button
postler/postler-bureau.vala | 56 +++++++++++++++++++++++++--------------
postler/postler-menuaction.vala | 25 -----------------
2 files changed, 36 insertions(+), 45 deletions(-)
diff --git a/postler/postler-bureau.vala b/postler/postler-bureau.vala
index a63a4f6..123def1 100644
--- a/postler/postler-bureau.vala
+++ b/postler/postler-bureau.vala
@@ -49,8 +49,6 @@ public class Postler.Bureau : Gtk.Window {
<menuitem action="ViewSource"/>
<separator/>
<menuitem action="Search"/>
- <separator/>
- <menuitem action="Preferences"/>
</menu>
<menu action="Help">
<menuitem action="About"/>
@@ -70,18 +68,15 @@ public class Postler.Bureau : Gtk.Window {
<toolitem action="MessageArchive"/>
<toolitem action="MessageDelete"/>
<separator/>
- <toolitem action="View">
- <menu action="View">
- <menuitem action="HideRead"/>
- <separator/>
- <menuitem action="Fullscreen"/>
- <menuitem action="ViewSource"/>
- </menu>
- </toolitem>
- <separator/>
- <toolitem action="About"/>
+ <toolitem action="View"/>
<separator expand="true"/>
</toolbar>
+ <popup name="view">
+ <menuitem action="HideRead"/>
+ <separator/>
+ <menuitem action="Fullscreen"/>
+ <menuitem action="ViewSource"/>
+ </popup>
<toolbar name="search_options">
<toolitem action="SearchSubject"/>
<toolitem action="SearchSender"/>
@@ -253,6 +248,30 @@ public class Postler.Bureau : Gtk.Window {
folders.populate ();
}
+ 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_view (Gtk.Action action) {
+ var menu = ui.get_widget ("/view") 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 ());
+ }
+
void action_fullscreen () {
if ((window.get_state () & Gdk.WindowState.FULLSCREEN) == 0) {
toolbar.hide ();
@@ -282,10 +301,6 @@ public class Postler.Bureau : Gtk.Window {
} );
}
- void action_preferences () {
- /* TODO */
- }
-
void action_quit () {
Gtk.main_quit ();
}
@@ -335,14 +350,14 @@ public class Postler.Bureau : Gtk.Window {
N_("Search the selected folder"), action_search },
{ "SaveSearch", null, N_("Save Search"), "<Ctrl><Shift>s",
N_("Save the current search"), action_save_search },
+ { "View", Gtk.STOCK_INDEX, N_("_View"), "",
+ null, action_view },
{ "Fullscreen", Gtk.STOCK_FULLSCREEN, null, "F11",
N_("View the message in fullscreen"), action_fullscreen },
{ "ViewSource", null, N_("View _Source"), "<Ctrl><Alt>u",
N_("View the source of the message"), action_view_source },
{ "AccountNew", STOCK_ACCOUNT_NEW, null, "",
N_("Setup a new account"), action_account_new },
- { "Preferences", Gtk.STOCK_PREFERENCES, null, "<Ctrl><Alt>p",
- N_("Configure the application preferences"), action_preferences },
{ "Help", null, N_("_Help") },
{ "About", Gtk.STOCK_ABOUT, null, "",
N_("Show information about the program"), action_about }
@@ -381,8 +396,6 @@ public class Postler.Bureau : Gtk.Window {
actions.add_actions (action_entries, this);
actions.add_toggle_actions (toggle_entries, this);
actions.add_radio_actions (radio_entries, 0, action_search_options);
- actions.add_action (new Postler.MenuAction ("View",
- _("_View"), _("View"), Gtk.STOCK_PREFERENCES));
ui.insert_action_group (actions, 0);
try {
ui.add_ui_from_string (ui_markup, -1);
@@ -496,6 +509,9 @@ public class Postler.Bureau : Gtk.Window {
var button = new Gtk.Button.from_stock (STOCK_ACCOUNT_NEW);
button.clicked.connect ((button) => { action_account_new (); } );
viewer.dashboard.pack_start (button, false, false, 0);
+ button = new Gtk.Button.from_stock (Gtk.STOCK_ABOUT);
+ button.clicked.connect ((button) => { action_about (); } );
+ viewer.dashboard.pack_start (button, false, false, 0);
viewer.dashboard.show_all ();
folders.set_headers_visible (false);
diff --git a/postler/postler-menuaction.vala b/postler/postler-menuaction.vala
deleted file mode 100644
index 876e67d..0000000
--- a/postler/postler-menuaction.vala
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- 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.
-*/
-
-public class Postler.MenuAction : Gtk.Action {
- Gtk.ToolItem toolitem;
-
- public MenuAction (string? name, string? label, string? tooltip,
- string? stock_id) {
- Object (name: name, label: label, tooltip: tooltip, stock_id: stock_id);
- }
-
- override unowned Gtk.Widget create_tool_item () {
- toolitem = new Gtk.MenuToolButton.from_stock (stock_id);
- return toolitem;
- }
-}
-
More information about the Xfce4-commits
mailing list