aboutsummaryrefslogtreecommitdiffstats
path: root/widgets/shortcut-bar
diff options
context:
space:
mode:
authorDamon Chaplin <damon@helixcode.com>2000-02-21 01:52:35 +0800
committerDamon Chaplin <damon@src.gnome.org>2000-02-21 01:52:35 +0800
commit83ad2c75e3da0305514dedcd22f67a9d2a516002 (patch)
treecd204a9f36ebba58437ae311d7e4e8087882eef3 /widgets/shortcut-bar
parent113c276df87402803382f26ee6eb1994e2e9f4ff (diff)
downloadgsoc2013-evolution-83ad2c75e3da0305514dedcd22f67a9d2a516002.tar
gsoc2013-evolution-83ad2c75e3da0305514dedcd22f67a9d2a516002.tar.gz
gsoc2013-evolution-83ad2c75e3da0305514dedcd22f67a9d2a516002.tar.bz2
gsoc2013-evolution-83ad2c75e3da0305514dedcd22f67a9d2a516002.tar.lz
gsoc2013-evolution-83ad2c75e3da0305514dedcd22f67a9d2a516002.tar.xz
gsoc2013-evolution-83ad2c75e3da0305514dedcd22f67a9d2a516002.tar.zst
gsoc2013-evolution-83ad2c75e3da0305514dedcd22f67a9d2a516002.zip
added libetext.a and libeutil.a to test_shortcut_bar_LDADD, and got rid of
2000-02-20 Damon Chaplin <damon@helixcode.com> * widgets/shortcut-bar/Makefile.am: added libetext.a and libeutil.a to test_shortcut_bar_LDADD, and got rid of e-icon-bar-text-item.[hc]. I'll delete these soon. * widgets/shortcut-bar/e-icon-bar.c: changed to be a subclass of ECanvas and to use EText instead of EIconBarTextItem. Also set "width_set" & "height_set" of the GnomeCanvasPixbuf items so they work in the "Small Icon" view. * widgets/shortcut-bar/e-vscrolled-bar.c: use map/unmap instead of show/hide for the up & down buttons to avoid queueing resizes. Otherwise the scrolling starts off a bit jerky. * widgets/shortcut-bar/test-shortcut-bar.c: output a message when the main label is resized, just for info. * widgets/shortcut-bar/*.[hc]: updated my email address. svn path=/trunk/; revision=1867
Diffstat (limited to 'widgets/shortcut-bar')
-rw-r--r--widgets/shortcut-bar/Makefile.am4
-rw-r--r--widgets/shortcut-bar/e-clipped-label.c2
-rw-r--r--widgets/shortcut-bar/e-clipped-label.h2
-rw-r--r--widgets/shortcut-bar/e-group-bar.c2
-rw-r--r--widgets/shortcut-bar/e-group-bar.h2
-rw-r--r--widgets/shortcut-bar/e-icon-bar-bg-item.c2
-rw-r--r--widgets/shortcut-bar/e-icon-bar-bg-item.h2
-rw-r--r--widgets/shortcut-bar/e-icon-bar-text-item.c2
-rw-r--r--widgets/shortcut-bar/e-icon-bar-text-item.h2
-rw-r--r--widgets/shortcut-bar/e-icon-bar.c332
-rw-r--r--widgets/shortcut-bar/e-icon-bar.h26
-rw-r--r--widgets/shortcut-bar/e-shortcut-bar.c6
-rw-r--r--widgets/shortcut-bar/e-shortcut-bar.h2
-rw-r--r--widgets/shortcut-bar/e-vscrolled-bar.c48
-rw-r--r--widgets/shortcut-bar/e-vscrolled-bar.h2
-rw-r--r--widgets/shortcut-bar/test-shortcut-bar.c16
16 files changed, 289 insertions, 163 deletions
diff --git a/widgets/shortcut-bar/Makefile.am b/widgets/shortcut-bar/Makefile.am
index ac81f2e2e6..54e6af0f5f 100644
--- a/widgets/shortcut-bar/Makefile.am
+++ b/widgets/shortcut-bar/Makefile.am
@@ -13,8 +13,6 @@ libshortcut_bar_a_SOURCES = \
e-group-bar.h \
e-icon-bar-bg-item.c \
e-icon-bar-bg-item.h \
- e-icon-bar-text-item.c \
- e-icon-bar-text-item.h \
e-icon-bar.c \
e-icon-bar.h \
e-shortcut-bar.c \
@@ -27,6 +25,8 @@ test_shortcut_bar_SOURCES = \
test_shortcut_bar_LDADD = \
./libshortcut-bar.a \
+ ../e-text/libetext.a \
+ ../../e-util/libeutil.a \
$(EXTRA_GNOME_LIBS)
test_shortcut_bar_LDFLAGS = \
diff --git a/widgets/shortcut-bar/e-clipped-label.c b/widgets/shortcut-bar/e-clipped-label.c
index 0b595f6063..e6666ae451 100644
--- a/widgets/shortcut-bar/e-clipped-label.c
+++ b/widgets/shortcut-bar/e-clipped-label.c
@@ -2,7 +2,7 @@
/*
* Author :
- * Damon Chaplin <damon@gtk.org>
+ * Damon Chaplin <damon@helixcode.com>
*
* Copyright 1999, Helix Code, Inc.
*
diff --git a/widgets/shortcut-bar/e-clipped-label.h b/widgets/shortcut-bar/e-clipped-label.h
index b94d261c11..a21ceadeca 100644
--- a/widgets/shortcut-bar/e-clipped-label.h
+++ b/widgets/shortcut-bar/e-clipped-label.h
@@ -2,7 +2,7 @@
/*
* Author :
- * Damon Chaplin <damon@gtk.org>
+ * Damon Chaplin <damon@helixcode.com>
*
* Copyright 1999, Helix Code, Inc.
*
diff --git a/widgets/shortcut-bar/e-group-bar.c b/widgets/shortcut-bar/e-group-bar.c
index ac3a8d62ab..de6c0cbbaf 100644
--- a/widgets/shortcut-bar/e-group-bar.c
+++ b/widgets/shortcut-bar/e-group-bar.c
@@ -2,7 +2,7 @@
/*
* Author :
- * Damon Chaplin <damon@gtk.org>
+ * Damon Chaplin <damon@helixcode.com>
*
* Copyright 1999, Helix Code, Inc.
*
diff --git a/widgets/shortcut-bar/e-group-bar.h b/widgets/shortcut-bar/e-group-bar.h
index 9a6f83b461..5c55bb585e 100644
--- a/widgets/shortcut-bar/e-group-bar.h
+++ b/widgets/shortcut-bar/e-group-bar.h
@@ -2,7 +2,7 @@
/*
* Author :
- * Damon Chaplin <damon@gtk.org>
+ * Damon Chaplin <damon@helixcode.com>
*
* Copyright 1999, Helix Code, Inc.
*
diff --git a/widgets/shortcut-bar/e-icon-bar-bg-item.c b/widgets/shortcut-bar/e-icon-bar-bg-item.c
index 1bdb7a308d..01ac735d8f 100644
--- a/widgets/shortcut-bar/e-icon-bar-bg-item.c
+++ b/widgets/shortcut-bar/e-icon-bar-bg-item.c
@@ -2,7 +2,7 @@
/*
* Author :
- * Damon Chaplin <damon@gtk.org>
+ * Damon Chaplin <damon@helixcode.com>
*
* Copyright 1999, Helix Code, Inc.
*
diff --git a/widgets/shortcut-bar/e-icon-bar-bg-item.h b/widgets/shortcut-bar/e-icon-bar-bg-item.h
index ae25e987d7..f8fa14f299 100644
--- a/widgets/shortcut-bar/e-icon-bar-bg-item.h
+++ b/widgets/shortcut-bar/e-icon-bar-bg-item.h
@@ -2,7 +2,7 @@
/*
* Author :
- * Damon Chaplin <damon@gtk.org>
+ * Damon Chaplin <damon@helixcode.com>
*
* Copyright 1999, Helix Code, Inc.
*
diff --git a/widgets/shortcut-bar/e-icon-bar-text-item.c b/widgets/shortcut-bar/e-icon-bar-text-item.c
index 5548c630b3..21c4fd9580 100644
--- a/widgets/shortcut-bar/e-icon-bar-text-item.c
+++ b/widgets/shortcut-bar/e-icon-bar-text-item.c
@@ -2,7 +2,7 @@
/*
* Author :
- * Damon Chaplin <damon@gtk.org>
+ * Damon Chaplin <damon@helixcode.com>
*
* Copyright 1999, Helix Code, Inc.
*
diff --git a/widgets/shortcut-bar/e-icon-bar-text-item.h b/widgets/shortcut-bar/e-icon-bar-text-item.h
index 7c0380c87b..ef621a4454 100644
--- a/widgets/shortcut-bar/e-icon-bar-text-item.h
+++ b/widgets/shortcut-bar/e-icon-bar-text-item.h
@@ -2,7 +2,7 @@
/*
* Author :
- * Damon Chaplin <damon@gtk.org>
+ * Damon Chaplin <damon@helixcode.com>
*
* Copyright 1999, Helix Code, Inc.
*
diff --git a/widgets/shortcut-bar/e-icon-bar.c b/widgets/shortcut-bar/e-icon-bar.c
index 1c87453507..9a34892218 100644
--- a/widgets/shortcut-bar/e-icon-bar.c
+++ b/widgets/shortcut-bar/e-icon-bar.c
@@ -2,7 +2,7 @@
/*
* Author :
- * Damon Chaplin <damon@gtk.org>
+ * Damon Chaplin <damon@helixcode.com>
*
* Copyright 1999, Helix Code, Inc.
*
@@ -23,7 +23,7 @@
*/
/*
- * EIconBar is a subclass of GnomeCanvas for displaying a vertical column of
+ * EIconBar is a subclass of ECanvas for displaying a vertical column of
* icons and descriptions. It provides 2 views - large icons and small icons.
*/
@@ -32,7 +32,7 @@
#include <gdk-pixbuf/gnome-canvas-pixbuf.h>
#include "e-icon-bar.h"
#include "e-icon-bar-bg-item.h"
-#include "e-icon-bar-text-item.h"
+#include "../e-text/e-text.h"
/* These are the offsets of the icons & text in both views. Note that the
shadow around icons is drawn in the space between items (as is the
@@ -47,7 +47,7 @@
#define E_ICON_BAR_SMALL_ICON_WIDTH 24
#define E_ICON_BAR_SMALL_ICON_HEIGHT 24
#define E_ICON_BAR_SMALL_ICON_X 4
-#define E_ICON_BAR_SMALL_ICON_TEXT_X (E_ICON_BAR_SMALL_ICON_WIDTH + 4)
+#define E_ICON_BAR_SMALL_ICON_TEXT_X (E_ICON_BAR_SMALL_ICON_WIDTH + 6)
/* The space we leave at the top or bottom of the bar when position an item
while it is being edited. This is used since the EIconBar may be in a
@@ -80,8 +80,6 @@ static gint e_icon_bar_focus_in (GtkWidget *widget,
GdkEventFocus *event);
static gint e_icon_bar_focus_out (GtkWidget *widget,
GdkEventFocus *event);
-static gint e_icon_bar_key_event (GtkWidget *widget, GdkEventKey *event);
-
static gint e_icon_bar_drag_motion (GtkWidget *widget,
GdkDragContext *context,
gint x,
@@ -96,8 +94,8 @@ static gboolean e_icon_bar_timeout_handler (gpointer data);
static void e_icon_bar_recalc_common_positions (EIconBar *icon_bar);
static gint e_icon_bar_recalc_item_positions (EIconBar *icon_bar);
-static void e_icon_bar_on_text_height_changed (GnomeCanvasItem *text_item,
- EIconBar *icon_bar);
+static void e_icon_bar_on_text_resized (GnomeCanvasItem *text_item,
+ EIconBar *icon_bar);
static gint e_icon_bar_find_item (EIconBar *icon_bar,
GnomeCanvasItem *text_item);
static gboolean e_icon_bar_on_item_event (GnomeCanvasItem *item,
@@ -120,10 +118,10 @@ static gboolean e_icon_bar_small_icons_is_before (EIconBar *icon_bar,
EIconBarItem *item,
gint x,
gint y);
-static void e_icon_bar_on_text_item_editing_started (EIconBarTextItem *text_item,
- EIconBar *icon_bar);
-static void e_icon_bar_on_text_item_editing_stopped (EIconBarTextItem *text_item,
- EIconBar *icon_bar);
+static void e_icon_bar_on_editing_started (EIconBar *icon_bar,
+ GnomeCanvasItem *item);
+static void e_icon_bar_on_editing_stopped (EIconBar *icon_bar,
+ GnomeCanvasItem *item);
static void e_icon_bar_ensure_edited_item_visible (EIconBar *icon_bar);
static void e_icon_bar_update_highlight (EIconBar *icon_bar);
@@ -136,7 +134,7 @@ enum
static guint e_icon_bar_signals[LAST_SIGNAL] = {0};
-static GnomeCanvasClass *parent_class;
+static ECanvasClass *parent_class;
GtkType
@@ -156,8 +154,8 @@ e_icon_bar_get_type (void)
(GtkClassInitFunc) NULL
};
- parent_class = gtk_type_class (gnome_canvas_get_type ());
- e_icon_bar_type = gtk_type_unique (gnome_canvas_get_type (),
+ parent_class = gtk_type_class (e_canvas_get_type ());
+ e_icon_bar_type = gtk_type_unique (e_canvas_get_type (),
&e_icon_bar_info);
}
@@ -203,8 +201,6 @@ e_icon_bar_class_init (EIconBarClass *class)
widget_class->leave_notify_event = e_icon_bar_leave_notify_event;
widget_class->focus_in_event = e_icon_bar_focus_in;
widget_class->focus_out_event = e_icon_bar_focus_out;
- widget_class->key_press_event = e_icon_bar_key_event;
- widget_class->key_release_event = e_icon_bar_key_event;
widget_class->drag_motion = e_icon_bar_drag_motion;
widget_class->drag_leave = e_icon_bar_drag_leave;
@@ -215,11 +211,16 @@ e_icon_bar_class_init (EIconBarClass *class)
static void
e_icon_bar_init (EIconBar *icon_bar)
{
+ GdkColormap *colormap;
+ gboolean success[E_ICON_BAR_COLOR_LAST];
+ gint nfailed;
+
icon_bar->view_type = E_ICON_BAR_LARGE_ICONS;
icon_bar->items = g_array_new (FALSE, FALSE, sizeof (EIconBarItem));
icon_bar->pressed_item_num = -1;
icon_bar->mouse_over_item_num = -1;
icon_bar->editing_item_num = -1;
+ icon_bar->edit_rect_item = NULL;
icon_bar->in_drag = FALSE;
icon_bar->dragging_before_item_num = -1;
icon_bar->icon_x = 0;
@@ -235,6 +236,30 @@ e_icon_bar_init (EIconBar *icon_bar)
e_icon_bar_bg_item_get_type (),
"EIconBarBgItem::icon_bar", icon_bar,
NULL);
+
+ colormap = gtk_widget_get_colormap (GTK_WIDGET (icon_bar));
+
+ icon_bar->colors[E_ICON_BAR_COLOR_TEXT].red = 65535;
+ icon_bar->colors[E_ICON_BAR_COLOR_TEXT].green = 65535;
+ icon_bar->colors[E_ICON_BAR_COLOR_TEXT].blue = 65535;
+
+ icon_bar->colors[E_ICON_BAR_COLOR_EDITING_TEXT].red = 0;
+ icon_bar->colors[E_ICON_BAR_COLOR_EDITING_TEXT].green = 0;
+ icon_bar->colors[E_ICON_BAR_COLOR_EDITING_TEXT].blue = 0;
+
+ icon_bar->colors[E_ICON_BAR_COLOR_EDITING_RECT].red = 65535;
+ icon_bar->colors[E_ICON_BAR_COLOR_EDITING_RECT].green = 65535;
+ icon_bar->colors[E_ICON_BAR_COLOR_EDITING_RECT].blue = 65535;
+
+ icon_bar->colors[E_ICON_BAR_COLOR_EDITING_RECT_OUTLINE].red = 0;
+ icon_bar->colors[E_ICON_BAR_COLOR_EDITING_RECT_OUTLINE].green = 0;
+ icon_bar->colors[E_ICON_BAR_COLOR_EDITING_RECT_OUTLINE].blue = 0;
+
+ nfailed = gdk_colormap_alloc_colors (colormap, icon_bar->colors,
+ E_ICON_BAR_COLOR_LAST, FALSE,
+ TRUE, success);
+ if (nfailed)
+ g_warning ("Failed to allocate all colors");
}
@@ -250,7 +275,9 @@ e_icon_bar_new (void)
GtkWidget *icon_bar;
icon_bar = GTK_WIDGET (gtk_type_new (e_icon_bar_get_type ()));
+#if 0
GNOME_CANVAS(icon_bar)->aa = 1;
+#endif
return icon_bar;
}
@@ -278,7 +305,9 @@ e_icon_bar_size_allocate (GtkWidget *widget, GtkAllocation *allocation)
{
EIconBar *icon_bar;
gint canvas_width, canvas_height, height;
-
+#if 0
+ g_print ("In e_icon_bar_size_allocate\n");
+#endif
icon_bar = E_ICON_BAR (widget);
GTK_WIDGET_CLASS (parent_class)->size_allocate (widget, allocation);
@@ -341,19 +370,28 @@ static gint
e_icon_bar_recalc_item_positions (EIconBar *icon_bar)
{
EIconBarItem *item;
- gint y, item_num;
- gdouble x1, y1, x2, y2, xalign;
+ gint y, item_num, text_h;
+ gdouble x1, y1, x2, y2, text_x;
GtkJustification justify;
+ GtkAnchorType anchor;
gint max_lines;
+ GdkFont *font;
+ gboolean line_wrap;
if (icon_bar->view_type == E_ICON_BAR_LARGE_ICONS) {
- xalign = 0.5;
justify = GTK_JUSTIFY_CENTER;
+ anchor = GTK_ANCHOR_N;
max_lines = 2;
+ text_x = icon_bar->text_x + (icon_bar->text_w / 2);
+ line_wrap = TRUE;
} else {
- xalign = 0.0;
justify = GTK_JUSTIFY_LEFT;
+ anchor = GTK_ANCHOR_NW;
max_lines = 1;
+ text_x = icon_bar->text_x;
+ font = GTK_WIDGET (icon_bar)->style->font;
+ text_h = font->ascent + font->descent;
+ line_wrap = FALSE;
}
/* Now step through the items, setting the y positions. */
@@ -362,42 +400,42 @@ e_icon_bar_recalc_item_positions (EIconBar *icon_bar)
item = &g_array_index (icon_bar->items,
EIconBarItem, item_num);
- e_icon_bar_text_item_set_width (E_ICON_BAR_TEXT_ITEM (item->text),
- icon_bar->text_w);
-
- /* Get the text item's height. */
- gnome_canvas_item_get_bounds (item->text, &x1, &y1, &x2, &y2);
- item->text_width = x2 - x1;
- item->text_height = y2 - y1;
-
if (icon_bar->view_type == E_ICON_BAR_LARGE_ICONS) {
item->icon_y = y;
item->text_y = y + E_ICON_BAR_LARGE_ICON_TEXT_Y;
-
- item->item_height = E_ICON_BAR_LARGE_ICON_TEXT_Y
- + item->text_height;
} else {
- item->item_height = MAX (item->text_height, E_ICON_BAR_SMALL_ICON_HEIGHT);
+ item->text_height = text_h;
+ item->item_height = MAX (text_h, E_ICON_BAR_SMALL_ICON_HEIGHT);
item->icon_y = y + (item->item_height - E_ICON_BAR_SMALL_ICON_HEIGHT) / 2;
item->text_y = y + (item->item_height - item->text_height) / 2;
}
- e_icon_bar_text_item_setxy (E_ICON_BAR_TEXT_ITEM (item->text),
- icon_bar->text_x, item->text_y);
+ gnome_canvas_item_set (item->text,
+ "clip_width", (gdouble) (icon_bar->text_w),
+ "justification", justify,
+ "anchor", anchor,
+ "max_lines", max_lines,
+ "line_wrap", line_wrap,
+ "x", text_x,
+ "y", (gdouble) item->text_y,
+ NULL);
- /* We need to get the bounds again, in case it has moved. */
+ /* Get the text item's height. */
gnome_canvas_item_get_bounds (item->text, &x1, &y1, &x2, &y2);
item->text_x = x1;
+ item->text_width = x2 - x1;
+ item->text_height = y2 - y1;
- gnome_canvas_item_set (item->text,
- "EIconBarTextItem::xalign", xalign,
- "EIconBarTextItem::justify", justify,
- "EIconBarTextItem::max_lines", max_lines,
- NULL);
+ if (icon_bar->view_type == E_ICON_BAR_LARGE_ICONS) {
+ item->item_height = E_ICON_BAR_LARGE_ICON_TEXT_Y
+ + item->text_height;
+ }
gnome_canvas_item_set (item->image,
"GnomeCanvasPixbuf::x", (gdouble)icon_bar->icon_x,
"GnomeCanvasPixbuf::y", (gdouble)item->icon_y,
+ "GnomeCanvasPixbuf::width_set", TRUE,
+ "GnomeCanvasPixbuf::height_set", TRUE,
"GnomeCanvasPixbuf::width", (gdouble)icon_bar->icon_w,
"GnomeCanvasPixbuf::height", (gdouble)icon_bar->icon_h,
NULL);
@@ -453,39 +491,6 @@ e_icon_bar_focus_out (GtkWidget *widget,
}
-/* Key event handler for the canvas.
- FIXME: GnomeCanvas bug workaround - I needed to override this to stop the
- canvas ignoring key events from other windows. */
-static gint
-e_icon_bar_key_event (GtkWidget *widget, GdkEventKey *event)
-{
- GnomeCanvas *canvas;
-
- g_return_val_if_fail (widget != NULL, FALSE);
- g_return_val_if_fail (E_IS_ICON_BAR (widget), FALSE);
- g_return_val_if_fail (event != NULL, FALSE);
-
- canvas = GNOME_CANVAS (widget);
-
- if (event->window != canvas->layout.bin_window) {
- /* We change the window in the event struct so the canvas
- doesn't ignore the event. Note that windows are ref-counted
- in the event struct. */
- if (event->window)
- gdk_window_unref (event->window);
- event->window = canvas->layout.bin_window;
- gdk_window_ref (event->window);
- }
-
- /* These both call the same function at present, but we'll do it
- properly just in case that changes. */
- if (event->type == GDK_KEY_PRESS)
- return (*GTK_WIDGET_CLASS (parent_class)->key_press_event)(widget, event);
- else
- return (*GTK_WIDGET_CLASS (parent_class)->key_release_event)(widget, event);
-}
-
-
/**
* e_icon_bar_set_view_type:
* @icon_bar: An #EIconBar.
@@ -527,9 +532,12 @@ e_icon_bar_add_item (EIconBar *icon_bar,
gint position)
{
EIconBarItem item;
- gfloat xalign;
GtkJustification justify;
+ GtkAnchorType anchor;
gint max_lines, retval;
+ GtkStyle *style;
+ GdkFont *font;
+ gdouble text_x, clip_height;
g_return_val_if_fail (E_IS_ICON_BAR (icon_bar), -1);
g_return_val_if_fail (text != NULL, -1);
@@ -537,36 +545,45 @@ e_icon_bar_add_item (EIconBar *icon_bar,
g_return_val_if_fail (position <= (gint)icon_bar->items->len, -1);
if (icon_bar->view_type == E_ICON_BAR_LARGE_ICONS) {
- xalign = 0.5;
justify = GTK_JUSTIFY_CENTER;
+ anchor = GTK_ANCHOR_N;
max_lines = 2;
+ text_x = icon_bar->text_x + (icon_bar->text_w / 2);
} else {
- xalign = 0.0;
justify = GTK_JUSTIFY_LEFT;
+ anchor = GTK_ANCHOR_NW;
max_lines = 1;
+ text_x = icon_bar->text_x;
}
+ gtk_widget_ensure_style (GTK_WIDGET (icon_bar));
+ style = GTK_WIDGET (icon_bar)->style;
+ font = style->font;
+ clip_height = max_lines * (font->ascent + font->descent);
item.text = gnome_canvas_item_new (GNOME_CANVAS_GROUP (GNOME_CANVAS (icon_bar)->root),
- e_icon_bar_text_item_get_type (),
- "EIconBarTextItem::xalign", xalign,
- "EIconBarTextItem::justify", justify,
- "EIconBarTextItem::max_lines", max_lines,
+ e_text_get_type (),
+ "font_gdk", font,
+ "fill_color_gdk", &icon_bar->colors[E_ICON_BAR_COLOR_TEXT],
+ "use_ellipsis", TRUE,
+ "anchor", anchor,
+ "editable", TRUE,
+ "justification", justify,
+ "line_wrap", TRUE,
+ "max_lines", max_lines,
+ "x", text_x,
+ "y", (gdouble) 0,
+ "clip", TRUE,
+ "clip_width", (gdouble) (icon_bar->text_w),
+ "clip_height", clip_height,
+ "text", text,
NULL);
- e_icon_bar_text_item_configure (E_ICON_BAR_TEXT_ITEM (item.text),
- icon_bar->text_x, 0,
- icon_bar->text_w, NULL,
- text, FALSE);
- gtk_signal_connect (GTK_OBJECT (item.text), "height_changed",
- GTK_SIGNAL_FUNC (e_icon_bar_on_text_height_changed), icon_bar);
+
+ gtk_signal_connect (GTK_OBJECT (item.text), "resize",
+ GTK_SIGNAL_FUNC (e_icon_bar_on_text_resized),
+ icon_bar);
gtk_signal_connect (GTK_OBJECT (item.text), "event",
GTK_SIGNAL_FUNC (e_icon_bar_on_item_event),
icon_bar);
- gtk_signal_connect (GTK_OBJECT (item.text), "editing_started",
- GTK_SIGNAL_FUNC (e_icon_bar_on_text_item_editing_started),
- icon_bar);
- gtk_signal_connect (GTK_OBJECT (item.text), "editing_stopped",
- GTK_SIGNAL_FUNC (e_icon_bar_on_text_item_editing_stopped),
- icon_bar);
item.image = gnome_canvas_item_new (GNOME_CANVAS_GROUP (GNOME_CANVAS (icon_bar)->root),
gnome_canvas_pixbuf_get_type (),
@@ -686,7 +703,7 @@ e_icon_bar_get_item_image (EIconBar *icon_bar,
item = &g_array_index (icon_bar->items, EIconBarItem, item_num);
gtk_object_get (GTK_OBJECT (item->image),
- "GnomeCanvasPixbuf::pixbuf", image,
+ "GnomeCanvasPixbuf::pixbuf", &image,
NULL);
return image;
}
@@ -724,20 +741,26 @@ e_icon_bar_set_item_image (EIconBar *icon_bar,
* @item_num: The index of the item.
* @Returns: The text of the given item.
*
- * Returns the text of the given item.
+ * Returns the text of the given item. This should be freed when no longer
+ * needed.
**/
gchar*
e_icon_bar_get_item_text (EIconBar *icon_bar,
gint item_num)
{
EIconBarItem *item;
+ gchar *text;
g_return_val_if_fail (E_IS_ICON_BAR (icon_bar), NULL);
g_return_val_if_fail (item_num >= 0, NULL);
g_return_val_if_fail (item_num < icon_bar->items->len, NULL);
item = &g_array_index (icon_bar->items, EIconBarItem, item_num);
- return e_icon_bar_text_item_get_text (E_ICON_BAR_TEXT_ITEM (item->text));
+ gtk_object_get (GTK_OBJECT (item->text),
+ "EText::text", &text,
+ NULL);
+
+ return text;
}
@@ -761,8 +784,9 @@ e_icon_bar_set_item_text (EIconBar *icon_bar,
g_return_if_fail (item_num < icon_bar->items->len);
item = &g_array_index (icon_bar->items, EIconBarItem, item_num);
- e_icon_bar_text_item_set_text (E_ICON_BAR_TEXT_ITEM (item->text),
- text, FALSE);
+ gnome_canvas_item_set (item->text,
+ "EText::text", text,
+ NULL);
}
@@ -839,9 +863,12 @@ e_icon_bar_set_item_data_full (EIconBar *icon_bar,
static void
-e_icon_bar_on_text_height_changed (GnomeCanvasItem *text_item,
- EIconBar *icon_bar)
+e_icon_bar_on_text_resized (GnomeCanvasItem *text_item,
+ EIconBar *icon_bar)
{
+#if 0
+ g_print ("In e_icon_bar_on_text_resized\n");
+#endif
gtk_widget_queue_resize (GTK_WIDGET (icon_bar));
}
@@ -882,15 +909,31 @@ e_icon_bar_on_item_event (GnomeCanvasItem *item,
event->button.x,
event->button.y,
NULL);
- e_icon_bar_item_pressed (icon_bar, item_num, event);
- return TRUE;
+ /* If the item is not being edited, we handle the event and
+ stop the signal so the text editing isn't started. */
+ if (icon_bar->editing_item_num == -1
+ || icon_bar->editing_item_num != item_num) {
+ e_icon_bar_item_pressed (icon_bar, item_num, event);
+ gtk_signal_emit_stop_by_name (GTK_OBJECT (item),
+ "event");
+ return TRUE;
+ }
+ break;
case GDK_BUTTON_RELEASE:
item_num = e_icon_bar_find_item_at_position (icon_bar,
event->button.x,
event->button.y,
NULL);
- e_icon_bar_item_released (icon_bar, item_num, event);
- return TRUE;
+ /* If the item is not being edited, we handle the event and
+ stop the signal so the text editing isn't started. */
+ if (icon_bar->editing_item_num == -1
+ || icon_bar->editing_item_num != item_num) {
+ e_icon_bar_item_released (icon_bar, item_num, event);
+ gtk_signal_emit_stop_by_name (GTK_OBJECT (item),
+ "event");
+ return TRUE;
+ }
+ break;
case GDK_MOTION_NOTIFY:
item_num = e_icon_bar_find_item_at_position (icon_bar,
event->motion.x,
@@ -898,6 +941,13 @@ e_icon_bar_on_item_event (GnomeCanvasItem *item,
NULL);
e_icon_bar_item_motion (icon_bar, item_num, event);
return TRUE;
+ case GDK_FOCUS_CHANGE:
+ if (event->focus_change.in)
+ e_icon_bar_on_editing_started (icon_bar, item);
+ else
+ e_icon_bar_on_editing_stopped (icon_bar, item);
+
+ return FALSE;
default:
break;
}
@@ -911,23 +961,15 @@ e_icon_bar_item_pressed (EIconBar *icon_bar,
gint item_num,
GdkEvent *event)
{
- EIconBarItem *item;
gint button;
/* If we are editing an item, and a different item (or anywhere outside
an item) is clicked, stop the edit. If the item being edited is
clicked we just return, since the user may be selecting text. */
if (icon_bar->editing_item_num != -1) {
- if (icon_bar->editing_item_num == item_num) {
- item = &g_array_index (icon_bar->items, EIconBarItem,
- icon_bar->editing_item_num);
- if (!GTK_WIDGET_HAS_FOCUS (item->text->canvas)
- || item->text->canvas->focused_item != item->text)
- gnome_canvas_item_grab_focus (item->text);
- } else {
+ if (icon_bar->editing_item_num != item_num) {
e_icon_bar_stop_editing_item (icon_bar, TRUE);
}
-
return;
}
@@ -1203,8 +1245,7 @@ e_icon_bar_start_editing_item (EIconBar *icon_bar,
item = &g_array_index (icon_bar->items,
EIconBarItem, item_num);
-
- e_icon_bar_text_item_start_editing (E_ICON_BAR_TEXT_ITEM (item->text));
+ e_canvas_item_grab_focus (item->text);
}
@@ -1221,25 +1262,29 @@ e_icon_bar_stop_editing_item (EIconBar *icon_bar,
gboolean accept)
{
EIconBarItem *item;
+ GtkWidget *toplevel;
g_return_if_fail (E_IS_ICON_BAR (icon_bar));
if (icon_bar->editing_item_num != -1) {
item = &g_array_index (icon_bar->items, EIconBarItem,
icon_bar->editing_item_num);
- e_icon_bar_text_item_stop_editing (E_ICON_BAR_TEXT_ITEM (item->text), accept);
+
+ toplevel = gtk_widget_get_toplevel (GTK_WIDGET (icon_bar));
+ if (toplevel && GTK_IS_WINDOW (toplevel))
+ gtk_window_set_focus (GTK_WINDOW (toplevel), NULL);
}
}
static void
-e_icon_bar_on_text_item_editing_started (EIconBarTextItem *text_item,
- EIconBar *icon_bar)
+e_icon_bar_on_editing_started (EIconBar *icon_bar,
+ GnomeCanvasItem *item)
{
gint item_num;
+ gdouble x1, y1, x2, y2;
- item_num = e_icon_bar_find_item (icon_bar,
- GNOME_CANVAS_ITEM (text_item));
+ item_num = e_icon_bar_find_item (icon_bar, item);
g_return_if_fail (item_num != -1);
/* Turn off any highlighted item. */
@@ -1248,24 +1293,57 @@ e_icon_bar_on_text_item_editing_started (EIconBarTextItem *text_item,
icon_bar->editing_item_num = item_num;
e_icon_bar_ensure_edited_item_visible (icon_bar);
+
+ /* Set the fg & bg colors. */
+ gnome_canvas_item_set (item,
+ "fill_color_gdk", &icon_bar->colors[E_ICON_BAR_COLOR_EDITING_TEXT],
+ NULL);
+
+ /* Create the edit rect if necessary. */
+ if (!icon_bar->edit_rect_item) {
+ icon_bar->edit_rect_item =
+ gnome_canvas_item_new (GNOME_CANVAS_GROUP (GNOME_CANVAS (icon_bar)->root),
+ gnome_canvas_rect_get_type(),
+ "fill_color_gdk", &icon_bar->colors[E_ICON_BAR_COLOR_EDITING_RECT],
+ "outline_color_gdk", &icon_bar->colors[E_ICON_BAR_COLOR_EDITING_RECT_OUTLINE],
+ NULL);
+ }
+
+ gnome_canvas_item_get_bounds (item, &x1, &y1, &x2, &y2);
+ gnome_canvas_item_set (icon_bar->edit_rect_item,
+ "x1", x1 - 1,
+ "y1", y1 - 1,
+ "x2", x2 + 1,
+ "y2", y2 + 1,
+ NULL);
+ gnome_canvas_item_show (icon_bar->edit_rect_item);
+
+ /* Make sure the text item is on top. */
+ gnome_canvas_item_raise_to_top (item);
}
static void
-e_icon_bar_on_text_item_editing_stopped (EIconBarTextItem *text_item,
- EIconBar *icon_bar)
+e_icon_bar_on_editing_stopped (EIconBar *icon_bar,
+ GnomeCanvasItem *item)
{
gint item_num;
- item_num = e_icon_bar_find_item (icon_bar,
- GNOME_CANVAS_ITEM (text_item));
+ item_num = e_icon_bar_find_item (icon_bar, item);
g_return_if_fail (item_num != -1);
- e_icon_bar_text_item_select (text_item, FALSE);
-
icon_bar->editing_item_num = -1;
e_icon_bar_update_highlight (icon_bar);
+
+ /* Reset the fg & bg colors. */
+ gnome_canvas_item_set (item,
+ "fill_color_gdk", &icon_bar->colors[E_ICON_BAR_COLOR_TEXT],
+ NULL);
+
+ if (icon_bar->edit_rect_item) {
+ gnome_canvas_item_hide (icon_bar->edit_rect_item);
+ }
}
diff --git a/widgets/shortcut-bar/e-icon-bar.h b/widgets/shortcut-bar/e-icon-bar.h
index 65ab69f23f..61c5f4dacc 100644
--- a/widgets/shortcut-bar/e-icon-bar.h
+++ b/widgets/shortcut-bar/e-icon-bar.h
@@ -2,7 +2,7 @@
/*
* Author :
- * Damon Chaplin <damon@gtk.org>
+ * Damon Chaplin <damon@helixcode.com>
*
* Copyright 1999, Helix Code, Inc.
*
@@ -25,8 +25,8 @@
#define _E_ICON_BAR_H_
#include <gdk_imlib.h>
-#include <libgnomeui/gnome-canvas.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
+#include "../../e-util/e-canvas.h"
#ifdef __cplusplus
extern "C" {
@@ -70,6 +70,18 @@ typedef enum
} EIconBarViewType;
+/* These index our colors array. */
+typedef enum
+{
+ E_ICON_BAR_COLOR_TEXT,
+ E_ICON_BAR_COLOR_EDITING_TEXT,
+ E_ICON_BAR_COLOR_EDITING_RECT,
+ E_ICON_BAR_COLOR_EDITING_RECT_OUTLINE,
+
+ E_ICON_BAR_COLOR_LAST
+} EIconBarColors;
+
+
#define E_ICON_BAR(obj) GTK_CHECK_CAST (obj, e_icon_bar_get_type (), EIconBar)
#define E_ICON_BAR_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, e_icon_bar_get_type (), EIconBarClass)
#define E_IS_ICON_BAR(obj) GTK_CHECK_TYPE (obj, e_icon_bar_get_type ())
@@ -80,7 +92,7 @@ typedef struct _EIconBarClass EIconBarClass;
struct _EIconBar
{
- GnomeCanvas canvas;
+ ECanvas canvas;
/* This specifies if we are using large icons or small icons. */
EIconBarViewType view_type;
@@ -105,6 +117,9 @@ struct _EIconBar
/* This is the item that we are currently editing, or -1. */
gint editing_item_num;
+ /* This is a GnomeCanvasRect which is placed around the edited item. */
+ GnomeCanvasItem *edit_rect_item;
+
/* This is the index of the item which is being dragged, or -1.
If the drag results in a move it will be deleted. */
gint dragged_item_num;
@@ -126,11 +141,14 @@ struct _EIconBar
gint auto_scroll_timeout_id;
gint auto_scroll_delay;
gboolean scrolling_up;
+
+ /* Colors for drawing. */
+ GdkColor colors[E_ICON_BAR_COLOR_LAST];
};
struct _EIconBarClass
{
- GnomeCanvasClass parent_class;
+ ECanvasClass parent_class;
void (*selected_item) (EIconBar *icon_bar,
GdkEvent *event,
diff --git a/widgets/shortcut-bar/e-shortcut-bar.c b/widgets/shortcut-bar/e-shortcut-bar.c
index 842a8927f9..431b9c1934 100644
--- a/widgets/shortcut-bar/e-shortcut-bar.c
+++ b/widgets/shortcut-bar/e-shortcut-bar.c
@@ -2,7 +2,7 @@
/*
* Author :
- * Damon Chaplin <damon@gtk.org>
+ * Damon Chaplin <damon@helixcode.com>
*
* Copyright 1999, Helix Code, Inc.
*
@@ -388,9 +388,9 @@ e_shortcut_bar_item_dragged (EIconBar *icon_bar,
group_num = e_group_bar_get_group_num (E_GROUP_BAR (shortcut_bar),
GTK_WIDGET (icon_bar)->parent);
- /* FIXME: free somewhere - drag_end? */
+ /* FIXME: free both somewhere - drag_end? */
shortcut_bar->dragged_url = g_strdup (e_icon_bar_get_item_data (icon_bar, item_num));
- shortcut_bar->dragged_name = g_strdup (e_icon_bar_get_item_text (icon_bar, item_num));
+ shortcut_bar->dragged_name = e_icon_bar_get_item_text (icon_bar, item_num);
target_list = gtk_target_list_new (target_table, n_targets);
gtk_drag_begin (GTK_WIDGET (icon_bar), target_list,
diff --git a/widgets/shortcut-bar/e-shortcut-bar.h b/widgets/shortcut-bar/e-shortcut-bar.h
index 1bbdfb6754..ff7702f869 100644
--- a/widgets/shortcut-bar/e-shortcut-bar.h
+++ b/widgets/shortcut-bar/e-shortcut-bar.h
@@ -2,7 +2,7 @@
/*
* Author :
- * Damon Chaplin <damon@gtk.org>
+ * Damon Chaplin <damon@helixcode.com>
*
* Copyright 1999, Helix Code, Inc.
*
diff --git a/widgets/shortcut-bar/e-vscrolled-bar.c b/widgets/shortcut-bar/e-vscrolled-bar.c
index 5d5f0ab2e2..af23b38a21 100644
--- a/widgets/shortcut-bar/e-vscrolled-bar.c
+++ b/widgets/shortcut-bar/e-vscrolled-bar.c
@@ -2,7 +2,7 @@
/*
* Author :
- * Damon Chaplin <damon@gtk.org>
+ * Damon Chaplin <damon@helixcode.com>
*
* Copyright 1999, Helix Code, Inc.
*
@@ -149,6 +149,7 @@ e_vscrolled_bar_init (EVScrolledBar *vscrolled_bar)
gtk_misc_set_padding (GTK_MISC (arrow), 1, 1);
gtk_widget_show (arrow);
gtk_container_add (GTK_CONTAINER (vscrolled_bar->up_button), arrow);
+ gtk_widget_show (vscrolled_bar->up_button);
gtk_signal_connect_after (GTK_OBJECT (vscrolled_bar->up_button), "pressed", GTK_SIGNAL_FUNC (e_vscrolled_bar_button_pressed), vscrolled_bar);
gtk_signal_connect_after (GTK_OBJECT (vscrolled_bar->up_button), "released", GTK_SIGNAL_FUNC (e_vscrolled_bar_button_released), vscrolled_bar);
gtk_signal_connect (GTK_OBJECT (vscrolled_bar->up_button), "clicked", GTK_SIGNAL_FUNC (e_vscrolled_bar_button_clicked), vscrolled_bar);
@@ -162,6 +163,7 @@ e_vscrolled_bar_init (EVScrolledBar *vscrolled_bar)
gtk_misc_set_padding (GTK_MISC (arrow), 1, 1);
gtk_widget_show (arrow);
gtk_container_add (GTK_CONTAINER (vscrolled_bar->down_button), arrow);
+ gtk_widget_show (vscrolled_bar->down_button);
gtk_signal_connect_after (GTK_OBJECT (vscrolled_bar->down_button), "pressed", GTK_SIGNAL_FUNC (e_vscrolled_bar_button_pressed), vscrolled_bar);
gtk_signal_connect_after (GTK_OBJECT (vscrolled_bar->down_button), "released", GTK_SIGNAL_FUNC (e_vscrolled_bar_button_released), vscrolled_bar);
gtk_signal_connect (GTK_OBJECT (vscrolled_bar->down_button), "clicked", GTK_SIGNAL_FUNC (e_vscrolled_bar_button_clicked), vscrolled_bar);
@@ -233,6 +235,7 @@ static void
e_vscrolled_bar_map (GtkWidget *widget)
{
EVScrolledBar *vscrolled_bar;
+ GtkAdjustment *adjustment;
g_return_if_fail (widget != NULL);
g_return_if_fail (E_IS_VSCROLLED_BAR (widget));
@@ -242,12 +245,16 @@ e_vscrolled_bar_map (GtkWidget *widget)
/* chain parent class handler to map self and child */
GTK_WIDGET_CLASS (parent_class)->map (widget);
- if (GTK_WIDGET_VISIBLE (vscrolled_bar->up_button) &&
- !GTK_WIDGET_MAPPED (vscrolled_bar->up_button))
+ adjustment = vscrolled_bar->adjustment;
+
+ if (GTK_WIDGET_VISIBLE (vscrolled_bar->up_button)
+ && adjustment->value != adjustment->lower
+ && !GTK_WIDGET_MAPPED (vscrolled_bar->up_button))
gtk_widget_map (vscrolled_bar->up_button);
- if (GTK_WIDGET_VISIBLE (vscrolled_bar->down_button) &&
- !GTK_WIDGET_MAPPED (vscrolled_bar->down_button))
+ if (GTK_WIDGET_VISIBLE (vscrolled_bar->down_button)
+ && adjustment->value < adjustment->upper - adjustment->page_size
+ && !GTK_WIDGET_MAPPED (vscrolled_bar->down_button))
gtk_widget_map (vscrolled_bar->down_button);
}
@@ -382,11 +389,11 @@ e_vscrolled_bar_draw (GtkWidget *widget,
gtk_widget_intersect (bin->child, area, &child_area))
gtk_widget_draw (bin->child, &child_area);
- if (GTK_WIDGET_VISIBLE (vscrolled_bar->up_button) &&
+ if (GTK_WIDGET_DRAWABLE (vscrolled_bar->up_button) &&
gtk_widget_intersect (vscrolled_bar->up_button, area, &child_area))
gtk_widget_draw (vscrolled_bar->up_button, &child_area);
- if (GTK_WIDGET_VISIBLE (vscrolled_bar->down_button) &&
+ if (GTK_WIDGET_DRAWABLE (vscrolled_bar->down_button) &&
gtk_widget_intersect (vscrolled_bar->down_button, area, &child_area))
gtk_widget_draw (vscrolled_bar->down_button, &child_area);
}
@@ -546,21 +553,30 @@ e_vscrolled_bar_adjustment_changed (GtkAdjustment *adjustment,
g_return_if_fail (adjustment != NULL);
g_return_if_fail (data != NULL);
-
+#if 0
+ g_print ("Adjustment changed to: %g\n", adjustment->value);
+#endif
vscrolled_bar = E_VSCROLLED_BAR (data);
+ if (!GTK_WIDGET_MAPPED (vscrolled_bar))
+ return;
+
/* If the adjustment value is not 0, show the up button. */
- if (adjustment->value != 0)
- gtk_widget_show (vscrolled_bar->up_button);
- else
- gtk_widget_hide (vscrolled_bar->up_button);
+ if (adjustment->value != adjustment->lower) {
+ gtk_widget_map (vscrolled_bar->up_button);
+ gdk_window_raise (vscrolled_bar->up_button->window);
+ } else {
+ gtk_widget_unmap (vscrolled_bar->up_button);
+ }
/* If the adjustment value is less than the maximum value, show the
down button. */
- if (adjustment->value < adjustment->upper - adjustment->page_size)
- gtk_widget_show (vscrolled_bar->down_button);
- else
- gtk_widget_hide (vscrolled_bar->down_button);
+ if (adjustment->value < adjustment->upper - adjustment->page_size) {
+ gtk_widget_map (vscrolled_bar->down_button);
+ gdk_window_raise (vscrolled_bar->down_button->window);
+ } else {
+ gtk_widget_unmap (vscrolled_bar->down_button);
+ }
}
diff --git a/widgets/shortcut-bar/e-vscrolled-bar.h b/widgets/shortcut-bar/e-vscrolled-bar.h
index d3273e6685..0f4c8bfcec 100644
--- a/widgets/shortcut-bar/e-vscrolled-bar.h
+++ b/widgets/shortcut-bar/e-vscrolled-bar.h
@@ -2,7 +2,7 @@
/*
* Author :
- * Damon Chaplin <damon@gtk.org>
+ * Damon Chaplin <damon@helixcode.com>
*
* Copyright 1999, Helix Code, Inc.
*
diff --git a/widgets/shortcut-bar/test-shortcut-bar.c b/widgets/shortcut-bar/test-shortcut-bar.c
index a86ec2a772..2018d614d1 100644
--- a/widgets/shortcut-bar/test-shortcut-bar.c
+++ b/widgets/shortcut-bar/test-shortcut-bar.c
@@ -2,7 +2,7 @@
/*
* Author :
- * Damon Chaplin <damon@gtk.org>
+ * Damon Chaplin <damon@helixcode.com>
*
* Copyright 1999, Helix Code, Inc.
*
@@ -37,6 +37,9 @@ gchar *shortcut_types[] = {
GtkWidget *main_label;
+static void on_main_label_size_allocate (GtkWidget *widget,
+ GtkAllocation *allocation,
+ gpointer data);
static void quit (GtkWidget *window, GdkEvent *event, gpointer data);
static void add_test_groups (EShortcutBar *shortcut_bar);
static void add_test_group (EShortcutBar *shortcut_bar, gint i,
@@ -102,6 +105,9 @@ main (int argc, char *argv[])
main_label = gtk_label_new ("Main Application Window Goes Here");
gtk_paned_pack2 (GTK_PANED (hpaned), main_label, TRUE, TRUE);
gtk_widget_show (main_label);
+ gtk_signal_connect (GTK_OBJECT (main_label), "size_allocate",
+ GTK_SIGNAL_FUNC (on_main_label_size_allocate),
+ NULL);
gtk_widget_pop_visual ();
@@ -120,6 +126,14 @@ main (int argc, char *argv[])
static void
+on_main_label_size_allocate (GtkWidget *widget,
+ GtkAllocation *allocation,
+ gpointer data)
+{
+ g_print ("In on_main_label_size_allocate\n");
+}
+
+static void
quit (GtkWidget *window, GdkEvent *event, gpointer data)
{
gtk_widget_destroy (window);