Exemple #1
0
void
e_canvas_item_set_cursor (GnomeCanvasItem *item, gpointer id)
{
	GList *list;
	int flags;
	ECanvas *canvas;
	ECanvasSelectionInfo *info;
	ECanvasItemSelectionFunc func;

	g_return_if_fail(item != NULL);
	g_return_if_fail(GNOME_IS_CANVAS_ITEM(item));
	g_return_if_fail(item->canvas != NULL);
	g_return_if_fail(E_IS_CANVAS(item->canvas));

	canvas = E_CANVAS(item->canvas);
	flags = E_CANVAS_ITEM_SELECTION_DELETE_DATA;

	for (list = canvas->selection; list; list = g_list_next(list)) {
		info = list->data;

		func = (ECanvasItemSelectionFunc)g_object_get_data(G_OBJECT(info->item),
								   "ECanvasItem::selection_callback");
		if (func)
			func(info->item, flags, info->id);
		g_message ("ECANVAS: free info (2): item %p, id %p",
			   info->item, info->id);
		g_object_unref (info->item);
		g_free(info);
	}
	g_list_free(canvas->selection);

	canvas->selection = NULL;

	gnome_canvas_item_grab_focus(item);

	info = g_new(ECanvasSelectionInfo, 1);
	info->item = item;
	g_object_ref (info->item);
	info->id = id;
	g_message ("ECANVAS: new info item %p, id %p", item, id);

	flags = E_CANVAS_ITEM_SELECTION_SELECT | E_CANVAS_ITEM_SELECTION_CURSOR;
	func = (ECanvasItemSelectionFunc)g_object_get_data(G_OBJECT(item),
							   "ECanvasItem::selection_callback");
	if (func)
		func(item, flags, id);

	canvas->selection = g_list_prepend(canvas->selection, info);
	canvas->cursor = info;
}
/* Ensure the item gets focused (both globally, and local to Gtk) */
static void
iti_ensure_focus (GnomeCanvasItem *item)
{
	GtkWidget *toplevel;

        /* gnome_canvas_item_grab_focus still generates focus out/in
         * events when focused_item == item
         */
        if (GNOME_CANVAS_ITEM (item)->canvas->focused_item != item) {
        	gnome_canvas_item_grab_focus (GNOME_CANVAS_ITEM (item));
        }

	toplevel = gtk_widget_get_toplevel (GTK_WIDGET (item->canvas));
	if (toplevel != NULL && GTK_WIDGET_REALIZED (toplevel)) {
		gdk_window_focus (toplevel->window, GDK_CURRENT_TIME);
	}
}
Exemple #3
0
/* Creates a "goto date" dialog and runs it */
void
goto_dialog (GnomeCalendar *gcal)
{
	time_t start_time;
	struct icaltimetype tt;
	int b;
	char *gladefile;

	if (dlg) {
		return;
	}

	dlg = g_new0 (GoToDialog, 1);

	/* Load the content widgets */
	gladefile = g_build_filename (EVOLUTION_GLADEDIR,
				      "goto-dialog.glade",
				      NULL);
	dlg->xml = glade_xml_new (gladefile, NULL, NULL);
	g_free (gladefile);
	if (!dlg->xml) {
		g_message ("goto_dialog(): Could not load the Glade XML file!");
		g_free (dlg);
		return;
	}

	if (!get_widgets (dlg)) {
		g_message ("goto_dialog(): Could not find all widgets in the XML file!");
		g_free (dlg);
		return;
	}
	dlg->gcal = gcal;

	gnome_calendar_get_selected_time_range (dlg->gcal, &start_time, NULL);
	tt = icaltime_from_timet_with_zone (start_time, FALSE, gnome_calendar_get_timezone (gcal));
	dlg->year_val = tt.year;
	dlg->month_val = tt.month - 1;
	dlg->day_val = tt.day;

	gtk_option_menu_set_history (GTK_OPTION_MENU (dlg->month), dlg->month_val);
	gtk_spin_button_set_value (GTK_SPIN_BUTTON (dlg->year), dlg->year_val);

	create_ecal (dlg);

	goto_dialog_init_widgets (dlg);

	gtk_window_set_transient_for (GTK_WINDOW (dlg->dialog),
				      GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (gcal))));

	/* set initial selection to current day */

	dlg->ecal->calitem->selection_set = TRUE;
	dlg->ecal->calitem->selection_start_month_offset = 0;
	dlg->ecal->calitem->selection_start_day = tt.day;
	dlg->ecal->calitem->selection_end_month_offset = 0;
	dlg->ecal->calitem->selection_end_day = tt.day;

	/* Set week_start_day. Convert it to 0 (Mon) to 6 (Sun), which is what we use. */
	dlg->ecal->calitem->week_start_day = (calendar_config_get_week_start_day () + 6) % 7;

	gnome_canvas_item_grab_focus (GNOME_CANVAS_ITEM (dlg->ecal->calitem));

	b = gtk_dialog_run (GTK_DIALOG (dlg->dialog));
	gtk_widget_destroy (dlg->dialog);

	if (b == 0)
		goto_today (dlg);

	g_object_unref (dlg->xml);
	g_free (dlg);
	dlg = NULL;
}
Exemple #4
0
static gboolean
ea_calendar_focus_watcher (GSignalInvocationHint *ihint,
                           guint n_param_values,
                           const GValue *param_values,
                           gpointer data)
{
	GObject *object;
	GdkEvent *event;
        AtkObject *ea_event = NULL;

	object = g_value_get_object (param_values + 0);
	event = g_value_get_boxed (param_values + 1);

	if ((E_IS_TEXT (object)) || (GNOME_IS_CANVAS_PIXBUF (object))) {
		/* "event" signal on canvas item
		 */
		GnomeCanvasItem *canvas_item;

		canvas_item = GNOME_CANVAS_ITEM (object);
		if (event->type == GDK_FOCUS_CHANGE) {
			if (event->focus_change.in) {
				ea_event =
					ea_calendar_helpers_get_accessible_for (canvas_item);
				if (!ea_event)
					/* not canvas item we want */
					return TRUE;

			}
			atk_focus_tracker_notify (ea_event);
		}
	}
	else if (E_IS_DAY_VIEW (object)) {
		EDayView *day_view = E_DAY_VIEW (object);
		if (event->type == GDK_FOCUS_CHANGE) {
			if (event->focus_change.in) {
				/* give main item chance to emit focus */
				gnome_canvas_item_grab_focus (day_view->main_canvas_item);
			}
		}
	}
	else if (E_IS_DAY_VIEW_MAIN_ITEM (object)) {
		if (event->type == GDK_FOCUS_CHANGE) {
			if (event->focus_change.in) {
				/* we should emit focus on main item */
				ea_event = atk_gobject_accessible_for_object (object);
			}
			else
				/* focus out */
				ea_event = NULL;
#ifdef ACC_DEBUG
			printf ("EvoAcc: focus notify on day main item %p\n", (void *)object);
#endif
			atk_focus_tracker_notify (ea_event);
		}
	} else if (E_IS_WEEK_VIEW (object)) {
		EWeekView *week_view = E_WEEK_VIEW (object);
		if (event->type == GDK_FOCUS_CHANGE) {
			if (event->focus_change.in) {
				/* give main item chance to emit focus */
				gnome_canvas_item_grab_focus (week_view->main_canvas_item);
			}
		}
	}
	else if (E_IS_WEEK_VIEW_MAIN_ITEM (object)) {
		if (event->type == GDK_FOCUS_CHANGE) {
			if (event->focus_change.in) {
				/* we should emit focus on main item */
				ea_event = atk_gobject_accessible_for_object (object);
			}
			else
				/* focus out */
				ea_event = NULL;
#ifdef ACC_DEBUG
			printf ("EvoAcc: focus notify on week main item %p\n", (void *)object);
#endif
			atk_focus_tracker_notify (ea_event);
		}
	}
	return TRUE;
}
Exemple #5
0
void
e_canvas_item_add_selection (GnomeCanvasItem *item, gpointer id)
{
	int flags;
	ECanvas *canvas;
	ECanvasSelectionInfo *info;
	ECanvasItemSelectionFunc func;
	GList *list;

	g_return_if_fail(item != NULL);
	g_return_if_fail(GNOME_IS_CANVAS_ITEM(item));
	g_return_if_fail(item->canvas != NULL);
	g_return_if_fail(E_IS_CANVAS(item->canvas));

	flags = E_CANVAS_ITEM_SELECTION_SELECT;
	canvas = E_CANVAS(item->canvas);

	if (canvas->cursor) {
		func = (ECanvasItemSelectionFunc)g_object_get_data(G_OBJECT(canvas->cursor->item),
								   "ECanvasItem::selection_callback");
		if (func)
			func(canvas->cursor->item, flags, canvas->cursor->id);
	}

	gnome_canvas_item_grab_focus(item);

	flags = E_CANVAS_ITEM_SELECTION_SELECT | E_CANVAS_ITEM_SELECTION_CURSOR;

	for (list = canvas->selection; list; list = g_list_next(list)) {
		ECanvasSelectionInfo *search;
		search = list->data;

		if (search->item == item) {
			ECanvasItemSelectionCompareFunc compare_func;
			compare_func = (ECanvasItemSelectionCompareFunc)g_object_get_data(G_OBJECT(search->item),
											  "ECanvasItem::selection_compare_callback");

			if (compare_func(search->item, search->id, id, 0) == 0) {
				canvas->cursor = search;
				func = (ECanvasItemSelectionFunc)g_object_get_data(G_OBJECT(item),
										   "ECanvasItem::selection_callback");
				if (func)
					func(item, flags, search->id);
				return;
			}
		}
	}

	info = g_new(ECanvasSelectionInfo, 1);
	info->item = item;
	g_object_ref (info->item);
	info->id = id;
	g_message ("ECANVAS: new info (2): item %p, id %p", item, id);

	func = (ECanvasItemSelectionFunc)g_object_get_data(G_OBJECT(item),
							   "ECanvasItem::selection_callback");
	if (func)
		func(item, flags, id);

	canvas->selection = g_list_prepend(canvas->selection, info);
	canvas->cursor = info;
}