Commit f8c85496 authored by Ziirish's avatar Ziirish

fix: gui bug with UTF-8 encoded characters + drawing symbols with cairo + mpd...

fix: gui bug with UTF-8 encoded characters + drawing symbols with cairo + mpd support improvements + fix with the 'return' callback
parent 217ebdc4
......@@ -74,7 +74,7 @@ PLAYER=0
INTER=5
#b Allow CID to monitor your player
#{Contextual menu in right clic. Play/Pause by left clicking. Next by middle clicking.}
#{Contextual menu in right clic.\n - Play/Pause by left clicking\n - Next by middle clicking}
MONITOR=
#b Display the controls
......@@ -83,9 +83,6 @@ CONTROLS=
#b Give the play/pause status
STATE=
#r[White;Yellow;Red] Status symbols color
SYMBOL_COLOR=
#U Search the following files
#{%user% stands for the username\n%home% stands for the user's home directory\n%artist% stands for the artist's name\n%album% stands for the album name}/
FILES_LIST=album;albumart;cover;folder;.cover;.folder;
......
......@@ -32,23 +32,22 @@ gboolean bFlyingButton;
static CidTask *pMeasureDownload = NULL;
void
cid_interrupt (void)
cid_interrupt (CidMainContainer **pCid)
{
_cid_quit(NULL,NULL);
_cid_quit(NULL,(gpointer *)pCid);
}
void
_cid_quit (GtkWidget *p_widget, gpointer user_data)
_cid_quit (GtkWidget *p_widget, gpointer *user_data)
{
cid_save_data (&cid);
cid_save_data ((CidMainContainer **)user_data);
cid_file_remove (DEFAULT_DOWNLOADED_IMAGE_LOCATION);
cid_sortie (&cid, CID_EXIT_SUCCESS);
cid_sortie ((CidMainContainer **)user_data, CID_EXIT_SUCCESS);
/* Parametres inutilises */
(void)p_widget;
(void)user_data;
}
gpointer
......
......@@ -20,12 +20,12 @@ G_BEGIN_DECLS
* @param p_widget non utilisé
* @param user_data non utilisé
*/
void _cid_quit (GtkWidget *p_widget, gpointer user_data);
void _cid_quit (GtkWidget *p_widget, gpointer *user_data);
/**
* Fonction exécutée en cas d'interruption du programme
*/
void cid_interrupt (void);
void cid_interrupt (CidMainContainer **pCid);
/**
* Fonction executée lors d'un clic de souris
......
......@@ -51,6 +51,7 @@ cid_read_config_after_update (CidMainContainer **pCid, const char *f)
if (cid->runtime->pMonitorList)
{
//g_slice_free (CidControlFunctionsList,cid->runtime->pMonitorList);
g_free (cid->runtime->pMonitorList);
cid->runtime->pMonitorList = NULL;
}
......@@ -221,7 +222,7 @@ cid_read_key_file (CidMainContainer **pCid, const gchar *f)
cid->config->bMonitorPlayer = CID_CONFIG_GET_BOOLEAN_WITH_DEFAULT ("System", "MONITOR", TRUE);
cid->config->bPlayerState = CID_CONFIG_GET_BOOLEAN_WITH_DEFAULT ("System", "STATE", TRUE);
cid->config->bDisplayTitle = CID_CONFIG_GET_BOOLEAN_WITH_DEFAULT ("System", "TITLE", TRUE);
cid->config->iSymbolColor = CID_CONFIG_GET_INTEGER ("System", "SYMBOL_COLOR");
//cid->config->iSymbolColor = CID_CONFIG_GET_INTEGER ("System", "SYMBOL_COLOR");
cid->config->bDisplayControl = CID_CONFIG_GET_BOOLEAN_WITH_DEFAULT ("System", "CONTROLS", TRUE);
cid->config->dPoliceSize = g_key_file_get_double (cid->pKeyFile, "System", "POLICE_SIZE", &error);
cid_free_and_debug_error(pCid, &error);
......@@ -369,7 +370,7 @@ cid_save_data (CidMainContainer **pCid)
// [System] configuration
g_key_file_set_integer (cid->pKeyFile, "System", "PLAYER", cid->config->iPlayer);
g_key_file_set_integer (cid->pKeyFile, "System", "INTER", cid->config->iInter/1000);
g_key_file_set_integer (cid->pKeyFile, "System", "SYMBOL_COLOR", cid->config->iSymbolColor);
//g_key_file_set_integer (cid->pKeyFile, "System", "SYMBOL_COLOR", cid->config->iSymbolColor);
g_key_file_set_boolean (cid->pKeyFile, "System", "MONITOR", cid->config->bMonitorPlayer);
g_key_file_set_boolean (cid->pKeyFile, "System", "STATE", cid->config->bPlayerState);
g_key_file_set_boolean (cid->pKeyFile, "System", "TITLE", cid->config->bDisplayTitle);
......
This diff is collapsed.
......@@ -20,6 +20,15 @@ G_BEGIN_DECLS
static gchar *STATE_SYMBOL[] = {"play","pause","next","prev"};
static gchar *STATE_COLOR[] = {"white","yellow","red"};
/// Liste des lecteurs supportés
typedef enum {
SHAPE_NONE,
SHAPE_PLAY,
SHAPE_PAUSE,
SHAPE_NEXT,
SHAPE_PREV
} CidShapes;
/**
* Permet de redessiner la fenêtre
*/
......
......@@ -198,7 +198,7 @@ cid_file_check (const gchar *f)
CidDataTable *
cid_images_lookup (CidMainContainer **pCid, const gchar *cDirName)
{
g_return_val_if_fail (cDirName != NULL, FALSE);
g_return_val_if_fail (cDirName != NULL, NULL);
CidMainContainer *cid = *pCid;
CidDataTable *ret = cid_datatable_new ();
......@@ -210,7 +210,7 @@ cid_images_lookup (CidMainContainer **pCid, const gchar *cDirName)
{
cid_warning ("%s", error->message);
g_clear_error (&error);
return FALSE;
return NULL;
}
const gchar *cEntry = NULL;
while ((cEntry = g_dir_read_name (cid->runtime->pLookupDirectory)) != NULL)
......
......@@ -43,7 +43,9 @@ cid_build_menu (CidMainContainer **pCid)
gtk_menu_shell_append (GTK_MENU_SHELL (pSubMenu), sep1);
_add_entry_in_menu (_("About"), GTK_STOCK_ABOUT, _cid_about, pSubMenu);
data = (gpointer *)pCid;
_add_entry_in_menu (_("Quit"), GTK_STOCK_QUIT, _cid_quit, pSubMenu);
data = NULL;
if (cid->config->bMonitorPlayer && cid->config->iPlayer!=PLAYER_NONE)
{
......
......@@ -14,10 +14,11 @@
#include "cid-messages.h"
#include "cid-utilities.h"
#include "cid-callbacks.h"
#include "cid-cover.h"
extern CidMainContainer *cid;
static gboolean cont, first;
static gboolean cont, first, paused = FALSE;
static mpd_Connection *conn = NULL;
gboolean
......@@ -84,6 +85,7 @@ cid_mpd_cover ()
{
if (bOldState!=musicData.playing || first)
{
paused = bOldState!=musicData.playing;
musicData.opening = FALSE;
first = FALSE;
mpd_freeStatus(status);
......@@ -117,7 +119,7 @@ cid_mpd_cover ()
continue;
}
if (musicData.playing_uri != NULL && strcmp (musicData.playing_uri,song->file) == 0)
if (musicData.playing_uri != NULL && strcmp (musicData.playing_uri,song->file) == 0 && !paused)
{
if (bOldState!=musicData.playing)
cid_display_image (musicData.playing_cover);
......@@ -173,30 +175,21 @@ cid_mpd_cover ()
if (cSongPath != NULL)
{
CidDataTable *p_tabFiles = cid_create_datatable(G_TYPE_STRING,"cover","album","albumart",
".folder",".cover","folder","Cover","Folder",
G_TYPE_INVALID);
gchar *cSongDir = g_path_get_dirname (cSongPath);
g_free (cSongPath);
musicData.playing_cover = g_strdup_printf ("%s/%s - %s.jpg", cSongDir, musicData.playing_artist, musicData.playing_album);
cid_debug (" test de %s\n", musicData.playing_cover);
BEGIN_FOREACH_DT(p_tabFiles)
if (g_file_test (musicData.playing_cover, G_FILE_TEST_EXISTS))
break;
g_free (musicData.playing_cover);
musicData.playing_cover = g_strdup_printf ("%s/%s.jpg", cSongDir, p_temp->content->string);
cid_debug (" test de %s\n", musicData.playing_cover);
END_FOREACH_DT
g_free (musicData.playing_cover);
musicData.playing_cover = cid_cover_lookup (&cid,
musicData.playing_artist,
musicData.playing_album,
cSongDir);
g_free (cSongDir);
if (! g_file_test (musicData.playing_cover, G_FILE_TEST_EXISTS))
{
cid->runtime->iCheckIter = 0;
if (cid->config->iPlayer != PLAYER_NONE)
{
cid_debug ("l'image n'existe pas encore => on boucle.\n");
musicData.iSidCheckCover = g_timeout_add (1 SECONDES, (GSourceFunc) _check_cover_is_present, &cid);
}
}
} else {
cid_debug ("l'image n'existe pas => on va la chercher.\n");
g_free (musicData.playing_cover);
musicData.playing_cover = cid_cover_lookup (&cid,
musicData.playing_artist,
musicData.playing_album,
NULL);
}
cid_info ("\nartist : %s\nalbum : %s\ntitle : %s\nsong uri : %s\ncover uri : %s",
......
......@@ -111,10 +111,11 @@ cid_str_replace_all_seq (gchar **string, gchar *seqFrom, gchar *seqTo)
void
cid_parse_nl (gchar **input)
{
gchar *in = g_locale_from_utf8(*input, -1, NULL, NULL, NULL);
gint length = strlen (in);
gchar *in = *input;
gint length = 0;
for (;in[length] != '\0'; length++);
gint ind = 0, cpt = 0;
gchar *output = g_malloc (sizeof(gchar)*length+1);
gchar *output = g_malloc (length);
while (ind<length)
{
if (in[ind] == '\\' && ind < length-1 && in[ind+1] == 'n')
......@@ -129,9 +130,9 @@ cid_parse_nl (gchar **input)
ind++,cpt++;
}
output[cpt] = '\0';
g_free (in);
in = NULL;
in = g_locale_to_utf8 (output, -1, NULL, NULL, NULL);
g_free (*input);
*input = NULL;
*input = g_strdup (output);
g_free (output);
}
......
......@@ -78,7 +78,7 @@ cid_intercept_signal (int number)
{
if (number == SIGINT || number == SIGTERM)
{
cid_interrupt ();
cid_interrupt (&cid);
return;
}
cid_warning ("Attention : cid has crashed (%d).", /*strsignal(*/number);
......@@ -250,7 +250,6 @@ main ( int argc, char **argv )
// La on lance la boucle GTK
cid_display_init (&cid,&argc,&argv);
//cid_display_init (&cid,0,NULL);
// Si on est ici, c'est qu'on a coupé la boucle GTK
// Du coup, on en profite pour faire un peu de ménage
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment