~indicators-gtk2-team/indicators-gtk2/ido-gtk2

« back to all changes in this revision

Viewing changes to src/idocalendarmenuitem.c

  • Committer: Lionel Le Folgoc
  • Date: 2012-09-09 10:41:29 UTC
  • Revision ID: mrpouit@ubuntu.com-20120909104129-69xnvfoa5ggx3hnx
Restore Gtk+2 support (take 2)

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
#include "idocalendarmenuitem.h"
28
28
#include "config.h"
29
29
 
30
 
static void     ido_calendar_menu_item_select            (GtkMenuItem        *item);
31
 
static void     ido_calendar_menu_item_deselect          (GtkMenuItem        *item);
 
30
static void     ido_calendar_menu_item_select            (GtkItem        *item);
 
31
static void     ido_calendar_menu_item_deselect          (GtkItem        *item);
32
32
static gboolean ido_calendar_menu_item_button_release    (GtkWidget      *widget,
33
33
                                                          GdkEventButton *event);
34
34
static gboolean ido_calendar_menu_item_button_press      (GtkWidget      *widget,
66
66
  GObjectClass     *gobject_class;
67
67
  GtkWidgetClass   *widget_class;
68
68
  GtkMenuItemClass *menu_item_class;
 
69
  GtkItemClass     *item_class;
69
70
 
70
71
  gobject_class = G_OBJECT_CLASS (klass);
71
72
  widget_class = GTK_WIDGET_CLASS (klass);
72
73
  menu_item_class = GTK_MENU_ITEM_CLASS (klass);
 
74
  item_class = GTK_ITEM_CLASS (klass);
73
75
 
74
76
  widget_class->button_release_event = ido_calendar_menu_item_button_release;
75
77
  widget_class->button_press_event = ido_calendar_menu_item_button_press;
76
78
 
77
 
  menu_item_class->select = ido_calendar_menu_item_select;
78
 
  menu_item_class->deselect = ido_calendar_menu_item_deselect;
 
79
  item_class->select = ido_calendar_menu_item_select;
 
80
  item_class->deselect = ido_calendar_menu_item_deselect;
79
81
 
80
82
  menu_item_class->hide_on_activate = TRUE;
81
83
 
116
118
                    G_CALLBACK (calendar_move_focus_cb),
117
119
                    item);
118
120
 
119
 
  priv->box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
 
121
  priv->box = gtk_hbox_new (FALSE, 0);
120
122
 
121
123
  gtk_box_pack_start (GTK_BOX (priv->box), priv->calendar, FALSE, FALSE, 0);
122
124
 
193
195
                        gtk_widget_grab_focus (calendar);
194
196
                }
195
197
 
196
 
                GdkEvent * newevent = gdk_event_copy((GdkEvent *)(event));
197
 
                GList * children = gdk_window_get_children(gtk_widget_get_window(calendar));
198
 
                GList * child;
199
 
 
200
 
                gint root_x = event->x_root;
201
 
                gint root_y = event->y_root;
202
 
 
203
 
                for (child = children; child != NULL; child = g_list_next(child)) {
204
 
                        gint newx, newy;
205
 
                        gint winx, winy;
206
 
                        GdkWindow * newwindow = (GdkWindow*)child->data;
207
 
 
208
 
                        ((GdkEventButton *)newevent)->window = newwindow;
209
 
 
210
 
                        gdk_window_get_origin(newwindow, &winx, &winy);
211
 
                        newx = root_x - winx;
212
 
                        newy = root_y - winy;
213
 
 
214
 
                        if (newx >= 0 && newy >= 0 && newx < gdk_window_get_width(newwindow) && newy < gdk_window_get_height(newwindow)) {
215
 
                                ((GdkEventButton *)newevent)->x = newx;
216
 
                                ((GdkEventButton *)newevent)->y = newy;
217
 
 
218
 
                                GTK_WIDGET_GET_CLASS(calendar)->button_press_event(GTK_WIDGET(calendar), (GdkEventButton*)newevent);
219
 
                        }
220
 
                }
221
 
 
222
 
                ((GdkEventButton *)newevent)->window = event->window;
223
 
                gdk_event_free(newevent);
224
 
 
225
198
                return TRUE;
226
199
        }
227
200
 
232
205
ido_calendar_menu_item_button_release (GtkWidget      *widget,
233
206
                                       GdkEventButton *event)
234
207
{
235
 
  GtkWidget *calendar = IDO_CALENDAR_MENU_ITEM (widget)->priv->calendar;
236
 
  GTK_WIDGET_GET_CLASS(calendar)->button_release_event(GTK_WIDGET(calendar), event);
237
 
 
238
208
  return TRUE;
239
209
}
240
210
 
241
211
static void
242
 
ido_calendar_menu_item_select (GtkMenuItem *item)
 
212
ido_calendar_menu_item_select (GtkItem *item)
243
213
{
244
214
  IDO_CALENDAR_MENU_ITEM (item)->priv->selected = TRUE;
245
215
 
247
217
}
248
218
 
249
219
static void
250
 
ido_calendar_menu_item_deselect (GtkMenuItem *item)
 
220
ido_calendar_menu_item_deselect (GtkItem *item)
251
221
{
252
222
  IDO_CALENDAR_MENU_ITEM (item)->priv->selected = FALSE;
253
223