summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--examples/mpg123-rcc.patch150
-rw-r--r--examples/rcc-gtk-config.c2
-rw-r--r--ui/gtk.c19
3 files changed, 156 insertions, 15 deletions
diff --git a/examples/mpg123-rcc.patch b/examples/mpg123-rcc.patch
new file mode 100644
index 0000000..36ad04a
--- /dev/null
+++ b/examples/mpg123-rcc.patch
@@ -0,0 +1,150 @@
+diff -dPNur mpg123-0.59r-orig/common.c mpg123-0.59r-new/common.c
+--- mpg123-0.59r-orig/common.c 2005-07-19 18:43:57.583934801 +0200
++++ mpg123-0.59r-new/common.c 2005-07-19 18:16:40.670756807 +0200
+@@ -15,6 +15,7 @@
+ #endif
+ #endif
+
++#include "rccpatch.h"
+ #include "mpg123.h"
+ #include "genre.h"
+ #include "common.h"
+@@ -487,6 +488,8 @@
+ char comment[31]={0,};
+ char genre[31]={0,};
+
++ char *ctitle, *cartist, *calbum, *ccomment;
++
+ if(param.quiet)
+ return;
+
+@@ -495,6 +498,11 @@
+ strncpy(album,tag->album,30);
+ strncpy(year,tag->year,4);
+ strncpy(comment,tag->comment,30);
++
++ ctitle = rccPatchRecode(title);
++ cartist = rccPatchRecode(artist);
++ calbum = rccPatchRecode(album);
++ ccomment = rccPatchRecode(comment);
+
+ if ( tag->genre <= sizeof(genre_table)/sizeof(*genre_table) ) {
+ strncpy(genre, genre_table[tag->genre], 30);
+@@ -502,9 +510,14 @@
+ strncpy(genre,"Unknown",30);
+ }
+
+- fprintf(stderr,"Title : %-30s Artist: %s\n",title,artist);
+- fprintf(stderr,"Album : %-30s Year : %4s\n",album,year);
+- fprintf(stderr,"Comment: %-30s Genre : %s\n",comment,genre);
++ fprintf(stderr,"Title : %-30s Artist: %s\n",ctitle?ctitle:title,cartist?cartist:artist);
++ fprintf(stderr,"Album : %-30s Year : %4s\n",calbum?calbum:album,year);
++ fprintf(stderr,"Comment: %-30s Genre : %s\n",ccomment?ccomment:comment,genre);
++
++ if (ctitle) free(ctitle);
++ if (cartist) free(cartist);
++ if (calbum) free(calbum);
++ if (ccomment) free(ccomment);
+ }
+
+ #if 0
+diff -dPNur mpg123-0.59r-orig/Makefile mpg123-0.59r-new/Makefile
+--- mpg123-0.59r-orig/Makefile 2005-07-19 18:43:57.553939726 +0200
++++ mpg123-0.59r-new/Makefile 2005-07-19 20:00:19.566458888 +0200
+@@ -581,12 +581,12 @@
+ mpg123-make:
+ @ $(MAKE) CFLAGS='$(CFLAGS)' BINNAME=mpg123 mpg123
+
+-mpg123: mpg123.o common.o $(OBJECTS) decode_2to1.o decode_4to1.o \
++mpg123: mpg123.o rccpatch.o common.o $(OBJECTS) decode_2to1.o decode_4to1.o \
+ tabinit.o audio.o layer1.o layer2.o layer3.o buffer.o \
+ getlopt.o httpget.o xfermem.o equalizer.o \
+ decode_ntom.o Makefile wav.o readers.o getbits.o \
+ control_generic.o
+- $(CC) $(CFLAGS) $(LDFLAGS) mpg123.o tabinit.o common.o layer1.o \
++ $(CC) $(CFLAGS) $(LDFLAGS) -lrcc mpg123.o tabinit.o rccpatch.o common.o layer1.o \
+ layer2.o layer3.o audio.o buffer.o decode_2to1.o equalizer.o \
+ decode_4to1.o getlopt.o httpget.o xfermem.o decode_ntom.o \
+ wav.o readers.o getbits.o control_generic.o \
+diff -dPNur mpg123-0.59r-orig/mpg123.c mpg123-0.59r-new/mpg123.c
+--- mpg123-0.59r-orig/mpg123.c 2005-07-19 18:43:57.558938905 +0200
++++ mpg123-0.59r-new/mpg123.c 2005-07-19 19:27:03.000000000 +0200
+@@ -33,6 +33,8 @@
+ #include "buffer.h"
+ #include "term.h"
+
++#include "rccpatch.h"
++
+ #include "version.h"
+
+ static void usage(char *dummy);
+@@ -904,6 +906,8 @@
+ exit(0);
+ }
+ #endif
++
++ rccPatchInit();
+
+ while ((fname = get_next_file(argc, argv))) {
+ char *dirname, *filename;
+@@ -1069,6 +1073,8 @@
+ intflag = FALSE;
+ }
+ }
++ rccPatchFree();
++
+ #ifndef NOXFERMEM
+ if (param.usebuffer) {
+ buffer_end();
+diff -dPNur mpg123-0.59r-orig/rccpatch.c mpg123-0.59r-new/rccpatch.c
+--- mpg123-0.59r-orig/rccpatch.c 1970-01-01 01:00:00.000000000 +0100
++++ mpg123-0.59r-new/rccpatch.c 2005-07-19 20:00:35.819789685 +0200
+@@ -0,0 +1,40 @@
++#include <librcc.h>
++
++#define ID3_CLASS 0
++#define OUT_CLASS 1
++static rcc_class classes[] = {
++ { "id3", RCC_CLASS_STANDARD, NULL, NULL, "ID3 Encoding", 0 },
++ { "out", RCC_CLASS_STANDARD, NULL, NULL, "Output Encoding", 0 },
++ { NULL }
++};
++
++static int rcc_initialized = 0;
++
++void rccPatchFree() {
++ if (rcc_initialized) {
++ rccFree();
++ rcc_initialized = 0;
++ }
++}
++
++void rccPatchInit() {
++ if (rcc_initialized) return;
++ rccInit();
++ rccInitDefaultContext(NULL, 0, 0, classes, 0);
++ rccLoad(NULL, "xmms");
++ rccInitDb4(NULL, NULL, 0);
++ rcc_initialized = 1;
++}
++
++static void rccPatchTryInit() {
++ if (!rcc_initialized) {
++ rccPatchInit();
++ if (rcc_initialized) atexit(rccPatchFree);
++ }
++}
++
++char *rccPatchRecode(const char *str) {
++ char *res;
++ rccPatchTryInit();
++ return rccRecode(NULL, ID3_CLASS, OUT_CLASS, str);
++}
+diff -dPNur mpg123-0.59r-orig/rccpatch.h mpg123-0.59r-new/rccpatch.h
+--- mpg123-0.59r-orig/rccpatch.h 1970-01-01 01:00:00.000000000 +0100
++++ mpg123-0.59r-new/rccpatch.h 2005-07-19 18:27:08.390669528 +0200
+@@ -0,0 +1,4 @@
++void rccPatchFree();
++void rccPatchInit();
++char *rccPatchRecode(const char *str);
++
diff --git a/examples/rcc-gtk-config.c b/examples/rcc-gtk-config.c
index eae029e..a46350f 100644
--- a/examples/rcc-gtk-config.c
+++ b/examples/rcc-gtk-config.c
@@ -45,7 +45,7 @@ int main (int argc, char *argv[])
uictx = rccUiCreateContext(ctx);
window1 = gtk_window_new (GTK_WINDOW_TOPLEVEL);
- gtk_window_set_policy(GTK_WINDOW (window1), FALSE, FALSE, FALSE);
+ gtk_window_set_policy(GTK_WINDOW (window1), FALSE, FALSE, TRUE);
gtk_window_set_title (GTK_WINDOW (window1), "LibRCC Config");
gtk_widget_show(window1);
diff --git a/ui/gtk.c b/ui/gtk.c
index cf69a87..a148210 100644
--- a/ui/gtk.c
+++ b/ui/gtk.c
@@ -12,7 +12,7 @@
#define BOX_BORDER 0
#define FRAME_SPACING 1
#define FRAME_BORDER 0
-#define PAGE_SPACING 0
+#define PAGE_SPACING 1
rcc_ui_internal rccUiCreateInternal(rcc_ui_context ctx) {
return NULL;
@@ -100,7 +100,6 @@ int rccUiMenuConfigureWidget(rcc_ui_menu_context ctx) {
if (!languages) return -1;
list = gtk_menu_new();
- gtk_widget_show(list);
for (i=0; languages[i]; i++) {
item = gtk_menu_item_new_with_label(rccUiGetLanguageName(uictx, languages[i]->sn));
gtk_widget_show(item);
@@ -114,7 +113,6 @@ int rccUiMenuConfigureWidget(rcc_ui_menu_context ctx) {
if (ctx->widget) menu = ctx->widget;
else {
menu = gtk_option_menu_new();
- gtk_widget_show(menu);
ctx->widget = menu;
}
gtk_option_menu_remove_menu(GTK_OPTION_MENU(menu));
@@ -128,7 +126,6 @@ int rccUiMenuConfigureWidget(rcc_ui_menu_context ctx) {
if (!charsets) return -1;
list = gtk_menu_new();
- gtk_widget_show(list);
for (i=0;charsets[i];i++) {
item = gtk_menu_item_new_with_label(rccUiGetCharsetName(uictx,charsets[i]));
gtk_widget_show(item);
@@ -138,7 +135,6 @@ int rccUiMenuConfigureWidget(rcc_ui_menu_context ctx) {
if (ctx->widget) menu = ctx->widget;
else {
menu = gtk_option_menu_new();
- gtk_widget_show(menu);
ctx->widget = menu;
}
@@ -157,7 +153,6 @@ int rccUiMenuConfigureWidget(rcc_ui_menu_context ctx) {
if (!engines) return -1;
list = gtk_menu_new();
- gtk_widget_show(list);
for (i=0;engines[i];i++) {
item = gtk_menu_item_new_with_label(rccUiGetEngineName(uictx,engines[i]->title));
gtk_widget_show(item);
@@ -167,7 +162,6 @@ int rccUiMenuConfigureWidget(rcc_ui_menu_context ctx) {
if (ctx->widget) menu = ctx->widget;
else {
menu = gtk_option_menu_new();
- gtk_widget_show(menu);
ctx->widget = menu;
}
@@ -183,7 +177,6 @@ int rccUiMenuConfigureWidget(rcc_ui_menu_context ctx) {
case RCC_OPTION_RANGE_TYPE_BOOLEAN:
if (!ctx->widget) {
item = gtk_check_button_new_with_label(rccUiGetOptionName(uictx, rccUiMenuGetOption(ctx)));
- gtk_widget_show(item);
ctx->widget = item;
}
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(ctx->widget), rccGetOption(rccctx, rccUiMenuGetOption(ctx)));
@@ -196,7 +189,6 @@ int rccUiMenuConfigureWidget(rcc_ui_menu_context ctx) {
if (!optnames) return -1;
list = gtk_menu_new();
- gtk_widget_show(list);
for (i=0;optnames[i];i++) {
item = gtk_menu_item_new_with_label(optnames[i]);
gtk_widget_show(item);
@@ -204,7 +196,6 @@ int rccUiMenuConfigureWidget(rcc_ui_menu_context ctx) {
}
menu = gtk_option_menu_new();
- gtk_widget_show(menu);
ctx->widget = menu;
gtk_option_menu_remove_menu(GTK_OPTION_MENU(menu));
@@ -227,7 +218,6 @@ 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, BOX_SPACING);
- gtk_widget_show(hbox);
gtk_container_border_width(GTK_CONTAINER(hbox), BOX_BORDER);
if ((ctx->type != RCC_UI_MENU_OPTION)||(rccUiMenuGetRangeType(ctx) != RCC_OPTION_RANGE_TYPE_BOOLEAN)) {
label = gtk_label_new(title);
@@ -235,6 +225,7 @@ rcc_ui_box rccUiBoxCreate(rcc_ui_menu_context ctx, const char *title) {
gtk_widget_set_usize(label, TITLE_WIDTH, TITLE_HEIGHT);
gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
}
+ gtk_widget_show((GtkWidget*)ctx->widget);
gtk_box_pack_start(GTK_BOX(hbox), (GtkWidget*)ctx->widget, TRUE, TRUE, 0);
return (rcc_ui_box)hbox;
}
@@ -245,13 +236,12 @@ rcc_ui_frame rccUiFrameCreate(rcc_ui_frame_context ctx, const char *title) {
if (!ctx) return NULL;
frame = gtk_frame_new(title?title:"");
- gtk_widget_show(frame);
gtk_container_border_width(GTK_CONTAINER(frame), FRAME_BORDER);
box = gtk_vbox_new(FALSE, FRAME_SPACING);
gtk_widget_show(box);
gtk_container_add(GTK_CONTAINER(frame), box);
-
+
return (rcc_ui_frame)frame;
}
@@ -265,6 +255,7 @@ int rccUiFrameAdd(rcc_ui_frame_context ctx, rcc_ui_box box) {
if ((!ctx)||(!box)) return -1;
vbox = gtk_container_children(GTK_CONTAINER(ctx->frame))->data;
+ gtk_widget_show(GTK_WIDGET(box));
gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(box), FALSE, FALSE, 0);
return 0;
}
@@ -272,12 +263,12 @@ int rccUiFrameAdd(rcc_ui_frame_context ctx, rcc_ui_box box) {
rcc_ui_page rccUiPageCreate(rcc_ui_context ctx, const char *title) {
GtkWidget *vbox;
vbox = gtk_vbox_new(FALSE, PAGE_SPACING);
- gtk_widget_show(vbox);
return (rcc_ui_page)vbox;
}
int rccUiPageAdd(rcc_ui_page page, rcc_ui_frame frame) {
if ((!page)||(!frame)) return -1;
+ gtk_widget_show(frame);
gtk_box_pack_start(GTK_BOX(page), GTK_WIDGET(frame), FALSE, FALSE, 0);
return 0;
}