static void
control_activate_cb (BonoboControl *control,
		     gboolean activate,
		     EYank *yank)
{
	BonoboUIComponent *ui_component;
	
	ui_component = bonobo_control_get_ui_component (control);
	
	if (yank->shell_view_interface == NULL) {
		Bonobo_ControlFrame control_frame;
		CORBA_Environment ev;

		control_frame = bonobo_control_get_control_frame (control);
		if (control_frame == NULL) {
			goto out;
		}

		CORBA_exception_init (&ev);
		yank->shell_view_interface = Bonobo_Unknown_queryInterface (control_frame, "IDL:GNOME/Evolution/ShellView:1.0", &ev);

		if (BONOBO_EX (&ev)) {
			g_warning ("Error getting ShellView. %s", CORBA_exception_id (&ev));
			yank->shell_view_interface = CORBA_OBJECT_NIL;
		}
		CORBA_exception_free (&ev);
	}
 out:

	if (activate)
		control_activate (control, ui_component, yank);
	else
		control_deactivate (control, ui_component, yank);
}
/* Sensitizes the UI Component menu/toolbar tasks commands based on the number
 * of selected tasks.  If enable is FALSE, all will be disabled.  Otherwise, the
 * currently-selected number of tasks will be used.
 */
static void
sensitize_taskpad_commands (GnomeCalendar *gcal, BonoboControl *control, gboolean enable)
{
	BonoboUIComponent *uic;
	ECalendarTable *task_pad;
	ECalModel *model;
	GSList *selected, *l;
	ECalMenu *menu;
	GPtrArray *events;
	ECalMenuTargetSelect *t;

	uic = bonobo_control_get_ui_component (control);
	g_return_if_fail (uic != NULL);

	menu = gnome_calendar_get_calendar_menu (gcal);
	task_pad = gnome_calendar_get_task_pad(gcal);
	model = e_calendar_table_get_model (task_pad);
	selected = e_calendar_table_get_selected(task_pad);
	events = g_ptr_array_new();
	for (l=selected;l;l=g_slist_next(l))
		g_ptr_array_add(events, e_cal_model_copy_component_data((ECalModelComponent *)l->data));
	g_slist_free(selected);

	t = e_cal_menu_target_new_select(menu, model, events);
	if (!enable)
		t->target.mask = ~0;

	sensitize_items(uic, taskpad_sensitize_table, t->target.mask);
}
void
calendar_control_deactivate (BonoboControl *control, GnomeCalendar *gcal)
{
	FocusData *focus;
	BonoboUIComponent *uic;

	uic = bonobo_control_get_ui_component (control);
	g_return_if_fail (uic != NULL);

	e_menu_activate((EMenu *)gnome_calendar_get_calendar_menu (gcal), uic, 0);
	e_menu_activate((EMenu *)gnome_calendar_get_taskpad_menu (gcal), uic, 0);

	gnome_calendar_set_ui_component (gcal, NULL);

	focus = g_object_get_data (G_OBJECT (control), "focus_data");
	g_return_if_fail (focus != NULL);

	g_object_set_data (G_OBJECT (control), "focus_data", NULL);
	g_free (focus);

	gnome_calendar_discard_view_menus (gcal);

	g_signal_handlers_disconnect_matched (gcal, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, control);

	bonobo_ui_component_rm (uic, "/", NULL);
 	bonobo_ui_component_unset_container (uic, NULL);
}
Beispiel #4
0
static void
view_control_activate_cb (BonoboControl *control, gboolean activate, EMFolderView *view)
{
	BonoboUIComponent *uic;
	static int recover = 0;

	uic = bonobo_control_get_ui_component (control);
	g_return_if_fail (uic != NULL);

	if (activate) {
		Bonobo_UIContainer container;

		container = bonobo_control_get_remote_ui_container (control, NULL);
		bonobo_ui_component_set_container (uic, container, NULL);
		bonobo_object_release_unref (container, NULL);

		g_return_if_fail (container == bonobo_ui_component_get_container(uic));
		g_return_if_fail (container != CORBA_OBJECT_NIL);

		em_folder_view_activate (view, uic, activate);
		e_user_creatable_items_handler_activate(g_object_get_data((GObject *)view, "e-creatable-items-handler"), uic);
	} else {
		em_folder_view_activate (view, uic, activate);
		bonobo_ui_component_unset_container (uic, NULL);
	}

	/* This is a weird place to put it, but createControls does it too early.
	   I also think we should wait to do it until we actually visit the mailer.
	   The delay is arbitrary - without it it shows up before the main window */
	if (!recover) {
		recover = 1;
		g_timeout_add(1000, check_autosave, NULL);
	}
}
void
calendar_control_activate (BonoboControl *control,
			   GnomeCalendar *gcal)
{
	Bonobo_UIContainer remote_uih;
	BonoboUIComponent *uic;
	FocusData *focus;
	gchar *xmlfile;

	uic = bonobo_control_get_ui_component (control);
	g_return_if_fail (uic != NULL);

	remote_uih = bonobo_control_get_remote_ui_container (control, NULL);
	bonobo_ui_component_set_container (uic, remote_uih, NULL);
	bonobo_object_release_unref (remote_uih, NULL);

	gnome_calendar_set_ui_component (gcal, uic);

	bonobo_ui_component_add_verb_list_with_data (uic, verbs, gcal);

	bonobo_ui_component_freeze (uic, NULL);

	xmlfile = g_build_filename (EVOLUTION_UIDIR,
				    "evolution-calendar.xml",
				    NULL);
	bonobo_ui_util_set_ui (uic, PREFIX,
			       xmlfile,
			       "evolution-calendar",
			       NULL);
	g_free (xmlfile);

	e_pixmaps_update (uic, pixmaps);

	gnome_calendar_setup_view_menus (gcal, uic);

	g_signal_connect (gcal, "calendar_focus_change",
			  G_CALLBACK (gcal_calendar_focus_change_cb), control);
	g_signal_connect (gcal, "taskpad_focus_change",
			  G_CALLBACK (gcal_taskpad_focus_change_cb), control);

	e_menu_activate((EMenu *)gnome_calendar_get_calendar_menu (gcal), uic, 1);
	e_menu_activate((EMenu *)gnome_calendar_get_taskpad_menu (gcal), uic, 1);

	calendar_control_sensitize_calendar_commands (control, gcal, TRUE);
	sensitize_taskpad_commands (gcal, control, TRUE);

	bonobo_ui_component_thaw (uic, NULL);

	focus = g_new (FocusData, 1);
	focus->calendar_focused = FALSE;
	focus->taskpad_focused = FALSE;

	g_object_set_data (G_OBJECT (control), "focus_data", focus);
}
Beispiel #6
0
static void
peacock_file_control_activate_cb (BonoboControl *control, gboolean state,
				  gpointer user_data)
{
	BonoboUIComponent *uic;

	uic = bonobo_control_get_ui_component (control);
	if (state) { /* Activate */
		bonobo_ui_util_set_ui (uic, UIXMLDIR,
				       "peacock-file-ui.xml",
				       "peacock-2", NULL);
	} else {
		bonobo_ui_component_unset_container (uic, NULL);
	}
}
/* Sensitizes the UI Component menu/toolbar calendar commands based on the
 * number of selected events. (This will always be 0 or 1 currently.)  If enable
 * is FALSE, all will be disabled.  Otherwise, the currently-selected number of
 * events will be used.
 */
