Esempio n. 1
0
static void
pkg_channels_page_init (PkgChannelsPage *page)
{
	PkgChannelsPagePrivate *priv;
	GtkTreeViewColumn *column;
	GtkCellRenderer *cell;
	gchar *path;

	ENTRY;
	page->priv = G_TYPE_INSTANCE_GET_PRIVATE(page,
	                                         PKG_TYPE_CHANNELS_PAGE,
	                                         PkgChannelsPagePrivate);
	priv = page->priv;

	path = pkg_path_for_data("ui", "pkg-channels-page.ui", NULL);
	priv->builder = gtk_builder_new();
	gtk_builder_add_from_file(priv->builder, path, NULL);

	#define EXTRACT_WIDGET(_n, _f)  \
		priv->_f = GTK_WIDGET(gtk_builder_get_object(priv->builder, _n))

	EXTRACT_WIDGET("channels-page", container);
	EXTRACT_WIDGET("channels", channels);
	EXTRACT_WIDGET("add", add);
	EXTRACT_WIDGET("remove", remove);

	gtk_widget_unparent(priv->container);
	gtk_container_add(GTK_CONTAINER(page), priv->container);

	priv->model = GTK_TREE_MODEL(gtk_list_store_new(2,
	                                                G_TYPE_INT,
	                                                G_TYPE_STRING));
	gtk_tree_view_set_model(GTK_TREE_VIEW(priv->channels), priv->model);

	column = gtk_tree_view_column_new();
	gtk_tree_view_column_set_title(column, _("ID"));
	gtk_tree_view_append_column(GTK_TREE_VIEW(priv->channels), column);
	cell = gtk_cell_renderer_text_new();
	gtk_tree_view_column_pack_start(column, cell, TRUE);
	gtk_tree_view_column_add_attribute(column, cell, "text", COLUMN_IDSTR);

	g_signal_connect(priv->add,
	                 "clicked",
	                 G_CALLBACK(pkg_channels_page_add_clicked_cb),
	                 page);
	g_signal_connect(priv->remove,
	                 "clicked",
	                 G_CALLBACK(pkg_channels_page_remove_clicked_cb),
	                 page);

	EXIT;
}
Esempio n. 2
0
static void
pkg_channel_page_init (PkgChannelPage *page)
{
	PkgChannelPagePrivate *priv;
	gchar *path;
	GtkTreeViewColumn *column;
	GtkCellRenderer *cell;

	ENTRY;
	page->priv = G_TYPE_INSTANCE_GET_PRIVATE(page,
	                                         PKG_TYPE_CHANNEL_PAGE,
	                                         PkgChannelPagePrivate);
	priv = page->priv;

	#define EXTRACT_WIDGET(_n, _w)                                          \
	    G_STMT_START {                                                      \
	        priv->_w = (gpointer)gtk_builder_get_object(priv->builder, _n); \
	    } G_STMT_END

	path = pkg_path_for_data("ui", "pkg-channel-page.ui", NULL);
	priv->builder = gtk_builder_new();
	gtk_builder_add_from_file(priv->builder, path, NULL);
	g_free(path);

	EXTRACT_WIDGET("page-label", page_label);
	EXTRACT_WIDGET("channel-page", container);
	EXTRACT_WIDGET("target", target);
	EXTRACT_WIDGET("args", args);
	EXTRACT_WIDGET("working-dir", working_dir);
	EXTRACT_WIDGET("env", env);
	EXTRACT_WIDGET("pid", pid);
	EXTRACT_WIDGET("kill-pid", kill_pid);
	EXTRACT_WIDGET("exit-status", exit_status);
	EXTRACT_WIDGET("muted", muted);
	EXTRACT_WIDGET("sources", sources);

	gtk_widget_unparent(priv->container);
	gtk_container_add(GTK_CONTAINER(page), priv->container);

	column = gtk_tree_view_column_new();
	gtk_tree_view_column_set_title(column, _("ID"));
	gtk_tree_view_append_column(GTK_TREE_VIEW(priv->sources), column);
	cell = gtk_cell_renderer_text_new();
	gtk_tree_view_column_pack_start(column, cell, TRUE);
	gtk_tree_view_column_add_attribute(column, cell, "text", COLUMN_IDSTR);

	column = gtk_tree_view_column_new();
	gtk_tree_view_column_set_title(column, _("Plugin"));
	gtk_tree_view_append_column(GTK_TREE_VIEW(priv->sources), column);
	cell = gtk_cell_renderer_text_new();
	gtk_tree_view_column_pack_start(column, cell, TRUE);
	gtk_tree_view_column_add_attribute(column, cell, "text", COLUMN_PLUGIN);

	priv->model = gtk_list_store_new(3,
	                                 G_TYPE_INT,
	                                 G_TYPE_STRING,
	                                 G_TYPE_STRING);
	gtk_tree_view_set_model(GTK_TREE_VIEW(priv->sources),
	                        GTK_TREE_MODEL(priv->model));

	EXIT;
}
Esempio n. 3
0
/**
 * pkg_sources_page_init:
 * @page: A #PkgSourcesPage.
 *
 * Initializes the newly created #PkgSourcesPage instance.
 *
 * Returns: None.
 * Side effects: None.
 */
