[Goodies-commits] r7755 - xfmpc/trunk/src

Vincent Legout vincent at xfce.org
Wed Jul 22 13:32:26 CEST 2009


Author: vincent
Date: 2009-07-22 11:32:26 +0000 (Wed, 22 Jul 2009)
New Revision: 7755

Modified:
   xfmpc/trunk/src/interface.c
   xfmpc/trunk/src/main-window.c
   xfmpc/trunk/src/playlist.c
   xfmpc/trunk/src/xfmpc.h
Log:
Run valac


Modified: xfmpc/trunk/src/interface.c
===================================================================
--- xfmpc/trunk/src/interface.c	2009-07-22 10:45:25 UTC (rev 7754)
+++ xfmpc/trunk/src/interface.c	2009-07-22 11:32:26 UTC (rev 7755)
@@ -91,8 +91,8 @@
 void xfmpc_interface_set_volume (XfmpcInterface* self, gint volume);
 void xfmpc_interface_popup_volume (XfmpcInterface* self);
 void xfmpc_interface_set_time (XfmpcInterface* self, gint time, gint time_total);
-void xfmpc_interface_clean (XfmpcInterface* self);
 void xfmpc_interface_update_title (XfmpcInterface* self);
+void xfmpc_interface_reset (XfmpcInterface* self);
 static void xfmpc_interface_cb_song_changed (XfmpcInterface* self);
 static void xfmpc_interface_cb_pp_changed (XfmpcInterface* self, gboolean is_playing);
 static void xfmpc_interface_cb_time_changed (XfmpcInterface* self, gint time, gint total_time);
@@ -241,27 +241,39 @@
 }
 
 
