Reply
Thread Tools
b-man's Avatar
Posts: 549 | Thanked: 502 times | Joined on Feb 2008 @ Bowling Green Ohio (united states)
#1
Can anyone help me with this? - i´m trying to write a single-column selector for a control panel applet for http://talk.maemo.org/showthread.php?t=33000 using the Data selection and Writing Control Panel Applets examples from the Maemo 5 Developer Guide but i´m having trouble applying the data selection to the applet.

can anyone help? (i´m new to GTK)
__________________
I'm an advanced user and a bit of a modder.
----------------------------------------------
I am involved with Mer, Deblet, and NITdroid.
My ports/creations/hacks: GNOME (for Deblet), Cdeb2», Ubuntu, playable flash games in the "Get Started" app, DBS, ect...


enhanced fedora port has been canceled in favor of NITDebian (TBA)
 
Posts: 61 | Thanked: 43 times | Joined on Aug 2008
#2
gtk_container_add (GTK_CONTAINER (GTK_DIALOG(dialog)->vbox), selector);

Now I want my name on the developers list.
 
b-man's Avatar
Posts: 549 | Thanked: 502 times | Joined on Feb 2008 @ Bowling Green Ohio (united states)
#3
lol, shure, you can be our tester/debugging expert
__________________
I'm an advanced user and a bit of a modder.
----------------------------------------------
I am involved with Mer, Deblet, and NITdroid.
My ports/creations/hacks: GNOME (for Deblet), Cdeb2», Ubuntu, playable flash games in the "Get Started" app, DBS, ect...


enhanced fedora port has been canceled in favor of NITDebian (TBA)

Last edited by b-man; 2009-10-18 at 13:56.
 
qwerty12's Avatar
Posts: 4,274 | Thanked: 5,358 times | Joined on Sep 2007 @ Looking at y'all and sighing
#4
This is my example attempt at this, in the style of the TV out applet that is included with the N900:

Code:
#include <hildon-cp-plugin/hildon-cp-plugin-interface.h>
#include <gtk/gtk.h>
#include <hildon/hildon.h>
#include <libintl.h>
#include <locale.h>
#include <libosso.h>
#include <glib.h>

typedef struct _user_data_t user_data_t;

struct _user_data_t
{
	GtkWidget *dialog, *selector, *button;
	gint response;
};

osso_return_t execute(osso_context_t *osso, gpointer user_data, gboolean user_activated)
{
	user_data_t *data = g_new0(user_data_t, 1);
	guint i;
	const gchar *items[] =
	{
		"Item 1",
		"Item 2",
		"Item 3"
	};

	//g_return_val_if_fail(data != NULL, OSSO_ERROR); //g_new0 already aborts when it cannot allocate the memory. Duh.

	setlocale(LC_ALL, "");

	data->dialog = gtk_dialog_new_with_buttons(
		"Choose summat",
		GTK_WINDOW(user_data),
		GTK_DIALOG_MODAL | GTK_DIALOG_NO_SEPARATOR,
		dgettext("hildon-libs", "wdgt_bd_save"),
		GTK_RESPONSE_OK,
		GTK_STOCK_CANCEL,
		GTK_RESPONSE_CANCEL,
		NULL);

	data->selector = hildon_touch_selector_new_text();
	for (i = 0; i < G_N_ELEMENTS(items); i++)
		hildon_touch_selector_append_text(HILDON_TOUCH_SELECTOR(data->selector), items[i]);

	data->button = hildon_picker_button_new(HILDON_SIZE_AUTO | HILDON_SIZE_FINGER_HEIGHT, HILDON_BUTTON_ARRANGEMENT_HORIZONTAL);
	hildon_picker_button_set_selector(HILDON_PICKER_BUTTON(data->button), HILDON_TOUCH_SELECTOR(data->selector)); 
	hildon_picker_button_set_active(HILDON_PICKER_BUTTON(data->button), 0);
	hildon_button_set_title(HILDON_BUTTON(data->button), "Pick one:");
	gtk_box_pack_start(GTK_BOX (GTK_DIALOG(data->dialog)->vbox), data->button, TRUE, TRUE, 0);
	gtk_widget_show(data->button);

	data->response = gtk_dialog_run(GTK_DIALOG(data->dialog));
	if (data->response == GTK_RESPONSE_OK)
	{
		gchar *text, *current_text;
		current_text = hildon_touch_selector_get_current_text(HILDON_TOUCH_SELECTOR(data->selector));
		text = g_strdup_printf("Selected: %s, index number: %d", current_text, hildon_touch_selector_get_active(HILDON_TOUCH_SELECTOR(data->selector), 0));
		hildon_banner_show_information(NULL, NULL, text);
		g_free(current_text);
		g_free(text);
		text = current_text = NULL;
	}

	gtk_widget_destroy(data->dialog);
	g_free(data);
	data = NULL;
	return OSSO_OK;
}
This is just one way of populating the TouchSelector (with predetermined contents); feel free to do it any other way.




Last edited by qwerty12; 2009-10-29 at 07:48.
 

The Following 2 Users Say Thank You to qwerty12 For This Useful Post:
b-man's Avatar
Posts: 549 | Thanked: 502 times | Joined on Feb 2008 @ Bowling Green Ohio (united states)
#5
Thanks qwerty12!

I have full selection working but it seems that i have ran into another issue - i´m also trying to add an add/remove function to the selection using the examples provided here, but i´m running into a bit of an issue while applying it (the guide assumes that your applying this to a window with GTKtree) and i´m a bit confused with how i should apply this function to the selection. Could someone someone help me with this? (sorry for all of the complicated questions- i´m still getting use to using this )

btw, i´m trying to apply the add and remove buttons above the ¨Done¨ button - to make things a bit clearer

__________________
I'm an advanced user and a bit of a modder.
----------------------------------------------
I am involved with Mer, Deblet, and NITdroid.
My ports/creations/hacks: GNOME (for Deblet), Cdeb2», Ubuntu, playable flash games in the "Get Started" app, DBS, ect...


enhanced fedora port has been canceled in favor of NITDebian (TBA)
 
Reply

Tags
gtk problem


 
Forum Jump


All times are GMT. The time now is 02:54.