[gnome-shell] shell-drawing: remove shell_draw_box_pointer()
- From: Dan Winship <danw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] shell-drawing: remove shell_draw_box_pointer()
- Date: Mon, 14 Feb 2011 14:39:35 +0000 (UTC)
commit 0c0e2cc68920e441c37f4b8dba4e6239b7fce93c
Author: Dan Winship <danw gnome org>
Date: Thu Feb 10 14:41:24 2011 -0500
shell-drawing: remove shell_draw_box_pointer()
This was originally done in C because it used cairo, but that can be
done from JS now. Since it was only used by altTab.js, move it there.
https://bugzilla.gnome.org/show_bug.cgi?id=642059
js/ui/altTab.js | 59 +++++++++++++++++++++++++++++++++++++++++---------
src/shell-drawing.c | 58 --------------------------------------------------
src/shell-drawing.h | 11 ---------
3 files changed, 48 insertions(+), 80 deletions(-)
---
diff --git a/js/ui/altTab.js b/js/ui/altTab.js
index 28d2b91..785263e 100644
--- a/js/ui/altTab.js
+++ b/js/ui/altTab.js
@@ -527,16 +527,11 @@ SwitcherList.prototype = {
this._leftArrow = new St.DrawingArea({ style_class: 'switcher-arrow',
pseudo_class: 'highlighted' });
this._leftArrow.connect('repaint', Lang.bind(this,
- function (area) {
- Shell.draw_box_pointer(area, Shell.PointerDirection.LEFT);
- }));
-
+ function() { _drawArrow(this._leftArrow, St.Side.LEFT); }));
this._rightArrow = new St.DrawingArea({ style_class: 'switcher-arrow',
pseudo_class: 'highlighted' });
this._rightArrow.connect('repaint', Lang.bind(this,
- function (area) {
- Shell.draw_box_pointer(area, Shell.PointerDirection.RIGHT);
- }));
+ function() { _drawArrow(this._rightArrow, St.Side.RIGHT); }));
this.actor.add_actor(this._leftArrow);
this.actor.add_actor(this._rightArrow);
@@ -992,10 +987,7 @@ AppSwitcher.prototype = {
let n = this._arrows.length;
let arrow = new St.DrawingArea({ style_class: 'switcher-arrow' });
- arrow.connect('repaint', Lang.bind(this,
- function (area) {
- Shell.draw_box_pointer(area, Shell.PointerDirection.DOWN);
- }));
+ arrow.connect('repaint', function() { _drawArrow(arrow, St.Side.BOTTOM); });
this._list.add_actor(arrow);
this._arrows.push(arrow);
@@ -1101,3 +1093,48 @@ ThumbnailList.prototype = {
this._thumbnailBins = new Array();
}
};
+
+function _drawArrow(area, side) {
+ let themeNode = area.get_theme_node();
+ let borderColor = new Clutter.Color();
+ themeNode.get_border_color(side, borderColor);
+ let bodyColor = new Clutter.Color();
+ themeNode.get_foreground_color(bodyColor);
+
+ let [width, height] = area.get_surface_size ();
+ let cr = area.get_context();
+
+ cr.setLineWidth(1.0);
+ Clutter.cairo_set_source_color(cr, borderColor);
+
+ switch (side) {
+ case St.Side.TOP:
+ cr.moveTo(0, height);
+ cr.lineTo(Math.floor(width * 0.5), 0);
+ cr.lineTo(width, height);
+ break;
+
+ case St.Side.BOTTOM:
+ cr.moveTo(width, 0);
+ cr.lineTo(Math.floor(width * 0.5), height);
+ cr.lineTo(0, 0);
+ break;
+
+ case St.Side.LEFT:
+ cr.moveTo(width, height);
+ cr.lineTo(0, Math.floor(height * 0.5));
+ cr.lineTo(width, 0);
+ break;
+
+ case St.Side.RIGHT:
+ cr.moveTo(0, 0);
+ cr.lineTo(width, Math.floor(height * 0.5));
+ cr.lineTo(0, height);
+ break;
+ }
+
+ cr.strokePreserve();
+
+ Clutter.cairo_set_source_color(cr, bodyColor);
+ cr.fill();
+}
diff --git a/src/shell-drawing.c b/src/shell-drawing.c
index aa32cea..885344f 100644
--- a/src/shell-drawing.c
+++ b/src/shell-drawing.c
@@ -48,61 +48,3 @@ shell_draw_clock (StDrawingArea *area,
yc + minute_radius * sin (angle));
cairo_stroke (cr);
}
-
-void
-shell_draw_box_pointer (StDrawingArea *area,
- ShellPointerDirection direction)
-{
- StThemeNode *theme_node;
- ClutterColor border_color, body_color;
- guint width, height;
- cairo_t *cr;
-
- theme_node = st_widget_get_theme_node (ST_WIDGET (area));
- st_theme_node_get_border_color (theme_node, (StSide)direction, &border_color);
- st_theme_node_get_foreground_color (theme_node, &body_color);
-
- st_drawing_area_get_surface_size (area, &width, &height);
-
- cr = st_drawing_area_get_context (area);
-
- cairo_set_line_width (cr, 1.0);
-
- clutter_cairo_set_source_color (cr, &border_color);
-
- switch (direction)
- {
- case SHELL_POINTER_UP:
- cairo_move_to (cr, 0, height);
- cairo_line_to (cr, floor (width * 0.5), 0);
- cairo_line_to (cr, width, height);
- break;
-
- case SHELL_POINTER_DOWN:
- cairo_move_to (cr, width, 0);
- cairo_line_to (cr, floor (width * 0.5), height);
- cairo_line_to (cr, 0, 0);
- break;
-
- case SHELL_POINTER_LEFT:
- cairo_move_to (cr, width, height);
- cairo_line_to (cr, 0, floor (height * 0.5));
- cairo_line_to (cr, width, 0);
- break;
-
- case SHELL_POINTER_RIGHT:
- cairo_move_to (cr, 0, 0);
- cairo_line_to (cr, width, floor (height * 0.5));
- cairo_line_to (cr, 0, height);
- break;
-
- default:
- g_assert_not_reached();
- }
-
- cairo_stroke_preserve (cr);
-
- clutter_cairo_set_source_color (cr, &body_color);
-
- cairo_fill (cr);
-}
diff --git a/src/shell-drawing.h b/src/shell-drawing.h
index f27aab7..2fd4dbf 100644
--- a/src/shell-drawing.h
+++ b/src/shell-drawing.h
@@ -8,17 +8,6 @@
G_BEGIN_DECLS
-/* Note that these correspond to StSide */
-typedef enum {
- SHELL_POINTER_UP,
- SHELL_POINTER_RIGHT,
- SHELL_POINTER_DOWN,
- SHELL_POINTER_LEFT
-} ShellPointerDirection;
-
-void shell_draw_box_pointer (StDrawingArea *area,
- ShellPointerDirection direction);
-
void shell_draw_clock (StDrawingArea *area,
int hour,
int minute);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]