void
calendar_control_sensitize_calendar_commands (BonoboControl *control, GnomeCalendar *gcal, gboolean enable)
{
	BonoboUIComponent *uic;
	GtkWidget *view;
	ECalMenu *menu;
	ECalModel *model;
	GPtrArray *events;
	GList *selected, *l;
	ECalMenuTargetSelect *t;

	uic = bonobo_control_get_ui_component (control);
	g_return_if_fail (uic != NULL);

	if (bonobo_ui_component_get_container (uic) == CORBA_OBJECT_NIL)
		return;

	view = gnome_calendar_get_current_view_widget (gcal);

	menu = gnome_calendar_get_calendar_menu (gcal);
	model = e_calendar_view_get_model((ECalendarView *)view);
	events = g_ptr_array_new();
	selected = e_calendar_view_get_selected_events((ECalendarView *)view);
	for (l=selected;l;l=g_list_next(l)) {
		ECalendarViewEvent *event = l->data;
		if (event && event->comp_data)
			g_ptr_array_add (events, e_cal_model_copy_component_data(event->comp_data));
	}
	g_list_free(selected);

	t = e_cal_menu_target_new_select(menu, model, events);
	if (!enable)
		t->target.mask = ~0;

	sensitize_items(uic, calendar_sensitize_table, t->target.mask);
#if 0
	/* retrieve read-onlyness of the default client */
	e_cal = e_cal_model_get_default_client (gnome_calendar_get_calendar_model (gcal));
	if (e_cal)
		e_cal_is_read_only (e_cal, &default_read_only, NULL);
	else
		default_read_only = TRUE;
#endif

	e_menu_update_target((EMenu *)menu, (EMenuTarget *)t);
}
Beispiel #8
0
static void
peacock_file_control_load_ui (BonoboControl *control,
			      PeacockFileControlData *cd)
{
	BonoboUIComponent *uic;

	bonobo_control_set_automerge (cd->control, TRUE);

	uic = bonobo_control_get_ui_component (cd->control);
	bonobo_ui_component_add_verb_list_with_data (uic, peacock_file_control_ui_verbs, (gpointer) cd);

	g_signal_connect (control, "activate",
			  G_CALLBACK (peacock_file_control_activate_cb),
			  NULL);

	return;
}