/* FIXME Some of these are duplicated from calendar-component.c */ static gboolean is_in_selection (GSList *selection, ESource *source) { GSList *l; for (l = selection; l; l = l->next) { ESource *selected_source = l->data; if (!strcmp (e_source_peek_uid (selected_source), e_source_peek_uid (source))) return TRUE; } return FALSE; }
static void update_uris_for_selection (MemosComponentView *component_view) { GSList *selection, *l, *uids_selected = NULL; selection = e_source_selector_get_selection (E_SOURCE_SELECTOR (component_view->source_selector)); for (l = component_view->source_selection; l; l = l->next) { ESource *old_selected_source = l->data; if (!is_in_selection (selection, old_selected_source)) e_memos_remove_memo_source (component_view->memos, old_selected_source); } for (l = selection; l; l = l->next) { ESource *selected_source = l->data; e_memos_add_memo_source (component_view->memos, selected_source); uids_selected = g_slist_append (uids_selected, (char *)e_source_peek_uid (selected_source)); } e_source_selector_free_selection (component_view->source_selection); component_view->source_selection = selection; /* Save the selection for next time we start up */ calendar_config_set_memos_selected (uids_selected); g_slist_free (uids_selected); }
static void _button_clicked_cb (MxButton *button, gpointer userdata) { PengeEventTilePrivate *priv = GET_PRIVATE (userdata); ECal *ecal; gchar *uid; gchar *command_line; g_object_get (priv->store, "ecal", &ecal, NULL); uid = jana_component_get_uid ((JanaComponent *)priv->event); command_line = g_strdup_printf ("evolution --express --component calendar \"calendar:///?source-uid=%s&comp-uid=%s\"", e_source_peek_uid (priv->source), uid); g_free (uid); if (!penge_utils_launch_by_command_line ((ClutterActor *)button, command_line)) { g_warning (G_STRLOC ": Error starting dates"); } else{ penge_utils_signal_activated ((ClutterActor *)userdata); } }
static void unsubscribe_dialog_ab_response (GtkDialog *dialog, int response, gpointer data) { if (response == GTK_RESPONSE_OK) { ExchangeAccount *account = NULL; gchar *path = NULL; gchar *uri = NULL; const char *source_uid = NULL; ESourceGroup *source_group = NULL; ESource *source = NULL; EABPopupTargetSource *target = data; account = exchange_operations_get_exchange_account (); if (!account) return; source = e_source_selector_peek_primary_selection (E_SOURCE_SELECTOR (target->selector)); uri = e_source_get_uri (source); path = g_strdup (uri + strlen ("exchange://") + strlen (account->account_filename)); source_uid = e_source_peek_uid (source); exchange_account_remove_shared_folder (account, path); source_group = e_source_peek_group (source); e_source_group_remove_source_by_uid (source_group, source_uid); g_free (path); gtk_widget_destroy (GTK_WIDGET (dialog)); } if (response == GTK_RESPONSE_CANCEL) gtk_widget_destroy (GTK_WIDGET (dialog)); if (response == GTK_RESPONSE_DELETE_EVENT) gtk_widget_destroy (GTK_WIDGET (dialog)); }
GtkWidget * e_book_file_dummy (EPlugin *epl, EConfigHookItemFactoryData *data) { EABConfigTargetSource *t = (EABConfigTargetSource *) data->target; ESource *source = t->source; gchar *uri_text; const gchar *relative_uri; uri_text = e_source_get_uri (source); if (strncmp (uri_text, "file", 4)) { g_free (uri_text); return NULL; } relative_uri = e_source_peek_relative_uri (source); g_free (uri_text); if (relative_uri && *relative_uri) { return NULL; } e_source_set_relative_uri (source, e_source_peek_uid (source)); return NULL; }
static void unsubscribe_dialog_response (GtkDialog *dialog, int response, gpointer data) { if (response == GTK_RESPONSE_OK) { GSList *ids, *node_to_be_deleted; ExchangeAccount *account = NULL; gchar *path = NULL; gchar *ruri = NULL; const char *source_uid = NULL; GConfClient *client; ESourceGroup *source_group = NULL; ESource *source = NULL; ECalPopupTargetSource *target = data; client = gconf_client_get_default (); account = exchange_operations_get_exchange_account (); if (!account) return; source = e_source_selector_peek_primary_selection (E_SOURCE_SELECTOR (target->selector)); ruri = (gchar *) e_source_peek_relative_uri (source); source_uid = e_source_peek_uid (source); path = g_strdup (ruri + strlen (account->account_filename)); exchange_account_remove_shared_folder (account, path); ids = gconf_client_get_list (client, CONF_KEY_SELECTED_CAL_SOURCES, GCONF_VALUE_STRING, NULL); if (ids) { node_to_be_deleted = g_slist_find_custom ( ids, source_uid, (GCompareFunc) strcmp); if (node_to_be_deleted) { g_free (node_to_be_deleted->data); ids = g_slist_delete_link (ids, node_to_be_deleted); gconf_client_set_list (client, CONF_KEY_SELECTED_CAL_SOURCES, GCONF_VALUE_STRING, ids, NULL); } g_slist_foreach (ids, (GFunc) g_free, NULL); g_slist_free (ids); } source_group = e_source_peek_group (source); e_source_group_remove_source_by_uid (source_group, source_uid); g_free (path); gtk_widget_destroy (GTK_WIDGET (dialog)); } if (response == GTK_RESPONSE_CANCEL) gtk_widget_destroy (GTK_WIDGET (dialog)); if (response == GTK_RESPONSE_DELETE_EVENT) gtk_widget_destroy (GTK_WIDGET (dialog)); }
char * evo_cal_source_get_uid(ECal *ecal) { ESource *source = NULL; const char *uid = NULL; source = e_cal_get_source(ecal); if (source) uid = e_source_peek_uid(source); if (uid) return g_strdup(uid); return NULL; }
/* snippet from evolution/calendar/gui/calendar-component.c:294 */ static gboolean is_in_uids (GSList *uids, ESource *source) { GSList *l; for (l = uids; l; l = l->next) { const char *uid = l->data; if (strcmp (uid, e_source_peek_uid (source)) == 0) return TRUE; } return FALSE; }
static void action_address_book_properties_cb (GtkAction *action, EBookShellView *book_shell_view) { EShellView *shell_view; EShellWindow *shell_window; EBookShellSidebar *book_shell_sidebar; ESource *source; ESourceSelector *selector; EditorUidClosure *closure; GHashTable *uid_to_editor; const gchar *uid; shell_view = E_SHELL_VIEW (book_shell_view); shell_window = e_shell_view_get_shell_window (shell_view); book_shell_sidebar = book_shell_view->priv->book_shell_sidebar; selector = e_book_shell_sidebar_get_selector (book_shell_sidebar); source = e_source_selector_get_primary_selection (selector); g_return_if_fail (source != NULL); uid = e_source_peek_uid (source); uid_to_editor = book_shell_view->priv->uid_to_editor; closure = g_hash_table_lookup (uid_to_editor, uid); if (closure == NULL) { GtkWidget *editor; editor = addressbook_config_edit_source ( GTK_WIDGET (shell_window), source); closure = g_new (EditorUidClosure, 1); closure->editor = editor; closure->uid = g_strdup (uid); closure->view = book_shell_view; g_hash_table_insert (uid_to_editor, closure->uid, closure); g_object_weak_ref ( G_OBJECT (closure->editor), (GWeakNotify) e_book_shell_view_editor_weak_notify, closure); } gtk_window_present (GTK_WINDOW (closure->editor)); }
static gboolean is_source_selected (ESource *esource, GSList *selected_sources) { const char *uid; GSList *l; uid = e_source_peek_uid (esource); for (l = selected_sources; l; l = l->next) { const char *source = l->data; if (!strcmp (source, uid)) return TRUE; } return FALSE; }
static inline void debug_dump_ecal_list (GSList *ecal_list) { #ifdef CALENDAR_ENABLE_DEBUG GSList *l; dprintf ("Loaded clients:\n"); for (l = ecal_list; l; l = l->next) { ECal *client = l->data; ESource *source = e_cal_get_source (client); dprintf (" %s %s %s\n", e_source_peek_uid (source), e_source_peek_name (source), e_cal_get_uri (client)); } #endif }
static void dump_source (ESource *source) { gchar *uri = e_source_get_uri (source); const gchar *color_spec; g_print ("\tSource %s\n", e_source_peek_uid (source)); g_print ("\t\tname: %s\n", e_source_peek_name (source)); g_print ("\t\trelative_uri: %s\n", e_source_peek_relative_uri (source)); g_print ("\t\tabsolute_uri: %s\n", uri); color_spec = e_source_peek_color_spec (source); if (color_spec != NULL) g_print ("\t\tcolor: %s\n", color_spec); g_print ("\t\tproperties:\n"); e_source_foreach_property (source, (GHFunc) dump_property, NULL); g_free (uri); }
static void update_uri_for_primary_selection (MemosComponentView *component_view) { ESource *source; EMemoTable *cal_table; ETable *etable; source = e_source_selector_peek_primary_selection (E_SOURCE_SELECTOR (component_view->source_selector)); if (!source) return; /* Set the default */ e_memos_set_default_source (component_view->memos, source); cal_table = e_memos_get_calendar_table (component_view->memos); etable = e_memo_table_get_table (cal_table); memos_control_sensitize_commands (component_view->view_control, component_view->memos, e_table_selected_count (etable)); /* Save the selection for next time we start up */ calendar_config_set_primary_memos (e_source_peek_uid (source)); }
static GtkWidget * sx_config_source_setup_ui (GtkWidget * parent, ESource * source) { GtkWidget *button; GtkWidget *label; GtkWidget *text; GtkWidget *ret; char *uri_text; const char *uid; const char *ruri; const char *name; gboolean new_source; gulong *sig_id; uri_text = e_source_get_uri (source); if (!g_str_has_prefix (uri_text, "scalix")) { g_free (uri_text); return NULL; } g_free (uri_text); g_assert (GTK_IS_BOX (parent) || GTK_IS_TABLE (parent)); /* Label */ label = gtk_label_new_with_mnemonic (_("_Location:")); gtk_widget_show (label); gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); button = gtk_button_new (); g_signal_connect (G_OBJECT (button), "clicked", G_CALLBACK (location_clicked), source); gtk_widget_show (button); uid = e_source_peek_uid (source); ruri = e_source_peek_relative_uri (source); name = e_source_peek_name (source); /* new source */ new_source = (ruri == NULL || ruri[0] == '\0' || g_str_equal (ruri, uid)); if (new_source) { if (name == NULL || name[0] == '\0') name = "nonameyet"; e_source_set_relative_uri (source, name); } if (is_toplevel (ruri)) { text = gtk_label_new (_("Toplevel")); } else { text = gtk_label_new (ruri); } gtk_widget_show (text); #if (GTK_CHECK_VERSION(2, 6, 0)) gtk_label_set_ellipsize (GTK_LABEL (text), PANGO_ELLIPSIZE_START); #endif gtk_container_add (GTK_CONTAINER (button), text); sig_id = (gulong *) g_malloc0 (sizeof (gulong)); *sig_id = g_signal_connect (source, "changed", G_CALLBACK (sn_changed), sig_id); /* We do not support renames (yet?!) */ if (new_source == FALSE) { gtk_widget_set_sensitive (button, FALSE); /* Nasty nasty hack ey ey ey */ find_entries_and_set_sensitive (parent, FALSE); } /* attach it */ if (!GTK_IS_BOX (parent)) { int row; row = GTK_TABLE (parent)->nrows; gtk_table_attach (GTK_TABLE (parent), label, 0, 1, row, row + 1, GTK_FILL, 0, 0, 0); gtk_table_attach (GTK_TABLE (parent), button, 1, 2, row, row + 1, GTK_EXPAND | GTK_FILL, 0, 0, 0); /* HACK for to have a return value != NULL */ ret = button; } else { GtkWidget *hbox; hbox = gtk_hbox_new (FALSE, 6); gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, TRUE, 6); gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 6); gtk_box_pack_start (GTK_BOX (parent), hbox, FALSE, FALSE, 6); gtk_widget_show_all (hbox); ret = hbox; } return ret; }
void dates_autoselect_calendars (DatesData *d, ESourceList * cal_list) { GSList *selected_list; if (!cal_list) return; selected_list = gconf_client_get_list (gconf_client_get_default (), CALENDAR_GCONF_SELECTED, GCONF_VALUE_STRING, NULL); if (!selected_list) { /* select all available calendars */ GSList *list = NULL, *groups, *g; groups = e_source_list_peek_groups (cal_list); #ifdef DEBUG if (d->debug & DATES_DEBUG_CALENDAR) g_debug ("Attempting to autoselect"); #endif for (g = groups; g; g = g->next) { GSList *sources, *s; sources = e_source_group_peek_sources (E_SOURCE_GROUP (g->data)); for (s = sources; s; s = s->next) { ESource *source = E_SOURCE (s->data); ECal *ecal; gchar * uid; ecal = dates_load_esource (source, E_CAL_SOURCE_TYPE_EVENT, NULL, d); if (!ecal) { #ifdef DEBUG if (d->debug & DATES_DEBUG_CALENDAR) g_debug ("No ecal"); #endif continue; } uid = (gchar *)e_source_peek_uid (e_cal_get_source (ecal)); list = g_slist_prepend (list, uid); } } if (list) { #ifdef DEBUG if (d->debug & DATES_DEBUG_CALENDAR) g_debug ("Setting new list"); #endif gconf_client_set_list (gconf_client_get_default (), CALENDAR_GCONF_SELECTED, GCONF_VALUE_STRING, list, NULL); } } else #ifdef DEBUG if (d->debug & DATES_DEBUG_CALENDAR) g_debug ("Have selected list"); #endif }
void dates_cal_open_cb (ECal *ecal, ECalendarStatus status, DatesData *d) { gboolean read_only; GError *error = NULL; const char *ecal_name; ESource *source; ESourceGroup *group; GtkTreeIter iter; gchar *primary_uid; GSList *selected_list; gboolean selected; gchar * cal_name; #ifdef DEBUG if (d->debug & DATES_DEBUG_CALENDAR) g_debug ("Calendar opened, setting up..."); #endif if (status != E_CALENDAR_STATUS_OK) { g_warning ("Error '%d' opening ecal", status); g_object_unref (ecal); if (d->first_load) { GtkWidget *dialog = gtk_message_dialog_new ( GTK_WINDOW (d->main_window), GTK_DIALOG_MODAL | GTK_DIALOG_NO_SEPARATOR, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, _("Dates failed to open the system calendar. " "You will not be able to view or create " "events; this may be remedied by restarting.")); gtk_dialog_run (GTK_DIALOG (dialog)); } return; } source = e_cal_get_source (ecal); ecal_name = e_source_peek_name (source); if (!e_cal_is_read_only (ecal, &read_only, &error)) { g_warning ("Error querying calendar's read-only status: %s", error->message); g_error_free (error); g_object_unref (ecal); return; } /* * Work around the fact that eds-dbus seems to be returning the wrong * value for e_cal_is_read_only on the calendar itself for the http * backend. But on the events themselves it is fine */ group = e_source_peek_group (source); if (strncmp (e_source_group_peek_base_uri (group), "webcal://", 9) == 0) read_only = TRUE; selected_list = gconf_client_get_list (gconf_client_get_default (), CALENDAR_GCONF_SELECTED, GCONF_VALUE_STRING, NULL); #ifdef DEBUG if (d->debug & DATES_DEBUG_CALENDAR) g_debug ("selected_list %p: is in uids %d", selected_list, is_in_uids (selected_list, source)); #endif if (selected_list && is_in_uids (selected_list, source)) { dates_view_add_calendar (d->view, ecal); g_signal_connect (G_OBJECT (ecal), "backend_died", G_CALLBACK (dates_backend_died_cb), d); selected = TRUE; } else { selected = FALSE; } if ((!read_only) && (selected)) { if (!d->dcal) d->dcal = ecal; else { /* Find out if it's the default calendar */ primary_uid = gconf_client_get_string ( gconf_client_get_default (), CALENDAR_GCONF_PRIMARY, NULL); if (primary_uid) { if (strcmp (e_source_peek_uid (source), primary_uid) == 0) d->dcal = ecal; g_free (primary_uid); } } d->cal_loaded = TRUE; if (d->TBNew) { #ifdef DEBUG if (d->debug & DATES_DEBUG_CALENDAR) g_debug ("*** Setting TBNew button sensitive ***"); #endif gtk_widget_set_sensitive (d->TBNew, TRUE); } } else { #ifdef DEBUG if (d->debug & DATES_DEBUG_CALENDAR) g_debug ("*** RO %d, Selected %d ***", read_only, selected); #endif } if (ecal_name && !read_only) cal_name = g_strdup (ecal_name); else if (ecal_name) cal_name = g_strconcat (ecal_name, _(" (Read Only)"), NULL); else if (!read_only) cal_name = g_strdup (_("Unknown")); else cal_name = g_strconcat (_("Unknown"), _(" (Read Only)"), NULL); gtk_list_store_insert_with_values (d->cal_list_store, &iter, G_MAXINT, COL_CALNAME, cal_name, COL_CALPTR, ecal, COL_NOTREADONLY, !read_only, COL_SELECTED, selected, -1); g_free (cal_name); #ifdef DEBUG if (d->debug & DATES_DEBUG_CALENDAR) g_debug ("Calendar added."); #endif dates_platform_cal_open (d); }
void e_sendoptions_utils_set_default_data (ESendOptionsDialog *sod, ESource *source, char * type) { ESendOptionsGeneral *gopts = NULL; ESendOptionsStatusTracking *sopts; GConfClient *gconf = gconf_client_get_default (); ESourceList *source_list; const char *uid; const char *value; gopts = sod->data->gopts; sopts = sod->data->sopts; if (!strcmp (type, "calendar")) source_list = e_source_list_new_for_gconf (gconf, "/apps/evolution/calendar/sources"); else source_list = e_source_list_new_for_gconf (gconf, "/apps/evolution/tasks/sources"); uid = e_source_peek_uid (source); source = e_source_list_peek_source_by_uid (source_list, uid); /* priority */ value = e_source_get_property (source, "priority"); if (value) { if (!strcmp (value, "high")) gopts->priority = E_PRIORITY_HIGH; else if (!strcmp (value, "standard")) gopts->priority = E_PRIORITY_STANDARD; else if (!strcmp (value, "low")) gopts->priority = E_PRIORITY_LOW; else gopts->priority = E_PRIORITY_UNDEFINED; } /* Reply requested */ value = e_source_get_property (source, "reply-requested"); if (value) { if (!strcmp (value, "none")) gopts->reply_enabled = FALSE; else if (!strcmp (value, "convinient")) { gopts->reply_enabled = TRUE; gopts->reply_convenient = TRUE; } else { gint i = atoi (value); gopts->reply_within = i; } } /* Delay delivery */ value = e_source_get_property (source, "delay-delivery"); if (value) { if (!strcmp (value, "none")) gopts->delay_enabled = FALSE; else { gopts->delay_enabled = TRUE; gopts->delay_until = icaltime_as_timet (icaltime_from_string (value)); } } /* Expiration Date */ value = e_source_get_property (source, "expiration"); if (value) { if (!strcmp (value, "none")) gopts->expiration_enabled = FALSE; else { gint i = atoi (value); if (i == 0) gopts->expiration_enabled = FALSE; else gopts->expiration_enabled = TRUE; gopts->expire_after = i; } } /* status tracking */ value = e_source_get_property (source, "status-tracking"); if (value) { if (!strcmp (value, "none")) sopts->tracking_enabled = FALSE; else { sopts->tracking_enabled = TRUE; if (!strcmp (value, "delivered")) sopts->track_when = E_DELIVERED; else if (!strcmp (value, "delivered-opened")) sopts->track_when = E_DELIVERED_OPENED; else sopts->track_when = E_ALL; } } /* Return Notifications */ value = e_source_get_property (source, "return-open"); if (value) { if (!strcmp (value, "none")) sopts->opened = E_RETURN_NOTIFY_NONE; else sopts->opened = E_RETURN_NOTIFY_MAIL; } value = e_source_get_property (source, "return-accept"); if (value) { if (!strcmp (value, "none")) sopts->accepted = E_RETURN_NOTIFY_NONE; else sopts->accepted = E_RETURN_NOTIFY_MAIL; } value = e_source_get_property (source, "return-decline"); if (value) { if (!strcmp (value, "none")) sopts->declined = E_RETURN_NOTIFY_NONE; else sopts->declined = E_RETURN_NOTIFY_MAIL; } value = e_source_get_property (source, "return-complete"); if (value) { if (!strcmp (value, "none")) sopts->completed = E_RETURN_NOTIFY_NONE; else sopts->completed = E_RETURN_NOTIFY_MAIL; } g_object_unref (gconf); }
static void calendar_sources_load_esource_list (CalendarSourceData *source_data) { GSList *clients = NULL; GSList *groups, *l; gboolean emit_signal = FALSE; g_return_if_fail (source_data->esource_list != NULL); debug_dump_selected_sources (source_data->selected_sources); dprintf ("Source groups:\n"); groups = e_source_list_peek_groups (source_data->esource_list); for (l = groups; l; l = l->next) { GSList *esources, *s; dprintf (" %s\n", e_source_group_peek_uid (l->data)); dprintf (" sources:\n"); esources = e_source_group_peek_sources (l->data); for (s = esources; s; s = s->next) { ESource *esource = E_SOURCE (s->data); ECal *client; dprintf (" type = '%s' uid = '%s', name = '%s', relative uri = '%s': \n", source_data->source_type == E_CAL_SOURCE_TYPE_EVENT ? "appointment" : "task", e_source_peek_uid (esource), e_source_peek_name (esource), e_source_peek_relative_uri (esource)); if (is_source_selected (esource, source_data->selected_sources) && (client = get_ecal_from_source (esource, source_data->source_type, source_data->clients))) { clients = g_slist_prepend (clients, client); } } } dprintf ("\n"); if (source_data->loaded && !compare_ecal_lists (source_data->clients, clients)) emit_signal = TRUE; for (l = source_data->clients; l; l = l->next) { g_signal_handlers_disconnect_by_func (G_OBJECT (l->data), G_CALLBACK (backend_died_cb), source_data); g_object_unref (l->data); } g_slist_free (source_data->clients); source_data->clients = g_slist_reverse (clients); /* connect to backend_died after we disconnected the previous signal * handlers. If we do it before, we'll lose some handlers (for clients that * were already there before) */ for (l = source_data->clients; l; l = l->next) { g_signal_connect (G_OBJECT (l->data), "backend_died", G_CALLBACK (backend_died_cb), source_data); } if (emit_signal) { dprintf ("Emitting %s-sources-changed signal\n", source_data->source_type == E_CAL_SOURCE_TYPE_EVENT ? "appointment" : "task"); g_signal_emit (source_data->sources, source_data->changed_signal, 0); } debug_dump_ecal_list (source_data->clients); }
static void ensure_sources (MemosComponent *component) { GSList *groups; ESourceList *source_list; ESourceGroup *group; ESourceGroup *on_this_computer; ESourceGroup *on_the_web; ESource *personal_source; char *base_uri, *base_uri_proto; const gchar *base_dir; on_this_computer = NULL; on_the_web = NULL; personal_source = NULL; if (!e_cal_get_sources (&source_list, E_CAL_SOURCE_TYPE_JOURNAL, NULL)) { g_warning ("Could not get memo source list from GConf!"); return; } base_dir = memos_component_peek_base_directory (component); base_uri = g_build_filename (base_dir, "local", NULL); base_uri_proto = g_filename_to_uri (base_uri, NULL, NULL); groups = e_source_list_peek_groups (source_list); if (groups) { /* groups are already there, we need to search for things... */ GSList *g; for (g = groups; g; g = g->next) { group = E_SOURCE_GROUP (g->data); /* compare only file:// part. If user home dir name changes we do not want to create one more group */ if (!on_this_computer && !strncmp (base_uri_proto, e_source_group_peek_base_uri (group), 7)) on_this_computer = group; else if (!on_the_web && !strcmp (WEB_BASE_URI, e_source_group_peek_base_uri (group))) on_the_web = group; } } if (on_this_computer) { /* make sure "Personal" shows up as a source under this group */ GSList *sources = e_source_group_peek_sources (on_this_computer); GSList *s; for (s = sources; s; s = s->next) { ESource *source = E_SOURCE (s->data); const gchar *relative_uri; relative_uri = e_source_peek_relative_uri (source); if (relative_uri == NULL) continue; if (!strcmp (PERSONAL_RELATIVE_URI, relative_uri)) { personal_source = source; break; } } /* Make sure we have the correct base uri. This can change when user's homedir name changes */ if (strcmp (base_uri_proto, e_source_group_peek_base_uri (on_this_computer))) { e_source_group_set_base_uri (on_this_computer, base_uri_proto); /* *sigh* . We shouldn't need this sync call here as set_base_uri call results in synching to gconf, but that happens in idle loop and too late to prevent user seeing "Can not Open ... because of invalid uri" error.*/ e_source_list_sync (source_list,NULL); } } else { /* create the local source group */ group = e_source_group_new (_("On This Computer"), base_uri_proto); e_source_list_add_group (source_list, group, -1); on_this_computer = group; } if (!personal_source) { GSList *memos_selected; /* Create the default Person addressbook */ ESource *source = e_source_new (_("Personal"), PERSONAL_RELATIVE_URI); e_source_group_add_source (on_this_computer, source, -1); memos_selected = calendar_config_get_memos_selected (); if (!calendar_config_get_primary_memos () && !memos_selected) { GSList selected; calendar_config_set_primary_memos (e_source_peek_uid (source)); selected.data = (gpointer)e_source_peek_uid (source); selected.next = NULL; calendar_config_set_memos_selected (&selected); } if (memos_selected) { g_slist_foreach (memos_selected, (GFunc) g_free, NULL); g_slist_free (memos_selected); } e_source_set_color_spec (source, "#BECEDD"); personal_source = source; } if (!on_the_web) { /* Create the LDAP source group */ group = e_source_group_new (_("On The Web"), WEB_BASE_URI); e_source_list_add_group (source_list, group, -1); on_the_web = group; } component->priv->source_list = source_list; g_free (base_uri_proto); g_free (base_uri); }
static void source_list_changed_cb (ESourceList *source_list, ESourceComboBox *source_combo_box) { ESourceComboBoxPrivate *priv; GtkComboBox *combo_box; GtkTreeModel *model; GtkListStore *store; GtkTreeIter iter; GtkTreePath *path; GSList *groups; GSList *sources, *s; const gchar *name; const gchar *uid; gchar *indented_name; gboolean visible = FALSE; gboolean iter_valid; priv = source_combo_box->priv; g_hash_table_remove_all (priv->uid_index); combo_box = GTK_COMBO_BOX (source_combo_box); gtk_combo_box_set_active (combo_box, -1); model = gtk_combo_box_get_model (combo_box); store = GTK_LIST_STORE (model); gtk_list_store_clear (store); for (groups = e_source_list_peek_groups (source_list); groups != NULL; groups = groups->next) { /* Only show source groups that have sources. */ if (e_source_group_peek_sources (groups->data) == NULL) continue; name = e_source_group_peek_name (groups->data); gtk_list_store_append (store, &iter); gtk_list_store_set ( store, &iter, COLUMN_COLOR, NULL, COLUMN_NAME, name, COLUMN_SENSITIVE, FALSE, COLUMN_SOURCE, groups->data, -1); sources = get_sorted_sources (e_source_group_peek_sources (groups->data)); for (s = sources; s != NULL; s = s->next) { const gchar *color_spec; GdkColor color; name = e_source_peek_name (s->data); indented_name = g_strconcat (" ", name, NULL); color_spec = e_source_peek_color_spec (s->data); if (color_spec != NULL) { gdk_color_parse (color_spec, &color); visible = TRUE; } gtk_list_store_append (store, &iter); gtk_list_store_set ( store, &iter, COLUMN_COLOR, color_spec ? &color : NULL, COLUMN_NAME, indented_name, COLUMN_SENSITIVE, TRUE, COLUMN_SOURCE, s->data, -1); uid = e_source_peek_uid (s->data); path = gtk_tree_model_get_path (model, &iter); g_hash_table_insert ( priv->uid_index, g_strdup (uid), gtk_tree_row_reference_new (model, path)); gtk_tree_path_free (path); g_free (indented_name); } g_slist_free (sources); } /* Set the visible column based on whether we've seen a color. */ iter_valid = gtk_tree_model_get_iter_first (model, &iter); while (iter_valid) { gtk_list_store_set ( store, &iter, COLUMN_VISIBLE, visible, -1); iter_valid = gtk_tree_model_iter_next (model, &iter); } }
static void create_memo_sources (EShellBackend *shell_backend, ESourceList *source_list, ESourceGroup **on_this_computer, ESourceGroup **on_the_web, ESource **personal_source) { EShell *shell; EShellSettings *shell_settings; GSList *groups; ESourceGroup *group; *on_this_computer = NULL; *on_the_web = NULL; *personal_source = NULL; shell = e_shell_backend_get_shell (shell_backend); shell_settings = e_shell_get_shell_settings (shell); groups = e_source_list_peek_groups (source_list); if (groups) { /* groups are already there, we need to search for things... */ GSList *g; gchar *base_dir, *base_uri; base_dir = g_build_filename (e_shell_backend_get_data_dir (shell_backend), "local", NULL); base_uri = g_filename_to_uri (base_dir, NULL, NULL); for (g = groups; g; g = g->next) { group = E_SOURCE_GROUP (g->data); if (strcmp (base_uri, e_source_group_peek_base_uri (group)) == 0) e_source_group_set_base_uri (group, LOCAL_BASE_URI); if (!*on_this_computer && !strcmp (LOCAL_BASE_URI, e_source_group_peek_base_uri (group))) *on_this_computer = g_object_ref (group); else if (!*on_the_web && !strcmp (WEBCAL_BASE_URI, e_source_group_peek_base_uri (group))) *on_the_web = g_object_ref (group); } g_free (base_dir); g_free (base_uri); } if (*on_this_computer) { /* make sure "Personal" shows up as a source under * this group */ GSList *sources = e_source_group_peek_sources (*on_this_computer); GSList *s; for (s = sources; s; s = s->next) { ESource *source = E_SOURCE (s->data); const gchar *relative_uri; relative_uri = e_source_peek_relative_uri (source); if (relative_uri == NULL) continue; if (!strcmp (PERSONAL_RELATIVE_URI, relative_uri)) { *personal_source = g_object_ref (source); break; } } } else { /* create the local source group */ group = e_source_group_new (_("On This Computer"), LOCAL_BASE_URI); e_source_list_add_group (source_list, group, -1); *on_this_computer = group; } if (!*personal_source) { GSList *selected; gchar *primary_memo_list; /* Create the default Person memo list */ ESource *source = e_source_new (_("Personal"), PERSONAL_RELATIVE_URI); e_source_group_add_source (*on_this_computer, source, -1); primary_memo_list = e_shell_settings_get_string ( shell_settings, "cal-primary-memo-list"); selected = e_memo_shell_backend_get_selected_memo_lists ( E_MEMO_SHELL_BACKEND (shell_backend)); if (primary_memo_list == NULL && selected == NULL) { GSList link; e_shell_settings_set_string ( shell_settings, "cal-primary-memo-list", e_source_peek_uid (source)); link.data = (gpointer) e_source_peek_uid (source); link.next = NULL; e_memo_shell_backend_set_selected_memo_lists ( E_MEMO_SHELL_BACKEND (shell_backend), &link); } g_slist_foreach (selected, (GFunc) g_free, NULL); g_slist_free (selected); e_source_set_color_spec (source, "#BECEDD"); *personal_source = source; } if (!*on_the_web) { /* Create the Webcal source group */ group = e_source_group_new (_("On The Web"), WEBCAL_BASE_URI); e_source_list_add_group (source_list, group, -1); *on_the_web = group; } }