maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Development (https://talk.maemo.org/forumdisplay.php?f=13)
-   -   need help with including HildonTouchSelector in a control panel applet with GTK (https://talk.maemo.org/showthread.php?t=33024)

b-man 2009-10-18 01:39

need help with including HildonTouchSelector in a control panel applet with GTK
 
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)

harriva 2009-10-18 10:09

Re: need help with including HildonTouchSelector in a control panel applet with GTK
 
gtk_container_add (GTK_CONTAINER (GTK_DIALOG(dialog)->vbox), selector);

Now I want my name on the developers list.

b-man 2009-10-18 13:51

Re: need help with including HildonTouchSelector in a control panel applet with GTK
 
lol, shure, you can be our tester/debugging expert :p

qwerty12 2009-10-18 15:01

Re: need help with including HildonTouchSelector in a control panel applet with GTK
 
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.

http://imgur.com/m3K8h.png
http://imgur.com/SumIu.png
http://imgur.com/Hu49q.png

b-man 2009-10-20 02:29

Re: need help with including HildonTouchSelector in a control panel applet with GTK
 
Thanks qwerty12! :D

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 :p)

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

http://b-man.xceleo.org/images/fremantle/m5shot5.png


All times are GMT. The time now is 00:38.

vBulletin® Version 3.8.8