static void pkg_window_add_source (PkgWindow *window, /* IN */ PkConnection *connection, /* IN */ gint source) /* IN */ { PkgWindowPrivate *priv; GtkTreeIter iter; GtkTreeIter child; gchar *title; ENTRY; priv = window->priv; if (!pkg_window_get_sources_iter(window, connection, &iter)) { EXIT; } title = g_strdup_printf(_("Source %d"), source); gtk_tree_store_append(priv->model, &child, &iter); gtk_tree_store_set(priv->model, &child, COLUMN_CONNECTION, connection, COLUMN_TYPE, TYPE_SOURCE, COLUMN_ID, source, COLUMN_TITLE, title, COLUMN_SUBTITLE, _("Loading ..."), -1); pk_connection_source_get_plugin_async( connection, source, NULL, pkg_window_connection_source_get_plugin_cb, pkg_window_source_call_new( window, connection, source)); pkg_window_expand_to_iter(window, &child); g_free(title); EXIT; }
static void pkg_sources_page_add_source (PkgSourcesPage *page, /* IN */ gint source) /* IN */ { PkgSourcesPagePrivate *priv; GtkTreeIter iter; gchar *id_str; g_return_if_fail(PKG_IS_SOURCES_PAGE(page)); ENTRY; priv = page->priv; id_str = g_strdup_printf("%d", source); gtk_list_store_append(priv->model, &iter); gtk_list_store_set(priv->model, &iter, COLUMN_ID, source, COLUMN_IDSTR, id_str, -1); g_free(id_str); pk_connection_source_get_plugin_async( priv->connection, source, NULL, (GAsyncReadyCallback)pkg_sources_page_get_plugin_cb, pkg_source_call_new(priv->connection, source, g_object_ref(page))); EXIT; }
static void pkg_channel_page_get_sources_cb (GObject *object, /* IN */ GAsyncResult *result, /* IN */ gpointer user_data) /* IN */ { PkConnection *connection = PK_CONNECTION(object); PkgChannelPagePrivate *priv; gint *sources; gsize sources_len = 0; gchar *idstr; GError *error = NULL; GtkTreeIter iter; gint i; g_return_if_fail(PKG_IS_CHANNEL_PAGE(user_data)); ENTRY; priv = PKG_CHANNEL_PAGE(user_data)->priv; if (!pk_connection_channel_get_sources_finish(connection, result, &sources, &sources_len, &error)) { WARNING(Channel, "Error retrieving channel sources: %s", error->message); g_error_free(error); EXIT; } gtk_list_store_clear(priv->model); for (i = 0; i < sources_len; i++) { idstr = g_strdup_printf("%d", sources[i]); gtk_list_store_append(priv->model, &iter); gtk_list_store_set(priv->model, &iter, COLUMN_ID, sources[i], COLUMN_IDSTR, idstr, -1); g_free(idstr); pk_connection_source_get_plugin_async( priv->connection, sources[i], NULL, pkg_channel_page_source_get_plugin_cb, source_call_new(user_data, sources[i])); } g_free(sources); EXIT; }