diff --git a/camlibs/fujitsu/fujitsu.c b/camlibs/fujitsu/fujitsu.c index ae9dcd1b8..78b0d534a 100644 --- a/camlibs/fujitsu/fujitsu.c +++ b/camlibs/fujitsu/fujitsu.c @@ -369,7 +369,7 @@ return (GP_ERROR); int camera_config_get (CameraWidget *window) { - CameraWidget *t, *page; + CameraWidget *t, *section; int num; char buf[1024]; @@ -378,50 +378,32 @@ int camera_config_get (CameraWidget *window) { /* set the window label to something more specific */ strcpy(window->label, "Fujitsu Camera Settings"); - /* Create a new page for "Quality" */ - page = gp_widget_new(GP_WIDGET_PAGE, "Quality"); - gp_widget_append(window, page); + /* Create a new section for "Quality" */ + section = gp_widget_new(GP_WIDGET_SECTION, "Quality"); + gp_widget_append(window, section); /* Add the Resolution setting radio buttons */ t = gp_widget_new(GP_WIDGET_RADIO, "Resolution"); - strcpy(t->choice, "Standard"); - gp_widget_append(page, t); + gp_widget_choice_append(t, "Normal"); + gp_widget_choice_append(t, "High"); + gp_widget_choice_append(t, "Best"); + gp_widget_append(section, t); - t = gp_widget_new(GP_WIDGET_RADIO, "Resolution"); - strcpy(t->choice, "High"); - gp_widget_append(page, t); - - t = gp_widget_new(GP_WIDGET_RADIO, "Resolution"); - strcpy(t->choice, "Best"); - gp_widget_append(page, t); - - /* Create a new page for "Flash/Lens" and append to window */ - page = gp_widget_new(GP_WIDGET_PAGE, "Flash/Lens"); - gp_widget_append(window, page); + /* Create a new section for "Flash/Lens" and append to window */ + section = gp_widget_new(GP_WIDGET_SECTION, "Flash/Lens"); + gp_widget_append(window, section); t = gp_widget_new(GP_WIDGET_MENU, "Flash Setting"); - strcpy(t->choice, "Auto"); - gp_widget_append(page, t); - - t = gp_widget_new(GP_WIDGET_MENU, "Flash Setting"); - strcpy(t->choice, "Red-eye"); - gp_widget_append(page, t); - - t = gp_widget_new(GP_WIDGET_MENU, "Flash Setting"); - strcpy(t->choice, "Force"); - gp_widget_append(page, t); - - t = gp_widget_new(GP_WIDGET_MENU, "Flash Setting"); - strcpy(t->choice, "None"); - gp_widget_append(page, t); + gp_widget_choice_append(t, "Auto"); + gp_widget_choice_append(t, "Red-eye"); + gp_widget_choice_append(t, "Force"); + gp_widget_choice_append(t, "None"); + gp_widget_append(section, t); t = gp_widget_new(GP_WIDGET_RADIO, "Lens Mode"); - strcpy(t->choice, "Normal"); - gp_widget_append(page, t); - - t = gp_widget_new(GP_WIDGET_RADIO, "Lens Mode"); - strcpy(t->choice, "Macro"); - gp_widget_append(page, t); + gp_widget_choice_append(t, "Normal"); + gp_widget_choice_append(t, "Macro"); + gp_widget_append(section, t); return (GP_OK); } diff --git a/frontends/gtk-old/src/callbacks.c b/frontends/gtk-old/src/callbacks.c index e20b16686..660369029 100644 --- a/frontends/gtk-old/src/callbacks.c +++ b/frontends/gtk-old/src/callbacks.c @@ -960,43 +960,105 @@ void camera_delete_all() { camera_delete_common(1); } -void camera_configure_rec (CameraWidget *w, GtkWidget *page, GtkWidget *parent) { -/* - child_count = gp_widget_child_count(window); - for (x=0; xtype) { + case GP_WIDGET_WINDOW: + /* do nothing. */ + break; + case GP_WIDGET_SECTION: + if ((notebook=gtk_object_get_data(GTK_OBJECT(window), "notebook"))==NULL) { + notebook = gtk_notebook_new(); + gtk_widget_show(notebook); + gtk_box_pack_start(GTK_BOX(box), notebook, FALSE, FALSE, 0); + gtk_object_set_data(GTK_OBJECT(window), "notebook", notebook); + } + label = gtk_label_new(w->label); + gtk_widget_show(label); + vbox = gtk_vbox_new(FALSE, 0); + gtk_widget_show(vbox); + box = vbox; + gtk_notebook_append_page(GTK_NOTEBOOK(notebook), vbox, label); + break; + case GP_WIDGET_TEXT: + break; + case GP_WIDGET_RANGE: + break; + case GP_WIDGET_TOGGLE: + break; + case GP_WIDGET_RADIO: + break; + case GP_WIDGET_MENU: + break; + case GP_WIDGET_BUTTON: + break; + default: + break; } -*/ + + child_count = gp_widget_child_count(w); +printf("child_count=%i\n", child_count); + for (x=0; xlabel); - camera_configure_rec(window, NULL, NULL); + box = gtk_vbox_new(FALSE, 0); + gtk_widget_show(box); + gtk_container_add(GTK_CONTAINER(window), box); - gp_widget_free(window); + ok = gtk_button_new_with_label("OK"); + gtk_widget_show(ok); + + cancel = gtk_button_new_with_label("Cancel"); + gtk_widget_show(cancel); + + /* Build the dialog */ + camera_configure_rec(w, box, window); + + if (wait_for_hide(window, ok, NULL)==0) { + gp_widget_free(w); + return; + } + printf("gathering widget data\n"); + + /* Clean up and leave */ + gp_widget_free(w); + gtk_widget_destroy(window); } void camera_show_information() { diff --git a/include/gphoto2-datatypes.h b/include/gphoto2-datatypes.h index be52af651..60cedafb1 100644 --- a/include/gphoto2-datatypes.h +++ b/include/gphoto2-datatypes.h @@ -38,7 +38,7 @@ typedef enum { typedef enum { GP_WIDGET_WINDOW, - GP_WIDGET_PAGE, + GP_WIDGET_SECTION, GP_WIDGET_TEXT, GP_WIDGET_RANGE, GP_WIDGET_TOGGLE, @@ -61,9 +61,9 @@ struct CameraWidget { char value_string[32]; float value_number; - /* For Radio and Menu */ - char choice[32]; + char choice[32][64]; + int choice_count; /* For Range */ float min; diff --git a/libgphoto2/widget.c b/libgphoto2/widget.c index 3d111208a..973a77dfc 100644 --- a/libgphoto2/widget.c +++ b/libgphoto2/widget.c @@ -1,9 +1,14 @@ #include +#include #include +/* Create/free a widget */ +/* -------------------------------------------------------------------------- */ + CameraWidget* gp_widget_new(CameraWidgetType type, char *label) { CameraWidget *w; + int x; w = (CameraWidget*)malloc(sizeof(CameraWidget)); memset(w, 0, sizeof(CameraWidget)); @@ -16,9 +21,35 @@ CameraWidget* gp_widget_new(CameraWidgetType type, char *label) { memset(w->children, 0, sizeof(CameraWidget*)*64); w->children_count = 0; + for (x=0; x<32; x++) + strcpy(w->choice[x], ""); + w->choice_count = 0; + return (w); } +int gp_widget_free(CameraWidget *widget) { + /* Recursively delete the widget and all children */ + + int x; + + if (widget->children_count == 0) + return (GP_OK); + + for (x=0; xchildren_count; x++) { + gp_widget_free(widget->children[x]); + free(widget->children[x]); + } + + free(widget); + + return (GP_OK); +} + + +/* Attach widgets to a parent widget */ +/* -------------------------------------------------------------------------- */ + int gp_widget_append(CameraWidget *parent, CameraWidget *child) { parent->children[parent->children_count] = child; @@ -52,28 +83,38 @@ CameraWidget* gp_widget_child(CameraWidget *parent, int child_number) { return (parent->children[child_number]); } -int gp_widget_free(CameraWidget *widget) { - /* Recursively delete the widget and all children */ +/* Retrieve and set choices for menus/radio buttons */ +/* -------------------------------------------------------------------------- */ - int x; +int gp_widget_choice_append(CameraWidget *widget, char *choice) { - if (widget->children_count == 0) - return (GP_OK); - - for (x=0; xchildren_count; x++) { - gp_widget_free(widget->children[x]); - free(widget->children[x]); - } - - free(widget); + strncpy(widget->choice[widget->choice_count], choice, 64); + widget->choice_count += 1; return (GP_OK); } +int gp_widget_choice_count(CameraWidget *widget) { + + return (widget->choice_count); +} + +char *gp_widget_choice(CameraWidget *widget, int choice_number) { + + if (choice_number > widget->choice_count) + return NULL; + + return (widget->choice[choice_number]); +} + + + +/* Debugging output */ +/* -------------------------------------------------------------------------- */ + void gp_widget_dump_rec (CameraWidget *widget, int depth) { int x; - char buf[1024]; printf("core: "); for (x=0; xlabel); + printf("core: Dumping widget \"%s\" and children:\n", widget->label); gp_widget_dump_rec(widget, 0); return (GP_OK);