Index: callbacks.c
===================================================================
--- callbacks.c (revision 141)
+++ callbacks.c (working copy)
@@ -104,8 +104,8 @@
if(pos == -1) return;
- type = g_list_nth_data(__images, 9 * pos + 4);
- path = g_list_nth_data(__images, 9 * pos + 7);
+ type = g_list_nth_data(__images, IMG_COUNT * pos + IMG_TYPE);
+ path = g_list_nth_data(__images, IMG_COUNT * pos + IMG_PATH);
speedcombo = GTK_COMBO_BOX(glade_xml_get_widget(__xml, "optSpeed"));
@@ -179,7 +179,7 @@
GString* data;
GtkLabel* label;
gchar* str;
- gint pos;
+ gint pos, speedpos;
pos = gtk_tree_view_get_single_pos(treeview);
@@ -197,23 +197,30 @@
gtk_label_clear(label);
return;
}
-
+
+ speedpos = gtk_combo_box_get_active(combo);
+
+ data = g_list_nth_data(__images, IMG_COUNT * pos + IMG_TYPE);
+ str = data->str;
+
if(__last_type && *__last_type == 'C')
+ {
gtk_clean_combobox(combo, __cd_speed);
- else if(__last_type && *__last_type == 'D')
+ if(*str != 'C')
+ speedpos = 0;
+ } else if(__last_type && *__last_type == 'D') {
gtk_clean_combobox(combo, __dvd_speed);
+ if(*str == 'C')
+ speedpos = 0;
+ }
- data = g_list_nth_data(__images, 8*pos + 4);
-
- str = data->str;
-
if(*str == 'C')
{
__last_type = "CD";
- gtk_fill_combobox(combo, __cd_speed, 0);
+ gtk_fill_combobox(combo, __cd_speed, speedpos);
} else {
__last_type = "DVD";
- gtk_fill_combobox(combo, __dvd_speed, 0);
+ gtk_fill_combobox(combo, __dvd_speed, speedpos);
}
label = GTK_LABEL(glade_xml_get_widget(__xml, "lblDescription"));
Index: db.c
===================================================================
--- db.c (revision 141)
+++ db.c (working copy)
@@ -148,32 +148,32 @@
result = user;
- result = g_list_append(result, g_string_new(argv[0])); /* id */
- name_utf8 = g_string_iso_to_utf8(argv[1]); /* name */
- g_list_append(result, g_string_new( name_utf8 ? name_utf8->str : argv[1] ));
+ result = g_list_append(result, g_string_new(argv[IMG_ID])); /* id */
+ name_utf8 = g_string_iso_to_utf8(argv[IMG_NAME]); /* name */
+ g_list_append(result, g_string_new( name_utf8 ? name_utf8->str : argv[IMG_NAME] ));
g_string_free(name_utf8, TRUE);
- name_utf8 = g_string_iso_to_utf8(argv[2]); /* desc */
- g_list_append(result, g_string_new( name_utf8 ? name_utf8->str : argv[2] ));
+ name_utf8 = g_string_iso_to_utf8(argv[IMG_DESC]); /* desc */
+ g_list_append(result, g_string_new( name_utf8 ? name_utf8->str : argv[IMG_DESC] ));
g_string_free(name_utf8, TRUE);
- name_utf8 = g_string_iso_to_utf8(argv[3]); /* longdesc */
- g_list_append(result, g_string_new( name_utf8 ? name_utf8->str : argv[3] ));
+ name_utf8 = g_string_iso_to_utf8(argv[IMG_LONGDESC]); /* longdesc */
+ g_list_append(result, g_string_new( name_utf8 ? name_utf8->str : argv[IMG_LONGDESC] ));
g_string_free(name_utf8, TRUE);
- result = g_list_append(result, g_string_new(argv[4])); /* type */
- result = g_list_append(result, g_string_new(argv[5])); /* year */
+ result = g_list_append(result, g_string_new(argv[IMG_TYPE])); /* type */
+ result = g_list_append(result, g_string_new(argv[IMG_YEAR])); /* year */
- name_utf8 = g_string_iso_to_utf8(argv[6]); /* author */
- g_list_append(result, g_string_new( name_utf8 ? name_utf8->str : argv[6] ));
+ name_utf8 = g_string_iso_to_utf8(argv[IMG_AUTHOR]); /* author */
+ g_list_append(result, g_string_new( name_utf8 ? name_utf8->str : argv[IMG_AUTHOR] ));
g_string_free(name_utf8, TRUE);
- name_utf8 = g_string_iso_to_utf8(argv[7]); /* path */
- g_list_append(result, g_string_new( name_utf8 ? name_utf8->str : argv[7] ));
+ name_utf8 = g_string_iso_to_utf8(argv[IMG_PATH]); /* path */
+ g_list_append(result, g_string_new( name_utf8 ? name_utf8->str : argv[IMG_PATH] ));
g_string_free(name_utf8, TRUE);
- name_utf8 = g_string_iso_to_utf8(argv[8]); /* language */
- g_list_append(result, g_string_new( name_utf8 ? name_utf8->str : argv[8] ));
+ name_utf8 = g_string_iso_to_utf8(argv[IMG_LANGUAGE]); /* language */
+ g_list_append(result, g_string_new( name_utf8 ? name_utf8->str : argv[IMG_LANGUAGE] ));
g_string_free(name_utf8, TRUE);
return 0;
@@ -187,6 +187,10 @@
int i, rc;
GString* data;
+ /* NOTE: Each time the next sprintf changes, rewrite db.h with the
+ * new constans. DO NOT HARDCODE!
+ * Check function __get_images_callback !!! The order of this function is important! */
+
sprintf(sql_command, "SELECT I.id,I.name,I.desc,I.longdesc,I.type,I.year,I.author,I.path,I.language FROM image I JOIN category C on I.cat = C.id WHERE C.name = '%s' ORDER BY I.name, I.desc;", category);
result = g_list_append(result, g_string_new(""));
Index: gtk_common.c
===================================================================
--- gtk_common.c (revision 141)
+++ gtk_common.c (working copy)
@@ -98,21 +98,16 @@
GtkTreePath* path = NULL;
static int firstrun = 1;
- /* id, name, desc, longdesc, type, year, author, path, language
- * 0 1 2 3 4 5 6 7 8
- * + + + + + +
- */
-
store = gtk_list_store_new(NUM_COLS, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING);
len = g_list_length(list) / 9;
for(i = 0; i < len; ++i)
{
- name = g_list_nth_data(list, i*9 + 1);
- type = g_list_nth_data(list, i*9 + 4);
- desc = g_list_nth_data(list, i*9 + 2);
- lang = g_list_nth_data(list, i*9 + 8);
+ name = g_list_nth_data(list, IMG_COUNT * i + IMG_NAME);
+ type = g_list_nth_data(list, IMG_COUNT * i + IMG_TYPE);
+ desc = g_list_nth_data(list, IMG_COUNT * i + IMG_DESC);
+ lang = g_list_nth_data(list, IMG_COUNT * i + IMG_LANGUAGE);
gtk_list_store_append (store, &iter);
gtk_list_store_set(store, &iter,
@@ -204,19 +199,14 @@
Jahr: %s\n\n\
Beschreibung: %s";
- /* id, name, desc, longdesc, type, year, author, path, language
- * 0 1 2 3 4 5 6 7 8
- * + + + + + +
- */
+ name = g_list_nth_data(list, IMG_COUNT * pos + IMG_NAME);
+ desc = g_list_nth_data(list, IMG_COUNT * pos + IMG_DESC);
+ longdesc = g_list_nth_data(list, IMG_COUNT * pos + IMG_LONGDESC);
+ type = g_list_nth_data(list, IMG_COUNT * pos + IMG_TYPE);
+ year = g_list_nth_data(list, IMG_COUNT * pos + IMG_YEAR);
+ author = g_list_nth_data(list, IMG_COUNT * pos + IMG_AUTHOR);
+ language = g_list_nth_data(list, IMG_COUNT * pos + IMG_LANGUAGE);
- name = g_list_nth_data(list, 9*pos + 1);
- desc = g_list_nth_data(list, 9*pos + 2);
- longdesc = g_list_nth_data(list, 9*pos + 3);
- type = g_list_nth_data(list, 9*pos + 4);
- year = g_list_nth_data(list, 9*pos + 5);
- author = g_list_nth_data(list, 9*pos + 6);
- language = g_list_nth_data(list, 9*pos + 8);
-
field = g_string_new("");
g_string_append_printf(field, text, name->str, desc->str, type->str, language->str, author->str, year->str, longdesc->str);
Index: db.h
===================================================================
--- db.h (revision 141)
+++ db.h (working copy)
@@ -23,4 +23,18 @@
GList* get_categories();
GList* get_images(const gchar* category);
+enum
+{
+ IMG_ID = 0,
+ IMG_NAME,
+ IMG_DESC,
+ IMG_LONGDESC,
+ IMG_TYPE,
+ IMG_YEAR,
+ IMG_AUTHOR,
+ IMG_PATH,
+ IMG_LANGUAGE,
+ IMG_COUNT
+};
+
#endif