/** * compare_source_names * Compares sources by name. **/ static gint compare_source_names (gconstpointer a, gconstpointer b) { g_return_val_if_fail (E_IS_SOURCE (a), -1); g_return_val_if_fail (E_IS_SOURCE (b), 1); return g_utf8_collate (e_source_peek_name (E_SOURCE (a)), e_source_peek_name (E_SOURCE (b))); }
static void action_address_book_delete_cb (GtkAction *action, EBookShellView *book_shell_view) { EShellView *shell_view; EShellWindow *shell_window; EBookShellBackend *book_shell_backend; EBookShellSidebar *book_shell_sidebar; ESource *source; ESourceSelector *selector; ESourceGroup *source_group; ESourceList *source_list; EBookClient *book; gint response; GError *error = NULL; shell_view = E_SHELL_VIEW (book_shell_view); shell_window = e_shell_view_get_shell_window (shell_view); book_shell_backend = book_shell_view->priv->book_shell_backend; source_list = e_book_shell_backend_get_source_list (book_shell_backend); 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); response = e_alert_run_dialog_for_args ( GTK_WINDOW (shell_window), "addressbook:ask-delete-addressbook", e_source_peek_name (source), NULL); if (response != GTK_RESPONSE_YES) return; book = e_book_client_new (source, &error); if (error != NULL) { g_warning ("Error removing addressbook: %s", error->message); g_error_free (error); return; } if (!e_client_remove_sync (E_CLIENT (book), NULL, NULL)) { e_alert_run_dialog_for_args ( GTK_WINDOW (shell_window), "addressbook:remove-addressbook", NULL); g_object_unref (book); return; } if (e_source_selector_source_is_selected (selector, source)) e_source_selector_unselect_source (selector, source); source_group = e_source_peek_group (source); e_source_group_remove_source (source_group, source); e_source_list_sync (source_list, NULL); g_object_unref (book); }
static void selection_changed (GtkTreeSelection * selection, ESource * source) { GtkTreeModel *model; GtkTreeIter iter; GValue value = { 0, }; const char *path; if (gtk_tree_selection_get_selected (selection, &model, &iter)) { char *nruri; const char *name; gtk_tree_model_get_value (model, &iter, SCM_COL_PATH, &value); path = g_value_get_string (&value); name = e_source_peek_name (source); if (name == NULL || name[0] == '\0') { name = "nonameyet"; } if (path == NULL) { nruri = g_strdup (name); } else { nruri = g_build_path ("/", path, name, NULL); } e_source_set_relative_uri (source, nruri); g_free (nruri); g_value_unset (&value); } else { g_warning ("NARF"); } }
GList * evo_environment_list_cal_sources(ECalSourceType type) { GList *paths = NULL; ESourceList *sources = NULL; ESource *source = NULL; if (!e_cal_get_sources(&sources, type, NULL)) { return NULL; } GSList *g = NULL; for (g = e_source_list_peek_groups (sources); g; g = g->next) { ESourceGroup *group = E_SOURCE_GROUP (g->data); GSList *s = NULL; for (s = e_source_group_peek_sources (group); s; s = s->next) { source = E_SOURCE (s->data); evo_location_t *path = g_malloc0(sizeof(evo_location_t)); //FIXME: Word around #442187 //if (!first) { // first = TRUE; // path->uri = g_strdup("default"); //} else { path->uri = g_strdup(e_source_get_uri(source)); //} path->name = g_strdup(e_source_peek_name(source)); paths = g_list_append(paths, path); } } return paths; }
static void source_changed_cb (ESourceComboBox *combo_box) { ESource *source; source = e_source_combo_box_get_active (combo_box); g_print ("source selected: \"%s\"\n", e_source_peek_name (source)); }
static void source_changed_callback (ESource *source) { static gint count = 0; g_print ("** Event: source \"%s\" changed (%d)\n", e_source_peek_name (source), ++count); dump_on_idle (); }
void org_gnome_exchange_folder_ab_unsubscribe (EPopup *ep, EPopupItem *p, void *data) { GtkWidget *dialog = NULL; EABPopupTargetSource *target = data; ESource *source = NULL; ExchangeAccount *account = NULL; gchar *title = NULL; gchar *displayed_folder_name = NULL; gint response; gint mode; ExchangeConfigListenerStatus status; account = exchange_operations_get_exchange_account (); if (!account) return; status = exchange_is_offline (&mode); if (status != CONFIG_LISTENER_STATUS_OK) { g_warning ("Config listener not found"); return; } else if (mode == OFFLINE_MODE) { e_error_run (NULL, ERROR_DOMAIN ":account-offline-generic", NULL); return; } source = e_source_selector_peek_primary_selection (E_SOURCE_SELECTOR (target->selector)); displayed_folder_name = (gchar *) e_source_peek_name (source); dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_QUESTION, GTK_BUTTONS_NONE, _("Really unsubscribe from folder \"%s\"?"), displayed_folder_name); gtk_dialog_add_button (GTK_DIALOG (dialog), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL); gtk_dialog_add_button (GTK_DIALOG (dialog), GTK_STOCK_REMOVE, GTK_RESPONSE_OK); gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK); gtk_container_set_border_width (GTK_CONTAINER (dialog), 6); gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dialog)->vbox), 6); title = g_strdup_printf (_("Unsubscribe from \"%s\""), displayed_folder_name); gtk_window_set_title (GTK_WINDOW (dialog), title); response = gtk_dialog_run (GTK_DIALOG (dialog)); g_free (title); g_free (displayed_folder_name); gtk_widget_show (dialog); unsubscribe_dialog_ab_response (GTK_DIALOG (dialog), response, data); }
static void source_removed_callback (ESourceGroup *group, ESource *source) { static gint count = 0; g_print ("** Event: source \"%s\" removed (%d)\n", e_source_peek_name (source), ++count); disconnect_source (source); dump_on_idle (); }
static void on_delete_cb(GtkAction *action, EShellView *shell_view) { EShellSidebar *shell_sidebar = e_shell_view_get_shell_sidebar(shell_view); ESourceSelector *selector; g_object_get(shell_sidebar, "selector", &selector, NULL); ESource *source = e_source_selector_peek_primary_selection(selector); if (e_alert_run_dialog_for_args(GTK_WINDOW(shell_view), "calendar:prompt-delete-calendar", e_source_peek_name(source), NULL) != GTK_RESPONSE_YES) { g_object_unref (selector); return; } ESourceGroup *group = e_source_peek_group(source); char *calname = (char *)e_source_get_property(source, "eee-calname"); EeeAccount *account; GError *err = NULL; if (!eee_plugin_online) { display_error_message (gtk_widget_get_toplevel (GTK_WIDGET (selector)), _("This action is not available with 3e plugin in offline mode.")); g_object_unref (selector); return; } if (!e_source_is_3e_owned_calendar(source)) { display_error_message (gtk_widget_get_toplevel (GTK_WIDGET (selector)), _("This action is available only for 3e calendars.")); g_object_unref (selector); return; } g_object_unref (selector); account = eee_accounts_manager_find_account_by_source(mgr(), source); if (eee_account_delete_calendar(account, calname)) { // get ECal and remove calendar from the server ECalClient *ecal = e_cal_client_new(source, E_CAL_CLIENT_SOURCE_TYPE_EVENTS, &err); if (!e_client_remove_sync((EClient *)ecal, NULL, &err)) { g_warning("** EEE ** ECal remove failed (%d:%s)", err->code, err->message); g_clear_error(&err); } g_object_unref(ecal); e_source_group_remove_source(group, source); } eee_account_disconnect(account); eee_accounts_manager_restart_sync(mgr()); }
static void sn_changed (ESource * source, gpointer data) { const char *name; const char *ruri; //char **old_name; char **sv; char *nruri; guint n; gulong *sig_id; sig_id = (gulong *) data; name = e_source_peek_name (source); ruri = e_source_peek_relative_uri (source); /* Must block signal emission or this will give * a nice infinit chain and stack overflow */ g_signal_handler_block (source, *sig_id); if (is_toplevel (ruri)) { e_source_set_relative_uri (source, name); } else { sv = g_strsplit (ruri, "/", -1); n = g_strv_length (sv); if (n < 2) { g_print ("Error during split! (%s)\n", ruri); g_strfreev (sv); return; } g_free (sv[n - 1]); sv[n - 1] = g_strdup (name); nruri = g_strjoinv ("/", sv); e_source_set_relative_uri (source, nruri); g_free (nruri); g_strfreev (sv); } g_signal_handler_unblock (source, *sig_id); g_print ("RURI: %s\n", e_source_peek_relative_uri (source)); }
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 GSList *traverse_sources(GSList *ebooks, GSList *sources, char **default_src) { GError *gerr = NULL; for (; sources != NULL; sources = g_slist_next(sources)) { char *uri; ESource *source = E_SOURCE(sources->data); EBook *ebook = e_book_new(source, &gerr); if (ebook == NULL) { error("Can't create user's address book: %s", gerr->message); g_clear_error(&gerr); continue; } uri = e_source_get_uri(source); if (g_strcmp0(*default_src, uri) == 0) { g_free(uri); continue; } g_free(uri); if (e_book_open(ebook, FALSE, &gerr) == FALSE) { error("Can't open e-book address book: %s", gerr->message); g_object_unref(ebook); g_clear_error(&gerr); continue; } if (*default_src == NULL) *default_src = e_source_get_uri(source); DBG("%s address book opened", e_source_peek_name(source)); ebooks = g_slist_append(ebooks, ebook); } return ebooks; }
/* The clients are just created here but not loaded */ static ECal * get_ecal_from_source (ESource *esource, ECalSourceType source_type, GSList *existing_clients) { ECal *retval; if (existing_clients) { GSList *l; for (l = existing_clients; l; l = l->next) { ECal *client = E_CAL (l->data); if (e_source_equal (esource, e_cal_get_source (client))) { dprintf (" load_esource: found existing source ... returning that\n"); return g_object_ref (client); } } } retval = e_cal_new (esource, source_type); if (!retval) { g_warning ("Could not load source '%s' from '%s'\n", e_source_peek_name (esource), e_source_peek_relative_uri (esource)); return NULL; } e_cal_set_auth_func (retval, auth_func_cb, NULL); return retval; }
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 eee_calendar_properties_commit(EPlugin *epl, ECalConfigTargetSource *target) { ESource *source = target->source; ESourceGroup *group = e_source_peek_group(source); const char *color = e_source_peek_color_spec(source); GdkColor parsed_color; char converted_color[COLOR_COMPONENT_SIZE * 3 * 2 + 2]; //3 components, 2 hex chars in byte, 2 additional chars (# and \0) if (!gdk_color_parse(color, &parsed_color)) { g_warning("EEE: Unable to convert color \"%s\" from Evolution.", color); parsed_color.red = -1; parsed_color.green = 0; parsed_color.blue = 0; } parsed_color.red >>= (2 - COLOR_COMPONENT_SIZE) * 8; //GdkColor comonent is 2 byte integer, there are 8 bits in byte parsed_color.green >>= (2 - COLOR_COMPONENT_SIZE) * 8; parsed_color.blue >>= (2 - COLOR_COMPONENT_SIZE) * 8; snprintf(converted_color, COLOR_COMPONENT_SIZE * 3 * 2 + 2, "#%0*X%0*X%0*X", COLOR_COMPONENT_SIZE * 2, parsed_color.red, COLOR_COMPONENT_SIZE * 2, parsed_color.green, COLOR_COMPONENT_SIZE * 2, parsed_color.blue); converted_color[COLOR_COMPONENT_SIZE * 3 * 2 + 1] = '\0'; //g_debug("** EEE ** Properties Dialog Commit Hook Call:\n\n%s\n\n", e_source_to_standalone_xml(target->source)); if (!e_source_group_is_3e(group)) { return; } if (!eee_plugin_online) { return; } if (is_new_calendar_dialog(source)) { char *calname = NULL; EeeAccount *account = eee_accounts_manager_find_account_by_group(mgr(), group); if (account == NULL || account->state != EEE_ACCOUNT_STATE_ONLINE) { return; } if (eee_account_create_new_calendar(account, &calname)) { eee_account_update_calendar_settings(account, account->name, calname, e_source_peek_name(source), converted_color); } eee_account_disconnect(account); e_source_set_3e_properties(source, calname, account->name, account, "write", NULL, 0); // title and color are already set eee_accounts_manager_add_source(mgr(), account->name, g_object_ref(source)); g_free(calname); } else { EeeAccount *account = eee_accounts_manager_find_account_by_source(mgr(), source); if (account == NULL || account->state != EEE_ACCOUNT_STATE_ONLINE) { return; } const char *calname = e_source_get_property(source, "eee-calname"); const char *owner = e_source_get_property(source, "eee-owner"); eee_account_update_calendar_settings(account, owner, calname, e_source_peek_name(source), converted_color); eee_account_disconnect(account); struct acl_context * ctx = g_object_get_data (G_OBJECT (target->source), "eee-acl-context"); store_acl (ctx); acl_gui_destroy (); } eee_accounts_manager_restart_sync(mgr()); }
/* The following function taken from gnome clock-applet * (gnome-panel/applets/clock/calendar-sources.c) */ ECal * dates_load_esource (ESource *esource, ECalSourceType source_type, GSList *existing_clients, DatesData *d) { ECal *retval; GError *error; if (existing_clients) { GSList *l; for (l = existing_clients; l; l = l->next) { ECal *client = E_CAL (l->data); if (e_source_equal (esource, e_cal_get_source (client))) { #ifdef DEBUG if (d->debug & DATES_DEBUG_CALENDAR) g_debug ("load_esource: found existing source, returning that"); #endif return g_object_ref (client); } } } retval = e_cal_new (esource, source_type); if (!retval) { g_warning ("Could not load source '%s' from '%s'\n", e_source_peek_name (esource), e_source_get_uri (esource)); return NULL; } error = NULL; if (!e_cal_open (retval, FALSE, &error)) { g_assert (error != NULL); g_warning ("Cannot open calendar from uri '%s': %s\n", e_cal_get_uri (retval), error->message); g_error_free (error); g_object_unref (retval); return NULL; } #ifdef DEBUG if (d->debug & DATES_DEBUG_CALENDAR) g_debug ("Loaded calendar from uri '%s'", e_cal_get_uri (retval)); #endif /* * Set the calendar mode to CAL_MODE_REMOTE. This is necessary to get the * remote (webcal) calendars to work. It doesn't seem to have any effect * on the file backend. */ e_cal_set_mode (retval, CAL_MODE_REMOTE); return retval; }
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 gevo_addrbooks_model_populate(GtkTreeModel *model) { ESourceList *addressbooks; GError *err = NULL; GSList *groups, *g; GtkTreeIter iter; GtkListStore *list; g_return_if_fail(model != NULL); g_return_if_fail(GTK_IS_LIST_STORE(model)); list = GTK_LIST_STORE(model); if (!e_book_get_addressbooks(&addressbooks, &err)) { purple_debug_error("evolution", "Unable to fetch list of address books.\n"); gtk_list_store_append(list, &iter); gtk_list_store_set(list, &iter, ADDRBOOK_COLUMN_NAME, _("None"), ADDRBOOK_COLUMN_URI, NULL, -1); return; } groups = e_source_list_peek_groups(addressbooks); if (groups == NULL) { gtk_list_store_append(list, &iter); gtk_list_store_set(list, &iter, ADDRBOOK_COLUMN_NAME, _("None"), ADDRBOOK_COLUMN_URI, NULL, -1); return; } for (g = groups; g != NULL; g = g->next) { GSList *sources, *s; sources = e_source_group_peek_sources(g->data); for (s = sources; s != NULL; s = s->next) { ESource *source = E_SOURCE(s->data); g_object_ref(source); gtk_list_store_append(list, &iter); gtk_list_store_set(list, &iter, ADDRBOOK_COLUMN_NAME, e_source_peek_name(source), ADDRBOOK_COLUMN_URI, e_source_get_uri(source), -1); } } g_object_unref(addressbooks); }
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 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); }