-void xfmpc_interface_clean (XfmpcInterface* self) {
+void xfmpc_interface_reset (XfmpcInterface* self) {
 	g_return_if_fail (self != NULL);
 	xfmpc_interface_set_pp (self, FALSE);
 	xfmpc_interface_set_time (self, 0, 0);
 	xfmpc_interface_set_volume (self, 0);
-	xfmpc_interface_set_title (self, _ ("Not connected"));
-	xfmpc_interface_set_subtitle (self, PACKAGE_STRING);
+	xfmpc_interface_update_title (self);
 }
 
 
 void xfmpc_interface_update_title (XfmpcInterface* self) {
 	g_return_if_fail (self != NULL);
-	if (xfmpc_mpdclient_get_title (self->priv->mpdclient) != NULL) {
-		GString* text;
+	if (xfmpc_mpdclient_is_playing (self->priv->mpdclient)) {
+		char* text;
 		xfmpc_interface_set_title (self, xfmpc_mpdclient_get_title (self->priv->mpdclient));
-		/* subtitle "by \"artist\" from \"album\" (year)" */
-		text = g_string_new ("");
-		g_string_append_printf (text, _ ("by \"%s\" from \"%s\" (%s)"), xfmpc_mpdclient_get_artist (self->priv->mpdclient), xfmpc_mpdclient_get_album (self->priv->mpdclient), xfmpc_mpdclient_get_date (self->priv->mpdclient));
-		/* text = xfmpc_interface_get_subtitle (interface); to avoid "n/a" values, so far I don't care */
-		xfmpc_interface_set_subtitle (self, text->str);
-		(text == NULL) ? NULL : (text = (g_string_free (text, TRUE), NULL));
+		/*
+		// write private function in case it is wished to avoid the
+		// "n/a" values, but no big deal IMO
+		text = get_subtitle (interface);
+		 
+		 TRANSLATORS: subtitle "by \"artist\" from \"album\" (year)" */
+		text = g_strdup_printf (_ ("by \"%s\" from \"%s\" (%s)"), xfmpc_mpdclient_get_artist (self->priv->mpdclient), xfmpc_mpdclient_get_album (self->priv->mpdclient), xfmpc_mpdclient_get_date (self->priv->mpdclient));
+		xfmpc_interface_set_subtitle (self, text);
+		text = (g_free (text), NULL);
+	} else {
+		if (xfmpc_mpdclient_is_stopped (self->priv->mpdclient)) {
+			xfmpc_interface_set_title (self, _ ("Stopped"));
+			xfmpc_interface_set_subtitle (self, PACKAGE_STRING);
+		} else {
+			if (!xfmpc_mpdclient_is_connected (self->priv->mpdclient)) {
+				xfmpc_interface_set_title (self, _ ("Not connected"));
+				xfmpc_interface_set_subtitle (self, PACKAGE_STRING);
+			}
+		}
 	}
 }
 
@@ -299,7 +311,8 @@
 
 static void xfmpc_interface_cb_stopped (XfmpcInterface* self) {
 	g_return_if_fail (self != NULL);
-	xfmpc_interface_clean (self);
+	xfmpc_interface_set_pp (self, FALSE);
+	xfmpc_interface_update_title (self);
 }
 
 

Modified: xfmpc/trunk/src/main-window.c
===================================================================
--- xfmpc/trunk/src/main-window.c	2009-07-22 10:45:25 UTC (rev 7754)
+++ xfmpc/trunk/src/main-window.c	2009-07-22 11:32:26 UTC (rev 7755)
@@ -95,8 +95,8 @@
 	XfmpcExtendedInterface* extended_interface;
 	GtkVBox* vbox;
 	GtkActionGroup* action_group;
-	GtkWidget* statusbar;
 	GtkUIManager* ui_manager;
+	XfmpcStatusbar* statusbar;
 };
 
 
@@ -106,6 +106,7 @@
 GType xfmpc_preferences_get_type (void);
 GType xfmpc_interface_get_type (void);
 GType xfmpc_extended_interface_get_type (void);
+GType xfmpc_statusbar_get_type (void);
 #define XFMPC_MAIN_WINDOW_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), XFMPC_TYPE_MAIN_WINDOW, XfmpcMainWindowPrivate))
 enum  {
 	XFMPC_MAIN_WINDOW_DUMMY_PROPERTY
@@ -125,8 +126,7 @@
 static void xfmpc_main_window_action_volume (XfmpcMainWindow* self);
 static void _xfmpc_main_window_action_volume_gtk_action_callback (GtkAction* action, gpointer self);
 #define XFMPC_MAIN_WINDOW_ui_string "\n<ui>\n  <accelerator action=\"quit\" />\n  <accelerator action=\"previous\" />\n  <accelerator action=\"pp\" />\n  <accelerator action=\"stop\" />\n  <accelerator action=\"next\" />\n  <accelerator action=\"volume\" />\n</ui>\n"
-void xfmpc_interface_clean (XfmpcInterface* self);
-GType xfmpc_statusbar_get_type (void);
+void xfmpc_interface_reset (XfmpcInterface* self);
 void xfmpc_statusbar_set_text (XfmpcStatusbar* self, const char* value);
 void xfmpc_interface_update_title (XfmpcInterface* self);
 static gboolean xfmpc_main_window_refresh (XfmpcMainWindow* self);
@@ -212,9 +212,11 @@
 	if (xfmpc_mpdclient_is_connected (self->priv->mpdclient)) {
 		xfmpc_mpdclient_update_status (self->priv->mpdclient);
 	} else {
-		xfmpc_interface_clean (self->priv->interface);
+		xfmpc_interface_reset (self->priv->interface);
 		xfmpc_mpdclient_reload (self->priv->mpdclient);
-		xfmpc_statusbar_set_text (XFMPC_STATUSBAR (self->priv->statusbar), "");
+		if (self->priv->statusbar != NULL) {
+			xfmpc_statusbar_set_text (self->priv->statusbar, "");
+		}
 		xfmpc_mpdclient_connect (self->priv->mpdclient);
 		if (xfmpc_mpdclient_is_connected (self->priv->mpdclient)) {
 			xfmpc_interface_update_title (self->priv->interface);
@@ -339,7 +341,7 @@
 		_tmp0_ = FALSE;
 	}
 	if (_tmp0_) {
-		GtkWidget* _tmp1_;
+		XfmpcStatusbar* _tmp1_;
 		gtk_object_destroy ((GtkObject*) self->priv->statusbar);
 		_tmp1_ = NULL;
 		self->priv->statusbar = (_tmp1_ = NULL, (self->priv->statusbar == NULL) ? NULL : (self->priv->statusbar = (g_object_unref (self->priv->statusbar), NULL)), _tmp1_);
@@ -352,11 +354,11 @@
 			_tmp2_ = FALSE;
 		}
 		if (_tmp2_) {
-			GtkWidget* _tmp3_;
+			XfmpcStatusbar* _tmp3_;
 			_tmp3_ = NULL;
-			self->priv->statusbar = (_tmp3_ = (GtkWidget*) g_object_ref_sink (xfmpc_statusbar_new ()), (self->priv->statusbar == NULL) ? NULL : (self->priv->statusbar = (g_object_unref (self->priv->statusbar), NULL)), _tmp3_);
-			gtk_widget_show (self->priv->statusbar);
-			gtk_box_pack_start ((GtkBox*) self->priv->vbox, self->priv->statusbar, FALSE, FALSE, (guint) 0);
+			self->priv->statusbar = (_tmp3_ = g_object_ref_sink (xfmpc_statusbar_new ()), (self->priv->statusbar == NULL) ? NULL : (self->priv->statusbar = (g_object_unref (self->priv->statusbar), NULL)), _tmp3_);
+			gtk_widget_show ((GtkWidget*) self->priv->statusbar);
+			gtk_box_pack_start ((GtkBox*) self->priv->vbox, (GtkWidget*) self->priv->statusbar, FALSE, FALSE, (guint) 0);
 		}
 	}
 }
@@ -383,7 +385,7 @@
 	} else {
 		g_string_append_printf (text, _ ("%d songs, %d minutes"), length, (seconds / 60) % 60);
 	}
