[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

gnomequran: patch to make the appli compile and run



Assalamo alaykom,

I give here a patch to resolve gnomequran bugs due to inconsistency between libquran and the gnome application (missing functions, wrong arguments, missing data structure elements, ...). I tried to make the changes minimal in order not to alter the application structure, although optimization is needed to have a better application. Feedback is welcome.

Nabil Ben Khalifa

Index: configure
===================================================================
RCS file: /home/arabeyes/cvs/projects/quran/gnomequran/configure,v
retrieving revision 1.3
diff -b -u -2 -r1.3 configure
--- configure 25 Dec 2002 13:28:02 -0000 1.3
+++ configure 17 Jul 2007 15:40:49 -0000
@@ -1502,7 +1502,7 @@
fi

-ac_safe=`echo "speex.h" | sed 'y%./+-%__p_%'`
-echo $ac_n "checking for speex.h""... $ac_c" 1>&6
-echo "configure:1507: checking for speex.h" >&5
+ac_safe=`echo "speex/speex.h" | sed 'y%./+-%__p_%'`
+echo $ac_n "checking for speex/speex.h""... $ac_c" 1>&6
+echo "configure:1507: checking for speex/speex.h" >&5
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set";
then
echo $ac_n "(cached) $ac_c" 1>&6
@@ -1511,5 +1511,5 @@
#line 1512 "configure"
#include "confdefs.h"
-#include <speex.h>
+#include <speex/speex.h>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
Index: configure.in
===================================================================
RCS file: /home/arabeyes/cvs/projects/quran/gnomequran/configure.in,v
retrieving revision 1.3
diff -b -u -2 -r1.3 configure.in
--- configure.in 25 Dec 2002 13:28:02 -0000 1.3
+++ configure.in 17 Jul 2007 15:40:49 -0000
@@ -15,5 +15,5 @@
AC_CHECK_HEADER(quran.h,,AC_MSG_ERROR("libquran not found"))
AC_CHECK_HEADER(expat.h,,AC_MSG_ERROR("libexpat not found"))
-AC_CHECK_HEADER(speex.h,,AC_MSG_ERROR("Speex not found"))
+AC_CHECK_HEADER(speex/speex.h,,AC_MSG_ERROR("Speex not found"))
XIPH_PATH_VORBIS(,AC_MSG_ERROR("Vorbis not found"))
XIPH_PATH_AO(,AC_MSG_ERROR("libao not found"))
Index: src/main.c
===================================================================
RCS file: /home/arabeyes/cvs/projects/quran/gnomequran/src/main.c,v
retrieving revision 1.4
diff -b -u -2 -r1.4 main.c
--- src/main.c 25 Dec 2002 13:28:05 -0000 1.4
+++ src/main.c 17 Jul 2007 15:40:50 -0000
@@ -20,4 +20,6 @@

int i;
+ int j;
+
#ifdef ENABLE_NLS
bindtextdomain (PACKAGE, PACKAGE_LOCALE_DIR);
@@ -25,4 +27,5 @@
#endif

+ ctx.initialized = 0;
has_audio = quran_opened = 0;
active_sura = active_aya = 1;
@@ -34,10 +37,10 @@
m = g_mutex_new();

- i = quran_init();
- libquran = quran_get_libquran();
+ i = quran_init(&ctx);
if (i!=0) {
fprintf(stderr,"libquran initialization failed: %i\n",i);
return 0;
}
+
gconf = gconf_client_get_default();
gconf_client_add_dir(gconf,
GNOMEQURAN_GCONF_PATH,GCONF_CLIENT_PRELOAD_NONE,NULL);
@@ -46,15 +49,24 @@
gnome_init ("gnomequran", VERSION, argc, argv);

- if (libquran.num_all_audio_packages>0) {
+ if (ctx.libquran.num_langs > 0)
+ {
+ for (i=0;i<ctx.libquran.num_langs;i++)
+ {
+ if (ctx.libquran.avail_langs[i].num_audio_packages > 0)
+ {
ao_initialize();
- if (active_driver) {
+ if (active_driver)
+ {
audio_init(active_driver);
if (audio_driver>=0) has_audio = 1;
}
+ break;
+ }
+ }
}

- q_all = malloc(libquran.num_langs*sizeof(quran));
- picked_package = malloc(libquran.num_langs*sizeof(char*));
- for (i=0;i<libquran.num_langs;i++) {
+ q_all = malloc(ctx.libquran.num_langs*sizeof(quran));
+ picked_package = malloc(ctx.libquran.num_langs*sizeof(char*));
+ for (i=0;i<ctx.libquran.num_langs;i++) {
picked_package[i] = NULL;
}
Index: src/ngajiquran.c
===================================================================
RCS file:
/home/arabeyes/cvs/projects/quran/gnomequran/src/ngajiquran.c,v
retrieving revision 1.4
diff -b -u -2 -r1.4 ngajiquran.c
--- src/ngajiquran.c 25 Dec 2002 13:28:05 -0000 1.4
+++ src/ngajiquran.c 17 Jul 2007 15:40:51 -0000
@@ -10,4 +10,5 @@
#include "callbacks.h"

+void open_audio(gint quran_index);
void close_audio();

@@ -48,5 +49,6 @@
}

-static void t_play_audio() {
+static gpointer t_play_audio(gpointer thr_data)
+{
quran_audio_play(qa, on_audio_played);
close_audio();
@@ -62,5 +64,5 @@

audio_playing = 1;
- t = g_thread_create((GThreadFunc*)t_play_audio, NULL, FALSE, NULL);
+ t = g_thread_create(t_play_audio, NULL, FALSE, NULL);
}

@@ -80,5 +82,5 @@
if (audio_device) ao_close(audio_device);
audio_device = NULL;
- quran_audio_close(qa);
+ quran_audio_close(qa, &ctx);
qa = NULL;
audible = 1;
@@ -116,5 +118,5 @@
if (qa==NULL) {
if (picked_package[quran_index]) {
-
qa=quran_audio_open(q_all[quran_index]->lang,picked_package[quran_index],active_sura,active_aya);
+
qa=quran_audio_open(q_all[quran_index]->lang,picked_package[quran_index],active_sura,active_aya, &ctx);
audio_device = NULL;
audio_playing = 0;
@@ -129,7 +131,10 @@
int i,j;

- for (i=0;i<libquran.num_audio_langs;i++) {
- if (strcmp(lang,libquran.avail_audio_langs[i])==0) {
- if (libquran.num_audio_packages[i]>0) return 1;
+ for (i=0;i<ctx.libquran.num_langs;i++) {
+ if (strcmp(lang,ctx.libquran.avail_langs[i].name)==0) {
+ if (ctx.libquran.avail_langs[i].num_audio_packages>0)
+ {
+ return 1;
+ }
}
}
@@ -140,8 +145,9 @@
int i,j,add;
GList *package_items = NULL;
- for (i=0;i<libquran.num_langs;i++) {
- if (strcmp(lang,libquran.avail_langs[i])==0) {
- for (j=0;j<libquran.num_audio_packages[i];j++) {
- package_items =
g_list_append(package_items,(gpointer)libquran.audio_packages[i][j]);
+
+ for (i=0;i<ctx.libquran.num_langs;i++) {
+ if (strcmp(lang,ctx.libquran.avail_langs[i].name)==0) {
+ for (j=0;j<ctx.libquran.avail_langs[i].num_audio_packages;j++) {
+ package_items =
g_list_append(package_items,(gpointer)ctx.libquran.avail_langs[i].avail_audio_packages[j].filename);
}
}
@@ -154,8 +160,9 @@
int i,j,add;
GList *lang_items = NULL;
- for (i=0;i<libquran.num_langs;i++) {
+
+ for (i=0;i<ctx.libquran.num_langs;i++) {
add = 1;
for (j=0;j<quran_opened;j++) {
- if (strcmp(q_all[j]->lang,libquran.avail_langs[i])==0) {
+ if (strcmp(q_all[j]->lang,ctx.libquran.avail_langs[i].name)==0) {
add = 0;
break;
@@ -163,5 +170,5 @@
}
if (add)
- lang_items =
g_list_append(lang_items,(gpointer)libquran.avail_langs[i]);
+ lang_items =
g_list_append(lang_items,(gpointer)ctx.libquran.avail_langs[i].name);
}
return lang_items;
@@ -183,5 +190,4 @@
g_object_unref(gconf);
gtk_main_quit();
- fprintf(stderr,"exiting\n");
}

@@ -248,5 +254,4 @@

if
(check_audio(q_all[quran_opened]->lang)&&picked_package[quran_opened]) {
-
vbox2 = gtk_hbutton_box_new ();
gtk_hbutton_box_set_layout_default(GTK_BUTTONBOX_START);
@@ -274,7 +279,7 @@
btn_read_thru = gtk_check_button_new_with_label(_("Read Through"));
if (read_through)
- gtk_toggle_button_set_active(btn_read_thru, TRUE);
+ gtk_toggle_button_set_active((GtkToggleButton
*)btn_read_thru, TRUE);
else
- gtk_toggle_button_set_active(btn_read_thru, FALSE);
+ gtk_toggle_button_set_active((GtkToggleButton *)btn_read_thru,
FALSE);

gtk_widget_ref (btn_read_thru);
@@ -285,5 +290,5 @@
gtk_box_pack_start(GTK_BOX(vbox2), btn_read_thru, FALSE, FALSE, 0);

- reciter = gtk_label_new(g_strdup_printf("Reciter:
%s",quran_recitor_name(q_all[quran_opened]->lang,picked_package[quran_opened])));
+ reciter = gtk_label_new(g_strdup_printf("Reciter: %s",
ctx.libquran.avail_langs[quran_opened].avail_audio_packages[quran_opened].author));
gtk_widget_ref(reciter);
gtk_object_set_data_full (GTK_OBJECT (handlebox1), "reciter",
reciter,
@@ -325,5 +330,5 @@
if (aya_descr) {
quran_info = gtk_object_get_data(GTK_OBJECT(frm_main),"status_bar");
- gnome_appbar_set_status(quran_info,g_strdup_printf(_("Juz %d "),
aya_descr->juz_number));
+ gnome_appbar_set_status((GnomeAppBar
*)quran_info,g_strdup_printf(_("Juz %d "), aya_descr->juz_number));
free(aya_descr);
}
@@ -360,7 +365,7 @@
gtk_widget_modify_font (txt_aya, font_desc);
gtk_widget_modify_font (opt_sura, font_desc);
- if (g_ascii_strcasecmp(q_all[i],"ar")==0)
pango_font_description_free (font_desc);
+ if (g_ascii_strcasecmp(q_all[quran_opened]->lang,"ar")==0)
pango_font_description_free (font_desc);
}
- ayastr = quran_read_verse(q_all[i],sura, active_aya,0);
+ ayastr = quran_read_verse(q_all[i],sura, active_aya, &ctx);
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (txt_aya));
gtk_text_buffer_set_text (buffer, ayastr, -1);
@@ -370,6 +375,6 @@
quran_audio *qx;
GtkWidget *btn_play =
gtk_object_get_data(GTK_OBJECT(hbox),"btn_play");
- if ((qx=quran_audio_open(q_all[i]->lang, picked_package[i], sura,
aya))!=NULL) {
- quran_audio_close(qx);
+ if ((qx=quran_audio_open(ctx.libquran.avail_langs[i].code,
picked_package[i], sura, aya, &ctx))!=NULL) {
+ quran_audio_close(qx, &ctx);
gtk_widget_set_sensitive (btn_play, TRUE);
} else {
@@ -397,11 +402,12 @@
}

-void open_quran() {
-
- q_all[quran_opened] = quran_open(picked_lang);
+void open_quran()
+{
+ q_all[quran_opened] =
quran_open(ctx.libquran.avail_langs[quran_opened].code,
ctx.libquran.avail_langs[quran_opened].avail_texts[quran_opened].filename, &ctx);
+ free(q_all[quran_opened]->lang);
+ q_all[quran_opened]->lang =
strdup(ctx.libquran.avail_langs[quran_opened].name);
free(picked_lang);

prepare_quran_widgets();
-
quran_opened++;
display_verse(active_sura, active_aya);
@@ -422,5 +428,5 @@

gtk_widget_set_sensitive(gtk_object_get_data(GTK_OBJECT(frm_main),"btn_go"), FALSE);
}
- quran_close(q_all[quran_opened]);
+ quran_close(q_all[quran_opened], &ctx);
if (picked_package[quran_opened]) free(picked_package[quran_opened]);

Index: src/ngajiquran.h
===================================================================
RCS file:
/home/arabeyes/cvs/projects/quran/gnomequran/src/ngajiquran.h,v
retrieving revision 1.4
diff -b -u -2 -r1.4 ngajiquran.h
--- src/ngajiquran.h 25 Dec 2002 13:28:05 -0000 1.4
+++ src/ngajiquran.h 17 Jul 2007 15:40:51 -0000
@@ -32,5 +32,5 @@
ao_sample_format audio_format;
ao_device *audio_device;
-_libquran libquran;
+libquran_ctx ctx;
int audio_playing, last_audio_error, current_index_playing;
int read_through;



Ne gardez plus qu'une seule adresse mail ! Copiez vos mails vers Yahoo! Mail