static void
pkg_sources_page_init (PkgSourcesPage *page) /* IN */
{
	PkgSourcesPagePrivate *priv;
	GtkTreeViewColumn *column;
	GtkCellRenderer *cell;
	gchar *path;

	ENTRY;
	page->priv = G_TYPE_INSTANCE_GET_PRIVATE(page,
	                                         PKG_TYPE_SOURCES_PAGE,
	                                         PkgSourcesPagePrivate);
	priv = page->priv;

	#define EXTRACT_WIDGET(_n, _f) \
		priv->_f = GTK_WIDGET(gtk_builder_get_object(priv->builder, _n))

	path = pkg_path_for_data("ui", "pkg-sources-page.ui", NULL);
	priv->builder = gtk_builder_new();
	gtk_builder_add_from_file(priv->builder, path, NULL);
	g_free(path);

	EXTRACT_WIDGET("sources-page", container);
	EXTRACT_WIDGET("treeview", treeview);
	EXTRACT_WIDGET("add", add);
	EXTRACT_WIDGET("remove", remove);
	EXTRACT_WIDGET("combo", combo);

	column = gtk_tree_view_column_new();
	gtk_tree_view_column_set_title(column, _("ID"));
	cell = gtk_cell_renderer_text_new();
	gtk_tree_view_column_pack_start(column, cell, TRUE);
	gtk_tree_view_column_add_attribute(column, cell, "text", 1);
	gtk_tree_view_append_column(GTK_TREE_VIEW(priv->treeview), column);

	column = gtk_tree_view_column_new();
	gtk_tree_view_column_set_title(column, _("Type"));
	cell = gtk_cell_renderer_text_new();
	gtk_tree_view_column_pack_start(column, cell, TRUE);
	gtk_tree_view_column_add_attribute(column, cell, "text", 2);
	gtk_tree_view_append_column(GTK_TREE_VIEW(priv->treeview), column);

	priv->model = gtk_list_store_new(4,
	                                 G_TYPE_INT,
	                                 G_TYPE_STRING,
	                                 G_TYPE_STRING,
	                                 G_TYPE_STRING);
	gtk_tree_view_set_model(GTK_TREE_VIEW(priv->treeview),
	                        GTK_TREE_MODEL(priv->model));

	cell = gtk_cell_renderer_text_new();
	gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(priv->combo), cell, TRUE);
	gtk_cell_layout_add_attribute(GTK_CELL_LAYOUT(priv->combo), cell, "text", 0);

	priv->types = gtk_list_store_new(1, G_TYPE_STRING);
	gtk_combo_box_set_model(GTK_COMBO_BOX(priv->combo),
	                        GTK_TREE_MODEL(priv->types));

	g_signal_connect(priv->combo,
	                 "changed",
	                 G_CALLBACK(pkg_sources_page_combo_changed_cb),
	                 page);

	g_signal_connect(priv->add,
	                 "clicked",
	                 G_CALLBACK(pkg_sources_page_add_clicked_cb),
	                 page);

	g_signal_connect(priv->remove,
	                 "clicked",
	                 G_CALLBACK(pkg_sources_page_remove_clicked_cb),
	                 page);

	g_signal_connect(gtk_tree_view_get_selection(GTK_TREE_VIEW(priv->treeview)),
	                 "changed",
	                 G_CALLBACK(pkg_sources_page_selection_changed_cb),
	                 page);

	gtk_widget_unparent(priv->container);
	gtk_container_add(GTK_CONTAINER(page), priv->container);

	EXIT;
}