[gitg/vala] Add menu conrfiguration button
- From: Jesse van den Kieboom <jessevdk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gitg/vala] Add menu conrfiguration button
- Date: Wed, 18 Jul 2012 15:39:55 +0000 (UTC)
commit e05c755a05cf96f21c1cc9f8fb58c1f8ad531a1f
Author: Jesse van den Kieboom <jesse vandenkieboom epfl ch>
Date: Wed Jul 18 17:38:38 2012 +0200
Add menu conrfiguration button
gitg/gitg-window.vala | 56 ++++++++++++++++++
gitg/resources/ui/gitg-window.ui | 118 ++++++++++++++------------------------
2 files changed, 100 insertions(+), 74 deletions(-)
---
diff --git a/gitg/gitg-window.vala b/gitg/gitg-window.vala
index 9cfb08b..f77efc5 100644
--- a/gitg/gitg-window.vala
+++ b/gitg/gitg-window.vala
@@ -29,6 +29,8 @@ 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;
+
// Widgets
private Gtk.Toolbar d_toolbar_views;
private Gtk.Toolbar d_toolbar_panels;
@@ -69,10 +71,64 @@ 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.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;
+
+ 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;
+ }
+
private void on_view_activated(UIElements elements,
GitgExt.UIElement element)
{
diff --git a/gitg/resources/ui/gitg-window.ui b/gitg/resources/ui/gitg-window.ui
index 8366527..dbec989 100644
--- a/gitg/resources/ui/gitg-window.ui
+++ b/gitg/resources/ui/gitg-window.ui
@@ -15,88 +15,37 @@
<child>
<object class="GtkToolbar" id="toolbar1">
<property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="hexpand">True</property>
+ <property name="toolbar_style">icons</property>
+ <property name="icon_size">2</property>
<style>
<class name="menubar"/>
</style>
<child>
<object class="GtkToolItem" id="toolbutton1">
+ <property name="use_action_appearance">False</property>
<property name="visible">True</property>
+ <property name="can_focus">False</property>
<style>
<class name="raised"/>
</style>
<child>
- <object class="GtkAlignment" id="alignment1">
+ <object class="GtkAlignment" id="entry-alignment">
<property name="visible">True</property>
- <property name="top_padding">5</property>
- <property name="bottom_padding">5</property>
- <property name="left_padding">10</property>
- <property name="right_padding">5</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">1</property>
+ <property name="xscale">0</property>
<child>
- <object class="GtkHBox" id="hbox1">
+ <object class="GtkEntry" id="search-entry">
+ <property name="width_request">210</property>
<property name="visible">True</property>
- <child>
- <object class="GtkAspectFrame" id="home-aspect-frame">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="xalign">0</property>
- <property name="ratio">1</property>
- <property name="shadow-type">none</property>
- <property name="obey-child">False</property>
- <child>
- <object class="GtkButton" id="home-button">
- <property name="use_action_appearance">False</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <property name="no_show_all">True</property>
- <property name="use_action_appearance">False</property>
- <property name="image">image1</property>
- <property name="use_underline">True</property>
- <child internal-child="accessible">
- <object class="AtkObject" id="home-button-atkobject">
- <property name="AtkObject::accessible-name" translatable="yes">All Repositories</property>
- </object>
- </child>
- </object>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkAlignment" id="entry-alignment">
- <property name="visible">True</property>
- <property name="xalign">1</property>
- <property name="xscale">0</property>
- <child>
- <object class="GtkBox" id="topright">
- <property name="visible">True</property>
- <property name="orientation">horizontal</property>
- <child>
- <object class="GtkEntry" id="search-entry">
- <property name="width_request">210</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="invisible_char">●</property>
- <property name="secondary-icon-name">edit-find-symbolic</property>
- <property name="secondary-icon-activatable">False</property>
- <property name="secondary-icon-sensitive">False</property>
- </object>
- </child>
- <child>
- <object class="GtkLockButton" id="lock-button">
- <property name="visible">False</property>
- <property name="no_show_all">True</property>
- </object>
- </child>
- </object>
- </child>
- </object>
- <packing>
- <property name="position">1</property>
- </packing>
- </child>
+ <property name="can_focus">True</property>
+ <property name="invisible_char">â</property>
+ <property name="invisible_char_set">True</property>
+ <property name="secondary_icon_name">edit-find-symbolic</property>
+ <property name="secondary_icon_activatable">False</property>
+ <property name="secondary_icon_sensitive">False</property>
</object>
</child>
</object>
@@ -107,12 +56,36 @@
<property name="homogeneous">True</property>
</packing>
</child>
+ <child>
+ <object class="GtkToolItem" id="toolbutton2">
+ <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">
+ <property name="visible">True</property>
+ <property name="image">image_config</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ </packing>
+ </child>
</object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">0</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
</child>
<child>
<object class="GtkPaned" id="paned_views">
<property name="visible">True</property>
<property name="can_focus">True</property>
+ <property name="hexpand">True</property>
<property name="vexpand">True</property>
<property name="position">200</property>
<property name="position_set">True</property>
@@ -256,13 +229,10 @@
</object>
</child>
</object>
- <object class="GtkImage" id="image1">
+ <object class="GtkImage" id="image_config">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="icon_name">view-grid-symbolic</property>
- <property name="use_fallback">True</property>
+ <property name="icon_name">preferences-system-symbolic</property>
<property name="pixel-size">16</property>
</object>
</interface>
-
-<!-- ex:set ts=2 et: -->
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]