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 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); } }
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()); }