From: <des...@us...> - 2003-12-26 05:29:39
|
Update of /cvsroot/beepmp/bmp/beep In directory sc8-pr-cvs1:/tmp/cvs-serv25857 Modified Files: dirbrowser.h effect.c effect.h playlist_list.c util.c util.h Log Message: - cleanups Index: dirbrowser.h =================================================================== RCS file: /cvsroot/beepmp/bmp/beep/dirbrowser.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** dirbrowser.h 24 Dec 2003 14:03:14 -0000 1.2 --- dirbrowser.h 26 Dec 2003 05:29:35 -0000 1.3 *************** *** 6,9 **** --- 6,10 ---- GtkWidget *beep_create_dir_browser(gchar * current_path); + GtkWidget *bmp_db_create(gchar * current_path); #endif Index: effect.c =================================================================== RCS file: /cvsroot/beepmp/bmp/beep/effect.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** effect.c 24 Dec 2003 14:03:14 -0000 1.3 --- effect.c 26 Dec 2003 05:29:35 -0000 1.4 *************** *** 16,25 **** * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ ! #include "beep.h" struct EffectPluginData *ep_data; ! static int effect_do_mod_samples(gpointer * data, gint length, AFormat fmt, ! gint srate, gint nch) { GList *l = ep_data->enabled_list; --- 16,30 ---- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ ! ! #include "effect.h" ! ! #include <glib.h> ! #include <string.h> ! #include "plugin.h" struct EffectPluginData *ep_data; ! static gint effect_do_mod_samples(gpointer * data, gint length, ! AFormat fmt, gint srate, gint nch) { GList *l = ep_data->enabled_list; *************** *** 73,77 **** } ! int effects_enabled(void) { return TRUE; --- 78,82 ---- } ! gint effects_enabled(void) { return TRUE; Index: effect.h =================================================================== RCS file: /cvsroot/beepmp/bmp/beep/effect.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** effect.h 24 Dec 2003 14:03:14 -0000 1.3 --- effect.h 26 Dec 2003 05:29:35 -0000 1.4 *************** *** 2,5 **** --- 2,7 ---- #define EFFECT_H + #include <glib.h> + struct EffectPluginData { GList *effect_list; *************** *** 11,19 **** GList *get_effect_list(void); ! void effect_about(int i); ! void effect_configure(int i); GList *get_effect_enabled_list(void); ! void enable_effect_plugin(int i, gboolean enable); ! gboolean effect_enabled(int i); gchar *effect_stringify_enabled_list(void); void effect_enable_from_stringified_list(const gchar * list); --- 13,21 ---- GList *get_effect_list(void); ! void effect_about(gint i); ! void effect_configure(gint i); GList *get_effect_enabled_list(void); ! void enable_effect_plugin(gint i, gboolean enable); ! gboolean effect_enabled(gint i); gchar *effect_stringify_enabled_list(void); void effect_enable_from_stringified_list(const gchar * list); Index: playlist_list.c =================================================================== RCS file: /cvsroot/beepmp/bmp/beep/playlist_list.c,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** playlist_list.c 26 Dec 2003 03:40:44 -0000 1.14 --- playlist_list.c 26 Dec 2003 05:29:35 -0000 1.15 *************** *** 424,432 **** gdk_gc_set_foreground(gc, get_skin_color(SKIN_PLEDIT_NORMAL)); ! if (g_utf8_validate(entry->title, -1, NULL)) ! title = g_strdup(entry->title); ! else title = g_path_get_basename(entry->filename); - convert_title_text(title); --- 424,432 ---- gdk_gc_set_foreground(gc, get_skin_color(SKIN_PLEDIT_NORMAL)); ! /* FIXME: this can be done more efficiently by working on the ! * playlist instead */ ! if (! ! (title = g_locale_to_utf8(entry->title, -1, NULL, NULL, NULL))) title = g_path_get_basename(entry->filename); convert_title_text(title); *************** *** 437,446 **** if (pos != -1) ! g_snprintf(tail, 100, "|%d|%s", pos + 1, entry->length != -1 ? " " : ""); if (entry->length != -1) ! g_snprintf(length, 40, "%d:%-2.2d", entry->length / 60000, ! (entry->length / 1000) % 60); if (pos != -1 || entry->length != -1) { --- 437,446 ---- if (pos != -1) ! g_snprintf(tail, sizeof(tail), "|%d|%s", pos + 1, entry->length != -1 ? " " : ""); if (entry->length != -1) ! g_snprintf(length, sizeof(length), "%d:%-2.2d", ! entry->length / 60000, (entry->length / 1000) % 60); if (pos != -1 || entry->length != -1) { Index: util.c =================================================================== RCS file: /cvsroot/beepmp/bmp/beep/util.c,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** util.c 26 Dec 2003 03:33:06 -0000 1.11 --- util.c 26 Dec 2003 05:29:35 -0000 1.12 *************** *** 18,21 **** --- 18,22 ---- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + #include "beep_mini.xpm" #include "beep.h" *************** *** 26,29 **** --- 27,31 ---- #include <sys/ipc.h> #include <ctype.h> + #ifdef HAVE_FTS_H #include <fts.h> *************** *** 41,50 **** */ ! char *escape_shell_chars(const char *string) { ! const char *special = "$`\"\\"; /* Characters to escape */ ! const char *in = string; ! char *out, *escaped; ! int num = 0; while (*in != '\0') --- 43,52 ---- */ ! gchar *escape_shell_chars(const gchar * string) { ! const gchar *special = "$`\"\\"; /* Characters to escape */ ! const gchar *in = string; ! gchar *out, *escaped; ! gint num = 0; while (*in != '\0') *************** *** 85,114 **** gchar *find_file_recursively(const gchar * dirname, const gchar * file) { ! GDir *dir2; ! GError *error = NULL; gchar *result, *found = NULL, *retval = NULL; ! const gchar *tmp; ! dir2 = g_dir_open(dirname, 0, &error); ! ! if (error) { ! g_critical("error!!"); ! return retval; } ! if (!dir2) ! return retval; ! while ((tmp = g_dir_read_name(dir2)) != NULL) { /* We need this in order to find out if file is directory */ ! found = g_build_filename(dirname, tmp, NULL); if (g_file_test(found, G_FILE_TEST_IS_REGULAR)) { /* Normal file -- maybe just what we are looking for? */ ! if (!strcasecmp(tmp, file)) { if (strlen(found) > FILENAME_MAX) { /* No good! File + path too long */ - g_dir_close(dir2); break; } else { retval = found; - found = NULL; break; } --- 87,110 ---- gchar *find_file_recursively(const gchar * dirname, const gchar * file) { ! GDir *dir; gchar *result, *found = NULL, *retval = NULL; + const gchar *direntry; ! if (!(dir = g_dir_open(dirname, 0, NULL))) { ! g_critical("failed to open directory %s", dirname); ! return NULL; } ! ! while ((direntry = g_dir_read_name(dir))) { /* We need this in order to find out if file is directory */ ! found = g_build_filename(dirname, direntry, NULL); if (g_file_test(found, G_FILE_TEST_IS_REGULAR)) { /* Normal file -- maybe just what we are looking for? */ ! if (!strcasecmp(direntry, file)) { if (strlen(found) > FILENAME_MAX) { /* No good! File + path too long */ break; } else { retval = found; break; } *************** *** 116,137 **** } else if (g_file_test(found, G_FILE_TEST_IS_DIR)) { result = find_file_recursively(found, file); ! if (result != NULL) { retval = result; break; } } g_free(found); - found = NULL; } - if (found) - g_free(found); ! g_dir_close(dir2); return retval; } ! typedef enum { ARCHIVE_DIR = 0, ARCHIVE_TAR = ! 1, ARCHIVE_TGZ, ARCHIVE_ZIP, ARCHIVE_TBZ2 } ArchiveType; --- 112,135 ---- } else if (g_file_test(found, G_FILE_TEST_IS_DIR)) { result = find_file_recursively(found, file); ! if (result) { retval = result; + g_free(found); break; } } g_free(found); } ! g_dir_close(dir); return retval; } ! typedef enum { ! ARCHIVE_DIR = 0, ! ARCHIVE_TAR = 1, ! ARCHIVE_TGZ, ! ARCHIVE_ZIP, ! ARCHIVE_TBZ2 } ArchiveType; *************** *** 278,285 **** ! void del_directory(const char *dirname) { #ifdef HAVE_FTS_H ! char *const argv[2] = { (char *) dirname, NULL }; FTS *fts; FTSENT *p; --- 276,283 ---- ! void del_directory(const gchar * dirname) { #ifdef HAVE_FTS_H ! gchar *const argv[2] = { (gchar *) dirname, NULL }; FTS *fts; FTSENT *p; *************** *** 329,335 **** register guint x, y; ! /* ! * This needs to be optimized ! */ dblimg = --- 327,331 ---- register guint x, y; ! /* FIXME: This needs to be optimized */ dblimg = *************** *** 430,460 **** } ! char *read_ini_string(const char *filename, const char *section, ! const char *key) { ! FILE *file; ! char *buffer, *ret_buffer = NULL; ! int found_section = 0, off = 0, len = 0; ! struct stat statbuf; if (!filename) return NULL; ! if ((file = fopen(filename, "r")) == NULL) ! return NULL; ! ! if (stat(filename, &statbuf) < 0) { ! fclose(file); return NULL; - } ! buffer = g_malloc(statbuf.st_size); ! fread(buffer, 1, statbuf.st_size, file); ! while (!ret_buffer && off < statbuf.st_size) { ! while (off < statbuf.st_size && (buffer[off] == '\r' || buffer[off] == '\n' || buffer[off] == ' ' || buffer[off] == '\t')) off++; ! if (off >= statbuf.st_size) break; if (buffer[off] == '[') { --- 426,448 ---- } ! gchar *read_ini_string(const gchar * filename, const gchar * section, ! const gchar * key) { ! gchar *buffer, *ret_buffer = NULL; ! gint found_section = 0, off = 0, len = 0; ! gsize filesize; if (!filename) return NULL; ! if (!g_file_get_contents(filename, &buffer, &filesize, NULL)) return NULL; ! while (!ret_buffer && off < filesize) { ! while (off < filesize && (buffer[off] == '\r' || buffer[off] == '\n' || buffer[off] == ' ' || buffer[off] == '\t')) off++; ! if (off >= filesize) break; if (buffer[off] == '[') { *************** *** 462,466 **** off++; found_section = 0; ! if (off + slen + 1 < statbuf.st_size && !strncasecmp(section, &buffer[off], slen)) { off += slen; --- 450,454 ---- off++; found_section = 0; ! if (off + slen + 1 < filesize && !strncasecmp(section, &buffer[off], slen)) { off += slen; *************** *** 470,490 **** } } ! } else if (found_section && off + strlen(key) < statbuf.st_size && !strncasecmp(key, &buffer[off], strlen(key))) { off += strlen(key); ! while (off < statbuf.st_size && (buffer[off] == ' ' || buffer[off] == '\t')) off++; ! if (off >= statbuf.st_size) break; if (buffer[off] == '=') { off++; ! while (off < statbuf.st_size && (buffer[off] == ' ' || buffer[off] == '\t')) off++; ! if (off >= statbuf.st_size) break; len = 0; ! while (off + len < statbuf.st_size && buffer[off + len] != '\r' && buffer[off + len] != '\n' && --- 458,478 ---- } } ! } else if (found_section && off + strlen(key) < filesize && !strncasecmp(key, &buffer[off], strlen(key))) { off += strlen(key); ! while (off < filesize && (buffer[off] == ' ' || buffer[off] == '\t')) off++; ! if (off >= filesize) break; if (buffer[off] == '=') { off++; ! while (off < filesize && (buffer[off] == ' ' || buffer[off] == '\t')) off++; ! if (off >= filesize) break; len = 0; ! while (off + len < filesize && buffer[off + len] != '\r' && buffer[off + len] != '\n' && *************** *** 495,499 **** } } ! while (off < statbuf.st_size && buffer[off] != '\r' && buffer[off] != '\n') off++; --- 483,487 ---- } } ! while (off < filesize && buffer[off] != '\r' && buffer[off] != '\n') off++; *************** *** 501,505 **** g_free(buffer); - fclose(file); return ret_buffer; } --- 489,492 ---- *************** *** 660,664 **** GList *node; ! text = (char *) gtk_entry_get_text(GTK_ENTRY(entry)); if (!g_list_find_custom(cfg.url_history, text, util_find_compare_func)) { cfg.url_history = g_list_prepend(cfg.url_history, g_strdup(text)); --- 647,651 ---- GList *node; ! text = (gchar *) gtk_entry_get_text(GTK_ENTRY(entry)); if (!g_list_find_custom(cfg.url_history, text, util_find_compare_func)) { cfg.url_history = g_list_prepend(cfg.url_history, g_strdup(text)); *************** *** 749,753 **** gtk_widget_realize(win); ! addurl_set_icon(win, "bmp: Add Url..."); // somehow gcc thinks this is a function declaration return win; } --- 736,740 ---- gtk_widget_realize(win); ! addurl_set_icon(win, "bmp: Add Url..."); return win; } *************** *** 757,766 **** GList *list; GList *node; ! char *filename = (char *) gtk_file_selection_get_filename(GTK_FILE_SELECTION(filesel)); GtkListStore *store; GtkTreeIter iter; ! if ((list = input_scan_dir(filename)) != NULL) { /* * We enter a directory that has been "hijacked" by an --- 744,753 ---- GList *list; GList *node; ! gchar *filename = (gchar *) gtk_file_selection_get_filename(GTK_FILE_SELECTION(filesel)); GtkListStore *store; GtkTreeIter iter; ! if ((list = input_scan_dir(filename))) { /* * We enter a directory that has been "hijacked" by an *************** *** 796,799 **** --- 783,787 ---- } */ + static void filebrowser_entry_changed(GtkEditable * entry, gpointer data) { *************** *** 802,806 **** } ! /* static void filebrowser_dir_select(GtkCList *clist, int row, int col, GdkEventButton *event, gpointer data) { if (event->type == GDK_2BUTTON_PRESS) --- 790,795 ---- } ! /* ! static void filebrowser_dir_select(GtkCList *clist, int row, int col, GdkEventButton *event, gpointer data) { if (event->type == GDK_2BUTTON_PRESS) *************** *** 808,822 **** } */ gboolean util_filebrowser_is_dir(GtkFileSelection * filesel) { ! char *text; ! struct stat buf; gboolean retv = FALSE; text = g_strdup(gtk_file_selection_get_filename(filesel)); ! if (stat(text, &buf) == 0 && S_ISDIR(buf.st_mode)) { /* Selected directory */ ! int len = strlen(text); if (len > 3 && !strcmp(text + len - 4, "/../")) { if (len == 4) --- 797,811 ---- } */ + gboolean util_filebrowser_is_dir(GtkFileSelection * filesel) { ! gchar *text; gboolean retv = FALSE; text = g_strdup(gtk_file_selection_get_filename(filesel)); ! if (g_file_test(text, G_FILE_TEST_IS_DIR)) { /* Selected directory */ ! gint len = strlen(text); if (len > 3 && !strcmp(text + len - 4, "/../")) { if (len == 4) *************** *** 824,828 **** *(text + len - 3) = '\0'; else { ! char *ptr; *(text + len - 4) = '\0'; ptr = strrchr(text, '/'); --- 813,817 ---- *(text + len - 3) = '\0'; else { ! gchar *ptr; *(text + len - 4) = '\0'; ptr = strrchr(text, '/'); *************** *** 841,846 **** GtkFileSelection * filesel) { ! int ctr = 0; ! char *ptr; if (GTK_IS_WIDGET(mainwin_jtf)) --- 830,835 ---- GtkFileSelection * filesel) { ! gint ctr = 0; ! gchar *ptr; if (GTK_IS_WIDGET(mainwin_jtf)) *************** *** 858,862 **** &ptr); ! /* This will give an extra slash if the current dir is the root. */ cfg.filesel_path = g_strconcat(ptr, "/", NULL); } --- 847,852 ---- &ptr); ! /* This will give an extra slash if the current dir is the ! * root. */ cfg.filesel_path = g_strconcat(ptr, "/", NULL); } *************** *** 922,926 **** GtkWidget *button_add_selected, *button_add_all, *button_close, *button_add; ! char *title; if (dialog != NULL) { --- 912,916 ---- GtkWidget *button_add_selected, *button_add_all, *button_close, *button_add; ! gchar *title; if (dialog != NULL) { *************** *** 936,941 **** dialog = gtk_file_selection_new(title); ! // I don't think anyone should be even able to delete files from his/her media player, yes i'm making a decision for a plurality here ! // but it's just safer despite the confirmation requests gtk_file_selection_hide_fileop_buttons(GTK_FILE_SELECTION(dialog)); gtk_window_set_position(GTK_WINDOW(dialog), GTK_WIN_POS_CENTER); --- 926,932 ---- dialog = gtk_file_selection_new(title); ! /* I don't think anyone should be even able to delete files from ! * his/her media player, yes i'm making a decision for a plurality ! * here but it's just safer despite the confirmation requests */ gtk_file_selection_hide_fileop_buttons(GTK_FILE_SELECTION(dialog)); gtk_window_set_position(GTK_WINDOW(dialog), GTK_WIN_POS_CENTER); *************** *** 948,959 **** cfg.filesel_path); ! // if we destroy the OK button we'll never receive a GTK_RESPONSE_OK e.g. trough dbl click on a file gtk_widget_hide(GTK_FILE_SELECTION(dialog)->ok_button); gtk_widget_destroy(GTK_FILE_SELECTION(dialog)->cancel_button); ! /* ! * The mnemonics are quite unorthodox, but that should guarantee they're unique in any locale ! * plus kinda easy to use ! */ button_add_selected = gtk_dialog_add_button(GTK_DIALOG(dialog), "Add selected", --- 939,949 ---- cfg.filesel_path); ! /* if we destroy the OK button we'll never receive a ! * GTK_RESPONSE_OK e.g. trough dbl click on a file */ gtk_widget_hide(GTK_FILE_SELECTION(dialog)->ok_button); gtk_widget_destroy(GTK_FILE_SELECTION(dialog)->cancel_button); ! /* The mnemonics are quite unorthodox, but that should guarantee ! * they're unique in any locale plus kinda easy to use */ button_add_selected = gtk_dialog_add_button(GTK_DIALOG(dialog), "Add selected", *************** *** 1018,1028 **** } ! GdkFont *util_font_load(char *name) { GdkFont *font; - PangoFontDescription *desc; - desc = pango_font_description_from_string(name); font = gdk_font_from_description(desc); --- 1008,1017 ---- } ! GdkFont *util_font_load(const gchar * name) { GdkFont *font; PangoFontDescription *desc; + desc = pango_font_description_from_string(name); font = gdk_font_from_description(desc); *************** *** 1031,1037 **** #ifdef ENABLE_NLS ! char *util_menu_translate(const char *path, void *func_data) { ! char *translation = gettext(path); if (!translation || *translation != '/') { --- 1020,1026 ---- #ifdef ENABLE_NLS ! gchar *util_menu_translate(const gchar * path, gpointer func_data) { ! gchar *translation = gettext(path); if (!translation || *translation != '/') { *************** *** 1061,1078 **** } ! // text_get_extents() taken from The GIMP (C) Spencer Kimball, Peter Mattis et al ! gboolean ! text_get_extents(const gchar * fontname, ! const gchar * text, ! gint * width, ! gint * height, gint * ascent, gint * descent) { PangoFontDescription *font_desc; PangoLayout *layout; PangoRectangle rect; - /* PangoContext *context; - PangoLayout *layout; - PangoRectangle rect; - */ g_return_val_if_fail(fontname != NULL, FALSE); --- 1050,1063 ---- } ! /* text_get_extents() taken from The GIMP (C) Spencer Kimball, Peter ! * Mattis et al */ ! gboolean text_get_extents(const gchar * fontname, ! const gchar * text, ! gint * width, gint * height, ! gint * ascent, gint * descent) { PangoFontDescription *font_desc; PangoLayout *layout; PangoRectangle rect; g_return_val_if_fail(fontname != NULL, FALSE); *************** *** 1080,1098 **** /* FIXME: resolution */ - - // context = pango_ft2_get_context (72.0, 72.0); - - - // layout = pango_layout_new(pango_context_new()); - layout = gtk_widget_create_pango_layout(GTK_WIDGET(mainwin), text); - // g_object_unref (context); - font_desc = pango_font_description_from_string(fontname); pango_layout_set_font_description(layout, font_desc); pango_font_description_free(font_desc); - // pango_layout_set_text (layout, text, -1); - pango_layout_get_pixel_extents(layout, NULL, &rect); --- 1065,1073 ---- *************** *** 1125,1129 **** void util_dump_menu_rc(void) { ! // char *filename = g_strconcat(g_get_home_dir(), "/.beep/menurc", NULL); // gtk_item_factory_dump_rc(filename, NULL, FALSE); // g_free(filename); --- 1100,1104 ---- void util_dump_menu_rc(void) { ! // char *filename = g_build_filename(g_get_home_dir(), ".bmp/menurc", NULL); // gtk_item_factory_dump_rc(filename, NULL, FALSE); // g_free(filename); *************** *** 1132,1136 **** void util_read_menu_rc(void) { ! // char *filename = g_strconcat(g_get_home_dir(), "/.beep/menurc", NULL); // gtk_item_factory_parse_rc(filename); // g_free(filename); --- 1107,1111 ---- void util_read_menu_rc(void) { ! // char *filename = g_strconcat(g_get_home_dir(), ".bmp/menurc", NULL); // gtk_item_factory_parse_rc(filename); // g_free(filename); Index: util.h =================================================================== RCS file: /cvsroot/beepmp/bmp/beep/util.h,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** util.h 26 Dec 2003 03:33:06 -0000 1.7 --- util.h 26 Dec 2003 05:29:35 -0000 1.8 *************** *** 48,52 **** gboolean util_run_filebrowser(gboolean clear_pl_on_ok); gboolean util_filebrowser_is_dir(GtkFileSelection * filesel); ! GdkFont *util_font_load(gchar * name); void util_set_cursor(GtkWidget * window); void util_dump_menu_rc(void); --- 48,52 ---- gboolean util_run_filebrowser(gboolean clear_pl_on_ok); gboolean util_filebrowser_is_dir(GtkFileSelection * filesel); ! GdkFont *util_font_load(const gchar * name); void util_set_cursor(GtkWidget * window); void util_dump_menu_rc(void); |