Exemplo n.º 1
0
static void
mail_view_set_shell_view (EMailView *view,
                          EShellView *shell_view)
{
	g_return_if_fail (E_IS_SHELL_VIEW (shell_view));
	g_return_if_fail (view->priv->shell_view == NULL);

	view->priv->shell_view = g_object_ref (shell_view);
}
static void
memo_shell_content_is_editing_changed_cb (EMemoTable *memo_table,
                                          GParamSpec *param,
                                          EShellView *shell_view)
{
	g_return_if_fail (E_IS_SHELL_VIEW (shell_view));

	e_shell_view_update_actions (shell_view);
}
static void
e_mapi_config_ui_extension_shell_view_toggled_cb (EShellView *shell_view,
						  EMapiConfigUIExtension *ui_ext)
{
	EShellViewClass *shell_view_class;
	EShellWindow *shell_window;
	GtkUIManager *ui_manager;
	gpointer key = NULL, value = NULL;
	const gchar *ui_def;
	gboolean is_active, need_update;

	g_return_if_fail (E_IS_SHELL_VIEW (shell_view));
	g_return_if_fail (ui_ext != NULL);

	shell_view_class = E_SHELL_VIEW_GET_CLASS (shell_view);
	g_return_if_fail (shell_view_class != NULL);

	shell_window = e_shell_view_get_shell_window (shell_view);
	ui_manager = e_shell_window_get_ui_manager (shell_window);

	need_update = ui_ext->current_ui_id != 0;
	if (ui_ext->current_ui_id) {
		gtk_ui_manager_remove_ui (ui_manager, ui_ext->current_ui_id);
		ui_ext->current_ui_id = 0;
	}

	is_active = e_shell_view_is_active (shell_view);
	if (!is_active) {
		if (need_update)
			gtk_ui_manager_ensure_update (ui_manager);

		return;
	}

	if (!g_hash_table_lookup_extended (ui_ext->ui_definitions, shell_view_class->ui_manager_id, &key, &value)) {
		gchar *ui_definition = NULL;

		e_mapi_config_utils_init_ui (shell_view, shell_view_class->ui_manager_id, &ui_definition);
		g_hash_table_insert (ui_ext->ui_definitions, g_strdup (shell_view_class->ui_manager_id), ui_definition);
	}

	ui_def = g_hash_table_lookup (ui_ext->ui_definitions, shell_view_class->ui_manager_id);
	if (ui_def) {
		GError *error = NULL;

		ui_ext->current_ui_id = gtk_ui_manager_add_ui_from_string (ui_manager, ui_def, -1, &error);
		need_update = TRUE;

		if (error) {
			g_warning ("%s: Failed to add ui definition: %s", G_STRFUNC, error->message);
			g_error_free (error);
		}
	}

	if (need_update)
		gtk_ui_manager_ensure_update (ui_manager);
}
Exemplo n.º 4
0
static void
update_mmp_entries_cb (EShellView *shell_view,
                       gpointer user_data)
{
	EShellWindow *shell_window;
	GtkActionGroup *action_group;
	gboolean visible;
	gchar *full_name = NULL, *uri = NULL;
	guint n_selected = 0;

	g_return_if_fail (E_IS_SHELL_VIEW (shell_view));

	shell_window = e_shell_view_get_shell_window (shell_view);
	action_group = e_shell_window_get_action_group (shell_window, "mail");

	visible = is_in_gw_account (shell_view, NULL, &full_name);
	if (visible) {
		EShellContent *shell_content;
		EMailReader *reader;
		GPtrArray *uids;

		shell_content = e_shell_view_get_shell_content (shell_view);

		reader = E_MAIL_READER (shell_content);
		uids = e_mail_reader_get_selected_uids (reader);

		if (uids)
			n_selected = uids->len;

		em_utils_uids_free (uids);

		visible = n_selected > 0;
	}

	visible_actions (action_group, visible, mmp_entries, G_N_ELEMENTS (mmp_entries));

	if (visible) {
		GtkAction *action;
		gboolean is_sent_items_folder = full_name && g_ascii_strncasecmp (full_name, "Sent Items", 10) == 0;

		action = gtk_action_group_get_action (action_group, "gw-track-message-status");
		g_return_if_fail (action != NULL);
		gtk_action_set_visible (action, is_sent_items_folder && n_selected == 1);

		action = gtk_action_group_get_action (action_group, "gw-retract-mail");
		g_return_if_fail (action != NULL);
		gtk_action_set_visible (action, is_sent_items_folder && n_selected == 1);
	}

	g_free (full_name);
	g_free (uri);
}
static void
update_source_entries_cb (EShellView *shell_view,
                          GtkActionEntry *entries)
{
	GtkActionGroup *action_group;
	EShellWindow *shell_window;
	GtkAction *action;
	const gchar *group;
	gchar *uri = NULL;
	gboolean is_eex_source, is_eex_avail;
	gint i;

	g_return_if_fail (E_IS_SHELL_VIEW (shell_view));
	g_return_if_fail (entries != NULL);

	if (strstr (entries->name, "calendar"))
		group = "calendar";
	else if (strstr (entries->name, "tasks"))
		group = "tasks";
	else
		group = "contacts";

	is_eex_source = is_eex_source_selected (shell_view, &uri);
	is_eex_avail = is_eex_source || is_eex_source_available (shell_view);
	shell_window = e_shell_view_get_shell_window (shell_view);
	action_group = e_shell_window_get_action_group (shell_window, group);

	/* index 0 ... Permissions
	 * index 1 ... Subscribe to
	 * index 2 ... Unsubscribe */
	for (i = 0; i < NUM_ENTRIES; i++) {
		gboolean visible = is_eex_avail;

		action = gtk_action_group_get_action (action_group, entries[i].name);
		g_return_if_fail (action != NULL);

		if (visible && i == 2) {
			/* it's an unsubscribe, check if this is public and show/hide based on that */
			visible = uri && is_subscribed_folder (uri);
		}

		gtk_action_set_visible (action, visible);
		gtk_action_set_sensitive (action, i == 1 || (visible && is_eex_source));
	}

	g_free (uri);
}
void
e_kolab_backend_sync_ui_conflict_cb (EShellView *shell_view)
{
	GObject *dialog = NULL;

	KolabBackendSyncConflictUIData *uidata = NULL;

	if (shell_view != NULL)
		g_assert (E_IS_SHELL_VIEW (shell_view));

	uidata = kolab_backend_sync_conflict_ui_new ();
	dialog = G_OBJECT (uidata->widgets->container);
	g_object_set_data_full (dialog, "e-kolab-backend-sync-prop", uidata, kolab_backend_sync_conflict_ui_destroy);

	/* signals */

	gtk_widget_show (GTK_WIDGET (dialog));
}
static gboolean
kolab_folder_metadata_ui_syncstrategy_set (KolabFolderMetaUIData *uidata,
                                           GCancellable *cancellable,
                                           GError **err)
{
	ESource *source = NULL;
	ESourceResource *resource = NULL;
	gboolean is_kolab = FALSE;
	GError *tmp_err = NULL;
	gboolean ok = TRUE;

	g_return_val_if_fail (uidata != NULL, FALSE);
	g_return_val_if_fail (E_IS_SHELL_VIEW (uidata->shell_view), FALSE);
	/* cancellable may be NULL */
	g_return_val_if_fail (err == NULL || *err == NULL, FALSE);

	is_kolab = e_kolab_plugin_util_ui_get_selected_source (uidata->shell_view,
	                                                       &source);
	if (! is_kolab) {
		g_warning ("%s()[%u] expected Kolab source, got something else, skipping",
		           __func__, __LINE__);
		goto exit;
	}

	resource = E_SOURCE_RESOURCE (e_source_get_extension (source,
	                                                      E_SOURCE_EXTENSION_KOLAB_FOLDER));
	e_source_kolab_folder_set_sync_strategy (E_SOURCE_KOLAB_FOLDER (resource),
	                                         uidata->metadata->strategy);
	ok = e_source_write_sync (source,
	                          cancellable,
	                          &tmp_err);
 exit:
	if (tmp_err != NULL) {
		g_propagate_error (err, tmp_err);
		ok = FALSE;
	}

	if (source != NULL)
		g_object_unref (source);

	return ok;
}
Exemplo n.º 8
0
void
vfolder_edit (EShellView *shell_view)
{
	EShellBackend *shell_backend;
	EShellWindow *shell_window;
	EMailBackend *backend;
	GtkWidget *dialog;
	const gchar *config_dir;
	gchar *filename;

	g_return_if_fail (E_IS_SHELL_VIEW (shell_view));

	shell_backend = e_shell_view_get_shell_backend (shell_view);
	shell_window = e_shell_view_get_shell_window (shell_view);

	config_dir = e_shell_backend_get_config_dir (shell_backend);
	filename = g_build_filename (config_dir, "vfolders.xml", NULL);

	backend = E_MAIL_BACKEND (shell_backend);

	vfolder_load_storage (backend);

	dialog = em_vfolder_editor_new (context);
	gtk_window_set_title (
		GTK_WINDOW (dialog), _("Search Folders"));
	gtk_window_set_transient_for (
		GTK_WINDOW (dialog), GTK_WINDOW (shell_window));

	switch (gtk_dialog_run (GTK_DIALOG (dialog))) {
		case GTK_RESPONSE_OK:
			e_rule_context_save ((ERuleContext *) context, filename);
			break;
		default:
			e_rule_context_revert ((ERuleContext *) context, filename);
			break;
	}

	gtk_widget_destroy (dialog);
}
static void
update_mail_entries_cb (EShellView *shell_view,
                        gpointer user_data)
{
	GtkActionGroup *action_group;
	EShellWindow *shell_window;
	GtkAction *action;
	gboolean is_eex, is_eex_avail;
	gchar *uri = NULL;
	gint i;

	g_return_if_fail (E_IS_SHELL_VIEW (shell_view));

	is_eex = is_eex_folder_selected (shell_view, &uri);
	is_eex_avail = is_eex || is_eex_store_available (shell_view);
	shell_window = e_shell_view_get_shell_window (shell_view);
	action_group = e_shell_window_get_action_group (shell_window, "mail");

	/* index 0 ... Permissions
	 * index 1 ... Subscribe to
	 * index 2 ... Unsubscribe */
	for (i = 0; i < G_N_ELEMENTS (mail_entries); i++) {
		gboolean visible = is_eex_avail;

		action = gtk_action_group_get_action (action_group, mail_entries[i].name);
		g_return_if_fail (action != NULL);

		if (visible && i == 2) {
			/* it's an unsubscribe, check if this is public and show/hide based on that */
			visible = uri && is_subscribed_folder (uri);
		}

		gtk_action_set_visible (action, visible);
		gtk_action_set_sensitive (action, i == 1 || (visible && is_eex));
	}

	g_free (uri);
}
Exemplo n.º 10
0
static KolabSyncStrategyID
kolab_folder_metadata_ui_syncstrategy_get (KolabFolderMetaUIData *uidata)
{
	KolabSyncStrategyID strategy = KOLAB_SYNC_STRATEGY_DEFAULT;
	ESource *source = NULL;
	ESourceResource *resource = NULL;
	gboolean is_kolab = FALSE;

	g_return_val_if_fail (uidata != NULL, KOLAB_SYNC_STRATEGY_DEFAULT);
	g_return_val_if_fail (E_IS_SHELL_VIEW (uidata->shell_view), KOLAB_SYNC_STRATEGY_DEFAULT);

	is_kolab = e_kolab_plugin_util_ui_get_selected_source (uidata->shell_view,
	                                                       &source);
	g_return_val_if_fail (is_kolab, KOLAB_SYNC_STRATEGY_DEFAULT);

	resource = E_SOURCE_RESOURCE (e_source_get_extension (source,
	                                                      E_SOURCE_EXTENSION_KOLAB_FOLDER));
	strategy = e_source_kolab_folder_get_sync_strategy (E_SOURCE_KOLAB_FOLDER (resource));

	g_object_unref (source);

	return strategy;
}
Exemplo n.º 11
0
static void
update_mfp_entries_cb (EShellView *shell_view,
                       gpointer user_data)
{
	GtkActionGroup *action_group;
	EShellWindow *shell_window;
	gboolean is_on_store = FALSE, visible;

	g_return_if_fail (E_IS_SHELL_VIEW (shell_view));

	shell_window = e_shell_view_get_shell_window (shell_view);
	action_group = e_shell_window_get_action_group (shell_window, "mail");

	visible = is_in_gw_account (shell_view, &is_on_store, NULL);
	visible_actions (action_group, visible, mfp_entries, G_N_ELEMENTS (mfp_entries));

	if (visible && !is_on_store) {
		GtkAction *action = gtk_action_group_get_action (action_group, "gw-proxy-login");

		g_return_if_fail (action != NULL);

		gtk_action_set_visible (action, FALSE);
	}
}
Exemplo n.º 12
0
static void
update_cal_entries_cb (EShellView *shell_view,
                       gpointer user_data)
{
	EShellWindow *shell_window;
	GtkActionGroup *action_group;
	gboolean visible = FALSE, is_unaccepted = FALSE, is_mtg_owner = FALSE;
	EShellContent *shell_content;
	GnomeCalendar *gcal = NULL;
	GnomeCalendarViewType view_type;
	ECalendarView *view;

	g_return_if_fail (E_IS_SHELL_VIEW (shell_view));

	shell_window = e_shell_view_get_shell_window (shell_view);
	shell_content = e_shell_view_get_shell_content (shell_view);

	g_object_get (shell_content, "calendar", &gcal, NULL);

	view_type = gnome_calendar_get_view (gcal);
	view = gnome_calendar_get_calendar_view (gcal, view_type);

	if (view) {
		GList *selected;

		selected = e_calendar_view_get_selected_events (view);
		if (selected && selected->data) {
			ECalendarViewEvent *event = (ECalendarViewEvent *) selected->data;
			const gchar *uri;

			uri = is_comp_data_valid (event) ? e_client_get_uri (E_CLIENT (event->comp_data->client)) : NULL;

			if (uri && g_ascii_strncasecmp (uri, "groupwise://", 12) == 0) {
				visible = e_cal_util_component_has_attendee (event->comp_data->icalcomp);
				if (visible) {
					ECalComponent *comp;

					comp = e_cal_component_new ();
					e_cal_component_set_icalcomponent (comp, icalcomponent_new_clone (event->comp_data->icalcomp));

					if (e_client_check_capability (E_CLIENT (event->comp_data->client), CAL_STATIC_CAPABILITY_HAS_UNACCEPTED_MEETING)) {
						gchar *user_email;

						user_email = itip_get_comp_attendee (comp, event->comp_data->client);

						is_unaccepted = needs_to_accept (event->comp_data->icalcomp, user_email);

						g_free (user_email);
					}

					is_mtg_owner = is_meeting_owner (comp, event->comp_data->client);

					g_object_unref (comp);
				}
			}
		}

		g_list_free (selected);
	}

	action_group = e_shell_window_get_action_group (shell_window, "calendar");
	visible_actions (action_group, visible, cal_entries, G_N_ELEMENTS (cal_entries));

	if (visible && !is_unaccepted) {
		GtkAction *action;

		action = gtk_action_group_get_action (action_group, "gw-meeting-accept");
		g_return_if_fail (action != NULL);
		gtk_action_set_visible (action, FALSE);

		action = gtk_action_group_get_action (action_group, "gw-meeting-accept-tentative");
		g_return_if_fail (action != NULL);
		gtk_action_set_visible (action, FALSE);
	}

	if (visible && !is_mtg_owner) {
		GtkAction *action;

		action = gtk_action_group_get_action (action_group, "gw-resend-meeting");
		g_return_if_fail (action != NULL);
		gtk_action_set_visible (action, FALSE);
	}

	g_object_unref (gcal);
}
Exemplo n.º 13
0
gboolean
e_kolab_folder_metadata_ui_write_store (KolabFolderMetaUIData *uidata,
                                        GCancellable *cancellable,
                                        GError **err)
{
	CamelKolabIMAPXStore *kstore = NULL;
	gchar *selected_path = NULL;
	GError *tmp_err = NULL;
	gboolean ok = FALSE;

	g_return_val_if_fail (uidata != NULL, FALSE);
	/* cancellable may be NULL */
	g_return_val_if_fail (err == NULL || *err == NULL, FALSE);

	g_return_val_if_fail (E_IS_SHELL_VIEW (uidata->shell_view), FALSE);
	g_return_val_if_fail (uidata->metadata != NULL, FALSE);

	if (uidata->shell_context != KOLAB_FOLDER_CONTEXT_EMAIL)
		goto email_skip;

	if (! (uidata->changed_metadata || uidata->changed_visibility))
		return TRUE;

	ok = e_kolab_plugin_util_ui_get_selected_store (uidata->shell_view,
	                                                &kstore,
	                                                &selected_path,
	                                                &tmp_err);
	if (! ok)
		goto exit;

	if (g_strcmp0 (uidata->foldername, selected_path) != 0)
		g_warning ("%s()[%u] foldername change: stored '%s' vs. current '%s'",
		           __func__, __LINE__, uidata->foldername, selected_path);

	if (! uidata->metadata)
		goto metadata_skip;

	ok = camel_kolab_imapx_store_set_folder_type (kstore,
	                                              uidata->foldername,
	                                              uidata->metadata->foldertype,
	                                              cancellable,
	                                              &tmp_err);
	if (! ok)
		goto exit;

 metadata_skip:

	if (! uidata->changed_visibility)
		goto exit;

	ok = camel_kolab_imapx_store_set_show_all_folders (kstore,
	                                                   uidata->metadata->show_all,
	                                                   cancellable,
	                                                   &tmp_err);
 email_skip:

	if (! ((uidata->shell_context == KOLAB_FOLDER_CONTEXT_CALENDAR) ||
	       (uidata->shell_context == KOLAB_FOLDER_CONTEXT_CONTACT)))
		goto exit;

	ok = kolab_folder_metadata_ui_syncstrategy_set (uidata,
	                                                cancellable,
	                                                &tmp_err);
 exit:

	if (tmp_err != NULL) {
		g_propagate_error (err, tmp_err);
		ok = FALSE;
	}

	if (kstore != NULL)
		g_object_unref (kstore);

	if (selected_path != NULL)
		g_free (selected_path);

	return ok;
}
Exemplo n.º 14
0
gboolean
e_kolab_folder_metadata_ui_query_store (KolabFolderMetaUIData *uidata,
                                        GCancellable *cancellable,
                                        GError **err)
{
	CamelKolabIMAPXStore *kstore = NULL;
	KolabSyncStrategyID strategy = KOLAB_SYNC_STRATEGY_DEFAULT;
	gchar *selected_path = NULL;
	GError *tmp_err = NULL;
	gboolean ok = TRUE;

	g_return_val_if_fail (uidata != NULL, FALSE);
	/* cancellable may be NULL */
	g_return_val_if_fail (err == NULL || *err == NULL, FALSE);

	g_return_val_if_fail (E_IS_SHELL_VIEW (uidata->shell_view), FALSE);
	g_return_val_if_fail (uidata->metadata != NULL, FALSE);

	if (uidata->shell_context != KOLAB_FOLDER_CONTEXT_EMAIL)
		goto skip_email;

	/* If we cannot get the store here, it means
	 * that the store associated with the selected
	 * path is not a CamelKolabIMAPXStore. This
	 * should not happen at this point (if the store
	 * in question is not a Kolab store, then no
	 * Kolab folder options context menu entry should
	 * have been shown).
	 */
	ok = e_kolab_plugin_util_ui_get_selected_store (uidata->shell_view,
	                                                &kstore,
	                                                &selected_path,
	                                                &tmp_err);
	if (! ok)
		goto exit;

	/* FIXME we have the foldername duped in uidata->foldername */
	uidata->metadata->foldername = selected_path;
	uidata->metadata->show_all =
		camel_kolab_imapx_store_get_show_all_folders (kstore);
	uidata->metadata->foldertype =
		camel_kolab_imapx_store_get_folder_type (kstore,
		                                         selected_path,
		                                         TRUE,
		                                         cancellable,
		                                         &tmp_err);
 skip_email:

	if (! ((uidata->shell_context == KOLAB_FOLDER_CONTEXT_CALENDAR) ||
	       (uidata->shell_context == KOLAB_FOLDER_CONTEXT_CONTACT)))
		goto exit;

	uidata->metadata->foldername = g_strdup (uidata->foldername);
	uidata->metadata->foldertype =
		e_kolab_plugin_util_ui_get_shell_type (uidata->shell_view);

	strategy = kolab_folder_metadata_ui_syncstrategy_get (uidata);
	uidata->metadata->strategy = strategy;

 exit:

	if (tmp_err != NULL) {
		g_propagate_error (err, tmp_err);
		ok = FALSE;
	}

	if (kstore != NULL)
		g_object_unref (kstore);

	return ok;
}
Exemplo n.º 15
0
void
e_kolab_folder_metadata_ui_update_from_uidata (KolabFolderMetaUIData *uidata)
{
	GtkWidget *widget = NULL;
	gulong handler_id = 0;
	guint ii = 0;

	g_return_if_fail (uidata != NULL);
	g_return_if_fail (E_IS_SHELL_VIEW (uidata->shell_view));
	g_return_if_fail (E_IS_ALERT_BAR (uidata->alert_bar));
	g_return_if_fail (uidata->metadata != NULL);
	g_return_if_fail (uidata->widgets != NULL);

	/* When updating the state of the UI here,
	 * we need to always make sure not to trigger
	 * signals which we may have handlers for.
	 * Updating the UI this way is meant to happen
	 * before the user actually uses it.
	 */

	/* radio button group (current folder type) */
	for (ii = 0; ii < KOLAB_FOLDER_META_UI_NUM_TYPES; ii++) {
		g_signal_handler_block (uidata->widgets->radio_btn_type[ii],
		                        uidata->widgets->radio_btn_handler_id[ii]);
	}

	switch (uidata->metadata->foldertype) {

	case KOLAB_FOLDER_TYPE_EVENT:
	case KOLAB_FOLDER_TYPE_EVENT_DEFAULT:
		ii = 1;
		break;

	case KOLAB_FOLDER_TYPE_NOTE:
	case KOLAB_FOLDER_TYPE_NOTE_DEFAULT:
		ii = 2;
		break;

	case KOLAB_FOLDER_TYPE_TASK:
	case KOLAB_FOLDER_TYPE_TASK_DEFAULT:
		ii = 3;
		break;

	case KOLAB_FOLDER_TYPE_CONTACT:
	case KOLAB_FOLDER_TYPE_CONTACT_DEFAULT:
		ii = 4;
		break;

	default:
		/* all else is regarded email */
		ii = 0;
	}

	widget = uidata->widgets->radio_btn_type[ii];
	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), TRUE);

	for (ii = 0; ii < KOLAB_FOLDER_META_UI_NUM_TYPES; ii++) {
		g_signal_handler_unblock (uidata->widgets->radio_btn_type[ii],
		                          uidata->widgets->radio_btn_handler_id[ii]);
	}

	/* PIM options */

	/* option: sync conflict strategy */
	widget = uidata->widgets->cbox_syncstrategy;
	g_return_if_fail (GTK_IS_COMBO_BOX_TEXT (widget));
	handler_id = uidata->widgets->cbox_syncstrategy_id;
	g_signal_handler_block (widget, handler_id);
	gtk_combo_box_set_active (GTK_COMBO_BOX (widget),
	                          (gint) uidata->metadata->strategy);
	g_signal_handler_unblock (widget, handler_id);

	/* whether to show all PIM folders in email view */

	widget = uidata->widgets->chk_btn_show_all;
	g_return_if_fail (GTK_IS_CHECK_BUTTON (widget));
	handler_id = uidata->widgets->chk_btn_show_all_handler_id;

	g_signal_handler_block (widget, handler_id);
	if (uidata->metadata->show_all)
		gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget),
		                              TRUE);
	else
		gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget),
		                              FALSE);
	g_signal_handler_unblock (widget, handler_id);
}