Re: Key-value file parser, howto get all groups and create loop from them
- From: rupert <rupertt gmail com>
- To: "Christian Neumair" <chris gnome-de org>
- Cc: gtk-app-devel-list <gtk-app-devel-list gnome org>
- Subject: Re: Key-value file parser, howto get all groups and create loop from them
- Date: Tue, 1 Aug 2006 19:57:18 +0200
On 8/1/06, Christian Neumair <chris gnome-de org> wrote:
Am Dienstag, den 01.08.2006, 19:12 +0200 schrieb rupert:
> Im so far with my code that i want to create a table where each group
> gets a row that has labels, buttons and textentries.
> right now im using a GtkTable where i create the Widgets in the for
> loop that gets the content from the keyfile, is this possible or do I
> have to use a treeview?
No, unfortunately there is currently no button implementation for tree
views, at least none I know of.
> I can compile the app but get a segfault while running, it looks like
> this with one static row http://az-lantech.de/ubuntu/view.png.
Without seeing your code, we can't really help you.
this is the part with the for loop ,
i had the idea of using a +i in the gtk_table_attach_defaults comamnd for
the placement, right now the for only has one iteration, with more it
crashes..
GtkWidget *crypto_keys;
gboolean *isfile=FALSE;
gchar *startgroup;
gchar **groups=NULL;
//GArray *groups=NULL;
gint i, *groupcounter=0, *grouplenght=NULL;
GString *device, *mapper, *mountpoint, *password, *keyfile;
crypto_keys = g_key_file_new();
g_key_file_load_from_file(crypto_keys,
"/home/Programmierung/GTK_Projects/project_dmaster/src/crypto.ini",
G_KEY_FILE_NONE, NULL) ;
groups = g_key_file_get_groups(crypto_keys, &grouplenght);
//g_print("\n %d", grouplenght);
for(i=0; i<1; i++)
{
//put tthe info from the keyfile in variables
//g_print("\n %s", groups[i]);
device = g_key_file_get_string(crypto_keys, groups[i], "device",
NULL);
mapper = g_key_file_get_string(crypto_keys, groups[i],
"mapperdevice", NULL);
mountpoint = g_key_file_get_string(crypto_keys, groups[i],
"mountpoint", NULL);
password = g_key_file_get_string(crypto_keys, groups[i], "password",
NULL);
keyfile = g_key_file_get_string(crypto_keys, groups[i], "keyfile",
NULL);
g_print("\n %s", device);
g_print("\n %s", mapper);
g_print("\n %s", mountpoint);
g_print("\n %s", password);
g_print("\n %s", keyfile);
//free the strings
// g_strfreev(groups);
crypto_mapper_button = gtk_button_new(); //1
gtk_box_pack_start(GTK_BOX(crypto_content_vbox), cryptohbox, FALSE,
TRUE, 0);
pic_mapper_device = g_object_new(GTK_TYPE_IMAGE,"file",
"pics/no.png", NULL);
gtk_button_set_image(crypto_mapper_button, pic_mapper_device);
gtk_button_set_relief(crypto_mapper_button, GTK_RELIEF_NONE);
gtk_container_add(GTK_CONTAINER(crypto_mapper_button),
pic_mapper_device);
crypto_mount_button = gtk_button_new(); //2
pic_drive_mounted = g_object_new(GTK_TYPE_IMAGE,"file",
"pics/mount.png", NULL);
gtk_button_set_image(crypto_mount_button, pic_drive_mounted );
gtk_button_set_relief(crypto_mount_button, GTK_RELIEF_NONE);
gtk_container_add(GTK_CONTAINER(crypto_mount_button),
pic_drive_mounted);
crypto_device = gtk_label_new(device); //3
crypto_volume_name = gtk_label_new(mapper);//4
crypto_mountpoint = gtk_label_new(mountpoint);//5
crypto_go_button = gtk_button_new_with_label("Go");
crypto_passHbox = gtk_hbox_new(FALSE, 0);//6
crypto_password = gtk_entry_new();
crypto_keyfiles = gtk_label_new(keyfile);
//decide if use a keyfile or enter the password
if(iskey)
gtk_box_pack_start(GTK_BOX(crypto_passHbox), crypto_keyfiles, FALSE,
TRUE, 0);
else
gtk_box_pack_start(GTK_BOX(crypto_passHbox), crypto_password, FALSE,
TRUE, 0);
gtk_box_pack_start(GTK_BOX(crypto_passHbox), crypto_go_button,
FALSE, TRUE, 0);
//pack everything into the table
gtk_table_attach_defaults(crypto_table,
GTK_WIDGET(crypto_mapper_button), 0,1,1,2);
gtk_table_attach_defaults(crypto_table,
GTK_WIDGET(crypto_mount_button), 1,2,1,2);
gtk_table_attach_defaults(crypto_table, GTK_WIDGET(crypto_device),
2,3,1,2);
gtk_table_attach_defaults(crypto_table,
GTK_WIDGET(crypto_volume_name), 3,4,1,2);
gtk_table_attach_defaults(crypto_table,
GTK_WIDGET(crypto_mountpoint), 4,5,1,2);
gtk_table_attach_defaults(crypto_table, GTK_WIDGET(crypto_passHbox),
5,6,1,2);
//abfrage des init und mountstatus
// g_timeout_add(1000, crypto_out_device, pic_mapper_device);
// g_timeout_add(1000, crypto_mount_check, pic_drive_mounted);
gtk_entry_set_visibility(crypto_password, FALSE);
//buttonpress events, replace the NULL with the device/mountpoint
...
g_signal_connect(G_OBJECT(crypto_mount_button),
"button_press_event", G_CALLBACK(crypto_mount_drive), NULL);
g_signal_connect(G_OBJECT(crypto_mapper_button),
"button_press_event", G_CALLBACK(crypto_remove_mapper), NULL);
g_signal_connect(G_OBJECT(crypto_go_button), "button_press_event",
G_CALLBACK(crypto_init_mapper), NULL);
//eventbox
gtk_widget_set_events(crypto_mount_button, GDK_BUTTON_PRESS_MASK);
g_signal_connect(G_OBJECT(crypto_mount_button), "enter",
G_CALLBACK(crypto_onmouse_in), GINT_TO_POINTER(crypto_buffer));
g_signal_connect(G_OBJECT(crypto_mount_button), "leave",
G_CALLBACK(crypto_onmouse_out), GINT_TO_POINTER(crypto_buffer));
//function calls
// dev_init_status = crypto_out_device(pic_mapper_device);
dev_init_status = crypto_out_device(pic_mapper_device);
crypto_mount_check(pic_drive_mounted);
// g_print("%c", dev_init_status);
}
//for end
gtk_widget_show_all(crypto_table);
--
Christian Neumair <chris gnome-de org>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]