|
2009-10-22
, 21:57
|
Guest |
Posts: n/a |
Thanked: 0 times |
Joined on
|
#2
|
|
2009-10-22
, 23:30
|
|
Posts: 1,637 |
Thanked: 4,424 times |
Joined on Apr 2009
@ Germany
|
#3
|
It seems that I have ran into another problem while using hildon touch selector . I´m trying to have hildon touch selector display l list of files from a directory as items on the selector, but i haven´t been able to find any documentation for this function. Can anyone help me with this?
here´s a code snippet of what i have so far; the ¨const gchar *items[] = {Splash *}; function would be replaced by the file list function.
...
#include <gio/gio.h> #include <stdio.h> int main(int argc, char** argv) { gtk_init(&argc, &argv); char* path = "/home"; GFile* file = g_file_new_for_path(path); printf("path name: %s\n", g_file_get_basename(file)); GFileEnumerator* files = g_file_enumerate_children(file, G_FILE_ATTRIBUTE_STANDARD_NAME, G_FILE_QUERY_INFO_NONE, NULL, NULL); if(files!=NULL) { GFileInfo* info = g_file_enumerator_next_file(files, NULL, NULL); while(info) { printf("name %s\n", g_file_info_get_name(info)); info = g_file_enumerator_next_file(files, NULL, NULL); } g_object_unref(files); } return 0; }
The Following User Says Thank You to nicolai For This Useful Post: | ||
|
2009-10-23
, 08:30
|
Posts: 432 |
Thanked: 645 times |
Joined on Mar 2009
|
#4
|
|
2009-10-25
, 18:06
|
|
Posts: 549 |
Thanked: 502 times |
Joined on Feb 2008
@ Bowling Green Ohio (united states)
|
#5
|
#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, *label; GSList *item; GtkListStore *items; HildonTouchSelectorColumn *column; GtkCellRenderer *renderer; 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; /* get object data for selection objects */ char* path = "/home/maemo/code"; GFile* file = g_file_new_for_path(path); GFileEnumerator* files = g_file_enumerate_children(file, G_FILE_ATTRIBUTE_STANDARD_NAME, G_FILE_QUERY_INFO_NONE, NULL, NULL); if(file!=NULL) { GFileInfo* info = g_file_enumerator_next_file(files, NULL, NULL); while(info) { data->items = g_file_info_get_name(info); info = g_file_enumerator_next_file(files, NULL, NULL); } g_object_unref(files); } g_return_val_if_fail(data != NULL, OSSO_ERROR); setlocale(LC_ALL, ""); data->dialog = gtk_dialog_new_with_buttons( "Bootsplash selection", 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 (); data->selector = hildon_touch_selector_new_text(); for (i = 0; i < G_N_ELEMENTS(data->items); i++) hildon_touch_selector_append_text(HILDON_TOUCH_SELECTOR(data->selector), data->items); hildon_touch_selector_set_column_selection_mode (HILDON_TOUCH_SELECTOR (data->selector), HILDON_TOUCH_SELECTOR_SELECTION_MODE_MULTIPLE); 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), "Selection:"); 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(GTK_WIDGET(data->dialog)); g_free(data); data = NULL; return OSSO_OK; } osso_return_t save_state(osso_context_t *osso, gpointer data) { /* ... save state ... */ return OSSO_OK; }
|
2009-10-26
, 10:05
|
|
Posts: 1,637 |
Thanked: 4,424 times |
Joined on Apr 2009
@ Germany
|
#6
|
I got the file list function applied but now i´m having issues with piping the data into my selection menu
...
Code:.... while(info) { data->items = g_file_info_get_name(info); info = g_file_enumerator_next_file(files, NULL, NULL); } ....
The Following User Says Thank You to nicolai For This Useful Post: | ||
here´s a code snippet of what i have so far; the ¨const gchar *items[] = {Splash *}; function would be replaced by the file list function.
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)