aboutsummaryrefslogtreecommitdiffstats
path: root/addressbook/gui
diff options
context:
space:
mode:
authorChris Toshok <toshok@ximian.com>2003-04-08 12:44:58 +0800
committerChris Toshok <toshok@src.gnome.org>2003-04-08 12:44:58 +0800
commitc5bab4bb067169afa5ef9ae2c0e2926f9c67c6a5 (patch)
tree4eed594a35869c0ec4cf5094cbb689c8cb40455e /addressbook/gui
parentfc5fc4dcf006ff720c73620c233a3655d479c05a (diff)
downloadgsoc2013-evolution-c5bab4bb067169afa5ef9ae2c0e2926f9c67c6a5.tar
gsoc2013-evolution-c5bab4bb067169afa5ef9ae2c0e2926f9c67c6a5.tar.gz
gsoc2013-evolution-c5bab4bb067169afa5ef9ae2c0e2926f9c67c6a5.tar.bz2
gsoc2013-evolution-c5bab4bb067169afa5ef9ae2c0e2926f9c67c6a5.tar.lz
gsoc2013-evolution-c5bab4bb067169afa5ef9ae2c0e2926f9c67c6a5.tar.xz
gsoc2013-evolution-c5bab4bb067169afa5ef9ae2c0e2926f9c67c6a5.tar.zst
gsoc2013-evolution-c5bab4bb067169afa5ef9ae2c0e2926f9c67c6a5.zip
[ fixes #7103 ] init style_set. and add the signal.
2003-04-07 Chris Toshok <toshok@ximian.com> [ fixes #7103 ] * gui/widgets/e-minicard-label.c (e_minicard_label_class_init): init style_set. and add the signal. (e_minicard_label_realize): include e_minicard_label_construct's code here, and call set_colors after we create the sub-items. (e_minicard_label_unrealize): indent, and remove dead code. (e_minicard_label_event): indent, and call set_colors instead of setting the colors manually. (set_colors): new function, set our colors based on the current style. (e_minicard_label_style_set): new function, just call set_colors. (e_minicard_label_new): e_minicard_label_construct doesn't exist anymore. * gui/widgets/e-minicard-label.h (struct _EMinicardLabelClass): add style_set signal. * gui/widgets/e-minicard.c (set_selected): little tweaks in the coloring. (e_minicard_unrealize): reindent, and remove some unused code. * gui/widgets/e-minicard-view-widget.h (struct _EMinicardViewWidget): add background. * gui/widgets/e-minicard-view-widget.c (e_minicard_view_widget_class_init): init widget_class->style_class. (e_minicard_view_widget_style_set): new function, just set the background's fill_color_gdk to base[GTK_STATE_NORMAL]. (e_minicard_view_widget_realize): store off the background canvas item so we can set the color later. svn path=/trunk/; revision=20742
Diffstat (limited to 'addressbook/gui')
-rw-r--r--addressbook/gui/widgets/e-minicard-label.c200
-rw-r--r--addressbook/gui/widgets/e-minicard-label.h2
-rw-r--r--addressbook/gui/widgets/e-minicard-view-widget.c25
-rw-r--r--addressbook/gui/widgets/e-minicard-view-widget.h1
-rw-r--r--addressbook/gui/widgets/e-minicard.c21
5 files changed, 152 insertions, 97 deletions
diff --git a/addressbook/gui/widgets/e-minicard-label.c b/addressbook/gui/widgets/e-minicard-label.c
index e541fc7982..b20f7dad5d 100644
--- a/addressbook/gui/widgets/e-minicard-label.c
+++ b/addressbook/gui/widgets/e-minicard-label.c
@@ -22,6 +22,7 @@
#include <config.h>
#include "e-minicard-label.h"
+#include "e-addressbook-marshal.h"
#include <gtk/gtksignal.h>
#include <libgnomecanvas/gnome-canvas-rect-ellipse.h>
@@ -40,9 +41,12 @@ static gboolean e_minicard_label_event (GnomeCanvasItem *item, GdkEvent *event);
static void e_minicard_label_realize (GnomeCanvasItem *item);
static void e_minicard_label_unrealize (GnomeCanvasItem *item);
static void e_minicard_label_reflow(GnomeCanvasItem *item, int flags);
+static void e_minicard_label_style_set (EMinicardLabel *label, GtkStyle *previous_style);
static void e_minicard_label_resize_children( EMinicardLabel *e_minicard_label );
+static void set_colors (EMinicardLabel *label);
+
static GnomeCanvasGroupClass *parent_class = NULL;
/* The arguments we take */
@@ -58,6 +62,13 @@ enum {
PROP_EDITABLE
};
+enum {
+ STYLE_SET,
+ LAST_SIGNAL
+};
+
+static guint e_minicard_label_signals [LAST_SIGNAL] = {0, };
+
GType
e_minicard_label_get_type (void)
{
@@ -91,6 +102,8 @@ e_minicard_label_class_init (EMinicardLabelClass *klass)
object_class = G_OBJECT_CLASS (klass);
item_class = (GnomeCanvasItemClass *) klass;
+ klass->style_set = e_minicard_label_style_set;
+
parent_class = g_type_class_peek_parent (klass);
object_class->set_property = e_minicard_label_set_property;
@@ -153,6 +166,16 @@ e_minicard_label_class_init (EMinicardLabelClass *klass)
FALSE,
G_PARAM_READWRITE));
+ e_minicard_label_signals [STYLE_SET] =
+ g_signal_new ("style_set",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (EMinicardLabelClass, style_set),
+ NULL, NULL,
+ e_addressbook_marshal_VOID__OBJECT,
+ G_TYPE_NONE, 1,
+ GTK_TYPE_STYLE);
+
/* GnomeCanvasItem method overrides */
item_class->realize = e_minicard_label_realize;
item_class->unrealize = e_minicard_label_unrealize;
@@ -258,25 +281,17 @@ e_minicard_label_get_property (GObject *object, guint prop_id, GValue *value, G
static void
e_minicard_label_realize (GnomeCanvasItem *item)
{
- if (GNOME_CANVAS_ITEM_CLASS( parent_class )->realize)
- (* GNOME_CANVAS_ITEM_CLASS( parent_class )->realize) (item);
-
- e_canvas_item_request_reflow(item);
-
- if (!item->canvas->aa)
- {
- }
-}
-
-void
-e_minicard_label_construct (GnomeCanvasItem *item)
-{
EMinicardLabel *e_minicard_label;
GnomeCanvasGroup *group;
e_minicard_label = E_MINICARD_LABEL (item);
group = GNOME_CANVAS_GROUP( item );
+ if (GNOME_CANVAS_ITEM_CLASS( parent_class )->realize)
+ (* GNOME_CANVAS_ITEM_CLASS( parent_class )->realize) (item);
+
+ e_canvas_item_request_reflow(item);
+
e_minicard_label->rect =
gnome_canvas_item_new( group,
gnome_canvas_rect_get_type(),
@@ -313,87 +328,70 @@ e_minicard_label_construct (GnomeCanvasItem *item)
NULL );
e_canvas_item_move_absolute(e_minicard_label->field, ( e_minicard_label->width / 2 + 2), 1);
+ set_colors (e_minicard_label);
+
e_canvas_item_request_reflow(item);
}
static void
e_minicard_label_unrealize (GnomeCanvasItem *item)
{
- EMinicardLabel *e_minicard_label;
-
- e_minicard_label = E_MINICARD_LABEL (item);
+ EMinicardLabel *e_minicard_label;
- if (!item->canvas->aa)
- {
- }
+ e_minicard_label = E_MINICARD_LABEL (item);
- if (GNOME_CANVAS_ITEM_CLASS( parent_class )->unrealize)
- (* GNOME_CANVAS_ITEM_CLASS( parent_class )->unrealize) (item);
+ if (GNOME_CANVAS_ITEM_CLASS( parent_class )->unrealize)
+ (* GNOME_CANVAS_ITEM_CLASS( parent_class )->unrealize) (item);
}
static gboolean
e_minicard_label_event (GnomeCanvasItem *item, GdkEvent *event)
{
- EMinicardLabel *e_minicard_label;
+ EMinicardLabel *e_minicard_label;
- e_minicard_label = E_MINICARD_LABEL (item);
-
- switch( event->type )
- {
- case GDK_KEY_PRESS:
- if (event->key.keyval == GDK_Escape) {
- GnomeCanvasItem *parent;
-
- e_text_cancel_editing (E_TEXT (e_minicard_label->field));
-
- parent = GNOME_CANVAS_ITEM (e_minicard_label)->parent;
- if (parent)
- e_canvas_item_grab_focus(parent, FALSE);
- }
- break;
- case GDK_FOCUS_CHANGE:
- {
- GdkEventFocus *focus_event = (GdkEventFocus *) event;
- if ( focus_event->in )
- {
- gnome_canvas_item_set( e_minicard_label->rect,
- "outline_color", "grey50",
- "fill_color", "grey90",
- NULL );
- e_minicard_label->has_focus = TRUE;
- }
- else
- {
- gnome_canvas_item_set( e_minicard_label->rect,
- "outline_color", NULL,
- "fill_color", NULL,
- NULL );
- e_minicard_label->has_focus = FALSE;
- }
-
- g_object_set (e_minicard_label->field,
- "handle_popup", e_minicard_label->has_focus,
- NULL);
- }
- break;
- case GDK_BUTTON_PRESS:
- case GDK_BUTTON_RELEASE:
- case GDK_MOTION_NOTIFY:
- case GDK_ENTER_NOTIFY:
- case GDK_LEAVE_NOTIFY: {
- gboolean return_val;
- g_signal_emit_by_name(e_minicard_label->field, "event", event, &return_val);
- return return_val;
- break;
- }
- default:
- break;
- }
+ e_minicard_label = E_MINICARD_LABEL (item);
+
+ switch( event->type ) {
+ case GDK_KEY_PRESS:
+ if (event->key.keyval == GDK_Escape) {
+ GnomeCanvasItem *parent;
+
+ e_text_cancel_editing (E_TEXT (e_minicard_label->field));
+
+ parent = GNOME_CANVAS_ITEM (e_minicard_label)->parent;
+ if (parent)
+ e_canvas_item_grab_focus(parent, FALSE);
+ }
+ break;
+ case GDK_FOCUS_CHANGE: {
+ GdkEventFocus *focus_event = (GdkEventFocus *) event;
+ GtkWidget *canvas = GTK_WIDGET (GNOME_CANVAS_ITEM (item)->canvas);
+
+ e_minicard_label->has_focus = focus_event->in;
+ set_colors (e_minicard_label);
+
+ g_object_set (e_minicard_label->field,
+ "handle_popup", e_minicard_label->has_focus,
+ NULL);
+ break;
+ }
+ case GDK_BUTTON_PRESS:
+ case GDK_BUTTON_RELEASE:
+ case GDK_MOTION_NOTIFY:
+ case GDK_ENTER_NOTIFY:
+ case GDK_LEAVE_NOTIFY: {
+ gboolean return_val;
+ g_signal_emit_by_name(e_minicard_label->field, "event", event, &return_val);
+ return return_val;
+ }
+ default:
+ break;
+ }
- if (GNOME_CANVAS_ITEM_CLASS( parent_class )->event)
- return (* GNOME_CANVAS_ITEM_CLASS( parent_class )->event) (item, event);
- else
- return 0;
+ if (GNOME_CANVAS_ITEM_CLASS( parent_class )->event)
+ return (* GNOME_CANVAS_ITEM_CLASS( parent_class )->event) (item, event);
+ else
+ return 0;
}
static void
@@ -414,6 +412,49 @@ e_minicard_label_resize_children(EMinicardLabel *e_minicard_label)
}
static void
+set_colors (EMinicardLabel *label)
+{
+ if ( (GTK_OBJECT_FLAGS( label ) & GNOME_CANVAS_ITEM_REALIZED) ) {
+ GtkWidget *canvas = GTK_WIDGET (GNOME_CANVAS_ITEM (label)->canvas);
+ GtkStyle *style = gtk_widget_get_style (canvas);
+ if (label->has_focus) {
+ gnome_canvas_item_set (label->rect,
+ "outline_color_gdk", &style->mid[GTK_STATE_SELECTED],
+ "fill_color_gdk", &style->bg[GTK_STATE_SELECTED],
+ NULL);
+
+ gnome_canvas_item_set (label->field,
+ "fill_color_gdk", &canvas->style->text[GTK_STATE_SELECTED],
+ NULL);
+
+ gnome_canvas_item_set (label->fieldname,
+ "fill_color_gdk", &canvas->style->text[GTK_STATE_SELECTED],
+ NULL);
+ }
+ else {
+ gnome_canvas_item_set (label->rect,
+ "outline_color_gdk", NULL,
+ "fill_color_gdk", NULL,
+ NULL);
+
+ gnome_canvas_item_set (label->field,
+ "fill_color_gdk", &canvas->style->text[GTK_STATE_NORMAL],
+ NULL);
+
+ gnome_canvas_item_set (label->fieldname,
+ "fill_color_gdk", &canvas->style->text[GTK_STATE_NORMAL],
+ NULL);
+ }
+ }
+}
+
+static void
+e_minicard_label_style_set (EMinicardLabel *label, GtkStyle *previous_style)
+{
+ set_colors (label);
+}
+
+static void
e_minicard_label_reflow(GnomeCanvasItem *item, int flags)
{
EMinicardLabel *e_minicard_label = E_MINICARD_LABEL(item);
@@ -459,7 +500,6 @@ GnomeCanvasItem *
e_minicard_label_new(GnomeCanvasGroup *parent)
{
GnomeCanvasItem *item = gnome_canvas_item_new(parent, e_minicard_label_get_type(), NULL);
- e_minicard_label_construct(item);
return item;
}
diff --git a/addressbook/gui/widgets/e-minicard-label.h b/addressbook/gui/widgets/e-minicard-label.h
index 0fdc48a451..d914cb30bb 100644
--- a/addressbook/gui/widgets/e-minicard-label.h
+++ b/addressbook/gui/widgets/e-minicard-label.h
@@ -69,6 +69,8 @@ struct _EMinicardLabel
struct _EMinicardLabelClass
{
GnomeCanvasGroupClass parent_class;
+
+ void (* style_set) (EMinicardLabel *label, GtkStyle *previous_style);
};
diff --git a/addressbook/gui/widgets/e-minicard-view-widget.c b/addressbook/gui/widgets/e-minicard-view-widget.c
index 2ba6bc6852..b4681e1b4b 100644
--- a/addressbook/gui/widgets/e-minicard-view-widget.c
+++ b/addressbook/gui/widgets/e-minicard-view-widget.c
@@ -36,6 +36,7 @@ static void e_minicard_view_widget_get_property (GObject *object, guint prop_id
static void e_minicard_view_widget_dispose (GObject *object);
static void e_minicard_view_widget_reflow (ECanvas *canvas);
static void e_minicard_view_widget_size_allocate (GtkWidget *widget, GtkAllocation *allocation);
+static void e_minicard_view_widget_style_set (GtkWidget *widget, GtkStyle *previous_style);
static void e_minicard_view_widget_realize (GtkWidget *widget);
static ECanvasClass *parent_class = NULL;
@@ -154,6 +155,7 @@ e_minicard_view_widget_class_init (EMinicardViewWidgetClass *klass)
e_addressbook_marshal_INT__POINTER,
G_TYPE_INT, 1, G_TYPE_POINTER);
+ widget_class->style_set = e_minicard_view_widget_style_set;
widget_class->realize = e_minicard_view_widget_realize;
widget_class->size_allocate = e_minicard_view_widget_size_allocate;
@@ -316,14 +318,29 @@ right_click (EMinicardView *view, GdkEvent *event, EMinicardViewWidget *widget)
}
static void
+e_minicard_view_widget_style_set (GtkWidget *widget, GtkStyle *previous_style)
+{
+ EMinicardViewWidget *view = E_MINICARD_VIEW_WIDGET(widget);
+
+ if (view->background)
+ gnome_canvas_item_set (view->background,
+ "fill_color_gdk", &widget->style->base[GTK_STATE_NORMAL],
+ NULL );
+
+ if (GTK_WIDGET_CLASS(parent_class)->style_set)
+ GTK_WIDGET_CLASS(parent_class)->style_set (widget, previous_style);
+}
+
+static void
e_minicard_view_widget_realize (GtkWidget *widget)
{
EMinicardViewWidget *view = E_MINICARD_VIEW_WIDGET(widget);
+ GtkStyle *style = gtk_widget_get_style (widget);
- gnome_canvas_item_new(gnome_canvas_root( GNOME_CANVAS(view) ),
- e_canvas_background_get_type(),
- "fill_color", "white",
- NULL );
+ view->background = gnome_canvas_item_new(gnome_canvas_root( GNOME_CANVAS(view) ),
+ e_canvas_background_get_type(),
+ "fill_color_gdk", &style->base[GTK_STATE_NORMAL],
+ NULL );
view->emv = gnome_canvas_item_new(
gnome_canvas_root( GNOME_CANVAS(view) ),
diff --git a/addressbook/gui/widgets/e-minicard-view-widget.h b/addressbook/gui/widgets/e-minicard-view-widget.h
index abb6b9c745..4e2da4cedf 100644
--- a/addressbook/gui/widgets/e-minicard-view-widget.h
+++ b/addressbook/gui/widgets/e-minicard-view-widget.h
@@ -40,6 +40,7 @@ struct _EMinicardViewWidget
{
ECanvas parent;
+ GnomeCanvasItem *background;
GnomeCanvasItem *emv;
EAddressbookReflowAdapter *adapter;
diff --git a/addressbook/gui/widgets/e-minicard.c b/addressbook/gui/widgets/e-minicard.c
index bb9234083d..782f5c40a9 100644
--- a/addressbook/gui/widgets/e-minicard.c
+++ b/addressbook/gui/widgets/e-minicard.c
@@ -260,7 +260,7 @@ set_selected (EMinicard *minicard, gboolean selected)
GtkWidget *canvas = GTK_WIDGET(GNOME_CANVAS_ITEM(minicard)->canvas);
if (selected) {
gnome_canvas_item_set (minicard->rect,
- "outline_color_gdk", &canvas->style->bg[GTK_STATE_NORMAL],
+ "outline_color_gdk", &canvas->style->bg[GTK_STATE_ACTIVE],
NULL);
gnome_canvas_item_set (minicard->header_rect,
"fill_color_gdk", &canvas->style->bg[GTK_STATE_SELECTED],
@@ -276,7 +276,7 @@ set_selected (EMinicard *minicard, gboolean selected)
"fill_color_gdk", &canvas->style->bg[GTK_STATE_NORMAL],
NULL);
gnome_canvas_item_set (minicard->header_text,
- "fill_color_gdk", &canvas->style->fg[GTK_STATE_NORMAL],
+ "fill_color_gdk", &canvas->style->text[GTK_STATE_NORMAL],
NULL);
}
minicard->selected = selected;
@@ -506,26 +506,21 @@ e_minicard_realize (GnomeCanvasItem *item)
"pixbuf", e_minicard->list_icon_pixbuf,
NULL);
+ set_selected (e_minicard, e_minicard->selected);
+
remodel(e_minicard);
e_canvas_item_request_reflow(item);
-
- if (!item->canvas->aa) {
- }
}
static void
e_minicard_unrealize (GnomeCanvasItem *item)
{
- EMinicard *e_minicard;
-
- e_minicard = E_MINICARD (item);
+ EMinicard *e_minicard;
- if (!item->canvas->aa)
- {
- }
+ e_minicard = E_MINICARD (item);
- if (GNOME_CANVAS_ITEM_CLASS(parent_class)->unrealize)
- (* GNOME_CANVAS_ITEM_CLASS(parent_class)->unrealize) (item);
+ if (GNOME_CANVAS_ITEM_CLASS(parent_class)->unrealize)
+ (* GNOME_CANVAS_ITEM_CLASS(parent_class)->unrealize) (item);
}
static void