From 5b606559c9497b7e70e83324af654db88fb9b3ec Mon Sep 17 00:00:00 2001 From: "eric.beuque" Date: Sat, 17 Jul 2010 15:11:23 +0000 Subject: [PATCH] [FreetuxTV] Glib log integration in GMMKeys. --- src/freetuxtv-app.h | 4 + src/freetuxtv-channels-list.c | 15 +- src/freetuxtv-db-sync.c | 1 - src/freetuxtv-tv-channels-list.c | 3 +- src/freetuxtv-window-add-channels-group.c | 1 - src/lib-gmmkeys.c | 396 +++++++++++--------- src/lib-gmmkeys.h | 38 +- src/main.c | 424 +++++++++++----------- 8 files changed, 468 insertions(+), 414 deletions(-) diff --git a/src/freetuxtv-app.h b/src/freetuxtv-app.h index 2e32b95..6dc8610 100644 --- a/src/freetuxtv-app.h +++ b/src/freetuxtv-app.h @@ -117,6 +117,10 @@ freetuxtv_action_deinterlace (FreetuxTVApp *app, const gchar* mode, void freetuxtv_quit (FreetuxTVApp *app); +void +freetuxtv_log (const gchar *log_domain, GLogLevelFlags log_level, + const gchar *message, gpointer user_data); + G_END_DECLS #endif /* FREETUXTV_APP_H */ diff --git a/src/freetuxtv-channels-list.c b/src/freetuxtv-channels-list.c index f944cc0..63844ff 100644 --- a/src/freetuxtv-channels-list.c +++ b/src/freetuxtv-channels-list.c @@ -266,14 +266,16 @@ channels_list_refresh_channels_group (FreetuxTVApp *app, GtkTreePath *path_group text = g_strdup_printf(_("Update \"%s\" channels list"), pChannelsGroupInfos->name); windowmain_statusbar_push (app, "UpdateMsg", text); g_free(text); - g_print("FreetuxTV : Start updating \"%s\" channels list\n", pChannelsGroupInfos->name); + g_log(FREETUXTV_LOG_DOMAIN, G_LOG_LEVEL_MESSAGE, + "Start updating \"%s\" channels list\n", pChannelsGroupInfos->name); if(pChannelsGroupInfos->type == FREETUXTV_CHANNELSGROUP_TYPEGROUP_PLAYLIST){ // Get the file of the playlist text = g_strdup_printf (_("Getting the file : \"%s\""), pChannelsGroupInfos->uri); windowmain_statusbar_push (app, "UpdateMsg", text); g_free(text); - g_print("FreetuxTV : Getting the file \"%s\"\n", pChannelsGroupInfos->uri); + g_log(FREETUXTV_LOG_DOMAIN, G_LOG_LEVEL_MESSAGE, + "Getting the file \"%s\"\n", pChannelsGroupInfos->uri); gchar *filename = NULL; channels_group_get_file (pChannelsGroupInfos, &filename, TRUE, error); @@ -293,7 +295,8 @@ channels_list_refresh_channels_group (FreetuxTVApp *app, GtkTreePath *path_group pdata.error = error; int res = 0; - g_print("FreetuxTV : Parsing the file \"%s\"\n", filename); + g_log(FREETUXTV_LOG_DOMAIN, G_LOG_LEVEL_MESSAGE, + "Parsing the file \"%s\"\n", filename); res = libm3uparser_parse(filename, &on_parsem3u_add_channel, &pdata); if (res != LIBM3UPARSER_OK){ if (res != LIBM3UPARSER_CALLBACK_RETURN_ERROR){ @@ -388,7 +391,8 @@ channels_list_delete_channels_group (FreetuxTVApp *app, GtkTreePath *path_group, if(*error == NULL){ channels_group_get_file (pChannelsGroupInfos, &filename, TRUE, error); - g_print("FreetuxTV : Deleting the file \"%s\"\n", filename); + g_log(FREETUXTV_LOG_DOMAIN, G_LOG_LEVEL_INFO, + "Deleting the file \"%s\"\n", filename); if(g_unlink(filename)){ } @@ -1262,7 +1266,8 @@ on_popupmenu_activated_addfavourites (GtkMenuItem *menuitem, gpointer user_data) gtk_tree_model_get (app->channelslist, &treeiter, CHANNEL_COLUMN, &pOriginalChannelInfos, -1); if(pOriginalChannelInfos){ - g_print("adding '%s' to group '%s'\n", pOriginalChannelInfos->name, pFavouritesChannelsGroupInfos->name); + g_log(FREETUXTV_LOG_DOMAIN, G_LOG_LEVEL_MESSAGE, + "Adding '%s' to favourites group '%s'\n", pOriginalChannelInfos->name, pFavouritesChannelsGroupInfos->name); // Copy the channel and add it in database pChannelInfos = freetuxtv_channel_infos_new (pOriginalChannelInfos->name, pOriginalChannelInfos->url); diff --git a/src/freetuxtv-db-sync.c b/src/freetuxtv-db-sync.c index e80135e..63b8c21 100644 --- a/src/freetuxtv-db-sync.c +++ b/src/freetuxtv-db-sync.c @@ -455,7 +455,6 @@ dbsync_add_channel (DBSync *dbsync, ); res = sqlite3_exec(dbsync->db_link, query, NULL, NULL, &db_err); - //g_print("%s\n", query); sqlite3_free(query); if(vlc_options){ diff --git a/src/freetuxtv-tv-channels-list.c b/src/freetuxtv-tv-channels-list.c index 3b296be..cb36ee5 100644 --- a/src/freetuxtv-tv-channels-list.c +++ b/src/freetuxtv-tv-channels-list.c @@ -66,7 +66,8 @@ tvchannels_list_synchronize (FreetuxTVApp *app, DBSync *dbsync, text = g_strdup_printf(_("Synchronizing the tv channels list")); windowmain_statusbar_push (app, "UpdateMsg", text); g_free(text); - g_print("FreetuxTV : Synchronizing the tv channels list\n"); + g_log(FREETUXTV_LOG_DOMAIN, G_LOG_LEVEL_MESSAGE, + "Synchronizing the tv channels list\n"); // Delete the TV channel in the database dbsync_delete_tvchannels (dbsync, error); diff --git a/src/freetuxtv-window-add-channels-group.c b/src/freetuxtv-window-add-channels-group.c index 54d653c..1f72ff6 100644 --- a/src/freetuxtv-window-add-channels-group.c +++ b/src/freetuxtv-window-add-channels-group.c @@ -620,7 +620,6 @@ on_buttonadd_clicked (GtkButton *button, gpointer user_data) gtk_tree_path_free(priv->pLastAddedChannelsGroupPath); } priv->pLastAddedChannelsGroupPath = pTreePathTmp; - // g_print("added %s\n", gtk_tree_path_to_string (pTreePathTmp)); tmptext = g_strdup_printf(_("%d channels group(s) have been successfully added."), 1); gtk_progress_dialog_set_text(pProgressDialog, tmptext); diff --git a/src/lib-gmmkeys.c b/src/lib-gmmkeys.c index ec519ee..5203fe5 100644 --- a/src/lib-gmmkeys.c +++ b/src/lib-gmmkeys.c @@ -1,19 +1,20 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8-*- */ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ /* - * FreetuxTV is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or + * freetuxtv + * Copyright (C) Eric Beuque 2010 + * + * freetuxtv is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * - * FreetuxTV is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Glade; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * + * + * freetuxtv is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . */ /* Based on the rb-mmkeys-plugin.c file */ @@ -48,17 +49,17 @@ G_DEFINE_TYPE (GMMKeys, g_mmkeys, G_TYPE_OBJECT); static void g_marshal_VOID__STRING_STRING (GClosure *closure, - GValue *return_value, - guint n_param_values, - const GValue *param_values, - gpointer invocation_hint, - gpointer marshal_data); + GValue *return_value, + guint n_param_values, + const GValue *param_values, + gpointer invocation_hint, + gpointer marshal_data); static void media_player_key_pressed (DBusGProxy *proxy, - const gchar *application, - const gchar *key, - GMMKeys *data); + const gchar *application, + const gchar *key, + GMMKeys *data); enum { MM_KEY_PRESSED, @@ -71,16 +72,16 @@ static guint signals[LAST_SIGNAL]; static void grab_mmkey (int key_code, - GdkWindow *root); + GdkWindow *root); static void ungrab_mmkey (int key_code, - GdkWindow *root); + GdkWindow *root); static GdkFilterReturn filter_mmkeys (GdkXEvent *xevent, - GdkEvent *event, - gpointer data); + GdkEvent *event, + gpointer data); static void mmkeys_grab (GMMKeys *self, gboolean grab); @@ -88,14 +89,30 @@ mmkeys_grab (GMMKeys *self, gboolean grab); #endif // HAVE_MMKEYS GMMKeys* -g_mmkeys_new (gchar *application) +g_mmkeys_new (gchar *application, GLogFunc log_func) { + int idLogFuncHandler = -1; + if(log_func){ + idLogFuncHandler = g_log_set_handler (GMMKEYS_LOG_DOMAIN, G_LOG_LEVEL_MASK, + log_func, NULL); + } + + g_log(GMMKEYS_LOG_DOMAIN, G_LOG_LEVEL_MESSAGE, + "Initialize\n"); + GMMKeys* self; self = G_MMKEYS (g_object_new (G_TYPE_MMKEYS, NULL)); - if(application == NULL){ - self->application = g_strdup("GMMKeys"); + if(self){ + if(application == NULL){ + self->application = g_strdup("GMMKeys"); + }else{ + self->application = g_strdup(application); + } + self->idLogFuncHandler = idLogFuncHandler; }else{ - self->application = g_strdup(application); + if(idLogFuncHandler >= 0){ + g_log_remove_handler(GMMKEYS_LOG_DOMAIN, idLogFuncHandler); + } } return self; } @@ -104,80 +121,87 @@ void g_mmkeys_activate (GMMKeys *self) { DBusGConnection *bus; - - g_print("GMMKeys : activating media player keys\n"); - + + g_log(GMMKEYS_LOG_DOMAIN, G_LOG_LEVEL_INFO, + "Activating media player keys\n"); + bus = dbus_g_bus_get (DBUS_BUS_SESSION, NULL); if (self->grab_type == NONE && bus != NULL) { - + GError *error = NULL; self->proxy = dbus_g_proxy_new_for_name_owner (bus, - "org.gnome.SettingsDaemon", - "/org/gnome/SettingsDaemon/MediaKeys", - "org.gnome.SettingsDaemon.MediaKeys", - &error); + "org.gnome.SettingsDaemon", + "/org/gnome/SettingsDaemon/MediaKeys", + "org.gnome.SettingsDaemon.MediaKeys", + &error); if (self->proxy == NULL) { - g_printerr ("GMMKeys : Unable to grab media player keys: %s\n", error->message); + g_log(GMMKEYS_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL, + "Unable to grab media player keys: %s\n", error->message); g_error_free (error); } else { dbus_g_proxy_call (self->proxy, - "GrabMediaPlayerKeys", &error, - G_TYPE_STRING, self->application, - G_TYPE_UINT, 0, - G_TYPE_INVALID, - G_TYPE_INVALID); + "GrabMediaPlayerKeys", &error, + G_TYPE_STRING, self->application, + G_TYPE_UINT, 0, + G_TYPE_INVALID, + G_TYPE_INVALID); // if the method doesn't exist, try the old interface/path if (error != NULL && error->domain == DBUS_GERROR && error->code == DBUS_GERROR_UNKNOWN_METHOD) { - g_clear_error (&error); - g_object_unref (self->proxy); - - g_print ("trying old dbus interface/path"); - self->proxy = dbus_g_proxy_new_for_name_owner (bus, - "org.gnome.SettingsDaemon", - "/org/gnome/SettingsDaemon", - "org.gnome.SettingsDaemon", - &error); - if (self->proxy != NULL) { - dbus_g_proxy_call (self->proxy, - "GrabMediaPlayerKeys", &error, - G_TYPE_STRING, self->application, - G_TYPE_UINT, 0, - G_TYPE_INVALID, - G_TYPE_INVALID); + g_clear_error (&error); + g_object_unref (self->proxy); + + g_log(GMMKEYS_LOG_DOMAIN, G_LOG_LEVEL_INFO, + "Trying old dbus interface/path"); + self->proxy = dbus_g_proxy_new_for_name_owner (bus, + "org.gnome.SettingsDaemon", + "/org/gnome/SettingsDaemon", + "org.gnome.SettingsDaemon", + &error); + if (self->proxy != NULL) { + dbus_g_proxy_call (self->proxy, + "GrabMediaPlayerKeys", &error, + G_TYPE_STRING, self->application, + G_TYPE_UINT, 0, + G_TYPE_INVALID, + G_TYPE_INVALID); + } } - } - + if (error == NULL) { - - g_print ("GMMKeys : created dbus proxy for org.gnome.SettingsDaemon.MediaKeys; grabbing keys\n"); + + g_log(GMMKEYS_LOG_DOMAIN, G_LOG_LEVEL_INFO, + "Created dbus proxy for org.gnome.SettingsDaemon.MediaKeys; grabbing keys\n"); dbus_g_object_register_marshaller (g_marshal_VOID__STRING_STRING, - G_TYPE_NONE, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID); - + G_TYPE_NONE, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID); + dbus_g_proxy_add_signal (self->proxy, - "MediaPlayerKeyPressed", - G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID); - + "MediaPlayerKeyPressed", + G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID); + dbus_g_proxy_connect_signal (self->proxy, - "MediaPlayerKeyPressed", - G_CALLBACK (media_player_key_pressed), - self, NULL); - + "MediaPlayerKeyPressed", + G_CALLBACK (media_player_key_pressed), + self, NULL); + self->grab_type = SETTINGS_DAEMON; } else { - g_printerr ("GMMKeys : Unable to grab media player keys: %s\n", error->message); + g_log(GMMKEYS_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL, + "Unable to grab media player keys: %s\n", error->message); g_error_free (error); } } } else { - g_print ("GMMKeys : couldn't get dbus session bus\n"); + g_log(GMMKEYS_LOG_DOMAIN, G_LOG_LEVEL_WARNING, + "Couldn't get dbus session bus\n"); } #ifdef HAVE_MMKEYS if (self->grab_type == NONE) { - g_print ("GMMKeys : attempting old-style key grabs\n"); + g_log(GMMKEYS_LOG_DOMAIN, G_LOG_LEVEL_INFO, + "Attempting old-style key grabs\n"); mmkeys_grab (self, TRUE); self->grab_type = X_KEY_GRAB; } @@ -187,17 +211,19 @@ g_mmkeys_activate (GMMKeys *self) void g_mmkeys_deactivate (GMMKeys *self) { - g_print("GMMKeys : deactivating media player keys\n"); + g_log(GMMKEYS_LOG_DOMAIN, G_LOG_LEVEL_INFO, + "Deactivating media player keys\n"); if (self->proxy != NULL) { GError *error = NULL; - + if (self->grab_type == SETTINGS_DAEMON) { dbus_g_proxy_call (self->proxy, - "ReleaseMediaPlayerKeys", &error, - G_TYPE_STRING, self->application, - G_TYPE_INVALID, G_TYPE_INVALID); + "ReleaseMediaPlayerKeys", &error, + G_TYPE_STRING, self->application, + G_TYPE_INVALID, G_TYPE_INVALID); if (error != NULL) { - g_printerr ("GMMKeys : Could not release media player keys: %s\n", error->message); + g_log(GMMKEYS_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL, + "Could not release media player keys: %s\n", error->message); g_error_free (error); } self->grab_type = NONE; @@ -208,7 +234,8 @@ g_mmkeys_deactivate (GMMKeys *self) } #ifdef HAVE_MMKEYS if (self->grab_type == X_KEY_GRAB) { - g_print ("GMMKeys : undoing old-style key grabs\n"); + g_log(FREETUXTV_LOG_DOMAIN, G_LOG_LEVEL_INFO, + "Undoing old-style key grabs\n"); mmkeys_grab (self, FALSE); self->grab_type = NONE; } @@ -218,41 +245,42 @@ g_mmkeys_deactivate (GMMKeys *self) static void media_player_key_pressed (DBusGProxy *proxy, - const gchar *application, - const gchar *key, - GMMKeys *data) + const gchar *application, + const gchar *key, + GMMKeys *data) { - g_print ("GMMKeys : got media key '%s' for application '%s'\n", - key, application); + g_log(GMMKEYS_LOG_DOMAIN, G_LOG_LEVEL_MESSAGE, + "Got media key '%s' for application '%s'\n", + key, application); if (strcmp (application, data->application)) return; - + if (strcmp (key, "Play") == 0) { g_signal_emit (G_OBJECT (data), - signals [MM_KEY_PRESSED], - 0, GMMKEYS_BUTTON_PLAY - ); + signals [MM_KEY_PRESSED], + 0, GMMKEYS_BUTTON_PLAY + ); } else if (strcmp (key, "Pause") == 0) { g_signal_emit (G_OBJECT (data), - signals [MM_KEY_PRESSED], - 0, GMMKEYS_BUTTON_PAUSE - ); + signals [MM_KEY_PRESSED], + 0, GMMKEYS_BUTTON_PAUSE + ); } else if (strcmp (key, "Stop") == 0) { g_signal_emit (G_OBJECT (data), - signals [MM_KEY_PRESSED], - 0,GMMKEYS_BUTTON_STOP - ); + signals [MM_KEY_PRESSED], + 0,GMMKEYS_BUTTON_STOP + ); } else if (strcmp (key, "Previous") == 0) { g_signal_emit (G_OBJECT (data), - signals [MM_KEY_PRESSED], - 0,GMMKEYS_BUTTON_PREV - ); + signals [MM_KEY_PRESSED], + 0,GMMKEYS_BUTTON_PREV + ); } else if (strcmp (key, "Next") == 0) { g_signal_emit (G_OBJECT (data), - signals [MM_KEY_PRESSED], - 0,GMMKEYS_BUTTON_NEXT - ); + signals [MM_KEY_PRESSED], + 0,GMMKEYS_BUTTON_NEXT + ); } } @@ -260,52 +288,53 @@ media_player_key_pressed (DBusGProxy *proxy, static void grab_mmkey (int key_code, - GdkWindow *root) + GdkWindow *root) { gdk_error_trap_push (); XGrabKey (GDK_DISPLAY (), key_code, - 0, - GDK_WINDOW_XID (root), True, - GrabModeAsync, GrabModeAsync); + 0, + GDK_WINDOW_XID (root), True, + GrabModeAsync, GrabModeAsync); XGrabKey (GDK_DISPLAY (), key_code, - Mod2Mask, - GDK_WINDOW_XID (root), True, - GrabModeAsync, GrabModeAsync); + Mod2Mask, + GDK_WINDOW_XID (root), True, + GrabModeAsync, GrabModeAsync); XGrabKey (GDK_DISPLAY (), key_code, - Mod5Mask, - GDK_WINDOW_XID (root), True, - GrabModeAsync, GrabModeAsync); + Mod5Mask, + GDK_WINDOW_XID (root), True, + GrabModeAsync, GrabModeAsync); XGrabKey (GDK_DISPLAY (), key_code, - LockMask, - GDK_WINDOW_XID (root), True, - GrabModeAsync, GrabModeAsync); + LockMask, + GDK_WINDOW_XID (root), True, + GrabModeAsync, GrabModeAsync); XGrabKey (GDK_DISPLAY (), key_code, - Mod2Mask | Mod5Mask, - GDK_WINDOW_XID (root), True, - GrabModeAsync, GrabModeAsync); + Mod2Mask | Mod5Mask, + GDK_WINDOW_XID (root), True, + GrabModeAsync, GrabModeAsync); XGrabKey (GDK_DISPLAY (), key_code, - Mod2Mask | LockMask, - GDK_WINDOW_XID (root), True, - GrabModeAsync, GrabModeAsync); + Mod2Mask | LockMask, + GDK_WINDOW_XID (root), True, + GrabModeAsync, GrabModeAsync); XGrabKey (GDK_DISPLAY (), key_code, - Mod5Mask | LockMask, - GDK_WINDOW_XID (root), True, - GrabModeAsync, GrabModeAsync); + Mod5Mask | LockMask, + GDK_WINDOW_XID (root), True, + GrabModeAsync, GrabModeAsync); XGrabKey (GDK_DISPLAY (), key_code, - Mod2Mask | Mod5Mask | LockMask, - GDK_WINDOW_XID (root), True, - GrabModeAsync, GrabModeAsync); + Mod2Mask | Mod5Mask | LockMask, + GDK_WINDOW_XID (root), True, + GrabModeAsync, GrabModeAsync); gdk_flush (); - if (gdk_error_trap_pop ()) { - g_print ("GMMKeys : Error grabbing key\n"); + if (gdk_error_trap_pop ()) { + g_log(FREETUXTV_LOG_DOMAIN, G_LOG_LEVEL_MESSAGE, + "Error grabbing key\n"); } } static void ungrab_mmkey (int key_code, - GdkWindow *root) + GdkWindow *root) { gdk_error_trap_push (); @@ -319,16 +348,17 @@ ungrab_mmkey (int key_code, XUngrabKey (GDK_DISPLAY (), key_code, Mod2Mask | Mod5Mask | LockMask, GDK_WINDOW_XID (root)); gdk_flush (); - if (gdk_error_trap_pop ()) { - g_print ("GMMKeys : Error grabbing key\n"); + if (gdk_error_trap_pop ()) { + g_log(FREETUXTV_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL, + "Error grabbing key\n"); } } static GdkFilterReturn filter_mmkeys (GdkXEvent *xevent, - GdkEvent *event, - gpointer data) + GdkEvent *event, + gpointer data) { XEvent *xev; XKeyEvent *key; @@ -341,36 +371,36 @@ filter_mmkeys (GdkXEvent *xevent, key = (XKeyEvent *) xevent; self = (GMMKeys *)data; - + if (XKeysymToKeycode (GDK_DISPLAY (), XF86XK_AudioPlay) == key->keycode) { g_signal_emit (G_OBJECT (data), - signals [MM_KEY_PRESSED], - 0, GMMKEYS_BUTTON_PLAY - ); + signals [MM_KEY_PRESSED], + 0, GMMKEYS_BUTTON_PLAY + ); return GDK_FILTER_REMOVE; } else if (XKeysymToKeycode (GDK_DISPLAY (), XF86XK_AudioPause) == key->keycode) { g_signal_emit (G_OBJECT (data), - signals [MM_KEY_PRESSED], - 0, GMMKEYS_BUTTON_PAUSE - ); + signals [MM_KEY_PRESSED], + 0, GMMKEYS_BUTTON_PAUSE + ); return GDK_FILTER_REMOVE; } else if (XKeysymToKeycode (GDK_DISPLAY (), XF86XK_AudioStop) == key->keycode) { g_signal_emit (G_OBJECT (data), - signals [MM_KEY_PRESSED], - 0, GMMKEYS_BUTTON_STOP - ); + signals [MM_KEY_PRESSED], + 0, GMMKEYS_BUTTON_STOP + ); return GDK_FILTER_REMOVE; } else if (XKeysymToKeycode (GDK_DISPLAY (), XF86XK_AudioPrev) == key->keycode) { g_signal_emit (G_OBJECT (data), - signals [MM_KEY_PRESSED], - 0, GMMKEYS_BUTTON_PREV - ); + signals [MM_KEY_PRESSED], + 0, GMMKEYS_BUTTON_PREV + ); return GDK_FILTER_REMOVE; } else if (XKeysymToKeycode (GDK_DISPLAY (), XF86XK_AudioNext) == key->keycode) { g_signal_emit (G_OBJECT (data), - signals [MM_KEY_PRESSED], - 0, GMMKEYS_BUTTON_NEXT - ); + signals [MM_KEY_PRESSED], + 0, GMMKEYS_BUTTON_NEXT + ); return GDK_FILTER_REMOVE; } else { return GDK_FILTER_CONTINUE; @@ -393,7 +423,7 @@ mmkeys_grab (GMMKeys *self, gboolean grab) keycodes[4] = XKeysymToKeycode (GDK_DISPLAY (), XF86XK_AudioPause); display = gdk_display_get_default (); - + for (i = 0; i < gdk_display_get_n_screens (display); i++) { screen = gdk_display_get_screen (display, i); @@ -411,10 +441,10 @@ mmkeys_grab (GMMKeys *self, gboolean grab) if (grab) gdk_window_add_filter (root, filter_mmkeys, - (gpointer) self); + (gpointer) self); else gdk_window_remove_filter (root, filter_mmkeys, - (gpointer) self); + (gpointer) self); } } } @@ -423,22 +453,22 @@ mmkeys_grab (GMMKeys *self, gboolean grab) static void g_marshal_VOID__STRING_STRING (GClosure *closure, - GValue *return_value, - guint n_param_values, - const GValue *param_values, - gpointer invocation_hint, - gpointer marshal_data) + GValue *return_value, + guint n_param_values, + const GValue *param_values, + gpointer invocation_hint, + gpointer marshal_data) { typedef void (*GMarshalFunc_VOID__STRING_STRING) (gpointer data1, - gpointer arg_1, - gpointer arg_2, - gpointer data2); + gpointer arg_1, + gpointer arg_2, + gpointer data2); register GMarshalFunc_VOID__STRING_STRING callback; register GCClosure *cc = (GCClosure*) closure; register gpointer data1, data2; - + g_return_if_fail (n_param_values == 3); - + if (G_CCLOSURE_SWAP_DATA (closure)) { data1 = closure->data; data2 = g_value_peek_pointer (param_values + 0); @@ -447,40 +477,46 @@ g_marshal_VOID__STRING_STRING (GClosure *closure, data2 = closure->data; } callback = (GMarshalFunc_VOID__STRING_STRING) (marshal_data ? marshal_data : cc->callback); - + callback (data1, - g_marshal_value_peek_string (param_values + 1), - g_marshal_value_peek_string (param_values + 2), - data2); + g_marshal_value_peek_string (param_values + 1), + g_marshal_value_peek_string (param_values + 2), + data2); } static void g_mmkeys_finalize (GObject *object) { - g_print ("GMMKeys : finalize\n"); + GMMKeys *self = G_MMKEYS(object); + + g_log(GMMKEYS_LOG_DOMAIN, G_LOG_LEVEL_MESSAGE, + "Finalize\n"); + if(self->idLogFuncHandler >= 0){ + g_log_remove_handler(GMMKEYS_LOG_DOMAIN, self->idLogFuncHandler); + } } static void g_mmkeys_init (GMMKeys *object) { - g_print ("GMMKeys : initialising\n"); + object->idLogFuncHandler = -1; } static void g_mmkeys_class_init (GMMKeysClass *klass) { GObjectClass *object_class; - + object_class = (GObjectClass*) klass; object_class->finalize = g_mmkeys_finalize; - + signals[MM_KEY_PRESSED] = g_signal_new ("mm_key_pressed", - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_LAST, - 0, - NULL, NULL, - g_cclosure_marshal_VOID__INT, - G_TYPE_NONE, 1, G_TYPE_INT); -} + G_TYPE_FROM_CLASS (klass), + G_SIGNAL_RUN_LAST, + 0, + NULL, NULL, + g_cclosure_marshal_VOID__INT, + G_TYPE_NONE, 1, G_TYPE_INT); +} \ No newline at end of file diff --git a/src/lib-gmmkeys.h b/src/lib-gmmkeys.h index 700a7e0..b4261d8 100644 --- a/src/lib-gmmkeys.h +++ b/src/lib-gmmkeys.h @@ -1,19 +1,20 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8-*- */ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ /* - * FreetuxTV is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or + * freetuxtv + * Copyright (C) Eric Beuque 2010 + * + * freetuxtv is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * - * FreetuxTV is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Glade; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * + * + * freetuxtv is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . */ /* Based on the rb-mmkeys-plugin.h file */ @@ -52,9 +53,12 @@ typedef struct SETTINGS_DAEMON, X_KEY_GRAB } grab_type; - + gchar *application; DBusGProxy *proxy; + + int idLogFuncHandler; + } GMMKeys; typedef struct @@ -70,8 +74,10 @@ typedef enum { GMMKEYS_BUTTON_NEXT } GMMKeysButton; +#define GMMKEYS_LOG_DOMAIN "GMMKeys" + GMMKeys* -g_mmkeys_new (gchar *application); +g_mmkeys_new (gchar *application, GLogFunc log_func); void g_mmkeys_activate (GMMKeys *self); diff --git a/src/main.c b/src/main.c index ece3c80..955ffe3 100644 --- a/src/main.c +++ b/src/main.c @@ -272,7 +272,7 @@ gboolean increase_progress_timeout (FreetuxTVApp *app) { GError* error = NULL; - + if(app->current.is_recording){ if(app->current.recording.duration != NULL){ @@ -281,7 +281,7 @@ increase_progress_timeout (FreetuxTVApp *app) gint second; second = (gint)g_timer_elapsed (app->current.recording.duration, NULL); - + // gtk_libvlc_media_player_set_time (app->player, second*1000); struct stat buf; @@ -294,7 +294,7 @@ increase_progress_timeout (FreetuxTVApp *app) gchar *size_text = format_size(file_size); gchar *text; text = g_strdup_printf (_("Recording : %s (%s) -> %s (%s)"), channel->name, - format, app->current.recording.dst_file, size_text); + format, app->current.recording.dst_file, size_text); windowmain_statusbar_pop (app, "RecordChannelMsg"); windowmain_statusbar_push (app, "RecordChannelMsg", text); g_free(text); @@ -303,40 +303,40 @@ increase_progress_timeout (FreetuxTVApp *app) if(app->current.recording.max_duration > 0){ GTimeVal max_time; GTimeVal now_time; - + g_get_current_time (&now_time); - + g_time_val_copy(&(app->current.recording.time_begin), &max_time); - + g_time_val_add_seconds(&max_time, app->current.recording.max_duration * 60); - + if(g_time_val_compare(&now_time, &max_time) > 0){ g_log(FREETUXTV_LOG_DOMAIN, G_LOG_LEVEL_MESSAGE, - "FreetuxTV : Stopping recording\n"); + "Stopping recording\n"); freetuxtv_action_stop(app, &error); } - + } } GtkLibvlcState state = gtk_libvlc_media_player_get_state(app->player, &error); switch(state){ - case GTK_LIBVLC_STATE_PAUSED : - case GTK_LIBVLC_STATE_PLAYING : - windowmain_timebar_update (app, gtk_libvlc_media_player_get_time(app->player, &error), - gtk_libvlc_media_player_get_length(app->player, &error), - gtk_libvlc_media_player_get_position(app->player, &error)); - break; - default: - break; + case GTK_LIBVLC_STATE_PAUSED : + case GTK_LIBVLC_STATE_PLAYING : + windowmain_timebar_update (app, gtk_libvlc_media_player_get_time(app->player, &error), + gtk_libvlc_media_player_get_length(app->player, &error), + gtk_libvlc_media_player_get_position(app->player, &error)); + break; + default: + break; } if(error != NULL){ g_error_free (error); error = NULL; } - + return TRUE; } @@ -347,12 +347,12 @@ splashscreen_statusbar_push (FreetuxTVApp *app, gchar *msg) GtkWidget *statusbar; statusbar = (GtkWidget *) gtk_builder_get_object (app->gui, - "splashscreen_statusbar"); + "splashscreen_statusbar"); context_id = gtk_statusbar_get_context_id(GTK_STATUSBAR(statusbar), - "Infos"); + "Infos"); gtk_statusbar_push (GTK_STATUSBAR(statusbar), - context_id, - msg); + context_id, + msg); while (g_main_context_iteration(NULL, FALSE)){} } @@ -363,9 +363,9 @@ splashscreen_statusbar_pop (FreetuxTVApp *app) GtkWidget *statusbar; statusbar = (GtkWidget *) gtk_builder_get_object (app->gui, - "splashscreen_statusbar"); + "splashscreen_statusbar"); context_id = gtk_statusbar_get_context_id(GTK_STATUSBAR(statusbar), - "Infos"); + "Infos"); gtk_statusbar_pop (GTK_STATUSBAR(statusbar), context_id); } @@ -375,10 +375,10 @@ splashscreen_app_init(gpointer data) { FreetuxTVApp *app = (FreetuxTVApp *)data; GError* error = NULL; - + GtkWidget *widget; widget = (GtkWidget *) gtk_builder_get_object (app->gui, - "splashscreen_version"); + "splashscreen_version"); gtk_label_set_text(GTK_LABEL(widget), VERSION); g_log(FREETUXTV_LOG_DOMAIN, G_LOG_LEVEL_INFO, @@ -397,7 +397,7 @@ splashscreen_app_init(gpointer data) load_user_configuration(app); splashscreen_statusbar_pop (app); } - + // Open database DBSync dbsync; dbsync_open_db (&dbsync, &error); @@ -419,7 +419,7 @@ splashscreen_app_init(gpointer data) // Initialise l'interface windowmain_display_buttons (app, WINDOW_MODE_STOPPED); - + // Loading the models if(error == NULL){ g_log(FREETUXTV_LOG_DOMAIN, G_LOG_LEVEL_INFO, @@ -449,19 +449,19 @@ splashscreen_app_init(gpointer data) g_log(FREETUXTV_LOG_DOMAIN, G_LOG_LEVEL_INFO, "Showing the main window, hide splashscreen\n"); widget = (GtkWidget *)gtk_builder_get_object (app->gui, - "splashscreen"); + "splashscreen"); gtk_widget_hide(widget); - + widget = (GtkWidget *)gtk_builder_get_object (app->gui, - "windowmain"); + "windowmain"); gtk_widget_show(widget); // Set the sound level of the media player widget = (GtkWidget *)gtk_builder_get_object (app->gui, - "windowmain_volumecontrol"); + "windowmain_volumecontrol"); gtk_range_set_value (GTK_RANGE(widget), app->config.volume); gtk_libvlc_media_player_set_volume (app->player, app->config.volume, NULL); - + // Play the last channel if needed if(app->current.path_channel != NULL){ freetuxtv_play_channel (app, app->current.path_channel, &error); @@ -473,7 +473,7 @@ splashscreen_app_init(gpointer data) if(nb_channelsgroup == 0){ FreetuxTVWindowAddChannelsGroup* pWindowAddChannelsGroups; gint res; - + pWindowAddChannelsGroups = freetuxtv_window_add_channels_group_new (app); res = freetuxtv_window_add_channels_group_run (pWindowAddChannelsGroups); @@ -483,7 +483,7 @@ splashscreen_app_init(gpointer data) // Update statut bar windowmain_update_statusbar_infos (app); - + // Close database dbsync_close_db(&dbsync); @@ -539,7 +539,7 @@ freetuxtv_app_create_app () // Initialize UI g_log(FREETUXTV_LOG_DOMAIN, G_LOG_LEVEL_INFO, - "FreetuxTV : Initializing user interface\n"); + "Initializing user interface\n"); windowmain_init(app); windowrecording_init(app); channels_list_init(app); @@ -547,9 +547,9 @@ freetuxtv_app_create_app () // Add player to UI g_log(FREETUXTV_LOG_DOMAIN, G_LOG_LEVEL_INFO, - "FreetuxTV : Creating media player widget\n"); + "Creating media player widget\n"); eventboxplayer = (GtkWidget *)gtk_builder_get_object (app->gui, - "windowmain_eventboxplayer"); + "windowmain_eventboxplayer"); GtkLibvlcInstance* instance; const gchar *options[] = {"--no-video-title-show"}; @@ -557,13 +557,13 @@ freetuxtv_app_create_app () if(error == NULL){ app->player = GTK_LIBVLC_MEDIA_PLAYER(gtk_libvlc_media_player_new(instance, NULL)); } - + gtk_widget_show(GTK_WIDGET(app->player)); g_object_unref(G_OBJECT(instance)); gtk_container_add (GTK_CONTAINER(eventboxplayer), GTK_WIDGET(app->player)); return app; - + } void @@ -574,38 +574,40 @@ freetuxtv_play_channel (FreetuxTVApp *app, GtkTreePath* path_channel, GError** e channel_infos = channels_list_get_channel(app, path_channel); g_log(FREETUXTV_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, - "freetuxtv_play_channel(%s)\n", channel_infos->name); + "freetuxtv_play_channel(%s)\n", channel_infos->name); gchar *text; if(!app->current.is_recording){ - g_print("FreetuxTV : Launching channel '%s' at '%s' -> %s\n", - channel_infos->name, gtk_tree_path_to_string(path_channel), channel_infos->url); + g_log(FREETUXTV_LOG_DOMAIN, G_LOG_LEVEL_MESSAGE, + "Launching channel '%s' at '%s' -> %s\n", + channel_infos->name, gtk_tree_path_to_string(path_channel), channel_infos->url); channels_list_set_playing(app, path_channel); text = g_strdup_printf (_("Playing : %s"), channel_infos->name); windowmain_statusbar_push (app, "PlayChannelMsg", text); - + // Send notification to desktop gchar *imgfile; imgfile = tvchannels_list_get_tvchannel_logo_path(app, channel_infos, TRUE); - + if(app->prefs.enable_notifications){ notify_notification_update (app->current.notification, channel_infos->name, - _("is playing"), imgfile); + _("is playing"), imgfile); if (!notify_notification_show (app->current.notification, NULL)) { - g_printerr("FreetuxTV : Failed to send notification\n"); + g_log(FREETUXTV_LOG_DOMAIN, G_LOG_LEVEL_WARNING, + "Failed to send notification\n"); } } g_free(imgfile); g_free(text); - + windowmain_display_buttons (app, WINDOW_MODE_PLAYING); - + GtkLibvlcMedia *media; media = gtk_libvlc_media_new(channel_infos->url); gtk_libvlc_media_set_options(media, channel_infos->vlc_options); - + gtk_libvlc_media_player_clear_media_list(app->player); gtk_libvlc_media_player_add_media(app->player, media); g_object_unref(media); @@ -618,15 +620,15 @@ freetuxtv_play_channel (FreetuxTVApp *app, GtkTreePath* path_channel, GError** e gtk_libvlc_media_player_play(app->player, options, error); } g_log(FREETUXTV_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, - "end freetuxtv_play_channel(%s)\n", channel_infos->name); + "end freetuxtv_play_channel(%s)\n", channel_infos->name); } void freetuxtv_play_media (FreetuxTVApp *app, GtkLibvlcMedia* media, GError** error) { g_log(FREETUXTV_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, - "freetuxtv_play_media(%s)\n", media->mrl); - + "freetuxtv_play_media(%s)\n", media->mrl); + windowmain_display_buttons (app, WINDOW_MODE_PLAYING); gtk_libvlc_media_player_clear_media_list(app->player); @@ -635,14 +637,14 @@ freetuxtv_play_media (FreetuxTVApp *app, GtkLibvlcMedia* media, GError** error) gtk_libvlc_media_player_play(app->player, NULL, error); g_log(FREETUXTV_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, - "end freetuxtv_play_media(%s)\n", media->mrl); + "end freetuxtv_play_media(%s)\n", media->mrl); } void freetuxtv_action_playpause (FreetuxTVApp *app, GError** error) { g_log(FREETUXTV_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, - "freetuxtv_action_playpause()\n"); + "freetuxtv_action_playpause()\n"); if(app->current.path_channel != NULL){ @@ -650,46 +652,47 @@ freetuxtv_action_playpause (FreetuxTVApp *app, GError** error) GtkLibvlcState state = gtk_libvlc_media_player_get_state(app->player, error); switch(state){ - case GTK_LIBVLC_STATE_PAUSED : - gtk_libvlc_media_player_pause(app->player, NULL); - windowmain_display_buttons (app, WINDOW_MODE_PLAYING); - break; - case GTK_LIBVLC_STATE_PLAYING : - if(gtk_libvlc_media_player_can_pause(app->player, NULL)){ + case GTK_LIBVLC_STATE_PAUSED : gtk_libvlc_media_player_pause(app->player, NULL); - } - windowmain_display_buttons (app, WINDOW_MODE_PAUSED); - break; - default: - channel_infos = channels_list_get_channel (app, app->current.path_channel); - - g_print("FreetuxTV-debug : current channel %s\n", channel_infos->name); - GtkLibvlcMedia *media; - media = gtk_libvlc_media_new(channel_infos->url); - gtk_libvlc_media_player_clear_media_list(app->player); - gtk_libvlc_media_player_add_media(app->player, media); - g_object_unref(media); - gtk_libvlc_media_player_play(app->player, NULL, error); - - windowmain_display_buttons (app, WINDOW_MODE_PLAYING); + windowmain_display_buttons (app, WINDOW_MODE_PLAYING); + break; + case GTK_LIBVLC_STATE_PLAYING : + if(gtk_libvlc_media_player_can_pause(app->player, NULL)){ + gtk_libvlc_media_player_pause(app->player, NULL); + } + windowmain_display_buttons (app, WINDOW_MODE_PAUSED); + break; + default: + channel_infos = channels_list_get_channel (app, app->current.path_channel); + + g_log(FREETUXTV_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, + "Current channel %s\n", channel_infos->name); + GtkLibvlcMedia *media; + media = gtk_libvlc_media_new(channel_infos->url); + gtk_libvlc_media_player_clear_media_list(app->player); + gtk_libvlc_media_player_add_media(app->player, media); + g_object_unref(media); + gtk_libvlc_media_player_play(app->player, NULL, error); + + windowmain_display_buttons (app, WINDOW_MODE_PLAYING); } } - + g_log(FREETUXTV_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, - "end freetuxtv_action_playpause()\n"); + "end freetuxtv_action_playpause()\n"); } void freetuxtv_action_stop (FreetuxTVApp *app, GError** error) { g_log(FREETUXTV_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, - "freetuxtv_action_stop()\n"); - + "freetuxtv_action_stop()\n"); + gchar *text; if(app->current.path_channel != NULL){ FreetuxTVChannelInfos* channel_infos; channel_infos = channels_list_get_channel (app, app->current.path_channel); - + if(gtk_libvlc_media_player_is_playing(app->player, error)){ if(app->current.is_recording){ @@ -699,7 +702,7 @@ freetuxtv_action_stop (FreetuxTVApp *app, GError** error) } windowmain_statusbar_push (app, "PlayChannelMsg", text); g_free(text); - + windowmain_display_buttons (app, WINDOW_MODE_STOPPED); gtk_libvlc_media_player_stop (app->player, error); @@ -709,80 +712,81 @@ freetuxtv_action_stop (FreetuxTVApp *app, GError** error) } } } - + g_log(FREETUXTV_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, - "end freetuxtv_action_stop()\n"); + "end freetuxtv_action_stop()\n"); } void freetuxtv_action_record (FreetuxTVApp *app, GError** error) { g_log(FREETUXTV_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, - "freetuxtv_action_record()\n"); - + "freetuxtv_action_record()\n"); + gchar *text; if(gtk_libvlc_media_player_is_playing(app->player, error) && !app->current.is_recording){ - - FreetuxTVChannelInfos* channel_infos; - channel_infos = channels_list_get_channel (app, app->current.path_channel); - - // Send notification to desktop - gchar *imgfile; - imgfile = tvchannels_list_get_tvchannel_logo_path(app, channel_infos, TRUE); - - if(app->prefs.enable_notifications){ - notify_notification_update (app->current.notification, channel_infos->name, - _("is recording"), imgfile); - if (!notify_notification_show (app->current.notification, NULL)) { - g_printerr("FreetuxTV : Failed to send notification\n"); - } - } - - g_free(imgfile); - windowmain_display_buttons (app, WINDOW_MODE_RECORDING); - - // Timer and file name - if(app->current.recording.duration != NULL){ - g_timer_stop (app->current.recording.duration); - g_timer_destroy (app->current.recording.duration); - } - app->current.recording.duration = g_timer_new (); - - GTimeVal now; - g_get_current_time(&now); - if(app->current.recording.dst_file != NULL){ - g_free(app->current.recording.dst_file); - app->current.recording.dst_file = NULL; - } - - gchar *base_filename; - base_filename = g_strconcat(channel_infos->name, " - ", g_time_val_to_iso8601(&now), NULL); - - gchar *options[2]; - options[0] = get_recording_options(app, base_filename, FALSE, &app->current.recording.dst_file); - options[1] = NULL; - - gtk_libvlc_media_player_play (app->player, options, error); - - g_free(base_filename); - g_free(options[0]); - - app->current.is_recording = TRUE; - text = g_strdup_printf (_("Recording : %s"), app->current.recording.dst_file); - windowmain_statusbar_push (app, "PlayChannelMsg", text); - g_free(text); - } + FreetuxTVChannelInfos* channel_infos; + channel_infos = channels_list_get_channel (app, app->current.path_channel); + + // Send notification to desktop + gchar *imgfile; + imgfile = tvchannels_list_get_tvchannel_logo_path(app, channel_infos, TRUE); + + if(app->prefs.enable_notifications){ + notify_notification_update (app->current.notification, channel_infos->name, + _("is recording"), imgfile); + if (!notify_notification_show (app->current.notification, NULL)) { + g_log(FREETUXTV_LOG_DOMAIN, G_LOG_LEVEL_WARNING, + "Failed to send notification\n"); + } + } + + g_free(imgfile); + windowmain_display_buttons (app, WINDOW_MODE_RECORDING); + + // Timer and file name + if(app->current.recording.duration != NULL){ + g_timer_stop (app->current.recording.duration); + g_timer_destroy (app->current.recording.duration); + } + app->current.recording.duration = g_timer_new (); + + GTimeVal now; + g_get_current_time(&now); + if(app->current.recording.dst_file != NULL){ + g_free(app->current.recording.dst_file); + app->current.recording.dst_file = NULL; + } + + gchar *base_filename; + base_filename = g_strconcat(channel_infos->name, " - ", g_time_val_to_iso8601(&now), NULL); + + gchar *options[2]; + options[0] = get_recording_options(app, base_filename, FALSE, &app->current.recording.dst_file); + options[1] = NULL; + + gtk_libvlc_media_player_play (app->player, options, error); + + g_free(base_filename); + g_free(options[0]); + + app->current.is_recording = TRUE; + + text = g_strdup_printf (_("Recording : %s"), app->current.recording.dst_file); + windowmain_statusbar_push (app, "PlayChannelMsg", text); + g_free(text); + } } void freetuxtv_action_prev (FreetuxTVApp *app, GError** error) { g_log(FREETUXTV_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, - "freetuxtv_action_prev()\n"); - + "freetuxtv_action_prev()\n"); + gboolean ret; GtkTreePath* path_prev_channel; if (app->current.path_channel != NULL) { @@ -799,8 +803,8 @@ void freetuxtv_action_next (FreetuxTVApp *app, GError** error) { g_log(FREETUXTV_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, - "freetuxtv_action_next()\n"); - + "freetuxtv_action_next()\n"); + gboolean ret; GtkTreePath* path_next_channel; if (app->current.path_channel != NULL) { @@ -818,8 +822,8 @@ freetuxtv_action_deinterlace (FreetuxTVApp *app, const gchar* mode, GError** error) { g_log(FREETUXTV_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, - "freetuxtv_action_deinterlace()\n"); - + "freetuxtv_action_deinterlace()\n"); + gboolean ret; GtkTreePath* path_next_channel; if (app->current.path_channel != NULL) { @@ -836,10 +840,10 @@ void freetuxtv_quit (FreetuxTVApp *app) { GError *error = NULL; - + g_log(FREETUXTV_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, - "freetuxtv_action_quit()\n"); - + "freetuxtv_action_quit()\n"); + GKeyFile *keyfile; char *contents, *filename; @@ -849,67 +853,67 @@ freetuxtv_quit (FreetuxTVApp *app) // Stop the current channel freetuxtv_action_stop(app, &error); - + keyfile = g_key_file_new (); // Save prefs g_key_file_set_boolean (keyfile, "general", - "channel_on_startup", - app->prefs.channelonstartup); + "channel_on_startup", + app->prefs.channelonstartup); g_key_file_set_boolean (keyfile, "general", - "enable_notifications", - app->prefs.enable_notifications); - + "enable_notifications", + app->prefs.enable_notifications); + g_key_file_set_string (keyfile, "general", - "directory_record", - app->prefs.directoryrecordings); + "directory_record", + app->prefs.directoryrecordings); g_free(app->prefs.directoryrecordings); g_key_file_set_integer (keyfile, "general", - "transcoding_mode", - app->prefs.transcoding_mode); + "transcoding_mode", + app->prefs.transcoding_mode); g_key_file_set_string (keyfile, "general", - "transcoding_format", - app->prefs.transcoding_format); + "transcoding_format", + app->prefs.transcoding_format); // Save current config g_key_file_set_double (keyfile, "general", - "volume", - app->config.volume); - + "volume", + app->config.volume); + if(app->current.path_channel != NULL && is_playing){ FreetuxTVChannelInfos* channel_infos; channel_infos = channels_list_get_channel(app, app->current.path_channel); g_key_file_set_integer (keyfile, "general", - "last_channel", - channel_infos->id); + "last_channel", + channel_infos->id); gtk_tree_path_free(app->current.path_channel); } g_key_file_set_integer (keyfile, "general", - "logos_file_date", - app->config.logosfiledate); + "logos_file_date", + app->config.logosfiledate); g_key_file_set_boolean (keyfile, "windowminimode", - "stay_on_top", - app->config.windowminimode_stayontop); + "stay_on_top", + app->config.windowminimode_stayontop); g_key_file_set_integer (keyfile, "windowminimode", - "width", - app->config.windowminimode_width); + "width", + app->config.windowminimode_width); g_key_file_set_integer (keyfile, "windowminimode", - "height", - app->config.windowminimode_height); - + "height", + app->config.windowminimode_height); + contents = g_key_file_to_data (keyfile, NULL, NULL); g_key_file_free (keyfile); filename = g_build_filename (g_get_user_config_dir(), - "FreetuxTV/config.ini", NULL); + "FreetuxTV/config.ini", NULL); g_log(FREETUXTV_LOG_DOMAIN, G_LOG_LEVEL_INFO, - "FreetuxTV : Writing config file %s\n", filename); + "Writing config file %s\n", filename); if (!g_file_set_contents (filename, contents, -1, NULL)){ g_log(FREETUXTV_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL, - "Error when writing config file\n"); + "Error when writing config file\n"); } g_free (filename); @@ -927,24 +931,24 @@ static void on_freetuxtv_mm_key_pressed (GMMKeys *mmkeys, GMMKeysButton button, FreetuxTVApp* app) { GError* error = NULL; - + g_log(FREETUXTV_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, - "on_freetuxtv_mm_key_pressed()\n"); - + "on_freetuxtv_mm_key_pressed()\n"); + switch(button){ - case GMMKEYS_BUTTON_PLAY : - case GMMKEYS_BUTTON_PAUSE : - freetuxtv_action_playpause (app, &error); - break; - case GMMKEYS_BUTTON_STOP : - freetuxtv_action_stop (app, &error); - break; - case GMMKEYS_BUTTON_PREV : - freetuxtv_action_prev (app, &error); - break; - case GMMKEYS_BUTTON_NEXT : - freetuxtv_action_next (app, &error); - break; + case GMMKEYS_BUTTON_PLAY : + case GMMKEYS_BUTTON_PAUSE : + freetuxtv_action_playpause (app, &error); + break; + case GMMKEYS_BUTTON_STOP : + freetuxtv_action_stop (app, &error); + break; + case GMMKEYS_BUTTON_PREV : + freetuxtv_action_prev (app, &error); + break; + case GMMKEYS_BUTTON_NEXT : + freetuxtv_action_next (app, &error); + break; } if(error){ @@ -961,42 +965,42 @@ freetuxtv_log (const gchar *log_domain, GLogLevelFlags log_level, const gchar* levelmsg = ""; gboolean bPrint = TRUE; - + switch(log_level){ - case G_LOG_LEVEL_ERROR : + case G_LOG_LEVEL_ERROR : levelmsg = "ERROR"; break; - case G_LOG_LEVEL_CRITICAL : + case G_LOG_LEVEL_CRITICAL : levelmsg = "CRITICAL"; break; - case G_LOG_LEVEL_WARNING : + case G_LOG_LEVEL_WARNING : levelmsg = "WARNING"; break; - case G_LOG_LEVEL_MESSAGE : + case G_LOG_LEVEL_MESSAGE : levelmsg = "MESSAGE"; break; - case G_LOG_LEVEL_INFO : + case G_LOG_LEVEL_INFO : levelmsg = "INFO"; break; - case G_LOG_LEVEL_DEBUG : + case G_LOG_LEVEL_DEBUG : levelmsg = "DEBUG"; if(!debug){ bPrint = FALSE; } break; - default : - break; + default : + break; } if(bPrint){ - g_print("[%s] %s \t: %s", log_domain, levelmsg, message); + g_print("[%s] \t%s \t: %s", log_domain, levelmsg, message); } } int main (int argc, char *argv[]) { - FreetuxTVApp *app; - + FreetuxTVApp *app; + GMMKeys* mmkeys; gboolean debug = FALSE; @@ -1014,7 +1018,7 @@ main (int argc, char *argv[]) idLogHandler = g_log_set_handler (FREETUXTV_LOG_DOMAIN, G_LOG_LEVEL_MASK, freetuxtv_log, (gpointer*)debug); - + #ifdef ENABLE_NLS bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); @@ -1023,7 +1027,7 @@ main (int argc, char *argv[]) g_log(FREETUXTV_LOG_DOMAIN, G_LOG_LEVEL_INFO, "Compiled with LibVLC version %s\n", gtk_libvlc_get_libvlc_version(NULL,NULL,NULL)); - + gtk_set_locale (); gtk_init (&argc, &argv); @@ -1036,14 +1040,14 @@ main (int argc, char *argv[]) notify_init("FreetuxTV"); app->current.notification = notify_notification_new ("FreetuxTV", NULL, NULL, NULL); - mmkeys = g_mmkeys_new ("FreetuxTV"); + mmkeys = g_mmkeys_new ("FreetuxTV", freetuxtv_log); g_mmkeys_activate (mmkeys); - + g_signal_connect(G_OBJECT(mmkeys), - "mm_key_pressed", - G_CALLBACK(on_freetuxtv_mm_key_pressed), - app); - + "mm_key_pressed", + G_CALLBACK(on_freetuxtv_mm_key_pressed), + app); + gtk_init_add (splashscreen_app_init, app); gtk_main ();