summaryrefslogtreecommitdiffstats
path: root/ui/gtk.c
diff options
context:
space:
mode:
Diffstat (limited to 'ui/gtk.c')
-rw-r--r--ui/gtk.c64
1 files changed, 53 insertions, 11 deletions
diff --git a/ui/gtk.c b/ui/gtk.c
index 2fdf2f4..22854ab 100644
--- a/ui/gtk.c
+++ b/ui/gtk.c
@@ -1,5 +1,8 @@
#include <stdio.h>
#include <gtk/gtk.h>
+
+#include <librcc.h>
+
#include "internal.h"
#include "rccnames.h"
@@ -71,7 +74,10 @@ int rccUiMenuConfigureWidget(rcc_ui_menu_context ctx) {
rcc_charset_id charset_id;
rcc_engine_id engine_id;
-
+
+ rcc_option_name *option_name;
+ rcc_option_value_names optnames;
+
GtkWidget *list, *item, *menu;
if (!ctx) return -1;
@@ -81,9 +87,10 @@ int rccUiMenuConfigureWidget(rcc_ui_menu_context ctx) {
switch (ctx->type) {
case RCC_UI_MENU_LANGUAGE:
- list = gtk_menu_new();
-
languages=rccGetLanguageList(rccctx);
+ if (!languages) return -1;
+
+ list = gtk_menu_new();
for (i=0; languages[i]; i++) {
item = gtk_menu_item_new_with_label(rccUiGetLanguageName(uictx, languages[i]->sn));
gtk_signal_connect(GTK_OBJECT(item), "activate", GTK_SIGNAL_FUNC(rccGtkMenuLanguageCB), ctx);
@@ -104,11 +111,12 @@ int rccUiMenuConfigureWidget(rcc_ui_menu_context ctx) {
gtk_option_menu_set_history(GTK_OPTION_MENU(menu), language_id);
break;
case RCC_UI_MENU_CHARSET:
- list = gtk_menu_new();
language_id = (rcc_language_id)rccUiMenuGet(uictx->language);
charsets = rccGetCharsetList(rccctx, language_id);
+ if (!charsets) return -1;
+ list = gtk_menu_new();
for (i=0;charsets[i];i++) {
item = gtk_menu_item_new_with_label(charsets[i]);
gtk_widget_show(item);
@@ -125,15 +133,17 @@ int rccUiMenuConfigureWidget(rcc_ui_menu_context ctx) {
gtk_option_menu_set_menu(GTK_OPTION_MENU(menu), list);
config = rccGetConfig(rccctx, language_id);
- charset_id = rccConfigGetSelectedCharset(config, (rcc_class_id)ctx->id);
+ charset_id = rccConfigGetSelectedCharset(config, rccUiMenuGetClassId(ctx));
if (charset_id == (rcc_charset_id)-1) charset_id = 0;
gtk_option_menu_set_history(GTK_OPTION_MENU(menu), charset_id);
break;
case RCC_UI_MENU_ENGINE:
- list = gtk_menu_new();
language_id = (rcc_language_id)rccUiMenuGet(uictx->language);
engines = rccGetEngineList(rccctx, language_id);
+ if (!engines) return -1;
+
+ list = gtk_menu_new();
for (i=0;engines[i];i++) {
item = gtk_menu_item_new_with_label(engines[i]->title);
gtk_widget_show(item);
@@ -154,12 +164,44 @@ int rccUiMenuConfigureWidget(rcc_ui_menu_context ctx) {
gtk_option_menu_set_history(GTK_OPTION_MENU(menu), engine_id);
break;
case RCC_UI_MENU_OPTION:
- 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;
+ switch (rccUiMenuGetRangeType(ctx)) {
+ case RCC_OPTION_RANGE_TYPE_BOOLEAN:
+ if (!ctx->widget) {
+ item = gtk_check_button_new_with_label(rccUiGetOptionName(uictx, rccUiMenuGetOption(ctx)));
+ ctx->widget = item;
+ }
+
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(item), rccGetOption(rccctx, rccUiMenuGetOption(ctx)));
+ break;
+ case RCC_OPTION_RANGE_TYPE_MENU:
+ if (!ctx->widget) {
+ option_name = rccUiGetOptionRccName(uictx, rccUiMenuGetOption(ctx));
+ if (!option_name) return -1;
+ optnames = option_name->value_names;
+ if (!optnames) return -1;
+
+ list = gtk_menu_new();
+ for (i=0;optnames[i];i++) {
+ item = gtk_menu_item_new_with_label(optnames[i]);
+ gtk_widget_show(item);
+ gtk_menu_append(GTK_MENU(list), item);
+ }
+
+ menu = gtk_option_menu_new();
+ ctx->widget = menu;
+
+ 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), rccGetOption(rccctx, rccUiMenuGetOption(ctx)));
+ break;
+ default:
+ return -1;
}
break;
+ default:
+ return -1;
}
return 0;
@@ -170,7 +212,7 @@ rcc_ui_box rccUiBoxCreate(rcc_ui_menu_context ctx, const char *title) {
GtkWidget *hbox, *label;
hbox = gtk_hbox_new(FALSE, BOX_SPACING);
gtk_container_border_width(GTK_CONTAINER(hbox), BOX_BORDER);
- if (ctx->type != RCC_UI_MENU_OPTION) {
+ if ((ctx->type != RCC_UI_MENU_OPTION)||(rccUiMenuGetRangeType(ctx) != RCC_OPTION_RANGE_TYPE_BOOLEAN)) {
label = gtk_label_new(title);
gtk_widget_set_usize(label, TITLE_WIDTH, TITLE_HEIGHT);
gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);