diff options
Diffstat (limited to 'src/idocalendarmenuitem.c')
-rw-r--r-- | src/idocalendarmenuitem.c | 52 |
1 files changed, 35 insertions, 17 deletions
diff --git a/src/idocalendarmenuitem.c b/src/idocalendarmenuitem.c index 0a8779c..806c863 100644 --- a/src/idocalendarmenuitem.c +++ b/src/idocalendarmenuitem.c @@ -26,8 +26,13 @@ #include <gdk/gdkkeysyms.h> #include "idocalendarmenuitem.h" +#if GTK_CHECK_VERSION (3, 0, 0) +static void ido_calendar_menu_item_select (GtkMenuItem *item); +static void ido_calendar_menu_item_deselect (GtkMenuItem *item); +#else static void ido_calendar_menu_item_select (GtkItem *item); static void ido_calendar_menu_item_deselect (GtkItem *item); +#endif static gboolean ido_calendar_menu_item_button_release (GtkWidget *widget, GdkEventButton *event); static gboolean ido_calendar_menu_item_button_press (GtkWidget *widget, @@ -65,18 +70,27 @@ ido_calendar_menu_item_class_init (IdoCalendarMenuItemClass *klass) GObjectClass *gobject_class; GtkWidgetClass *widget_class; GtkMenuItemClass *menu_item_class; +#if ! GTK_CHECK_VERSION (3, 0, 0) GtkItemClass *item_class; +#endif gobject_class = G_OBJECT_CLASS (klass); widget_class = GTK_WIDGET_CLASS (klass); menu_item_class = GTK_MENU_ITEM_CLASS (klass); +#if ! GTK_CHECK_VERSION (3, 0, 0) item_class = GTK_ITEM_CLASS (klass); +#endif widget_class->button_release_event = ido_calendar_menu_item_button_release; widget_class->button_press_event = ido_calendar_menu_item_button_press; +#if GTK_CHECK_VERSION (3, 0, 0) + menu_item_class->select = ido_calendar_menu_item_select; + menu_item_class->deselect = ido_calendar_menu_item_deselect; +#else item_class->select = ido_calendar_menu_item_select; item_class->deselect = ido_calendar_menu_item_deselect; +#endif menu_item_class->hide_on_activate = TRUE; @@ -101,12 +115,6 @@ static void ido_calendar_menu_item_init (IdoCalendarMenuItem *item) { IdoCalendarMenuItemPrivate *priv; - GtkBorder border; - - border.left = 4; - border.right = 4; - border.top = 2; - border.bottom = 2; priv = item->priv = IDO_CALENDAR_MENU_ITEM_GET_PRIVATE (item); @@ -143,7 +151,7 @@ ido_calendar_menu_item_send_focus_change (GtkWidget *widget, gtk_widget_grab_focus (widget); event->focus_change.type = GDK_FOCUS_CHANGE; - event->focus_change.window = g_object_ref (widget->window); + event->focus_change.window = g_object_ref (gtk_widget_get_window (widget)); event->focus_change.in = in; gtk_widget_event (widget, event); @@ -168,9 +176,9 @@ ido_calendar_menu_item_key_press (GtkWidget *widget, gtk_widget_event (calendar, ((GdkEvent *)(void*)(event))); - if (calendar->window != NULL) + if (gtk_widget_get_window (calendar) != NULL) { - gdk_window_raise (calendar->window); + gdk_window_raise (gtk_widget_get_window (calendar)); } if (!gtk_widget_has_focus (calendar)) @@ -178,7 +186,7 @@ ido_calendar_menu_item_key_press (GtkWidget *widget, gtk_widget_grab_focus (calendar); } - return event->keyval != GDK_Return; + return event->keyval != GDK_KEY_Return; } return FALSE; @@ -192,9 +200,9 @@ ido_calendar_menu_item_button_press (GtkWidget *widget, if (event->button == 1) { - if (calendar->window != NULL) + if (gtk_widget_get_window (calendar) != NULL) { - gdk_window_raise (calendar->window); + gdk_window_raise (gtk_widget_get_window (calendar)); } if (!gtk_widget_has_focus (calendar)) @@ -218,7 +226,11 @@ ido_calendar_menu_item_button_release (GtkWidget *widget, } static void +#if GTK_CHECK_VERSION (3, 0, 0) +ido_calendar_menu_item_select (GtkMenuItem *item) +#else ido_calendar_menu_item_select (GtkItem *item) +#endif { IDO_CALENDAR_MENU_ITEM (item)->priv->selected = TRUE; @@ -226,7 +238,11 @@ ido_calendar_menu_item_select (GtkItem *item) } static void +#if GTK_CHECK_VERSION (3, 0, 0) +ido_calendar_menu_item_deselect (GtkMenuItem *item) +#else ido_calendar_menu_item_deselect (GtkItem *item) +#endif { IDO_CALENDAR_MENU_ITEM (item)->priv->selected = FALSE; @@ -238,12 +254,12 @@ static void calendar_realized_cb (GtkWidget *widget, IdoCalendarMenuItem *item) { - if (widget->window != NULL) + if (gtk_widget_get_window (widget) != NULL) { - gdk_window_raise (widget->window); + gdk_window_raise (gtk_widget_get_window (widget)); } - g_signal_connect (GTK_WIDGET (item)->parent, + g_signal_connect (gtk_widget_get_parent (GTK_WIDGET (item)), "key-press-event", G_CALLBACK (ido_calendar_menu_item_key_press), item); @@ -322,7 +338,8 @@ ido_calendar_menu_item_mark_day (IdoCalendarMenuItem *menuitem, guint day) { g_return_val_if_fail(IDO_IS_CALENDAR_MENU_ITEM(menuitem), FALSE); - return gtk_calendar_mark_day(GTK_CALENDAR (menuitem->priv->calendar), day); + gtk_calendar_mark_day(GTK_CALENDAR (menuitem->priv->calendar), day); + return TRUE; } gboolean @@ -330,7 +347,8 @@ ido_calendar_menu_item_unmark_day (IdoCalendarMenuItem *menuitem, guint day) { g_return_val_if_fail(IDO_IS_CALENDAR_MENU_ITEM(menuitem), FALSE); - return gtk_calendar_unmark_day(GTK_CALENDAR (menuitem->priv->calendar), day); + gtk_calendar_unmark_day(GTK_CALENDAR (menuitem->priv->calendar), day); + return TRUE; } void |