[evolution/wip/gsettings] Adapt EMeetingTimeSel to latest gtk+-3.0 API.
- From: Rodrigo Moya <rodrigo src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution/wip/gsettings] Adapt EMeetingTimeSel to latest gtk+-3.0 API.
- Date: Wed, 29 Jun 2011 17:04:19 +0000 (UTC)
commit df3001c114ab019bce8ebf97a040b7c786467694
Author: Vibha Yadav <yvibha novell com>
Date: Thu Dec 2 17:12:19 2010 +0530
Adapt EMeetingTimeSel to latest gtk+-3.0 API.
calendar/gui/e-meeting-time-sel-item.c | 33 ++++++-----------
calendar/gui/e-meeting-time-sel.c | 61 ++++++++++++-------------------
2 files changed, 36 insertions(+), 58 deletions(-)
---
diff --git a/calendar/gui/e-meeting-time-sel-item.c b/calendar/gui/e-meeting-time-sel-item.c
index 14644c5..0ac891c 100644
--- a/calendar/gui/e-meeting-time-sel-item.c
+++ b/calendar/gui/e-meeting-time-sel-item.c
@@ -49,7 +49,7 @@ static void e_meeting_time_selector_item_update (GnomeCanvasItem *item,
const cairo_matrix_t *i2c,
gint flags);
static void e_meeting_time_selector_item_draw (GnomeCanvasItem *item,
- GdkDrawable *drawable,
+ cairo_t *cr,
gint x, gint y,
gint width, gint height);
static GnomeCanvasItem *e_meeting_time_selector_item_point (GnomeCanvasItem *item,
@@ -69,15 +69,15 @@ static void e_meeting_time_selector_item_paint_day_top (EMeetingTimeSelectorItem
GDate *date,
gint x, gint scroll_y,
gint width, gint height);
-static void e_meeting_time_selector_item_paint_all_attendees_busy_periods (EMeetingTimeSelectorItem *mts_item, GdkDrawable *drawable, GDate *date, gint x, gint y, gint width, gint height);
+static void e_meeting_time_selector_item_paint_all_attendees_busy_periods (EMeetingTimeSelectorItem *mts_item, cairo_t *cr, GDate *date, gint x, gint y, gint width, gint height);
static void e_meeting_time_selector_item_paint_day (EMeetingTimeSelectorItem *mts_item,
cairo_t *cr,
GDate *date,
gint x, gint scroll_y,
gint width, gint height);
-static void e_meeting_time_selector_item_paint_busy_periods (EMeetingTimeSelectorItem *mts_item, GdkDrawable *drawable, GDate *date, gint x, gint scroll_y, gint width, gint height);
+static void e_meeting_time_selector_item_paint_busy_periods (EMeetingTimeSelectorItem *mts_item, cairo_t *cr, GDate *date, gint x, gint scroll_y, gint width, gint height);
static gint e_meeting_time_selector_item_find_first_busy_period (EMeetingTimeSelectorItem *mts_item, GDate *date, gint row);
-static void e_meeting_time_selector_item_paint_attendee_busy_periods (EMeetingTimeSelectorItem *mts_item, GdkDrawable *drawable, gint row, gint x, gint y, gint width, gint first_period, EMeetingFreeBusyType busy_type, cairo_t *cr);
+static void e_meeting_time_selector_item_paint_attendee_busy_periods (EMeetingTimeSelectorItem *mts_item, cairo_t *cr, gint row, gint x, gint y, gint width, gint first_period, EMeetingFreeBusyType busy_type);
static EMeetingTimeSelectorPosition e_meeting_time_selector_item_get_drag_position (EMeetingTimeSelectorItem *mts_item, gint x, gint y);
static gboolean e_meeting_time_selector_item_calculate_busy_range (EMeetingTimeSelector *mts,
@@ -219,7 +219,7 @@ draw_strikeout_box (EMeetingTimeSelectorItem *mts_item, cairo_t *cr,
}
static void
-e_meeting_time_selector_item_draw (GnomeCanvasItem *item, GdkDrawable *drawable, gint x, gint y, gint width, gint height)
+e_meeting_time_selector_item_draw (GnomeCanvasItem *item, cairo_t *cr, gint x, gint y, gint width, gint height)
{
EMeetingTimeSelector *mts;
EMeetingTimeSelectorItem *mts_item;
@@ -228,12 +228,10 @@ e_meeting_time_selector_item_draw (GnomeCanvasItem *item, GdkDrawable *drawable,
gint row, row_y, start_x, end_x;
GDate date, last_date, current_date;
gboolean is_display_top, show_meeting_time;
- cairo_t *cr;
mts_item = E_MEETING_TIME_SELECTOR_ITEM (item);
mts = mts_item->mts;
g_return_if_fail (mts != NULL);
- cr = gdk_cairo_create (drawable);
is_display_top = (GTK_WIDGET (item->canvas) == mts->display_top)
? TRUE : FALSE;
@@ -334,9 +332,9 @@ e_meeting_time_selector_item_draw (GnomeCanvasItem *item, GdkDrawable *drawable,
/* Draw the busy periods. */
if (is_display_top)
- e_meeting_time_selector_item_paint_all_attendees_busy_periods (mts_item, drawable, &date, x, y, width, height);
+ e_meeting_time_selector_item_paint_all_attendees_busy_periods (mts_item, cr, &date, x, y, width, height);
else
- e_meeting_time_selector_item_paint_busy_periods (mts_item, drawable, &date, x, y, width, height);
+ e_meeting_time_selector_item_paint_busy_periods (mts_item, cr, &date, x, y, width, height);
/* Draw the currently-selected meeting time vertical bars. */
if (show_meeting_time) {
@@ -367,7 +365,6 @@ e_meeting_time_selector_item_draw (GnomeCanvasItem *item, GdkDrawable *drawable,
}
cairo_restore (cr);
}
- cairo_destroy (cr);
}
static void
@@ -479,16 +476,14 @@ e_meeting_time_selector_item_paint_day_top (EMeetingTimeSelectorItem *mts_item,
list of attendees. For now we just paint the bars for each attendee of
each other. If we want to speed it up we could optimise it later. */
static void
-e_meeting_time_selector_item_paint_all_attendees_busy_periods (EMeetingTimeSelectorItem *mts_item, GdkDrawable *drawable, GDate *date, gint x, gint scroll_y, gint width, gint height)
+e_meeting_time_selector_item_paint_all_attendees_busy_periods (EMeetingTimeSelectorItem *mts_item, cairo_t *cr, GDate *date, gint x, gint scroll_y, gint width, gint height)
{
EMeetingTimeSelector *mts;
EMeetingFreeBusyType busy_type;
gint row, y;
gint *first_periods;
- cairo_t *cr;
mts = mts_item->mts;
- cr = gdk_cairo_create (drawable);
/* Calculate the y coordinate to paint the row at in the drawable. */
y = 2 * mts->row_height - scroll_y - 1;
@@ -505,12 +500,11 @@ e_meeting_time_selector_item_paint_all_attendees_busy_periods (EMeetingTimeSelec
for (row = 0; row < e_meeting_store_count_actual_attendees (mts->model); row++) {
if (first_periods[row] == -1)
continue;
- e_meeting_time_selector_item_paint_attendee_busy_periods (mts_item, drawable, x, y, width, row, first_periods[row], busy_type, cr);
+ e_meeting_time_selector_item_paint_attendee_busy_periods (mts_item, cr, x, y, width, row, first_periods[row], busy_type);
}
}
g_free (first_periods);
- cairo_destroy (cr);
}
static void
@@ -593,15 +587,13 @@ e_meeting_time_selector_item_paint_day (EMeetingTimeSelectorItem *mts_item,
/* This paints the colored bars representing busy periods for the individual
attendees. */
static void
-e_meeting_time_selector_item_paint_busy_periods (EMeetingTimeSelectorItem *mts_item, GdkDrawable *drawable, GDate *date, gint x, gint scroll_y, gint width, gint height)
+e_meeting_time_selector_item_paint_busy_periods (EMeetingTimeSelectorItem *mts_item, cairo_t *cr, GDate *date, gint x, gint scroll_y, gint width, gint height)
{
EMeetingTimeSelector *mts;
EMeetingFreeBusyType busy_type;
gint row, y, first_period;
- cairo_t *cr;
mts = mts_item->mts;
- cr = gdk_cairo_create (drawable);
/* Calculate the first visible attendee row. */
row = scroll_y / mts->row_height;
@@ -622,13 +614,12 @@ e_meeting_time_selector_item_paint_busy_periods (EMeetingTimeSelectorItem *mts_i
busy_type < E_MEETING_FREE_BUSY_LAST;
busy_type++) {
gdk_cairo_set_source_color (cr, &mts->busy_colors[busy_type]);
- e_meeting_time_selector_item_paint_attendee_busy_periods (mts_item, drawable, x, y, width, row, first_period, busy_type, cr);
+ e_meeting_time_selector_item_paint_attendee_busy_periods (mts_item, cr, x, y, width, row, first_period, busy_type);
}
}
y += mts->row_height;
row++;
}
- cairo_destroy (cr);
}
/* This subtracts the attendees longest_period_in_days from the given date,
@@ -666,7 +657,7 @@ e_meeting_time_selector_item_find_first_busy_period (EMeetingTimeSelectorItem *m
busy type, e.g out of office. It is passed the index of the first visible
busy period of the attendee and continues until it runs off the screen. */
static void
-e_meeting_time_selector_item_paint_attendee_busy_periods (EMeetingTimeSelectorItem *mts_item, GdkDrawable *drawable, gint x, gint y, gint width, gint row, gint first_period, EMeetingFreeBusyType busy_type, cairo_t *cr)
+e_meeting_time_selector_item_paint_attendee_busy_periods (EMeetingTimeSelectorItem *mts_item, cairo_t *cr, gint x, gint y, gint width, gint row, gint first_period, EMeetingFreeBusyType busy_type)
{
EMeetingTimeSelector *mts;
EMeetingAttendee *ia;
diff --git a/calendar/gui/e-meeting-time-sel.c b/calendar/gui/e-meeting-time-sel.c
index d68c369..d694a4a 100644
--- a/calendar/gui/e-meeting-time-sel.c
+++ b/calendar/gui/e-meeting-time-sel.c
@@ -104,8 +104,8 @@ static void e_meeting_time_selector_add_key_color (EMeetingTimeSelector * mts,
GtkWidget *hbox,
gchar *label_text,
GdkColor *color);
-static gint e_meeting_time_selector_expose_key_color (GtkWidget *darea,
- GdkEventExpose *event,
+static gint e_meeting_time_selector_draw_key_color (GtkWidget *darea,
+ cairo_t *cr,
GdkColor *color);
static void e_meeting_time_selector_options_menu_detacher (GtkWidget *widget,
GtkMenu *menu);
@@ -115,9 +115,8 @@ static void e_meeting_time_selector_realize (GtkWidget *widget);
static void e_meeting_time_selector_unrealize (GtkWidget *widget);
static void e_meeting_time_selector_style_set (GtkWidget *widget,
GtkStyle *previous_style);
-static gint e_meeting_time_selector_expose_event (GtkWidget *widget,
- GdkEventExpose *event);
-static void e_meeting_time_selector_draw_shadow (EMeetingTimeSelector *mts);
+static gint e_meeting_time_selector_draw (GtkWidget *widget, cairo_t *cr);
+static void e_meeting_time_selector_draw_shadow (EMeetingTimeSelector *mts, cairo_t *cr);
static void e_meeting_time_selector_hadjustment_changed (GtkAdjustment *adjustment,
EMeetingTimeSelector *mts);
static void e_meeting_time_selector_vadjustment_changed (GtkAdjustment *adjustment,
@@ -319,7 +318,7 @@ e_meeting_time_selector_class_init (EMeetingTimeSelectorClass * class)
widget_class->realize = e_meeting_time_selector_realize;
widget_class->unrealize = e_meeting_time_selector_unrealize;
widget_class->style_set = e_meeting_time_selector_style_set;
- widget_class->expose_event = e_meeting_time_selector_expose_event;
+ widget_class->draw = e_meeting_time_selector_draw;
g_object_class_install_property (
object_class,
@@ -885,35 +884,28 @@ e_meeting_time_selector_add_key_color (EMeetingTimeSelector * mts,
gtk_box_pack_start (GTK_BOX (child_hbox), label, TRUE, TRUE, 6);
gtk_widget_show (label);
- g_signal_connect (darea, "expose_event",
- G_CALLBACK (e_meeting_time_selector_expose_key_color),
+ g_signal_connect (darea, "draw",
+ G_CALLBACK (e_meeting_time_selector_draw_key_color),
color);
}
static gint
-e_meeting_time_selector_expose_key_color (GtkWidget *darea,
- GdkEventExpose *event,
- GdkColor *color)
+e_meeting_time_selector_draw_key_color (GtkWidget *darea, cairo_t *cr, GdkColor *color)
{
EMeetingTimeSelector * mts;
GtkAllocation allocation;
- GdkWindow *window;
GtkStyle *style;
- cairo_t *cr;
style = gtk_widget_get_style (darea);
- window = gtk_widget_get_window (darea);
gtk_widget_get_allocation (darea, &allocation);
mts = g_object_get_data (G_OBJECT (darea), "data");
gtk_paint_shadow (
- style, window, GTK_STATE_NORMAL,
- GTK_SHADOW_IN, NULL, NULL, NULL, 0, 0,
+ style, cr, GTK_STATE_NORMAL,
+ GTK_SHADOW_IN, NULL, NULL, 0, 0,
allocation.width, allocation.height);
- cr = gdk_cairo_create (event->window);
-
if (color) {
gdk_cairo_set_source_color (cr, color);
} else {
@@ -924,8 +916,6 @@ e_meeting_time_selector_expose_key_color (GtkWidget *darea,
allocation.width - 2, allocation.height - 2);
cairo_fill (cr);
- cairo_destroy (cr);
-
return TRUE;
}
@@ -933,15 +923,11 @@ static void
e_meeting_time_selector_alloc_named_color (EMeetingTimeSelector * mts,
const gchar *name, GdkColor *c)
{
- GdkColormap *colormap;
-
g_return_if_fail (name != NULL);
g_return_if_fail (c != NULL);
- gdk_color_parse (name, c);
- colormap = gtk_widget_get_colormap (GTK_WIDGET (mts));
- if (!gdk_colormap_alloc_color (colormap, c, TRUE, TRUE))
- g_warning ("Failed to allocate color: %s\n", name);
+ if ( !gdk_color_parse (name, c))
+ g_warning ("Failed to parse color: %s\n", name);
}
static void
@@ -1209,29 +1195,29 @@ e_meeting_time_selector_style_set (GtkWidget *widget,
/* This draws a shadow around the top display and main display. */
static gint
-e_meeting_time_selector_expose_event (GtkWidget *widget,
- GdkEventExpose *event)
+e_meeting_time_selector_draw (GtkWidget *widget, cairo_t *cr)
{
EMeetingTimeSelector *mts;
mts = E_MEETING_TIME_SELECTOR (widget);
- e_meeting_time_selector_draw_shadow (mts);
+ e_meeting_time_selector_draw_shadow (mts, cr);
- if (GTK_WIDGET_CLASS (e_meeting_time_selector_parent_class)->expose_event)
- (*GTK_WIDGET_CLASS (e_meeting_time_selector_parent_class)->expose_event)(widget, event);
+ if (GTK_WIDGET_CLASS (e_meeting_time_selector_parent_class)->draw)
+ (*GTK_WIDGET_CLASS (e_meeting_time_selector_parent_class)->draw)(widget, cr);
return FALSE;
}
static void
-e_meeting_time_selector_draw_shadow (EMeetingTimeSelector *mts)
+e_meeting_time_selector_draw_shadow (EMeetingTimeSelector *mts, cairo_t *cr)
{
GtkAllocation allocation;
- GdkWindow *window;
GtkStyle *style;
gint x, y, w, h;
+ cairo_save (cr);
+
/* Draw the shadow around the graphical displays. */
gtk_widget_get_allocation (mts->display_top, &allocation);
x = allocation.x - 2;
@@ -1240,11 +1226,12 @@ e_meeting_time_selector_draw_shadow (EMeetingTimeSelector *mts)
h = allocation.height + allocation.height + 4;
style = gtk_widget_get_style (GTK_WIDGET (mts));
- window = gtk_widget_get_window (GTK_WIDGET (mts));
gtk_paint_shadow (
- style, window, GTK_STATE_NORMAL,
- GTK_SHADOW_IN, NULL, NULL, NULL, x, y, w, h);
+ style, cr, GTK_STATE_NORMAL,
+ GTK_SHADOW_IN, NULL, NULL, x, y, w, h);
+
+ cairo_restore (cr);
}
/* When the main canvas scrolls, we scroll the other canvases. */
@@ -2451,7 +2438,7 @@ e_meeting_time_selector_on_canvas_realized (GtkWidget *widget,
GdkWindow *window;
window = gtk_layout_get_bin_window (GTK_LAYOUT (widget));
- gdk_window_set_back_pixmap (window, NULL, FALSE);
+ gdk_window_set_background_pattern (window, NULL);
}
/* This is called when the meeting start time GnomeDateEdit is changed,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]