summaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorSuren A. Chilingaryan <csa@dside.dyndns.org>2005-07-05 03:15:53 +0000
committerSuren A. Chilingaryan <csa@dside.dyndns.org>2005-07-05 03:15:53 +0000
commit9922cef1af71786ae788903b52a8968e5775d510 (patch)
treebadf23fc2701946b61df1d15227736783e44a754 /ui
parenta21deef1c62467b21500f94dfb2ab3d58e69cb85 (diff)
downloadlibrcc-9922cef1af71786ae788903b52a8968e5775d510.tar.gz
librcc-9922cef1af71786ae788903b52a8968e5775d510.tar.bz2
librcc-9922cef1af71786ae788903b52a8968e5775d510.tar.xz
librcc-9922cef1af71786ae788903b52a8968e5775d510.zip
Save / Load
Diffstat (limited to 'ui')
-rw-r--r--ui/gtk.c16
-rw-r--r--ui/internal.h39
-rw-r--r--ui/librccui.c102
-rw-r--r--ui/rccnames.c27
4 files changed, 123 insertions, 61 deletions
diff --git a/ui/gtk.c b/ui/gtk.c
index 16b51db..84aa7df 100644
--- a/ui/gtk.c
+++ b/ui/gtk.c
@@ -53,7 +53,6 @@ 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);
}
@@ -184,8 +183,11 @@ rcc_ui_box rccUiBoxCreate(rcc_ui_menu_context ctx, const char *title) {
return (rcc_ui_box)hbox;
}
-rcc_ui_frame rccUiFrameCreate(rcc_ui_context ctx, const char *title) {
+rcc_ui_frame rccUiFrameCreate(rcc_ui_frame_context ctx, const char *title) {
GtkWidget *frame, *box;
+
+ if (!ctx) return NULL;
+
frame = gtk_frame_new(title?title:"");
gtk_container_border_width(GTK_CONTAINER(frame), FRAME_BORDER);
@@ -195,10 +197,16 @@ rcc_ui_frame rccUiFrameCreate(rcc_ui_context ctx, const char *title) {
return (rcc_ui_frame)frame;
}
-int rccUiFrameAdd(rcc_ui_frame frame, rcc_ui_box box) {
+void rccUiFrameFree(rcc_ui_frame_context ctx) {
+}
+
+
+int rccUiFrameAdd(rcc_ui_frame_context ctx, rcc_ui_box box) {
GtkWidget *vbox;
- vbox = gtk_container_children(GTK_CONTAINER(frame))->data;
+ if ((!ctx)||(!box)) return -1;
+
+ vbox = gtk_container_children(GTK_CONTAINER(ctx->frame))->data;
gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(box), FALSE, FALSE, 0);
return 0;
}
diff --git a/ui/internal.h b/ui/internal.h
index a16c506..8448fb5 100644
--- a/ui/internal.h
+++ b/ui/internal.h
@@ -5,7 +5,7 @@
#include "librccui.h"
typedef unsigned int rcc_ui_id;
-typedef void *rcc_ui_internal;
+
typedef void *rcc_ui_menu_internal;
enum rcc_ui_menu_type_t {
@@ -30,6 +30,30 @@ struct rcc_ui_menu_context_t {
typedef struct rcc_ui_menu_context_t rcc_ui_menu_context_s;
typedef struct rcc_ui_menu_context_t *rcc_ui_menu_context;
+typedef void *rcc_ui_frame_internal;
+
+enum rcc_ui_frame_type_t {
+ RCC_UI_FRAME_LANGUAGE = 0,
+ RCC_UI_FRAME_CHARSETS,
+ RCC_UI_FRAME_ENGINE,
+ RCC_UI_FRAME_MAX
+};
+typedef enum rcc_ui_frame_type_t rcc_ui_frame_type;
+
+struct rcc_ui_frame_context_t {
+ rcc_ui_frame frame;
+
+ rcc_ui_context uictx;
+ rcc_ui_frame_type type;
+
+ rcc_ui_frame_internal internal;
+};
+typedef struct rcc_ui_frame_context_t rcc_ui_frame_context_s;
+typedef struct rcc_ui_frame_context_t *rcc_ui_frame_context;
+
+
+typedef void *rcc_ui_internal;
+
struct rcc_ui_context_t {
rcc_context rccctx;
@@ -43,9 +67,9 @@ struct rcc_ui_context_t {
rcc_language_name *language_names;
rcc_option_name *option_names;
- rcc_ui_frame language_frame;
- rcc_ui_frame charset_frame;
- rcc_ui_frame engine_frame;
+ rcc_ui_frame_context language_frame;
+ rcc_ui_frame_context charset_frame;
+ rcc_ui_frame_context engine_frame;
rcc_ui_page page;
};
@@ -63,8 +87,11 @@ rcc_ui_id rccUiMenuGet(rcc_ui_menu_context ctx);
int rccUiMenuSet(rcc_ui_menu_context ctx, rcc_ui_id id);
rcc_ui_box rccUiBoxCreate(rcc_ui_menu_context ctx, const char *title);
-rcc_ui_frame rccUiFrameCreate(rcc_ui_context ctx, const char *title);
-int rccUiFrameAdd(rcc_ui_frame frame, rcc_ui_box box);
+
+rcc_ui_frame rccUiFrameCreate(rcc_ui_frame_context ctx, const char *title);
+void rccUiFrameFree(rcc_ui_frame_context ctx);
+int rccUiFrameAdd(rcc_ui_frame_context ctx, rcc_ui_box box);
+
rcc_ui_page rccUiPageCreate(rcc_ui_context ctx, const char *title);
int rccUiPageAdd(rcc_ui_page page, rcc_ui_frame frame);
diff --git a/ui/librccui.c b/ui/librccui.c
index 060ada3..c868708 100644
--- a/ui/librccui.c
+++ b/ui/librccui.c
@@ -28,6 +28,27 @@ static void rccUiMenuFreeContext(rcc_ui_menu_context ctx) {
free(ctx);
}
+static rcc_ui_frame_context rccUiFrameCreateContext(rcc_ui_frame_type type, rcc_ui_context uictx) {
+ rcc_ui_frame_context ctx;
+ if ((!uictx)||(type>RCC_UI_FRAME_MAX)) return NULL;
+
+ ctx = (rcc_ui_frame_context)malloc(sizeof(rcc_ui_frame_context_s));
+ if (!ctx) return ctx;
+
+ ctx->uictx = uictx;
+ ctx->type = type;
+
+ ctx->frame = NULL;
+
+ return ctx;
+}
+
+static void rccUiFrameFreeContext(rcc_ui_frame_context ctx) {
+ if (!ctx) return;
+ rccUiFrameFree(ctx);
+ free(ctx);
+}
+
rcc_ui_context rccUiCreateContext(rcc_context rccctx) {
int err = 0;
unsigned int i;
@@ -55,17 +76,12 @@ rcc_ui_context rccUiCreateContext(rcc_context rccctx) {
return NULL;
}
- ctx->language_frame = NULL;
- ctx->charset_frame = NULL;
- ctx->engine_frame = NULL;
- ctx->page = NULL;
-
ctx->options = options;
ctx->charsets = charsets;
ctx->rccctx = rccctx;
- ctx->language_names = rcc_default_language_names;
- ctx->option_names = rcc_default_option_names;
+ ctx->language_names = NULL;
+ ctx->option_names = NULL;
ctx->internal = rccUiCreateInternal(ctx);
@@ -81,7 +97,13 @@ rcc_ui_context rccUiCreateContext(rcc_context rccctx) {
if (!options[i]) err = 1;
}
- if ((err)||(!ctx->language)||(!ctx->engine)) {
+ ctx->language_frame = rccUiFrameCreateContext(RCC_UI_FRAME_LANGUAGE, ctx);
+ ctx->charset_frame = rccUiFrameCreateContext(RCC_UI_FRAME_CHARSETS, ctx);
+ ctx->engine_frame = rccUiFrameCreateContext(RCC_UI_FRAME_ENGINE, ctx);
+ ctx->page = NULL;
+
+
+ if ((err)||(!ctx->language)||(!ctx->engine)||(!ctx->language_frame)||(!ctx->charset_frame)||(!ctx->engine_frame)) {
rccUiFreeContext(ctx);
return NULL;
}
@@ -96,7 +118,11 @@ void rccUiFreeContext(rcc_ui_context ctx) {
if (!ctx) return;
rccUiFreeInternal(ctx);
-
+
+ if (ctx->engine_frame) rccUiFrameFreeContext(ctx->engine_frame);
+ if (ctx->charset_frame) rccUiFrameFreeContext(ctx->charset_frame);
+ if (ctx->language_frame) rccUiFrameFreeContext(ctx->language_frame);
+
if (ctx->charsets) {
classes = rccGetClassList(ctx->rccctx);
for (i=0; classes[i]; i++)
@@ -219,7 +245,6 @@ rcc_ui_widget rccUiGetCharsetMenu(rcc_ui_context ctx, rcc_class_id id) {
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[id])) return NULL;
@@ -265,7 +290,6 @@ 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;
@@ -274,10 +298,7 @@ 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;
}
@@ -297,38 +318,35 @@ 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;
}
rcc_ui_frame rccUiGetLanguageFrame(rcc_ui_context ctx, const char *title) {
+ rcc_ui_frame_context framectx;
rcc_ui_frame frame;
rcc_ui_box language;
if (!ctx) return NULL;
-
- if (ctx->language_frame) return ctx->language_frame;
- frame = rccUiFrameCreate(ctx, title);
- if (!frame) return NULL;
+ framectx = ctx->language_frame;
+ if (framectx->frame) return framectx->frame;
+
+ frame = rccUiFrameCreate(ctx->language_frame, title);
+ if (frame) framectx->frame = frame;
+ else return NULL;
language = rccUiGetLanguageBox(ctx, title);
if (!language) return NULL;
- rccUiFrameAdd(frame, language);
-
- ctx->language_frame = frame;
+ rccUiFrameAdd(framectx, language);
return frame;
}
@@ -336,25 +354,27 @@ rcc_ui_frame rccUiGetLanguageFrame(rcc_ui_context ctx, const char *title) {
rcc_ui_frame rccUiGetCharsetsFrame(rcc_ui_context ctx, const char *title) {
unsigned int i;
rcc_class_ptr *classes;
+ rcc_ui_frame_context framectx;
rcc_ui_frame frame;
rcc_ui_box charset;
if (!ctx) return NULL;
- if (ctx->charset_frame) return ctx->charset_frame;
+ framectx = ctx->charset_frame;
+ if (framectx->frame) return framectx->frame;
- frame = rccUiFrameCreate(ctx, title);
- if (!frame) return NULL;
+ frame = rccUiFrameCreate(framectx, title);
+ if (frame) framectx->frame = frame;
+ else return NULL;
classes = rccGetClassList(ctx->rccctx);
for (i=0; classes[i]; i++) {
if (classes[i]->fullname) {
charset = rccUiGetCharsetBox(ctx, (rcc_class_id)i, classes[i]->fullname);
- rccUiFrameAdd(frame, charset);
+ rccUiFrameAdd(framectx, charset);
}
}
- ctx->charset_frame = frame;
return frame;
}
@@ -362,30 +382,28 @@ rcc_ui_frame rccUiGetCharsetsFrame(rcc_ui_context ctx, const char *title) {
rcc_ui_frame rccUiGetEngineFrame(rcc_ui_context ctx, const char *title) {
unsigned int i;
+ rcc_ui_frame_context framectx;
rcc_ui_frame frame;
rcc_ui_box engine;
rcc_ui_box opt;
if (!ctx) return NULL;
- if (ctx->engine_frame) return ctx->engine_frame;
+ framectx = ctx->engine_frame;
+ if (framectx->frame) return framectx->frame;
- frame = rccUiFrameCreate(ctx, title);
- if (!frame) return NULL;
+ frame = rccUiFrameCreate(framectx, title);
+ if (frame) framectx->frame = frame;
+ else return NULL;
engine = rccUiGetEngineBox(ctx, title);
- puts("Engine");
- rccUiFrameAdd(frame, engine);
- puts("Added");
+ rccUiFrameAdd(framectx, engine);
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);
+ rccUiFrameAdd(framectx, opt);
}
- ctx->engine_frame = frame;
-
return frame;
}
@@ -401,18 +419,14 @@ rcc_ui_page rccUiGetPage(rcc_ui_context ctx, const char *title, const char *lang
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 961dbbc..2e11165 100644
--- a/ui/rccnames.c
+++ b/ui/rccnames.c
@@ -3,29 +3,42 @@
#include "internal.h"
const char *rccUiGetLanguageName(rcc_ui_context ctx, const char *lang) {
+ const char *res;
unsigned int i;
rcc_language_name *names;
if ((!ctx)||(!lang)) return NULL;
-
+
names = ctx->language_names;
+
+ if (names) {
+ for (i=0;names[i].sn;i++)
+ if (!strcmp(lang, names[i].sn)) return names[i].name;
+ }
- for (i=0;names[i].sn;i++)
- if (!strcmp(lang, names[i].sn)) return names[i].name;
+
+ res = rccGetLanguageFullName(lang);
+ if (res) return res;
return lang;
}
const char *rccUiGetOptionName(rcc_ui_context ctx, rcc_option option) {
+ const char *res;
unsigned int i;
rcc_option_name *names;
- if (!ctx) return NULL;
+ if ((!ctx)||(option<0)||(option>RCC_MAX_OPTIONS)) return NULL;
names = ctx->option_names;
- for (i=0;((i<RCC_MAX_OPTIONS)&&(names[i].option!=RCC_MAX_OPTIONS));i++)
- if (names[i].option == option) return names[i].name;
+ if (names) {
+ for (i=0;((i<RCC_MAX_OPTIONS)&&(names[i].option!=RCC_MAX_OPTIONS));i++)
+ if (names[i].option == option) return names[i].name;
+ }
+
+ res = rccGetOptionFullName(option);
+ if (res) return res;
- return NULL;
+ return "";
}