-	xfmpc_statusbar_set_text (XFMPC_STATUSBAR (self->priv->statusbar), text->str);
+	xfmpc_statusbar_set_text (self->priv->statusbar, text->str);
 	(text == NULL) ? NULL : (text = (g_string_free (text, TRUE), NULL));
 }
 
@@ -585,8 +587,8 @@
 	(self->priv->extended_interface == NULL) ? NULL : (self->priv->extended_interface = (g_object_unref (self->priv->extended_interface), NULL));
 	(self->priv->vbox == NULL) ? NULL : (self->priv->vbox = (g_object_unref (self->priv->vbox), NULL));
 	(self->priv->action_group == NULL) ? NULL : (self->priv->action_group = (g_object_unref (self->priv->action_group), NULL));
+	(self->priv->ui_manager == NULL) ? NULL : (self->priv->ui_manager = (g_object_unref (self->priv->ui_manager), NULL));
 	(self->priv->statusbar == NULL) ? NULL : (self->priv->statusbar = (g_object_unref (self->priv->statusbar), NULL));
-	(self->priv->ui_manager == NULL) ? NULL : (self->priv->ui_manager = (g_object_unref (self->priv->ui_manager), NULL));
 	G_OBJECT_CLASS (xfmpc_main_window_parent_class)->finalize (obj);
 }
 

Modified: xfmpc/trunk/src/playlist.c
===================================================================
--- xfmpc/trunk/src/playlist.c	2009-07-22 10:45:25 UTC (rev 7754)
+++ xfmpc/trunk/src/playlist.c	2009-07-22 11:32:26 UTC (rev 7755)
@@ -151,7 +151,7 @@
 static void xfmpc_playlist_menu_popup (XfmpcPlaylist* self);
 static gboolean xfmpc_playlist_cb_popup_menu (XfmpcPlaylist* self);
 void xfmpc_playlist_refresh_current_song (XfmpcPlaylist* self);
-void xfmpc_playlist_select_row (XfmpcPlaylist* self, gint i);
+static void xfmpc_playlist_cb_pp_changed (XfmpcPlaylist* self, gboolean is_playing);
 static void xfmpc_playlist_cb_song_changed (XfmpcPlaylist* self);
 void xfmpc_playlist_append (XfmpcPlaylist* self, gint id, gint pos, const char* filename, const char* song, const char* length);
 static void xfmpc_playlist_cb_playlist_changed (XfmpcPlaylist* self);
