Author: peter Date: 2008-08-10 11:22:05 +0000 (Sun, 10 Aug 2008) New Revision: 27439
Modified: squeeze/trunk/libsqueeze/command-option.c squeeze/trunk/libsqueeze/command-option.h squeeze/trunk/libsqueeze/scanf-parser.c squeeze/trunk/src/extract_dialog.c squeeze/trunk/src/extract_dialog.h Log: X-Squeeze-Options from the .squeeze files are read and displayed as check buttons Modified: squeeze/trunk/libsqueeze/command-option.c =================================================================== --- squeeze/trunk/libsqueeze/command-option.c 2008-08-10 11:04:46 UTC (rev 27438) +++ squeeze/trunk/libsqueeze/command-option.c 2008-08-10 11:22:05 UTC (rev 27439) @@ -27,7 +27,7 @@ LSQ_TYPE_COMMAND_OPTION, \ LSQCommandOptionClass)) -typedef void (*LSQCommandOptionGetDefaultFunc)(LSQCommandOption*, GValue*); +typedef void (*LSQCommandOptionGetDefaultFunc)(const LSQCommandOption*, GValue*); typedef struct _LSQCommandOptionClass LSQCommandOptionClass; @@ -119,7 +119,7 @@ } }; - lsq_command_option_type[0] = g_type_register_fundamental (G_TYPE_GTYPE, "LSQCommandOption", &lsq_command_option[0], &lsq_command_option_fund, 0); + lsq_command_option_type[0] = g_type_register_fundamental(g_type_fundamental_next(), "LSQCommandOption", &lsq_command_option[0], &lsq_command_option_fund, 0); lsq_command_option_type[1] = g_type_register_static (lsq_command_option_type[0], "LSQCommandOptionBool", &lsq_command_option[1], 0); lsq_command_option_type[2] = g_type_register_static (lsq_command_option_type[0], "LSQCommandOptionString", &lsq_command_option[2], 0); lsq_command_option_type[3] = g_type_register_static (lsq_command_option_type[0], "LSQCommandOptionInt", &lsq_command_option[3], 0); @@ -214,29 +214,62 @@ return option_pair; } +gchar ** +lsq_command_option_pair_get_args(LSQCommandOptionPair **pair) +{ + int length = 0; + LSQCommandOptionPair **option_iter; + gchar **argv, **argi; + + for(option_iter = pair; *option_iter; option_iter++) + { + length += lsq_command_option_get_args((*option_iter)->option, &(*option_iter)->value, NULL); + } + + argv = g_new0(gchar*, length+1); + argi = argv; + + for(option_iter = pair; *option_iter; option_iter++) + { + argi += lsq_command_option_get_args((*option_iter)->option, &(*option_iter)->value, argi); + } + + return argv; +} + +gint +lsq_command_option_get_args(const LSQCommandOption *option, GValue *value, gchar **argv) +{ + //TODO + return 0; +} + void -lsq_command_option_get_default(LSQCommandOption *option, GValue *value) +lsq_command_option_get_default(const LSQCommandOption *option, GValue *value) { g_return_if_fail(LSQ_COMMAND_OPTION_GET_CLASS(option)->get_default); LSQ_COMMAND_OPTION_GET_CLASS(option)->get_default(option, value); } -static void lsq_command_option_bool_get_default(LSQCommandOptionBool *option, GValue *value) +static void lsq_command_option_bool_get_default(const LSQCommandOptionBool *option, GValue *value) { g_value_set_boolean(value, option->default_value); } -static void lsq_command_option_string_get_default(LSQCommandOptionString *option, GValue *value) +static void lsq_command_option_string_get_default(const LSQCommandOptionString *option, GValue *value) { - g_value_set_string(value, option->default_value); + if(option->default_value) + g_value_set_string(value, option->default_value); +// else +// g_value_unset(value); } -static void lsq_command_option_int_get_default(LSQCommandOptionInt *option, GValue *value) +static void lsq_command_option_int_get_default(const LSQCommandOptionInt *option, GValue *value) { g_value_set_int(value, option->default_value); } -static void lsq_command_option_uint_get_default(LSQCommandOptionUint *option, GValue *value) +static void lsq_command_option_uint_get_default(const LSQCommandOptionUint *option, GValue *value) { g_value_set_uint(value, option->default_value); } Modified: squeeze/trunk/libsqueeze/command-option.h =================================================================== --- squeeze/trunk/libsqueeze/command-option.h 2008-08-10 11:04:46 UTC (rev 27438) +++ squeeze/trunk/libsqueeze/command-option.h 2008-08-10 11:22:05 UTC (rev 27439) @@ -54,9 +54,15 @@ LSQCommandOption ** lsq_command_option_create_list(XfceRc *rc, gchar **option_names); +gchar ** +lsq_command_option_pair_get_args(LSQCommandOptionPair **pair); + void -lsq_command_option_get_default(LSQCommandOption *option, GValue *value); +lsq_command_option_get_default(const LSQCommandOption *option, GValue *value); +gint +lsq_command_option_get_args(const LSQCommandOption *option, GValue *value, gchar **argv); + struct _LSQCommandOptionPair { GValue value; const LSQCommandOption *option; Modified: squeeze/trunk/libsqueeze/scanf-parser.c =================================================================== --- squeeze/trunk/libsqueeze/scanf-parser.c 2008-08-10 11:04:46 UTC (rev 27438) +++ squeeze/trunk/libsqueeze/scanf-parser.c 2008-08-10 11:22:05 UTC (rev 27439) @@ -564,8 +564,6 @@ if(!ptr) return 0; - g_debug("string: %s", (gchar*)(ctx->props_store[part->index] = g_strndup(cur, ptr-cur))); - return ptr - str; } @@ -1213,7 +1211,6 @@ if(!part) { - g_debug("file: %s", ctx->filename); LSQArchiveIter *iter = lsq_archive_add_file(LSQ_PARSER_CONTEXT(ctx)->archive, ctx->filename); lsq_archive_iter_set_propsv(iter, ctx->props_store); lsq_archive_iter_unref(iter); Modified: squeeze/trunk/src/extract_dialog.c =================================================================== --- squeeze/trunk/src/extract_dialog.c 2008-08-10 11:04:46 UTC (rev 27438) +++ squeeze/trunk/src/extract_dialog.c 2008-08-10 11:22:05 UTC (rev 27439) @@ -115,6 +115,17 @@ GtkWidget *r_vbox = gtk_vbox_new(FALSE, 0); gtk_container_add(GTK_CONTAINER(dialog->r_frame), r_vbox); + if((dialog->command_options = lsq_archive_get_command_options(archive, LSQ_COMMAND_TYPE_EXTRACT))) + { + LSQCommandOptionPair **options_iter; + for(options_iter = dialog->command_options; *options_iter; options_iter++) + { + GtkWidget *widget; + widget = gtk_check_button_new_with_label((*options_iter)->option->blurb); + gtk_box_pack_start(GTK_BOX(r_vbox), widget, FALSE, FALSE, 0); + } + } + /* FIXME, does not work correctly when there are more dots in a filename then the one identifying the extention */ gchar **filename_components = g_strsplit(g_path_get_basename(lsq_archive_get_filename(archive)), ".", 2); gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(dialog), filename_components[0]); Modified: squeeze/trunk/src/extract_dialog.h =================================================================== --- squeeze/trunk/src/extract_dialog.h 2008-08-10 11:04:46 UTC (rev 27438) +++ squeeze/trunk/src/extract_dialog.h 2008-08-10 11:22:05 UTC (rev 27439) @@ -46,6 +46,7 @@ GtkWidget *all_files_radio; GtkWidget *sel_files_radio; LSQArchive *archive; + LSQCommandOptionPair **command_options; }; typedef struct _SQExtractArchiveDialogClass SQExtractArchiveDialogClass; _______________________________________________ Xfce4-commits mailing list Xfce4-commits@xfce.org http://foo-projects.org/mailman/listinfo/xfce4-commits