diff options
Diffstat (limited to 'ui')
-rw-r--r-- | ui/gtk.c | 43 | ||||
-rw-r--r-- | ui/internal.h | 2 | ||||
-rw-r--r-- | ui/librccui.c | 77 | ||||
-rw-r--r-- | ui/rccnames.c | 2 |
4 files changed, 84 insertions, 40 deletions
@@ -3,6 +3,14 @@ #include "internal.h" #include "rccnames.h" +#define TITLE_WIDTH 160 +#define TITLE_HEIGHT 10 +#define BOX_SPACING 1 +#define BOX_BORDER 0 +#define FRAME_SPACING 1 +#define FRAME_BORDER 0 +#define PAGE_SPACING 0 + rcc_ui_internal rccUiCreateInternal(rcc_ui_context ctx) { return NULL; } @@ -14,7 +22,7 @@ rcc_ui_widget rccUiMenuCreateWidget(rcc_ui_menu_context ctx) { return NULL; } -void rccUiMenuDestroyWidget(rcc_ui_menu_context ctx) { +void rccUiMenuFreeWidget(rcc_ui_menu_context ctx) { } rcc_ui_id rccUiMenuGet(rcc_ui_menu_context ctx) { @@ -24,7 +32,7 @@ rcc_ui_id rccUiMenuGet(rcc_ui_menu_context ctx) { if (ctx->type == RCC_UI_MENU_OPTION) return gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(ctx->widget)); - + menu = gtk_option_menu_get_menu(ctx->widget); return g_list_index(GTK_MENU_SHELL(menu)->children, gtk_menu_get_active(GTK_MENU(menu))); } @@ -45,6 +53,7 @@ int rccUiMenuSet(rcc_ui_menu_context ctx, rcc_ui_id id) { static int rccGtkMenuLanguageCB(GtkWidget * w, gpointer item) { + puts("LanguageCB!!!!!!!!!!!!!!!!!!!!!!"); rccUiRestoreLanguage(((rcc_ui_menu_context)item)->uictx); } @@ -94,20 +103,18 @@ int rccUiMenuConfigureWidget(rcc_ui_menu_context ctx) { gtk_option_menu_remove_menu(GTK_OPTION_MENU(menu)); gtk_option_menu_set_menu(GTK_OPTION_MENU(menu), list); gtk_option_menu_set_history(GTK_OPTION_MENU(menu), language_id); - - return 0; break; case RCC_UI_MENU_CHARSET: - list = gtk_menu_new(); language_id = (rcc_language_id)rccUiMenuGet(uictx->language); charsets = rccGetCharsetList(rccctx, language_id); for (i=0;charsets[i];i++) { - list = gtk_menu_item_new_with_label(charsets[i]); + item = gtk_menu_item_new_with_label(charsets[i]); gtk_widget_show(item); gtk_menu_append(GTK_MENU(list), item); + puts(charsets[i]); } if (ctx->widget) menu = ctx->widget; @@ -130,9 +137,10 @@ int rccUiMenuConfigureWidget(rcc_ui_menu_context ctx) { language_id = (rcc_language_id)rccUiMenuGet(uictx->language); engines = rccGetEngineList(rccctx, language_id); for (i=0;engines[i];i++) { - list = gtk_menu_item_new_with_label(engines[i]->title); + item = gtk_menu_item_new_with_label(engines[i]->title); gtk_widget_show(item); gtk_menu_append(GTK_MENU(list), item); + puts(engines[i]->title); } if (ctx->widget) menu = ctx->widget; @@ -151,8 +159,11 @@ int rccUiMenuConfigureWidget(rcc_ui_menu_context ctx) { break; case RCC_UI_MENU_OPTION: - item = gtk_check_button_new_with_label(rccUiGetOptionName(uictx, (rcc_option)ctx->id)); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(item), rccGetOption(rccctx, (rcc_option)ctx->id)); + if (!ctx->widget) { + item = gtk_check_button_new_with_label(rccUiGetOptionName(uictx, (rcc_option)ctx->id)); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(item), rccGetOption(rccctx, (rcc_option)ctx->id)); + ctx->widget = item; + } break; } @@ -162,11 +173,11 @@ int rccUiMenuConfigureWidget(rcc_ui_menu_context ctx) { rcc_ui_box rccUiBoxCreate(rcc_ui_menu_context ctx, const char *title) { GtkWidget *hbox, *label; - hbox = gtk_hbox_new(FALSE, 10); - gtk_container_border_width(GTK_CONTAINER(hbox), 5); + hbox = gtk_hbox_new(FALSE, BOX_SPACING); + gtk_container_border_width(GTK_CONTAINER(hbox), BOX_BORDER); if (ctx->type != RCC_UI_MENU_OPTION) { label = gtk_label_new(title); - gtk_widget_set_usize(label, 120, 17); + gtk_widget_set_usize(label, TITLE_WIDTH, TITLE_HEIGHT); gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); } gtk_box_pack_start(GTK_BOX(hbox), (GtkWidget*)ctx->widget, TRUE, TRUE, 0); @@ -176,9 +187,9 @@ rcc_ui_box rccUiBoxCreate(rcc_ui_menu_context ctx, const char *title) { rcc_ui_frame rccUiFrameCreate(rcc_ui_context ctx, const char *title) { GtkWidget *frame, *box; frame = gtk_frame_new(title?title:""); - gtk_container_border_width(GTK_CONTAINER(frame), 5); + gtk_container_border_width(GTK_CONTAINER(frame), FRAME_BORDER); - box = gtk_vbox_new(FALSE, 3); + box = gtk_vbox_new(FALSE, FRAME_SPACING); gtk_container_add(GTK_CONTAINER(frame), box); return (rcc_ui_frame)frame; @@ -187,13 +198,13 @@ rcc_ui_frame rccUiFrameCreate(rcc_ui_context ctx, const char *title) { int rccUiFrameAdd(rcc_ui_frame frame, rcc_ui_box box) { GtkWidget *vbox; - vbox = gtk_container_get_toplevels()->data; + vbox = gtk_container_children(GTK_CONTAINER(frame))->data; gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(box), FALSE, FALSE, 0); return 0; } rcc_ui_page rccUiPageCreate(rcc_ui_context ctx, const char *title) { - return (rcc_ui_page)gtk_vbox_new(FALSE, 0); + return (rcc_ui_page)gtk_vbox_new(FALSE, PAGE_SPACING); } int rccUiPageAdd(rcc_ui_page page, rcc_ui_frame frame) { diff --git a/ui/internal.h b/ui/internal.h index afc0a08..a16c506 100644 --- a/ui/internal.h +++ b/ui/internal.h @@ -56,7 +56,7 @@ rcc_ui_internal rccUiCreateInternal(rcc_ui_context ctx); void rccUiFreeInternal(rcc_ui_context ctx); rcc_ui_widget rccUiMenuCreateWidget(rcc_ui_menu_context ctx); -void rccUiMenuDestroyWidget(rcc_ui_menu_context ctx); +void rccUiMenuFreeWidget(rcc_ui_menu_context ctx); int rccUiMenuConfigureWidget(rcc_ui_menu_context ctx); rcc_ui_id rccUiMenuGet(rcc_ui_menu_context ctx); diff --git a/ui/librccui.c b/ui/librccui.c index 0700b8b..060ada3 100644 --- a/ui/librccui.c +++ b/ui/librccui.c @@ -60,6 +60,7 @@ rcc_ui_context rccUiCreateContext(rcc_context rccctx) { ctx->engine_frame = NULL; ctx->page = NULL; + ctx->options = options; ctx->charsets = charsets; ctx->rccctx = rccctx; @@ -136,31 +137,44 @@ int rccUiSetOptionNames(rcc_ui_context ctx, rcc_option_name *names) { int rccUiRestoreLanguage(rcc_ui_context ctx) { unsigned int i; rcc_class_ptr *classes; - rcc_context rccctx; - - if (!ctx) return -1; - - rccctx = ctx->rccctx; + rcc_language_id language_id; - rccUiMenuSet(ctx->engine, (rcc_ui_id)rccGetSelectedEngine(rccctx)); + rcc_language_config config; - for (i=0;i<RCC_MAX_OPTIONS;i++) - rccUiMenuSet(ctx->options[i], rccGetOption(rccctx, (rcc_option)i)); + if (!ctx) return -1; + + language_id = (rcc_language_id)rccUiMenuGet(ctx->language); + config = rccGetConfig(ctx->rccctx, language_id); - classes = rccGetClassList(rccctx); + rccUiMenuConfigureWidget(ctx->engine); + //rccUiMenuSet(ctx->engine, (rcc_ui_id)rccConfigGetSelectedEngine(config)); + + classes = rccGetClassList(ctx->rccctx); for (i=0;classes[i];i++) - rccUiMenuSet(ctx->charsets[i], rccGetSelectedCharset(rccctx, (rcc_class_id)i)); + if (classes[i]->fullname) { + rccUiMenuConfigureWidget(ctx->charsets[i]); +// rccUiMenuSet(ctx->charsets[i], rccConfigGetSelectedCharset(config, (rcc_class_id)i)); + } + return 0; } int rccUiRestore(rcc_ui_context ctx) { + unsigned int i; + rcc_context rccctx; rcc_language_id language_id; if (!ctx) return -1; + + rccctx = ctx->rccctx; - language_id = rccGetSelectedLanguage(ctx->rccctx); + language_id = rccGetSelectedLanguage(rccctx); rccUiMenuSet(ctx->language, (rcc_ui_id)language_id); + + for (i=0;i<RCC_MAX_OPTIONS;i++) + rccUiMenuSet(ctx->options[i], rccGetOption(rccctx, (rcc_option)i)); + return 0; } @@ -182,7 +196,8 @@ int rccUiUpdate(rcc_ui_context ctx) { classes = rccGetClassList(rccctx); for (i=0;classes[i];i++) - rccSetCharset(rccctx, (rcc_class_id)i, rccUiMenuGet(ctx->charsets[i])); + if (classes[i]->fullname) + rccSetCharset(rccctx, (rcc_class_id)i, rccUiMenuGet(ctx->charsets[i])); return 0; } @@ -197,17 +212,18 @@ rcc_ui_widget rccUiGetLanguageMenu(rcc_ui_context ctx) { } rcc_ui_widget rccUiGetCharsetMenu(rcc_ui_context ctx, rcc_class_id id) { - rcc_charset *charsets; + rcc_class_ptr *classes; unsigned int i; if ((!ctx)||(id<0)) return NULL; - charsets = rccGetCurrentCharsetList(ctx->rccctx); - for (i=0;charsets[i];i++); + classes = rccGetClassList(ctx->rccctx); + for (i=0;classes[i];i++); + printf("Recalc: %i %i\n", id, i); if (id>=i) return NULL; - if (rccUiMenuConfigureWidget(ctx->charsets[i])) return NULL; - return ctx->charsets[i]->widget; + if (rccUiMenuConfigureWidget(ctx->charsets[id])) return NULL; + return ctx->charsets[id]->widget; } @@ -249,6 +265,7 @@ rcc_ui_box rccUiGetCharsetBox(rcc_ui_context ctx, rcc_class_id id, const char *t classes = rccGetClassList(ctx->rccctx); for (i=0; classes[i]; i++); + printf("Charset Box: %i %i\n", id, i); if (id>=i) return NULL; if (ctx->charsets[id]->box) return ctx->charsets[id]->box; @@ -256,8 +273,11 @@ rcc_ui_box rccUiGetCharsetBox(rcc_ui_context ctx, rcc_class_id id, const char *t charset = rccUiGetCharsetMenu(ctx, id); if (!charset) return NULL; - + + puts("Charset Box Pre"); + printf("%p %p\n", ctx->charsets[id], ctx->charsets[id]->widget); ctx->charsets[id]->box = rccUiBoxCreate(ctx->charsets[id], title); + puts("Charset Box Post"); return ctx->charsets[id]->box; } @@ -277,13 +297,17 @@ rcc_ui_box rccUiGetEngineBox(rcc_ui_context ctx, const char *title) { rcc_ui_box rccUiGetOptionBox(rcc_ui_context ctx, rcc_option option, const char *title) { rcc_ui_widget opt; + printf("Option Strt: %i %p\n", option, title); if ((!ctx)||(option<0)||(option>=RCC_MAX_OPTIONS)) return NULL; if (ctx->options[option]->box) return ctx->options[option]->box; + puts("=== Option Box ==="); opt = rccUiGetOptionMenu(ctx, option); if (!opt) return NULL; + puts("Option Menu"); ctx->options[option]->box = rccUiBoxCreate(ctx->options[option], title); + puts("Option Finish"); return ctx->options[option]->box; } @@ -324,8 +348,10 @@ rcc_ui_frame rccUiGetCharsetsFrame(rcc_ui_context ctx, const char *title) { classes = rccGetClassList(ctx->rccctx); for (i=0; classes[i]; i++) { - charset = rccUiGetCharsetBox(ctx, (rcc_class_id)i, classes[i]->fullname); - rccUiFrameAdd(frame, charset); + if (classes[i]->fullname) { + charset = rccUiGetCharsetBox(ctx, (rcc_class_id)i, classes[i]->fullname); + rccUiFrameAdd(frame, charset); + } } ctx->charset_frame = frame; @@ -348,9 +374,12 @@ rcc_ui_frame rccUiGetEngineFrame(rcc_ui_context ctx, const char *title) { if (!frame) return NULL; engine = rccUiGetEngineBox(ctx, title); + puts("Engine"); rccUiFrameAdd(frame, engine); + puts("Added"); for (i=0; i<RCC_MAX_OPTIONS; i++) { + printf("OptionBox: %u\n", i); opt = rccUiGetOptionBox(ctx, (rcc_option)i, rccUiGetOptionName(ctx, i)); rccUiFrameAdd(frame, opt); } @@ -368,18 +397,22 @@ rcc_ui_page rccUiGetPage(rcc_ui_context ctx, const char *title, const char *lang if (!ctx) return NULL; if (ctx->page) return ctx->page; - + page = rccUiPageCreate(ctx, title); if (!page) return NULL; - + + puts("P C"); frame = rccUiGetLanguageFrame(ctx, language_title); rccUiPageAdd(page, frame); + puts("L C"); frame = rccUiGetCharsetsFrame(ctx, charset_title); rccUiPageAdd(page, frame); + puts("C C"); frame = rccUiGetEngineFrame(ctx, engine_title); rccUiPageAdd(page, frame); + puts("E C"); ctx->page = page; diff --git a/ui/rccnames.c b/ui/rccnames.c index e4f4b48..961dbbc 100644 --- a/ui/rccnames.c +++ b/ui/rccnames.c @@ -24,7 +24,7 @@ const char *rccUiGetOptionName(rcc_ui_context ctx, rcc_option option) { names = ctx->option_names; - for (i=0;i<RCC_MAX_OPTIONS;i++) + for (i=0;((i<RCC_MAX_OPTIONS)&&(names[i].option!=RCC_MAX_OPTIONS));i++) if (names[i].option == option) return names[i].name; return NULL; |