@@ -159,6 +159,7 @@
 void xfmpc_playlist_delete_selection (XfmpcPlaylist* self);
 static gboolean xfmpc_playlist_cb_key_released (XfmpcPlaylist* self, const GdkEventKey* event);
 static gboolean xfmpc_playlist_cb_button_released (XfmpcPlaylist* self, const GdkEventButton* event);
+void xfmpc_playlist_select_row (XfmpcPlaylist* self, gint i);
 static void xfmpc_playlist_cb_filter_entry_activated (XfmpcPlaylist* self);
 static gboolean xfmpc_playlist_cb_filter_entry_key_released (XfmpcPlaylist* self, const GdkEventKey* event);
 static void xfmpc_playlist_cb_filter_entry_changed (XfmpcPlaylist* self);
@@ -171,6 +172,7 @@
 static void _xfmpc_playlist_delete_selection_gtk_menu_item_activate (GtkMenuItem* _sender, gpointer self);
 static void _xfmpc_playlist_cb_browse_selection_gtk_menu_item_activate (GtkMenuItem* _sender, gpointer self);
 static void _xfmpc_playlist_cb_info_selection_gtk_menu_item_activate (GtkMenuItem* _sender, gpointer self);
+static void _xfmpc_playlist_cb_pp_changed_xfmpc_mpdclient_pp_changed (XfmpcMpdclient* _sender, gboolean is_playing, gpointer self);
 static void _xfmpc_playlist_cb_song_changed_xfmpc_mpdclient_song_changed (XfmpcMpdclient* _sender, gpointer self);
 static void _xfmpc_playlist_cb_playlist_changed_xfmpc_mpdclient_playlist_changed (XfmpcMpdclient* _sender, gpointer self);
 static void _xfmpc_playlist_cb_row_activated_gtk_tree_view_row_activated (GtkTreeView* _sender, const GtkTreePath* path, GtkTreeViewColumn* column, gpointer self);
@@ -369,19 +371,21 @@
 }
 
 
+static void xfmpc_playlist_cb_pp_changed (XfmpcPlaylist* self, gboolean is_playing) {
+	g_return_if_fail (self != NULL);
+	/* This callback is needed cause there is an unknown state of the current
+	 * song when MPD is stopped and you run the client. When the client then
+	 * starts to play, the song-changed signal is not send and the current song
+	 * is kept on the first entry of te playlist. On another hand it also
+	 * refocus the current song in the playlist between play/pause which can be
+	 * nice ;-) */
+	xfmpc_playlist_refresh_current_song (self);
+}
+
+
 static void xfmpc_playlist_cb_song_changed (XfmpcPlaylist* self) {
-	gboolean _tmp0_;
 	g_return_if_fail (self != NULL);
 	xfmpc_playlist_refresh_current_song (self);
-	_tmp0_ = FALSE;
-	if (_vala_strcmp0 (gtk_entry_get_text (xfmpc_playlist_filter_entry), "") == 0) {
-		_tmp0_ = self->priv->autocenter;
-	} else {
-		_tmp0_ = FALSE;
-	}
-	if (_tmp0_) {
-		xfmpc_playlist_select_row (self, self->priv->current);
-	}
 }
 
 
@@ -391,7 +395,6 @@
 	char* length;
 	gint id;
 	gint pos;
-	gboolean _tmp0_;
 	g_return_if_fail (self != NULL);
 	filename = g_strdup ("");
 	song = g_strdup ("");
@@ -407,15 +410,6 @@
 		xfmpc_playlist_append (self, id, pos, filename, song, length);
 	}
 	xfmpc_playlist_refresh_current_song (self);
-	_tmp0_ = FALSE;
-	if (_vala_strcmp0 (gtk_entry_get_text (xfmpc_playlist_filter_entry), "") != 0) {
-		_tmp0_ = self->priv->autocenter;
-	} else {
-		_tmp0_ = FALSE;
-	}
-	if (_tmp0_) {
-		xfmpc_playlist_select_row (self, self->priv->current);
-	}
 	filename = (g_free (filename), NULL);
 	song = (g_free (song), NULL);
 	length = (g_free (length), NULL);
