aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJon Trowbridge <trow@ximian.com>2001-06-07 01:57:19 +0800
committerJon Trowbridge <trow@src.gnome.org>2001-06-07 01:57:19 +0800
commit35e7e4920112d6c1d4f73a82b7d1708522bd79fe (patch)
treee5d1334430db4a3ae346094a46af2280b4c3c5cf
parent5772c1180d10ac63904b57df5b2b3dc17d605b0d (diff)
downloadgsoc2013-evolution-35e7e4920112d6c1d4f73a82b7d1708522bd79fe.tar
gsoc2013-evolution-35e7e4920112d6c1d4f73a82b7d1708522bd79fe.tar.gz
gsoc2013-evolution-35e7e4920112d6c1d4f73a82b7d1708522bd79fe.tar.bz2
gsoc2013-evolution-35e7e4920112d6c1d4f73a82b7d1708522bd79fe.tar.lz
gsoc2013-evolution-35e7e4920112d6c1d4f73a82b7d1708522bd79fe.tar.xz
gsoc2013-evolution-35e7e4920112d6c1d4f73a82b7d1708522bd79fe.tar.zst
gsoc2013-evolution-35e7e4920112d6c1d4f73a82b7d1708522bd79fe.zip
Applied patch from Jacob Berkman to un-offset the completion popup and add
2001-06-06 Jon Trowbridge <trow@ximian.com> * gal/e-text/e-entry.c: * gal/e-text/e-completion-view.c: Applied patch from Jacob Berkman to un-offset the completion popup and add a border around it. I tweaked it slightly to make the border two pixels thick instead of one. (Which I like, but might annoy everyone else. We'll see.) svn path=/trunk/; revision=10133
-rw-r--r--widgets/text/e-completion-view.c140
-rw-r--r--widgets/text/e-completion-view.h2
-rw-r--r--widgets/text/e-entry.c10
3 files changed, 148 insertions, 4 deletions
diff --git a/widgets/text/e-completion-view.c b/widgets/text/e-completion-view.c
index 50f1c6b469..aac38ccec9 100644
--- a/widgets/text/e-completion-view.c
+++ b/widgets/text/e-completion-view.c
@@ -67,6 +67,131 @@ e_completion_view_local_key_press_handler (GtkWidget *w, GdkEventKey *ev)
return e_completion_view_key_press_handler (w, ev, w);
}
+static void
+e_completion_view_paint (GtkWidget *widget, GdkRectangle *area)
+{
+ gint i;
+
+ g_return_if_fail (widget != NULL);
+ g_return_if_fail (E_IS_COMPLETION_VIEW (widget));
+ g_return_if_fail (area != NULL);
+
+ if (!GTK_WIDGET_DRAWABLE (widget))
+ return;
+
+ for (i = 0; i < E_COMPLETION_VIEW (widget)->border_width; ++i) {
+
+ gdk_draw_rectangle (widget->window,
+ widget->style->black_gc,
+ FALSE, i, i,
+ widget->allocation.width-1-i,
+ widget->allocation.height-1-i);
+
+ }
+
+}
+
+static void
+e_completion_view_draw (GtkWidget *widget, GdkRectangle *area)
+{
+ GtkBin *bin;
+ GdkRectangle child_area;
+
+ g_return_if_fail (widget != NULL);
+ g_return_if_fail (E_IS_COMPLETION_VIEW (widget));
+ g_return_if_fail (area != NULL);
+
+ if (GTK_WIDGET_DRAWABLE (widget)) {
+ bin = GTK_BIN (widget);
+
+ e_completion_view_paint (widget, area);
+
+ if (bin->child && gtk_widget_intersect (bin->child, area, &child_area))
+ gtk_widget_draw (bin->child, &child_area);
+ }
+}
+
+static gint
+e_completion_view_expose_event (GtkWidget *widget, GdkEventExpose *event)
+{
+ GtkBin *bin;
+ GdkEventExpose child_event;
+
+ g_return_val_if_fail (widget != NULL, FALSE);
+ g_return_val_if_fail (E_IS_COMPLETION_VIEW (widget), FALSE);
+ g_return_val_if_fail (event != NULL, FALSE);
+
+ if (GTK_WIDGET_DRAWABLE (widget)) {
+ bin = GTK_BIN (widget);
+
+ e_completion_view_paint (widget, &event->area);
+
+ child_event = *event;
+ if (bin->child &&
+ GTK_WIDGET_NO_WINDOW (bin->child) &&
+ gtk_widget_intersect (bin->child, &event->area, &child_event.area))
+ gtk_widget_event (bin->child, (GdkEvent*) &child_event);
+ }
+
+ return FALSE;
+}
+
+static void
+e_completion_view_size_request (GtkWidget *widget, GtkRequisition *requisition)
+{
+ GtkBin *bin;
+
+ g_return_if_fail (widget != NULL);
+ g_return_if_fail (E_IS_COMPLETION_VIEW (widget));
+ g_return_if_fail (requisition != NULL);
+
+ bin = GTK_BIN (widget);
+
+ requisition->width = 2 * E_COMPLETION_VIEW (widget)->border_width;
+ requisition->height = 2 * E_COMPLETION_VIEW (widget)->border_width;
+
+ if (bin->child && GTK_WIDGET_VISIBLE (bin->child)) {
+ GtkRequisition child_requisition;
+
+ gtk_widget_size_request (bin->child, &child_requisition);
+
+ requisition->width += child_requisition.width;
+ requisition->height += child_requisition.height;
+ }
+}
+
+static void
+e_completion_view_size_allocate (GtkWidget *widget, GtkAllocation *allocation)
+{
+ GtkBin *bin;
+ GtkAllocation child_allocation;
+
+ g_return_if_fail (widget != NULL);
+ g_return_if_fail (E_IS_COMPLETION_VIEW (widget));
+ g_return_if_fail (allocation != NULL);
+
+ bin = GTK_BIN (widget);
+ widget->allocation = *allocation;
+
+ child_allocation.x = E_COMPLETION_VIEW (widget)->border_width;
+ child_allocation.width = MAX(0, (gint)allocation->width - child_allocation.x * 2);
+
+ child_allocation.y = E_COMPLETION_VIEW (widget)->border_width;
+ child_allocation.height = MAX (0, (gint)allocation->height - child_allocation.y * 2);
+
+ if (GTK_WIDGET_REALIZED (widget)) {
+ gdk_window_move_resize (widget->window,
+ allocation->x,
+ allocation->y,
+ allocation->width,
+ allocation->height);
+ }
+
+ if (bin->child) {
+ gtk_widget_size_allocate (bin->child, &child_allocation);
+ }
+}
+
GtkType
e_completion_view_get_type (void)
{
@@ -152,11 +277,16 @@ e_completion_view_class_init (ECompletionViewClass *klass)
object_class->destroy = e_completion_view_destroy;
widget_class->key_press_event = e_completion_view_local_key_press_handler;
+ widget_class->draw = e_completion_view_draw;
+ widget_class->expose_event = e_completion_view_expose_event;
+ widget_class->size_request = e_completion_view_size_request;
+ widget_class->size_allocate = e_completion_view_size_allocate;
}
static void
e_completion_view_init (ECompletionView *completion)
{
+ completion->border_width = 2;
}
static void
@@ -558,14 +688,20 @@ e_completion_view_construct (ECompletionView *cv, ECompletion *completion)
cv->table = e_table_scrolled_new (cv->model, NULL, simple_spec, NULL);
+ e_scroll_frame_set_shadow_type (E_SCROLL_FRAME (cv->table), GTK_SHADOW_NONE);
+ e_scroll_frame_set_scrollbar_spacing (E_SCROLL_FRAME (cv->table), 0);
e_scroll_frame_set_policy (E_SCROLL_FRAME (cv->table), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
+#if 0
frame = gtk_frame_new (NULL);
gtk_container_add (GTK_CONTAINER (cv), frame);
gtk_container_add (GTK_CONTAINER (frame), cv->table);
gtk_widget_show_all (frame);
-
+#else
+ gtk_container_add (GTK_CONTAINER (cv), cv->table);
+ gtk_widget_show_all (cv->table);
+#endif
gtk_signal_connect (GTK_OBJECT (e_completion_view_table (cv)),
"click",
GTK_SIGNAL_FUNC (table_click_cb),
@@ -677,7 +813,7 @@ e_completion_view_set_width (ECompletionView *cv, gint width)
lines = MIN (lines, drop_room);
/* We reduce the total height by a bit; in practice, this seems to work out well. */
- gtk_widget_set_usize (w, width, (gint) floor (line_height * lines * 0.97));
+ gtk_widget_set_usize (w, width, (gint) floor (line_height * (0.5 + (float)lines) * 0.97));
}
void
diff --git a/widgets/text/e-completion-view.h b/widgets/text/e-completion-view.h
index fc3a2598bf..ee18420fef 100644
--- a/widgets/text/e-completion-view.h
+++ b/widgets/text/e-completion-view.h
@@ -70,6 +70,8 @@ struct _ECompletionView {
gboolean editable;
gint selection;
+
+ gint border_width;
};
struct _ECompletionViewClass {
diff --git a/widgets/text/e-entry.c b/widgets/text/e-entry.c
index 022efa15f7..7d87b76587 100644
--- a/widgets/text/e-entry.c
+++ b/widgets/text/e-entry.c
@@ -49,6 +49,8 @@
#include "e-text.h"
#include "e-entry.h"
+#define MOVE_RIGHT_AND_UP 0
+
#define EVIL_POINTER_WARPING_HACK
#ifdef EVIL_POINTER_WARPING_HACK
@@ -150,7 +152,7 @@ canvas_size_allocate (GtkWidget *widget, GtkAllocation *alloc,
"clip_height", (double) (alloc->height),
NULL);
- if (entry->priv->draw_borders) {
+ if (!entry->priv->draw_borders) {
xthick = 0;
ythick = 0;
} else {
@@ -472,13 +474,17 @@ e_entry_show_popup (EEntry *entry, gboolean visible)
x = xo + dim->x;
y = yo + dim->height + dim->y;
+#if MOVE_RIGHT_AND_UP
/* Put our popup slightly to the right and up, to try to give a visual cue that this popup
is tied to this entry. Otherwise one-row popups can sort of "blend" with an entry
directly below. */
fudge = MAX (dim->height/10, 3); /* just in case we are using a really big font, etc. */
x += 2*fudge;
y -= fudge;
-
+#else
+ fudge = 1;
+ y -= fudge;
+#endif
gtk_widget_set_uposition (pop, x, y);
e_completion_view_set_width (E_COMPLETION_VIEW (entry->priv->completion_view), dim->width);