[gnome-boxes] Start MenuBox, a widget for wizard selection source
- From: Marc-Andre Lureau <malureau src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-boxes] Start MenuBox, a widget for wizard selection source
- Date: Mon, 14 Nov 2011 19:00:32 +0000 (UTC)
commit 2bda08228a4a21f0f19c0e5a08fb2e04552b3792
Author: Marc-Andrà Lureau <marcandre lureau gmail com>
Date: Mon Nov 14 19:20:28 2011 +0100
Start MenuBox, a widget for wizard selection source
data/gtk-style.css | 13 +++++
src/Makefile.am | 1 +
src/menu-box.vala | 107 +++++++++++++++++++++++++++++++++++++++++++
src/mini-graph.vala | 2 +
vapi/upstream/gtk+-3.0.vapi | 64 +++++++++++++++++++------
5 files changed, 171 insertions(+), 16 deletions(-)
---
diff --git a/data/gtk-style.css b/data/gtk-style.css
index 71e628c..c59308c 100644
--- a/data/gtk-style.css
+++ b/data/gtk-style.css
@@ -132,3 +132,16 @@
border-radius: 2;
border-width: 0;
}
+
+BoxesMenuBox .menuitem {
+ background-color: @theme_base_color;
+ border-radius: 10;
+}
+
+BoxesMenuBox .menuitem:focused {
+ background-color: @theme_selected_bg_color;
+}
+
+BoxesMenuBox .menuitem:prelight {
+ background-color: shade (@theme_base_color, 1.1);
+}
diff --git a/src/Makefile.am b/src/Makefile.am
index 717df90..ac97cd5 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -41,6 +41,7 @@ gnome_boxes_SOURCES = \
installer-media.vala \
libvirt-machine.vala \
machine.vala \
+ menu-box.vala \
mini-graph.vala \
main.vala \
os-database.vala \
diff --git a/src/menu-box.vala b/src/menu-box.vala
new file mode 100644
index 0000000..d4d0280
--- /dev/null
+++ b/src/menu-box.vala
@@ -0,0 +1,107 @@
+// This file is part of GNOME Boxes. License: LGPLv2+
+
+private class Boxes.MenuBox: Gtk.Box {
+ public signal void selected (Gtk.Widget widget);
+
+ private class Child {
+ public Gtk.Widget widget;
+ public bool in_item;
+
+ public Child (Gtk.Widget widget) {
+ this.widget = widget;
+ }
+
+ public void update_state () {
+ var flags = widget.get_state_flags ();
+
+ flags = flags & ~(Gtk.StateFlags.PRELIGHT | Gtk.StateFlags.ACTIVE);
+ if (in_item)
+ flags |= Gtk.StateFlags.PRELIGHT;
+
+ widget.set_state_flags (flags, true);
+ }
+ }
+
+ private new int spacing;
+ private HashTable<Gtk.Widget, Child> children;
+ construct {
+ children = new HashTable<Gtk.Widget, Child> (GLib.direct_hash, GLib.direct_equal);
+ }
+
+ public MenuBox (Gtk.Orientation orientation, int spacing = 10) {
+ GLib.Object (orientation: orientation);
+ this.spacing = spacing;
+ }
+
+ public override void remove (Gtk.Widget widget) {
+ children.remove (widget);
+ base.remove (widget);
+ }
+
+ public override void add (Gtk.Widget widget) {
+ var eventbox = new Gtk.EventBox ();
+ eventbox.get_style_context ().add_class ("menuitem");
+ eventbox.visible_window = false;
+ eventbox.can_focus = true;
+
+ var child = new Child (eventbox);
+ children.insert (eventbox, child);
+
+ eventbox.enter_notify_event.connect (() => {
+ child.in_item = true;
+ child.update_state ();
+ return true;
+ });
+
+ eventbox.leave_notify_event.connect (() => {
+ child.in_item = false;
+ child.update_state ();
+ return true;
+ });
+ eventbox.button_press_event.connect (() => {
+ eventbox.grab_focus ();
+ selected (widget);
+ return true;
+ });
+
+ var alignment = new Gtk.Alignment (0.0f, 0.0f, 1.0f, 1.0f);
+ alignment.add (widget);
+ alignment.margin_top = 10;
+ alignment.margin_bottom = 10;
+ eventbox.add (alignment);
+ base.add (eventbox);
+ }
+
+ public override bool draw (Cairo.Context cr) {
+ foreach (var child in get_children ()) {
+ int position = 0;
+ Gtk.Allocation allocation;
+ child_get (child, "position", ref position);
+ bool last = get_children ().length () == (position + 1);
+
+ child.get_allocation (out allocation);
+
+ var ctxt = child.get_style_context ();
+ Gtk.JunctionSides junction = 0;
+
+ if (orientation == Gtk.Orientation.VERTICAL) {
+ if (!last)
+ junction |= Gtk.JunctionSides.BOTTOM;
+ if (position != 0)
+ junction |= Gtk.JunctionSides.TOP;
+ } else {
+ if (!last)
+ junction |= Gtk.JunctionSides.RIGHT;
+ if (position != 0)
+ junction |= Gtk.JunctionSides.LEFT;
+ }
+
+ ctxt.set_state (child.get_state_flags ());
+ ctxt.set_junction_sides (junction);
+ ctxt.render_background (cr, allocation.x, allocation.y,
+ allocation.width, allocation.height);
+ }
+
+ return base.draw (cr);
+ }
+}
diff --git a/src/mini-graph.vala b/src/mini-graph.vala
index c84664e..ec285ec 100644
--- a/src/mini-graph.vala
+++ b/src/mini-graph.vala
@@ -1,3 +1,5 @@
+// This file is part of GNOME Boxes. License: LGPLv2+
+
private class Boxes.MiniGraph: Gtk.DrawingArea {
private double[] _points;
public double[] points { get { return _points; }
diff --git a/vapi/upstream/gtk+-3.0.vapi b/vapi/upstream/gtk+-3.0.vapi
index 89468f2..c6cfca8 100644
--- a/vapi/upstream/gtk+-3.0.vapi
+++ b/vapi/upstream/gtk+-3.0.vapi
@@ -1,4 +1,4 @@
-/* gtk+-3.0.vapi generated by vapigen, do not modify. */
+/* gtk+-3.0.vapi generated by lt-vapigen, do not modify. */
[CCode (gir_namespace = "Gtk", gir_version = "3.0")]
namespace Gtk {
@@ -482,7 +482,7 @@ namespace Gtk {
public class Alignment : Gtk.Bin, Atk.Implementor, Gtk.Buildable {
[CCode (has_construct_function = false, type = "GtkWidget*")]
public Alignment (float xalign, float yalign, float xscale, float yscale);
- public void get_padding (out uint? padding_top, out uint? padding_bottom, out uint? padding_left, out uint? padding_right);
+ public void get_padding (out uint padding_top, out uint padding_bottom, out uint padding_left, out uint padding_right);
public void @set (float xalign, float yalign, float xscale, float yscale);
public void set_padding (uint padding_top, uint padding_bottom, uint padding_left, uint padding_right);
[NoAccessorMethod]
@@ -921,18 +921,18 @@ namespace Gtk {
[CCode (has_construct_function = false)]
protected CellRenderer ();
public virtual bool activate (Gdk.Event event, Gtk.Widget widget, string path, Gdk.Rectangle background_area, Gdk.Rectangle cell_area, Gtk.CellRendererState flags);
- public virtual void get_aligned_area (Gtk.Widget widget, Gtk.CellRendererState flags, Gdk.Rectangle cell_area, out Gdk.Rectangle? aligned_area);
- public void get_alignment (out float? xalign, out float? yalign);
- public void get_fixed_size (out int? width, out int? height);
- public void get_padding (out int? xpad, out int? ypad);
- public virtual void get_preferred_height (Gtk.Widget widget, out int? minimum_size, out int? natural_size);
- public virtual void get_preferred_height_for_width (Gtk.Widget widget, int width, out int? minimum_height, out int? natural_height);
- public void get_preferred_size (Gtk.Widget widget, out Gtk.Requisition? minimum_size, out Gtk.Requisition? natural_size);
- public virtual void get_preferred_width (Gtk.Widget widget, out int? minimum_size, out int? natural_size);
- public virtual void get_preferred_width_for_height (Gtk.Widget widget, int height, out int? minimum_width, out int? natural_width);
+ public virtual Gdk.Rectangle get_aligned_area (Gtk.Widget widget, Gtk.CellRendererState flags, Gdk.Rectangle cell_area);
+ public void get_alignment (out float xalign, out float yalign);
+ public void get_fixed_size (out int width, out int height);
+ public void get_padding (out int xpad, out int ypad);
+ public virtual void get_preferred_height (Gtk.Widget widget, out int minimum_size, out int natural_size);
+ public virtual void get_preferred_height_for_width (Gtk.Widget widget, int width, out int minimum_height, out int natural_height);
+ public void get_preferred_size (Gtk.Widget widget, out Gtk.Requisition minimum_size, out Gtk.Requisition natural_size);
+ public virtual void get_preferred_width (Gtk.Widget widget, out int minimum_size, out int natural_size);
+ public virtual void get_preferred_width_for_height (Gtk.Widget widget, int height, out int minimum_width, out int natural_width);
public virtual Gtk.SizeRequestMode get_request_mode ();
public bool get_sensitive ();
- public abstract void get_size (Gtk.Widget widget, Gdk.Rectangle? cell_area, out int? x_offset, out int? y_offset, out int? width, out int? height);
+ public abstract void get_size (Gtk.Widget widget, Gdk.Rectangle? cell_area, out int x_offset, out int y_offset, out int width, out int height);
public Gtk.StateFlags get_state (Gtk.Widget widget, Gtk.CellRendererState cell_state);
public bool get_visible ();
public bool is_activatable ();
@@ -1512,7 +1512,7 @@ namespace Gtk {
[HasEmitter]
public virtual signal void remove (Gtk.Widget widget);
[HasEmitter]
- public virtual signal void set_focus_child (Gtk.Widget child);
+ public virtual signal void set_focus_child (Gtk.Widget? child);
}
[CCode (cheader_filename = "gtk/gtk.h")]
public class CssProvider : GLib.Object, Gtk.StyleProvider {
@@ -2768,8 +2768,8 @@ namespace Gtk {
public class Misc : Gtk.Widget, Atk.Implementor, Gtk.Buildable {
[CCode (has_construct_function = false)]
protected Misc ();
- public void get_alignment (out float? xalign, out float? yalign);
- public void get_padding (out int? xpad, out int? ypad);
+ public void get_alignment (out float xalign, out float yalign);
+ public void get_padding (out int xpad, out int ypad);
public void set_alignment (float xalign, float yalign);
public void set_padding (int xpad, int ypad);
[NoAccessorMethod]
@@ -4080,6 +4080,38 @@ namespace Gtk {
public void remove_provider (Gtk.StyleProvider provider);
public static void remove_provider_for_screen (Gdk.Screen screen, Gtk.StyleProvider provider);
public void remove_region (string region_name);
+ [CCode (cname = "gtk_render_activity")]
+ public void render_activity (Cairo.Context cr, double x, double y, double width, double height);
+ [CCode (cname = "gtk_render_arrow")]
+ public void render_arrow (Cairo.Context cr, double angle, double x, double y, double size);
+ [CCode (cname = "gtk_render_background")]
+ public void render_background (Cairo.Context cr, double x, double y, double width, double height);
+ [CCode (cname = "gtk_render_check")]
+ public void render_check (Cairo.Context cr, double x, double y, double width, double height);
+ [CCode (cname = "gtk_render_expander")]
+ public void render_expander (Cairo.Context cr, double x, double y, double width, double height);
+ [CCode (cname = "gtk_render_extension")]
+ public void render_extension (Cairo.Context cr, double x, double y, double width, double height, Gtk.PositionType gap_side);
+ [CCode (cname = "gtk_render_focus")]
+ public void render_focus (Cairo.Context cr, double x, double y, double width, double height);
+ [CCode (cname = "gtk_render_frame")]
+ public void render_frame (Cairo.Context cr, double x, double y, double width, double height);
+ [CCode (cname = "gtk_render_frame_gab")]
+ public void render_frame_gap (Cairo.Context cr, double x, double y, double width, double height, Gtk.PositionType gap_side, double xy0_gap, double xy1_gap);
+ [CCode (cname = "gtk_render_handle")]
+ public void render_handle (Cairo.Context cr, double x, double y, double width, double height);
+ [CCode (cname = "gtk_render_icon")]
+ public void render_icon (Cairo.Context cr, Gdk.Pixbuf pixbuf, double x, double y);
+ [CCode (cname = "gtk_render_icon_pixbuf")]
+ public unowned Gdk.Pixbuf render_icon_pixbuf (Gtk.IconSource source, Gtk.IconSize size);
+ [CCode (cname = "gtk_render_layout")]
+ public void render_layout (Cairo.Context cr, double x, double y, Pango.Layout layout);
+ [CCode (cname = "gtk_render_line")]
+ public void render_line (Cairo.Context cr, double x0, double y0, double x1, double y1);
+ [CCode (cname = "gtk_render_option")]
+ public void render_option (Cairo.Context cr, double x, double y, double width, double height);
+ [CCode (cname = "gtk_render_slider")]
+ public void render_slider (Cairo.Context cr, double x, double y, double width, double height, Gtk.Orientation orientation);
public static void reset_widgets (Gdk.Screen screen);
public void restore ();
public void save ();
@@ -4353,7 +4385,7 @@ namespace Gtk {
public virtual signal void insert_child_anchor (Gtk.TextIter iter, Gtk.TextChildAnchor anchor);
[HasEmitter]
public virtual signal void insert_pixbuf (Gtk.TextIter iter, Gdk.Pixbuf pixbuf);
- public virtual signal void insert_text (Gtk.TextIter pos, string new_text, int new_text_length);
+ public virtual signal void insert_text (ref Gtk.TextIter pos, string new_text, int new_text_length);
public virtual signal void mark_deleted (Gtk.TextMark mark);
public virtual signal void mark_set (Gtk.TextIter location, Gtk.TextMark mark);
public virtual signal void modified_changed ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]