[gitg] Use GtkMenuButton
- From: Ignacio Casal Quinteiro <icq src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gitg] Use GtkMenuButton
- Date: Wed, 17 Oct 2012 12:02:04 +0000 (UTC)
commit d52237fc8bf97892d597894e3c30f88b7a26e893
Author: Ignacio Casal Quinteiro <icq gnome org>
Date: Wed Oct 17 14:01:49 2012 +0200
Use GtkMenuButton
gitg/gitg-window.vala | 58 ++-----------------------------------
gitg/resources/ui/gitg-window.ui | 7 +++-
2 files changed, 9 insertions(+), 56 deletions(-)
---
diff --git a/gitg/gitg-window.vala b/gitg/gitg-window.vala
index f77efc5..546e21f 100644
--- a/gitg/gitg-window.vala
+++ b/gitg/gitg-window.vala
@@ -29,7 +29,7 @@ public class Window : Gtk.ApplicationWindow, GitgExt.Application, Initable, Gtk.
private UIElements<GitgExt.View> d_views;
private UIElements<GitgExt.Panel> d_panels;
- private Gtk.Button d_config;
+ private Gtk.MenuButton d_config;
// Widgets
private Gtk.Toolbar d_toolbar_views;
@@ -71,62 +71,12 @@ public class Window : Gtk.ApplicationWindow, GitgExt.Application, Initable, Gtk.
d_frame_panel = builder.get_object("frame_panel") as Gtk.Frame;
d_navigation = builder.get_object("tree_view_navigation") as GitgExt.NavigationTreeView;
- d_config = builder.get_object("button_config") as Gtk.Button;
+ d_config = builder.get_object("button_config") as Gtk.MenuButton;
- d_config.popup_menu.connect(on_config_popup);
-
- d_config.button_press_event.connect((w, ev) => {
- popup_config(ev);
- return true;
- });
-
- base.parser_finished(builder);
- }
-
- private void popup_config(Gdk.EventButton? ev = null)
- {
var model = Resource.load_object<MenuModel>("ui/gitg-menus.ui", "win-menu");
- var menu = new Gtk.Menu.from_model(model);
-
- menu.deactivate.connect((w) => w.destroy());
-
- uint button;
- uint evtime;
-
- if (ev != null)
- {
- button = ev.button;
- evtime = ev.time;
- }
- else
- {
- button = 0;
- evtime = Gtk.get_current_event_time();
- }
-
- menu.attach_to_widget(d_config, null);
- menu.popup(null, null, position_config_popup, button, evtime);
- }
-
- private void position_config_popup(Gtk.Menu menu, out int x, out int y, out bool pushin)
- {
- d_config.translate_coordinates(this, 0, 0, out x, out y);
-
- int px;
- int py;
+ d_config.menu_model = model;
- get_window().get_origin(out px, out py);
-
- x += px - menu.get_allocated_width() + d_config.get_allocated_width();
- y += py + d_config.get_allocated_height();
-
- pushin = false;
- }
-
- private bool on_config_popup(Gtk.Widget widget)
- {
- popup_config();
- return true;
+ base.parser_finished(builder);
}
private void on_view_activated(UIElements elements,
diff --git a/gitg/resources/ui/gitg-window.ui b/gitg/resources/ui/gitg-window.ui
index 923d317..d37fbdb 100644
--- a/gitg/resources/ui/gitg-window.ui
+++ b/gitg/resources/ui/gitg-window.ui
@@ -58,16 +58,19 @@
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="margin_left">6</property>
<child>
- <object class="GtkButton" id="button_config">
+ <object class="GtkMenuButton" id="button_config">
+ <property name="use_action_appearance">False</property>
<property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="margin_left">6</property>
<property name="image">image_config</property>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
+ <property name="homogeneous">True</property>
</packing>
</child>
</object>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]