Mercurial > hg > xmms-sid
comparison src/xmms-sid.c @ 208:8ebef120d67f
Use glib string functions more exclusively, moved fileinfo dialog
to separate module (like it was in 0.7-series)
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Wed, 15 Dec 2004 10:24:03 +0000 |
parents | fe684a2ccdc7 |
children | ebb6e23f6015 |
comparison
equal
deleted
inserted
replaced
207:7048944d3bca | 208:8ebef120d67f |
---|---|
28 #include <xmms/plugin.h> | 28 #include <xmms/plugin.h> |
29 #include <xmms/util.h> | 29 #include <xmms/util.h> |
30 | 30 |
31 #include <gdk/gdkkeysyms.h> | 31 #include <gdk/gdkkeysyms.h> |
32 #include <gtk/gtk.h> | 32 #include <gtk/gtk.h> |
33 | |
34 #include "xmms-sid.h" | |
35 #include "xs_support.h" | 33 #include "xs_support.h" |
36 #include "xs_config.h" | 34 #include "xs_config.h" |
37 #include "xs_length.h" | 35 #include "xs_length.h" |
38 #include "xs_stil.h" | 36 #include "xs_stil.h" |
39 #include "xs_interface.h" | 37 #include "xs_interface.h" |
95 | 93 |
96 | 94 |
97 /* | 95 /* |
98 * Global variables | 96 * Global variables |
99 */ | 97 */ |
100 static pthread_t xs_decode_thread; | |
101 static pthread_mutex_t xs_mutex = PTHREAD_MUTEX_INITIALIZER; | |
102 struct t_xs_cfg xs_cfg; | 98 struct t_xs_cfg xs_cfg; |
103 t_xs_status xs_status; | 99 t_xs_status xs_status; |
104 t_xs_player *xs_player = NULL; | 100 t_xs_player *xs_player = NULL; |
105 static GtkWidget *xs_fileinfowin = NULL, | 101 static pthread_t xs_decode_thread; |
106 *xs_subctrl = NULL; | 102 static pthread_mutex_t xs_mutex = PTHREAD_MUTEX_INITIALIZER; |
103 static GtkWidget *xs_subctrl = NULL; | |
107 static GtkObject *xs_subctrl_adj = NULL; | 104 static GtkObject *xs_subctrl_adj = NULL; |
108 static t_xs_tune *xs_fileinfotune = NULL; | 105 static t_xs_tune *xs_fileinfotune = NULL; |
109 static t_xs_stil_node *xs_fileinfostil = NULL; | 106 static t_xs_stil_node *xs_fileinfostil = NULL; |
110 | 107 |
111 | 108 |
244 { | 241 { |
245 pcExt++; | 242 pcExt++; |
246 switch (xs_cfg.playerEngine) { | 243 switch (xs_cfg.playerEngine) { |
247 case XS_ENG_SIDPLAY1: | 244 case XS_ENG_SIDPLAY1: |
248 case XS_ENG_SIDPLAY2: | 245 case XS_ENG_SIDPLAY2: |
249 if (!strcasecmp(pcExt, "psid")) return TRUE; | 246 if (!g_strcasecmp(pcExt, "psid")) return TRUE; |
250 if (!strcasecmp(pcExt, "sid")) return TRUE; | 247 if (!g_strcasecmp(pcExt, "sid")) return TRUE; |
251 if (!strcasecmp(pcExt, "dat")) return TRUE; | 248 if (!g_strcasecmp(pcExt, "dat")) return TRUE; |
252 if (!strcasecmp(pcExt, "inf")) return TRUE; | 249 if (!g_strcasecmp(pcExt, "inf")) return TRUE; |
253 if (!strcasecmp(pcExt, "info")) return TRUE; | 250 if (!g_strcasecmp(pcExt, "info")) return TRUE; |
254 break; | 251 break; |
255 } | 252 } |
256 } | 253 } |
257 | 254 |
258 return FALSE; | 255 return FALSE; |
845 } | 842 } |
846 | 843 |
847 g_free(pTune); | 844 g_free(pTune); |
848 } | 845 } |
849 | 846 |
850 | |
851 /* | |
852 * File-information window | |
853 */ | |
854 void xs_fileinfo_ok(void) | |
855 { | |
856 gtk_widget_destroy(xs_fileinfowin); | |
857 xs_fileinfowin = NULL; | |
858 } | |
859 | |
860 | |
861 void xs_fileinfo_subtune(GtkWidget *widget, void *data) | |
862 { | |
863 t_xs_stil_subnode *tmpNode; | |
864 GtkWidget *tmpItem, *tmpText; | |
865 gint tmpIndex; | |
866 gchar *subName, *subAuthor; | |
867 | |
868 /* Freeze text-widget and delete the old text */ | |
869 tmpText = LUW("fileinfo_sub_info"); | |
870 gtk_text_freeze(GTK_TEXT(tmpText)); | |
871 gtk_text_set_point(GTK_TEXT(tmpText), 0); | |
872 gtk_text_forward_delete(GTK_TEXT(tmpText), | |
873 gtk_text_get_length(GTK_TEXT(tmpText))); | |
874 | |
875 if (xs_fileinfostil) | |
876 { | |
877 /* Get subtune number */ | |
878 tmpItem = gtk_menu_get_active(GTK_MENU(data)); | |
879 tmpIndex = g_list_index(GTK_MENU_SHELL(data)->children, tmpItem); | |
880 | |
881 /* Get subtune information */ | |
882 tmpNode = &xs_fileinfostil->subTune[tmpIndex]; | |
883 subName = tmpNode->pName; | |
884 subAuthor = tmpNode->pAuthor; | |
885 | |
886 /* Put in the new text, if available */ | |
887 if (tmpNode->pInfo) | |
888 { | |
889 gtk_text_insert (GTK_TEXT (tmpText), NULL, NULL, NULL, | |
890 tmpNode->pInfo, strlen(tmpNode->pInfo)); | |
891 } | |
892 } else { | |
893 /* We don't have any information */ | |
894 subName = NULL; | |
895 subAuthor = NULL; | |
896 } | |
897 | |
898 /* Get and set subtune information */ | |
899 gtk_entry_set_text(GTK_ENTRY(LUW("fileinfo_sub_name")), subName ? subName : ""); | |
900 gtk_entry_set_text(GTK_ENTRY(LUW("fileinfo_sub_author")), subAuthor ? subAuthor : ""); | |
901 | |
902 /* Un-freeze the widget */ | |
903 gtk_text_thaw(GTK_TEXT(tmpText)); | |
904 } | |
905 | |
906 | |
907 void xs_fileinfo(gchar *pcFilename) | |
908 { | |
909 GtkWidget *tmpMenuItem, *tmpMenu, *tmpOptionMenu; | |
910 t_xs_stil_subnode *tmpNode; | |
911 gchar tmpStr[32], *tmpS; | |
912 gint n; | |
913 | |
914 /* Free old info, if set */ | |
915 if (xs_fileinfotune) | |
916 xs_tune_free(xs_fileinfotune); | |
917 | |
918 /* Get new tune information */ | |
919 if ((xs_fileinfotune = xs_player->plrGetSIDInfo(pcFilename)) == NULL) | |
920 return; | |
921 | |
922 if (xs_cfg.stilDBEnable) | |
923 xs_fileinfostil = xs_stil_get(pcFilename); | |
924 else | |
925 xs_fileinfostil = NULL; | |
926 | |
927 | |
928 /* Check if there already is an open fileinfo window */ | |
929 if (xs_fileinfowin) | |
930 { | |
931 /* Raise old window */ | |
932 gdk_window_raise(xs_fileinfowin->window); | |
933 | |
934 /* Delete items */ | |
935 tmpOptionMenu = LUW("fileinfo_sub_tune"); | |
936 gtk_widget_destroy(GTK_OPTION_MENU(tmpOptionMenu)->menu); | |
937 GTK_OPTION_MENU(tmpOptionMenu)->menu = gtk_menu_new(); | |
938 } else { | |
939 /* If not, create a new one */ | |
940 xs_fileinfowin = create_xs_fileinfowin(); | |
941 | |
942 /* Connect additional signals */ | |
943 gtk_signal_connect(GTK_OBJECT( | |
944 gtk_range_get_adjustment(GTK_RANGE(LUW("fileinfo_subctrl_adj")))), | |
945 "value_changed", GTK_SIGNAL_FUNC (xs_fileinfo_setsong), NULL); | |
946 } | |
947 | |
948 | |
949 /* Set the generic song information */ | |
950 gtk_entry_set_text(GTK_ENTRY(LUW("fileinfo_filename")), pcFilename); | |
951 gtk_entry_set_text(GTK_ENTRY(LUW("fileinfo_songname")), xs_fileinfotune->tuneName); | |
952 gtk_entry_set_text(GTK_ENTRY(LUW("fileinfo_composer")), xs_fileinfotune->tuneComposer); | |
953 gtk_entry_set_text(GTK_ENTRY(LUW("fileinfo_copyright")), xs_fileinfotune->tuneCopyright); | |
954 | |
955 | |
956 /* Main tune - the pseudo tune */ | |
957 tmpOptionMenu = LUW("fileinfo_sub_tune"); | |
958 tmpMenu = GTK_OPTION_MENU(tmpOptionMenu)->menu; | |
959 | |
960 tmpMenuItem = gtk_menu_item_new_with_label ("General info"); | |
961 gtk_widget_show (tmpMenuItem); | |
962 gtk_menu_append (GTK_MENU(tmpMenu), tmpMenuItem); | |
963 gtk_signal_connect (GTK_OBJECT (tmpMenuItem), "activate", | |
964 GTK_SIGNAL_FUNC (xs_fileinfo_subtune), tmpMenu); | |
965 | |
966 /* Other menu items */ | |
967 for (n = 1; n <= xs_fileinfotune->nsubTunes; n++) | |
968 { | |
969 if (xs_fileinfostil) | |
970 { | |
971 tmpNode = &xs_fileinfostil->subTune[n]; | |
972 if (tmpNode->pName) | |
973 tmpS = tmpNode->pName; | |
974 else | |
975 if (tmpNode->pInfo) | |
976 tmpS = tmpNode->pInfo; | |
977 else | |
978 tmpS = "---"; | |
979 | |
980 snprintf(tmpStr, sizeof(tmpStr), "Tune #%i: %s", n, tmpS); | |
981 } else | |
982 snprintf(tmpStr, sizeof(tmpStr), "Tune #%i", n); | |
983 | |
984 tmpMenuItem = gtk_menu_item_new_with_label(tmpStr); | |
985 gtk_widget_show (tmpMenuItem); | |
986 gtk_menu_append (GTK_MENU(tmpMenu), tmpMenuItem); | |
987 | |
988 gtk_signal_connect (GTK_OBJECT(tmpMenuItem), "activate", | |
989 GTK_SIGNAL_FUNC(xs_fileinfo_subtune), tmpMenu); | |
990 } | |
991 | |
992 /* Set the subtune information */ | |
993 xs_fileinfo_subtune(NULL, tmpMenu); | |
994 | |
995 /* Update subtune controls */ | |
996 xs_subctrl_update(); | |
997 | |
998 /* Show the window */ | |
999 gtk_widget_show(xs_fileinfowin); | |
1000 } |