aboutsummaryrefslogtreecommitdiffstats
path: root/widgets
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2012-11-30 02:12:41 +0800
committerMatthew Barnes <mbarnes@redhat.com>2012-11-30 02:24:24 +0800
commitd2fb5ee1a86539e49f02c1fe9ea10cf55b0b351a (patch)
tree0a0da6f348d8c41ac3e7712a5c18abe78e23d891 /widgets
parent67024e23ee07266a7b9854648454739e1824f91c (diff)
downloadgsoc2013-evolution-d2fb5ee1a86539e49f02c1fe9ea10cf55b0b351a.tar
gsoc2013-evolution-d2fb5ee1a86539e49f02c1fe9ea10cf55b0b351a.tar.gz
gsoc2013-evolution-d2fb5ee1a86539e49f02c1fe9ea10cf55b0b351a.tar.bz2
gsoc2013-evolution-d2fb5ee1a86539e49f02c1fe9ea10cf55b0b351a.tar.lz
gsoc2013-evolution-d2fb5ee1a86539e49f02c1fe9ea10cf55b0b351a.tar.xz
gsoc2013-evolution-d2fb5ee1a86539e49f02c1fe9ea10cf55b0b351a.tar.zst
gsoc2013-evolution-d2fb5ee1a86539e49f02c1fe9ea10cf55b0b351a.zip
Avoid using GdkEventButton directly in certain places.
Prefer dealing with GdkEvent pointers and using accessor functions like gdk_event_get_button(). This is complicated by the fact that some GtkWidget method declarations still use GdkEventButton pointers, and synthesizing button events pretty much requires direct GdkEventButton access. But GDK seems to be nudging itself toward sealing the GdkEvent union. Likely to happen in GDK4. Mainly clean up signal handlers and leave method overrides alone for now.
Diffstat (limited to 'widgets')
-rw-r--r--widgets/e-timezone-dialog/e-timezone-dialog.c15
-rw-r--r--widgets/misc/e-buffer-tagger.c35
-rw-r--r--widgets/misc/e-calendar-item.c15
-rw-r--r--widgets/misc/e-dateedit.c6
-rw-r--r--widgets/misc/e-map.c9
-rw-r--r--widgets/table/e-cell-combo.c24
-rw-r--r--widgets/table/e-cell-date-edit.c10
-rw-r--r--widgets/table/e-table-header-item.c23
-rw-r--r--widgets/table/e-table-header-item.h2
-rw-r--r--widgets/text/e-text.c72
-rw-r--r--widgets/text/e-text.h2
11 files changed, 127 insertions, 86 deletions
diff --git a/widgets/e-timezone-dialog/e-timezone-dialog.c b/widgets/e-timezone-dialog/e-timezone-dialog.c
index 337cb0ad99..9fd6b91446 100644
--- a/widgets/e-timezone-dialog/e-timezone-dialog.c
+++ b/widgets/e-timezone-dialog/e-timezone-dialog.c
@@ -95,7 +95,7 @@ static gboolean on_map_visibility_changed (GtkWidget *w,
GdkEventVisibility *event,
gpointer data);
static gboolean on_map_button_pressed (GtkWidget *w,
- GdkEventButton *event,
+ GdkEvent *button_event,
gpointer data);
static icaltimezone * get_zone_from_point (ETimezoneDialog *etd,
@@ -591,21 +591,26 @@ on_map_visibility_changed (GtkWidget *w,
static gboolean
on_map_button_pressed (GtkWidget *w,
- GdkEventButton *event,
+ GdkEvent *button_event,
gpointer data)
{
ETimezoneDialog *etd;
ETimezoneDialogPrivate *priv;
+ guint event_button = 0;
+ gdouble event_x_win = 0;
+ gdouble event_y_win = 0;
gdouble longitude, latitude;
etd = E_TIMEZONE_DIALOG (data);
priv = etd->priv;
+ gdk_event_get_button (button_event, &event_button);
+ gdk_event_get_coords (button_event, &event_x_win, &event_y_win);
+
e_map_window_to_world (
- priv->map, (gdouble) event->x, (gdouble) event->y,
- &longitude, &latitude);
+ priv->map, event_x_win, event_y_win, &longitude, &latitude);
- if (event->button != 1) {
+ if (event_button != 1) {
e_map_zoom_out (priv->map);
} else {
if (e_map_get_magnification (priv->map) <= 1.0)
diff --git a/widgets/misc/e-buffer-tagger.c b/widgets/misc/e-buffer-tagger.c
index 8a0d7ccbc3..b68d414868 100644
--- a/widgets/misc/e-buffer-tagger.c
+++ b/widgets/misc/e-buffer-tagger.c
@@ -466,30 +466,36 @@ update_ctrl_state (GtkTextView *textview,
/* Links can also be activated by clicking. */
static gboolean
textview_event_after (GtkTextView *textview,
- GdkEvent *ev)
+ GdkEvent *event)
{
GtkTextIter start, end, iter;
GtkTextBuffer *buffer;
- GdkEventButton *event;
gint x, y;
GdkModifierType mt = 0;
+ guint event_button = 0;
+ gdouble event_x_win = 0;
+ gdouble event_y_win = 0;
g_return_val_if_fail (GTK_IS_TEXT_VIEW (textview), FALSE);
- if (ev->type == GDK_KEY_PRESS || ev->type == GDK_KEY_RELEASE) {
- GdkEventKey *event_key = (GdkEventKey *) ev;
+ if (event->type == GDK_KEY_PRESS || event->type == GDK_KEY_RELEASE) {
+ guint event_keyval = 0;
- switch (event_key->keyval) {
- case GDK_KEY_Control_L:
- case GDK_KEY_Control_R:
- update_ctrl_state (textview, ev->type == GDK_KEY_PRESS);
- break;
+ gdk_event_get_keyval (event, &event_keyval);
+
+ switch (event_keyval) {
+ case GDK_KEY_Control_L:
+ case GDK_KEY_Control_R:
+ update_ctrl_state (
+ textview,
+ event->type == GDK_KEY_PRESS);
+ break;
}
return FALSE;
}
- if (!gdk_event_get_state (ev, &mt)) {
+ if (!gdk_event_get_state (event, &mt)) {
GdkWindow *window;
GdkDisplay *display;
GdkDeviceManager *device_manager;
@@ -505,12 +511,13 @@ textview_event_after (GtkTextView *textview,
update_ctrl_state (textview, (mt & GDK_CONTROL_MASK) != 0);
- if (ev->type != GDK_BUTTON_RELEASE)
+ if (event->type != GDK_BUTTON_RELEASE)
return FALSE;
- event = (GdkEventButton *) ev;
+ gdk_event_get_button (event, &event_button);
+ gdk_event_get_coords (event, &event_x_win, &event_y_win);
- if (event->button != 1 || (event->state & GDK_CONTROL_MASK) == 0)
+ if (event_button != 1 || (mt & GDK_CONTROL_MASK) == 0)
return FALSE;
buffer = gtk_text_view_get_buffer (textview);
@@ -523,7 +530,7 @@ textview_event_after (GtkTextView *textview,
gtk_text_view_window_to_buffer_coords (
textview,
GTK_TEXT_WINDOW_WIDGET,
- event->x, event->y, &x, &y);
+ event_x_win, event_y_win, &x, &y);
gtk_text_view_get_iter_at_location (textview, &iter, x, y);
diff --git a/widgets/misc/e-calendar-item.c b/widgets/misc/e-calendar-item.c
index 0f38c7b16a..1b1a72281d 100644
--- a/widgets/misc/e-calendar-item.c
+++ b/widgets/misc/e-calendar-item.c
@@ -188,7 +188,7 @@ static gboolean e_calendar_item_ensure_days_visible
gint end_day,
gboolean emission);
static void e_calendar_item_show_popup_menu (ECalendarItem *calitem,
- GdkEventButton *event,
+ GdkEvent *button_event,
gint month_offset);
static void e_calendar_item_on_menu_item_activate
(GtkWidget *menuitem,
@@ -2253,9 +2253,7 @@ e_calendar_item_button_press (ECalendarItem *calitem,
if (event->button.button == 3 && day == -1
&& e_calendar_item_get_display_popup (calitem)) {
e_calendar_item_show_popup_menu (
- calitem,
- (GdkEventButton *) event,
- month_offset);
+ calitem, event, month_offset);
return TRUE;
}
@@ -3529,13 +3527,15 @@ deactivate_menu_cb (GtkWidget *menu)
static void
e_calendar_item_show_popup_menu (ECalendarItem *calitem,
- GdkEventButton *event,
+ GdkEvent *button_event,
gint month_offset)
{
GtkWidget *menu, *submenu, *menuitem, *label;
gint year, month;
const gchar *name;
gchar buffer[64];
+ guint event_button = 0;
+ guint32 event_time;
menu = gtk_menu_new ();
@@ -3582,10 +3582,13 @@ e_calendar_item_show_popup_menu (ECalendarItem *calitem,
menu, "deactivate",
G_CALLBACK (deactivate_menu_cb), NULL);
+ gdk_event_get_button (button_event, &event_button);
+ event_time = gdk_event_get_time (button_event);
+
gtk_menu_popup (
GTK_MENU (menu), NULL, NULL,
e_calendar_item_position_menu, calitem,
- event->button, event->time);
+ event_button, event_time);
}
static void
diff --git a/widgets/misc/e-dateedit.c b/widgets/misc/e-dateedit.c
index 45c4f7148b..e24d4137cb 100644
--- a/widgets/misc/e-dateedit.c
+++ b/widgets/misc/e-dateedit.c
@@ -161,7 +161,7 @@ static gint on_date_popup_key_press (GtkWidget *widget,
GdkEventKey *event,
EDateEdit *dedit);
static gint on_date_popup_button_press (GtkWidget *widget,
- GdkEventButton *event,
+ GdkEvent *button_event,
gpointer data);
static void on_date_popup_date_selected (ECalendarItem *calitem,
EDateEdit *dedit);
@@ -1537,7 +1537,7 @@ on_date_popup_key_press (GtkWidget *widget,
* (This function is yanked from gtkcombo.c) */
static gint
on_date_popup_button_press (GtkWidget *widget,
- GdkEventButton *event,
+ GdkEvent *button_event,
gpointer data)
{
EDateEdit *dedit;
@@ -1545,7 +1545,7 @@ on_date_popup_button_press (GtkWidget *widget,
dedit = data;
- child = gtk_get_event_widget ((GdkEvent *) event);
+ child = gtk_get_event_widget (button_event);
/* We don't ask for button press events on the grab widget, so
* if an event is reported directly to the grab widget, it must
diff --git a/widgets/misc/e-map.c b/widgets/misc/e-map.c
index 40fe589a8c..ebccf385d7 100644
--- a/widgets/misc/e-map.c
+++ b/widgets/misc/e-map.c
@@ -722,15 +722,18 @@ static gint
e_map_button_press (GtkWidget *widget,
GdkEventButton *event)
{
- if (!gtk_widget_has_focus (widget)) gtk_widget_grab_focus (widget);
- return TRUE;
+ if (!gtk_widget_has_focus (widget))
+ gtk_widget_grab_focus (widget);
+
+ return TRUE;
}
static gint
e_map_button_release (GtkWidget *widget,
GdkEventButton *event)
{
- if (event->button != 1) return FALSE;
+ if (event->button != 1)
+ return FALSE;
gdk_pointer_ungrab (event->time);
return TRUE;
diff --git a/widgets/table/e-cell-combo.c b/widgets/table/e-cell-combo.c
index 48bf24724d..cc72e90a20 100644
--- a/widgets/table/e-cell-combo.c
+++ b/widgets/table/e-cell-combo.c
@@ -95,10 +95,10 @@ static void e_cell_combo_get_popup_pos (ECellCombo *ecc,
static void e_cell_combo_selection_changed (GtkTreeSelection *selection,
ECellCombo *ecc);
static gint e_cell_combo_button_press (GtkWidget *popup_window,
- GdkEvent *event,
+ GdkEvent *button_event,
ECellCombo *ecc);
static gint e_cell_combo_button_release (GtkWidget *popup_window,
- GdkEventButton *event,
+ GdkEvent *button_event,
ECellCombo *ecc);
static gint e_cell_combo_key_press (GtkWidget *popup_window,
GdkEventKey *event,
@@ -575,12 +575,14 @@ e_cell_combo_selection_changed (GtkTreeSelection *selection,
* which we ignore. */
static gint
e_cell_combo_button_press (GtkWidget *popup_window,
- GdkEvent *event,
+ GdkEvent *button_event,
ECellCombo *ecc)
{
GtkWidget *event_widget;
+ guint32 event_time;
- event_widget = gtk_get_event_widget (event);
+ event_time = gdk_event_get_time (button_event);
+ event_widget = gtk_get_event_widget (button_event);
/* If the button press was for a widget inside the popup list, but
* not the popup window itself, then we ignore the event and return
@@ -595,8 +597,8 @@ e_cell_combo_button_press (GtkWidget *popup_window,
}
gtk_grab_remove (ecc->popup_window);
- gdk_pointer_ungrab (event->button.time);
- gdk_keyboard_ungrab (event->button.time);
+ gdk_pointer_ungrab (event_time);
+ gdk_keyboard_ungrab (event_time);
gtk_widget_hide (ecc->popup_window);
e_cell_popup_set_shown (E_CELL_POPUP (ecc), FALSE);
@@ -618,12 +620,14 @@ e_cell_combo_button_press (GtkWidget *popup_window,
* cell with the new selection. */
static gint
e_cell_combo_button_release (GtkWidget *popup_window,
- GdkEventButton *event,
+ GdkEvent *button_event,
ECellCombo *ecc)
{
GtkWidget *event_widget;
+ guint32 event_time;
- event_widget = gtk_get_event_widget ((GdkEvent *) event);
+ event_time = gdk_event_get_time (button_event);
+ event_widget = gtk_get_event_widget (button_event);
/* See if the button was released in the list (or its children). */
while (event_widget && event_widget != ecc->popup_tree_view)
@@ -636,8 +640,8 @@ e_cell_combo_button_release (GtkWidget *popup_window,
/* The button was released inside the list, so we hide the popup and
* update the cell to reflect the new selection. */
gtk_grab_remove (ecc->popup_window);
- gdk_pointer_ungrab (event->time);
- gdk_keyboard_ungrab (event->time);
+ gdk_pointer_ungrab (event_time);
+ gdk_keyboard_ungrab (event_time);
gtk_widget_hide (ecc->popup_window);
e_cell_popup_set_shown (E_CELL_POPUP (ecc), FALSE);
diff --git a/widgets/table/e-cell-date-edit.c b/widgets/table/e-cell-date-edit.c
index 46f224f315..be834f5686 100644
--- a/widgets/table/e-cell-date-edit.c
+++ b/widgets/table/e-cell-date-edit.c
@@ -81,7 +81,7 @@ static gint e_cell_date_edit_key_press (GtkWidget *popup_window,
GdkEventKey *event,
ECellDateEdit *ecde);
static gint e_cell_date_edit_button_press (GtkWidget *popup_window,
- GdkEventButton *event,
+ GdkEvent *button_event,
ECellDateEdit *ecde);
static void e_cell_date_edit_on_ok_clicked (GtkWidget *button,
ECellDateEdit *ecde);
@@ -746,15 +746,15 @@ e_cell_date_edit_key_press (GtkWidget *popup_window,
*/
static gint
e_cell_date_edit_button_press (GtkWidget *popup_window,
- GdkEventButton *event,
+ GdkEvent *button_event,
ECellDateEdit *ecde)
{
GtkWidget *event_widget;
- event_widget = gtk_get_event_widget ((GdkEvent *) event);
- if (gtk_widget_get_toplevel (event_widget) != popup_window) {
+ event_widget = gtk_get_event_widget (button_event);
+
+ if (gtk_widget_get_toplevel (event_widget) != popup_window)
e_cell_date_edit_hide_popup (ecde);
- }
return TRUE;
}
diff --git a/widgets/table/e-table-header-item.c b/widgets/table/e-table-header-item.c
index d8e0665b8e..8bec92fa10 100644
--- a/widgets/table/e-table-header-item.c
+++ b/widgets/table/e-table-header-item.c
@@ -1674,7 +1674,7 @@ popup_custom (GtkWidget *menu_item,
static void
ethi_header_context_menu (ETableHeaderItem *ethi,
- GdkEventButton *event)
+ GdkEvent *button_event)
{
EthiHeaderInfo *info = g_new (EthiHeaderInfo, 1);
GtkMenu *popup;
@@ -1682,10 +1682,19 @@ ethi_header_context_menu (ETableHeaderItem *ethi,
GtkWidget *menu_item, *sub_menu;
ETableSortColumn column;
gboolean ascending = TRUE;
+ gdouble event_x_win = 0;
+ gdouble event_y_win = 0;
+ guint event_button = 0;
+ guint32 event_time;
+
d (g_print ("ethi_header_context_menu: \n"));
+ gdk_event_get_button (button_event, &event_button);
+ gdk_event_get_coords (button_event, &event_x_win, &event_y_win);
+ event_time = gdk_event_get_time (button_event);
+
info->ethi = ethi;
- info->col = ethi_find_col_by_x (ethi, event->x);
+ info->col = ethi_find_col_by_x (ethi, event_x_win);
popup = e_popup_menu_create_with_domain (
ethi_context_menu,
@@ -1771,14 +1780,14 @@ ethi_header_context_menu (ETableHeaderItem *ethi,
gtk_menu_popup (
GTK_MENU (popup),
NULL, NULL, NULL, NULL,
- event->button, event->time);
+ event_button, event_time);
}
static void
ethi_button_pressed (ETableHeaderItem *ethi,
- GdkEventButton *event)
+ GdkEvent *button_event)
{
- g_signal_emit (ethi, ethi_signals[BUTTON_PRESSED], 0, event);
+ g_signal_emit (ethi, ethi_signals[BUTTON_PRESSED], 0, button_event);
}
void
@@ -1957,9 +1966,9 @@ ethi_event (GnomeCanvasItem *item,
if (gtk_widget_get_can_focus (GTK_WIDGET (item->canvas)))
e_canvas_item_grab_focus (item, TRUE);
} else if (e->button.button == 3) {
- ethi_header_context_menu (ethi, &e->button);
+ ethi_header_context_menu (ethi, e);
} else
- ethi_button_pressed (ethi, &e->button);
+ ethi_button_pressed (ethi, e);
}
break;
diff --git a/widgets/table/e-table-header-item.h b/widgets/table/e-table-header-item.h
index be8e10820a..baaa07cacf 100644
--- a/widgets/table/e-table-header-item.h
+++ b/widgets/table/e-table-header-item.h
@@ -131,7 +131,7 @@ struct _ETableHeaderItemClass {
/* Signals */
void (*button_pressed) (ETableHeaderItem *ethi,
- GdkEventButton *button);
+ GdkEvent *button_event);
};
GType e_table_header_item_get_type (void) G_GNUC_CONST;
diff --git a/widgets/text/e-text.c b/widgets/text/e-text.c
index cb97e8e26a..da10bb02f9 100644
--- a/widgets/text/e-text.c
+++ b/widgets/text/e-text.c
@@ -120,7 +120,9 @@ static void calc_height (EText *text);
static gboolean show_pango_rectangle (EText *text, PangoRectangle rect);
-static void e_text_do_popup (EText *text, GdkEventButton *button, gint position);
+static void e_text_do_popup (EText *text,
+ GdkEvent *event_button,
+ gint position);
static void e_text_update_primary_selection (EText *text);
static void e_text_paste (EText *text, GdkAtom selection);
@@ -1678,13 +1680,12 @@ e_text_event (GnomeCanvasItem *item,
/* Simulate a GdkEventButton here, so that we can
* call e_text_do_popup directly */
- GdkEventButton *button;
+ GdkEvent *button_event;
- button = (GdkEventButton *)
- gdk_event_new (GDK_BUTTON_PRESS);
- button->time = event->key.time;
- button->button = 0;
- e_text_do_popup (text, button, 0);
+ button_event = gdk_event_new (GDK_BUTTON_PRESS);
+ button_event->button.time = event->key.time;
+ button_event->button.button = 0;
+ e_text_do_popup (text, button_event, 0);
return 1;
}
@@ -1748,7 +1749,7 @@ e_text_event (GnomeCanvasItem *item,
if (event->type == GDK_BUTTON_PRESS && event->button.button == 3) {
if (text->handle_popup) {
e_text_do_popup (
- text, &(event->button),
+ text, event,
get_position_from_xy (
text, event->button.x,
event->button.y));
@@ -2006,7 +2007,7 @@ e_text_paste (EText *text,
typedef struct {
EText *text;
- GdkEventButton *button;
+ GdkEvent *event;
gint position;
} PopupClosure;
@@ -2046,10 +2047,15 @@ popup_targets_received (GtkClipboard *clipboard,
{
PopupClosure *closure = user_data;
EText *text = closure->text;
- GdkEventButton *button = closure->button;
+ GdkEvent *event = closure->event;
gint position = closure->position;
GtkWidget *popup_menu = gtk_menu_new ();
GtkWidget *menuitem, *submenu;
+ guint event_button = 0;
+ guint32 event_time;
+
+ gdk_event_get_button (event, &event_button);
+ event_time = gdk_event_get_time (event);
g_free (closure);
@@ -2114,36 +2120,40 @@ popup_targets_received (GtkClipboard *clipboard,
GTK_MENU_SHELL (submenu));
}
- g_signal_emit (text,
- e_text_signals[E_TEXT_POPULATE_POPUP],
- 0,
- button, position,
- popup_menu);
-
- /* If invoked by S-F10 key binding, button will be 0. */
- if (button->button == 0) {
- gtk_menu_popup (GTK_MENU (popup_menu), NULL, NULL,
- popup_menu_placement_cb, (gpointer) text,
- button->button, GDK_CURRENT_TIME);
- } else {
- gtk_menu_popup (GTK_MENU (popup_menu), NULL, NULL,
- NULL, NULL,
- button->button, button->time);
- }
-
- g_object_unref (text);
- gdk_event_free ((GdkEvent *) button);
+ g_signal_emit (
+ text,
+ e_text_signals[E_TEXT_POPULATE_POPUP],
+ 0,
+ event,
+ position,
+ popup_menu);
+
+ /* If invoked by S-F10 key binding, button will be 0. */
+ if (event_button == 0) {
+ gtk_menu_popup (
+ GTK_MENU (popup_menu), NULL, NULL,
+ popup_menu_placement_cb, (gpointer) text,
+ event_button, GDK_CURRENT_TIME);
+ } else {
+ gtk_menu_popup (
+ GTK_MENU (popup_menu), NULL, NULL,
+ NULL, NULL,
+ event_button, event_time);
+ }
+
+ g_object_unref (text);
+ gdk_event_free (event);
}
static void
e_text_do_popup (EText *text,
- GdkEventButton *button,
+ GdkEvent *button_event,
gint position)
{
PopupClosure *closure = g_new (PopupClosure, 1);
closure->text = g_object_ref (text);
- closure->button = (GdkEventButton *) gdk_event_copy ((GdkEvent *) button);
+ closure->event = gdk_event_copy (button_event);
closure->position = position;
gtk_clipboard_request_contents (
diff --git a/widgets/text/e-text.h b/widgets/text/e-text.h
index 17e51eb9b3..b3099f1a64 100644
--- a/widgets/text/e-text.h
+++ b/widgets/text/e-text.h
@@ -212,7 +212,7 @@ struct _ETextClass {
void (* changed) (EText *text);
void (* activate) (EText *text);
void (* keypress) (EText *text, guint keyval, guint state);
- void (* populate_popup) (EText *text, GdkEventButton *ev, gint pos, GtkMenu *menu);
+ void (* populate_popup) (EText *text, GdkEvent *button_event, gint pos, GtkMenu *menu);
void (* style_set) (EText *text, GtkStyle *previous_style);
};