@@ -609,6 +603,7 @@
 	GtkTreePath* path;
 	GtkTreePath* _tmp0_;
 	GtkTreePath* _tmp1_;
+	gboolean _tmp2_;
 	g_return_if_fail (self != NULL);
 	path = NULL;
 	if (self->priv->current < 0) {
@@ -625,6 +620,15 @@
 	if (gtk_tree_model_get_iter ((GtkTreeModel*) self->priv->store, &iter, path)) {
 		gtk_list_store_set (self->priv->store, &iter, XFMPC_PLAYLIST_COLUMNS_COLUMN_WEIGHT, PANGO_WEIGHT_BOLD, -1, -1);
 	}
+	_tmp2_ = FALSE;
+	if (_vala_strcmp0 (gtk_entry_get_text (xfmpc_playlist_filter_entry), "") == 0) {
+		_tmp2_ = self->priv->autocenter;
+	} else {
+		_tmp2_ = FALSE;
+	}
+	if (_tmp2_) {
+		xfmpc_playlist_select_row (self, self->priv->current);
+	}
 	(path == NULL) ? NULL : (path = (gtk_tree_path_free (path), NULL));
 }
 
@@ -756,6 +760,11 @@
 }
 
 
+static void _xfmpc_playlist_cb_pp_changed_xfmpc_mpdclient_pp_changed (XfmpcMpdclient* _sender, gboolean is_playing, gpointer self) {
+	xfmpc_playlist_cb_pp_changed (self, is_playing);
+}
+
+
 static void _xfmpc_playlist_cb_song_changed_xfmpc_mpdclient_song_changed (XfmpcMpdclient* _sender, gpointer self) {
 	xfmpc_playlist_cb_song_changed (self);
 }
@@ -889,6 +898,7 @@
 		gtk_box_pack_start ((GtkBox*) self, (GtkWidget*) scrolled, TRUE, TRUE, (guint) 0);
 		gtk_box_pack_start ((GtkBox*) self, (GtkWidget*) xfmpc_playlist_filter_entry, FALSE, FALSE, (guint) 0);
 		/* Signals */
+		g_signal_connect_object (self->priv->mpdclient, "pp-changed", (GCallback) _xfmpc_playlist_cb_pp_changed_xfmpc_mpdclient_pp_changed, self, 0);
 		g_signal_connect_object (self->priv->mpdclient, "song-changed", (GCallback) _xfmpc_playlist_cb_song_changed_xfmpc_mpdclient_song_changed, self, 0);
 		g_signal_connect_object (self->priv->mpdclient, "playlist-changed", (GCallback) _xfmpc_playlist_cb_playlist_changed_xfmpc_mpdclient_playlist_changed, self, 0);
 		g_signal_connect_object (self->priv->treeview, "row-activated", (GCallback) _xfmpc_playlist_cb_row_activated_gtk_tree_view_row_activated, self, 0);

Modified: xfmpc/trunk/src/xfmpc.h
===================================================================
--- xfmpc/trunk/src/xfmpc.h	2009-07-22 10:45:25 UTC (rev 7754)
+++ xfmpc/trunk/src/xfmpc.h	2009-07-22 11:32:26 UTC (rev 7755)
@@ -248,7 +248,7 @@
 void xfmpc_interface_set_volume (XfmpcInterface* self, gint volume);
 void xfmpc_interface_popup_volume (XfmpcInterface* self);
 void xfmpc_interface_set_time (XfmpcInterface* self, gint time, gint time_total);
-void xfmpc_interface_clean (XfmpcInterface* self);
+void xfmpc_interface_reset (XfmpcInterface* self);
 void xfmpc_interface_update_title (XfmpcInterface* self);
 XfmpcInterface* xfmpc_interface_new (void);
 XfmpcInterface* xfmpc_interface_construct (GType object_type);




More information about the Goodies-commits mailing list