commit 59ac974abd7ee252048e89928b28404f9a85f1f9
Author: phantomjinx <[email protected]>
Date: Thu Jul 22 18:41:41 2010 +0100
Fixing some more TODO messages
* lyrics editor
* Adds interfaces for the UI component responsible for editing lyrics
* Currently the details editor is registered as the lyrics editor
libgtkpod/Makefile.am | 1 +
libgtkpod/gtkpod_app_iface.c | 25 ++++++++++++++++++
libgtkpod/gtkpod_app_iface.h | 10 ++++++-
libgtkpod/lyrics_editor_iface.c | 53 ++++++++++++++++++++++++++++++++++++++
libgtkpod/lyrics_editor_iface.h | 54 +++++++++++++++++++++++++++++++++++++++
plugins/details_editor/plugin.c | 11 ++++++++
plugins/details_editor/plugin.h | 1 +
src/details.c | 20 +++++++++++---
src/details.h | 6 +++-
src/display_itdb.c | 6 +---
src/display_tracks.c | 6 +---
src/misc_playlist.c | 7 -----
12 files changed, 176 insertions(+), 24 deletions(-)
---
diff --git a/libgtkpod/Makefile.am b/libgtkpod/Makefile.am
index 2b2d591..940b8c4 100644
--- a/libgtkpod/Makefile.am
+++ b/libgtkpod/Makefile.am
@@ -4,6 +4,7 @@ libgtkpod_la_SOURCES = gtkpod_app_iface.h gtkpod_app_iface.c \
exporter_iface.h
exporter_iface.c \
repository_editor_iface.h
repository_editor_iface.c \
details_editor_iface.h
details_editor_iface.c \
+ lyrics_editor_iface.h
lyrics_editor_iface.c \
photo_editor_iface.h
photo_editor_iface.c \
itdb.h file_convert_info.h \
gp_private.h gp_private.c \
diff --git a/libgtkpod/gtkpod_app_iface.c b/libgtkpod/gtkpod_app_iface.c
index 53e8bd1..2b7e2f1 100644
--- a/libgtkpod/gtkpod_app_iface.c
+++ b/libgtkpod/gtkpod_app_iface.c
@@ -508,6 +508,31 @@ void gtkpod_edit_details(GList *selected_tracks) {
editor_iface->edit_details(selected_tracks);
}
+void gtkpod_register_lyrics_editor(LyricsEditor *editor) {
+ g_return_if_fail (GTKPOD_IS_APP(gtkpod_app));
+ g_return_if_fail (LYRICS_EDITOR_IS_EDITOR(editor));
+ GTKPOD_APP_GET_INTERFACE (gtkpod_app)->lyrics_editor = editor;
+}
+
+void gtkpod_unregister_lyrics_editor() {
+ g_return_if_fail (GTKPOD_IS_APP(gtkpod_app));
+ GTKPOD_APP_GET_INTERFACE (gtkpod_app)->lyrics_editor = NULL;
+}
+
+gboolean gtkpod_has_lyrics_editor() {
+ g_return_val_if_fail (GTKPOD_IS_APP(gtkpod_app), FALSE);
+ return (GTKPOD_APP_GET_INTERFACE (gtkpod_app)->lyrics_editor != NULL);
+}
+
+void gtkpod_edit_lyrics(GList *selected_tracks) {
+ g_return_if_fail(GTKPOD_IS_APP(gtkpod_app));
+ g_return_if_fail (GTKPOD_APP_GET_INTERFACE (gtkpod_app)->lyrics_editor);
+
+ GtkPodAppInterface *gp_iface = GTKPOD_APP_GET_INTERFACE (gtkpod_app);
+ LyricsEditorInterface *editor_iface =
LYRICS_EDITOR_GET_INTERFACE(gp_iface->lyrics_editor);
+ editor_iface->edit_lyrics(selected_tracks);
+}
+
void gtkpod_register_photo_editor(PhotoEditor *editor) {
g_return_if_fail (GTKPOD_IS_APP(gtkpod_app));
g_return_if_fail (PHOTO_EDITOR_IS_EDITOR(editor));
diff --git a/libgtkpod/gtkpod_app_iface.h b/libgtkpod/gtkpod_app_iface.h
index 1282e71..38cc2f9 100644
--- a/libgtkpod/gtkpod_app_iface.h
+++ b/libgtkpod/gtkpod_app_iface.h
@@ -39,6 +39,7 @@
#include "exporter_iface.h"
#include "repository_editor_iface.h"
#include "details_editor_iface.h"
+#include "lyrics_editor_iface.h"
#include "photo_editor_iface.h"
#define GTKPOD_APP_ICON_STOCK_ID "gtkpod"
@@ -120,7 +121,7 @@ struct _GtkPodAppInterface {
/* pointer to the currently displayed set of tracks */
GList *displayed_tracks;
/* pointer to the currently selected set of tracks */
- GList *selected_tracks;
+ GList *selected_tracks;
/* flag indicating whether sorting is enabled/disabled */
gboolean sort_enablement;
/* xml filename */
@@ -131,6 +132,8 @@ struct _GtkPodAppInterface {
RepositoryEditor *repository_editor;
/* Details Editor */
DetailsEditor *details_editor;
+ /* Lyrics Editor */
+ LyricsEditor *lyrics_editor;
/* Photo Editor */
PhotoEditor *photo_editor;
@@ -215,6 +218,11 @@ void gtkpod_unregister_details_editor();
gboolean gtkpod_has_details_editor();
void gtkpod_edit_details(GList* selected_tracks);
+void gtkpod_register_lyrics_editor(LyricsEditor *editor);
+void gtkpod_unregister_lyrics_editor();
+gboolean gtkpod_has_lyrics_editor();
+void gtkpod_edit_lyrics(GList* selected_tracks);
+
void gtkpod_register_photo_editor(PhotoEditor *editor);
void gtkpod_unregister_photo_editor();
gboolean gtkpod_has_photo_editor();
diff --git a/libgtkpod/lyrics_editor_iface.c b/libgtkpod/lyrics_editor_iface.c
new file mode 100644
index 0000000..5516b76
--- /dev/null
+++ b/libgtkpod/lyrics_editor_iface.c
@@ -0,0 +1,53 @@
+/*
+ | Copyright (C) 2002-2010 Jorg Schuler <jcsjcs at users sourceforge net>
+ | Paul Richardson <phantom_sf at
users.sourceforge.net>
+ | Part of the gtkpod project.
+ |
+ | URL: http://www.gtkpod.org/
+ | URL: http://gtkpod.sourceforge.net/
+ |
+ | This program 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
+ | (at your option) any later version.
+ |
+ | This program 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 lyrics.
+ |
+ | You should have received a copy of the GNU General Public License
+ | along with this program; if not, write to the Free Software
+ | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ |
+ | iTunes and iPod are trademarks of Apple
+ |
+ | This product is not supported/written/published by Apple!
+ |
+ */
+
+#ifdef HAVE_CONFIG_H
+ #include <config.h>
+#endif
+
+#include "lyrics_editor_iface.h"
+
+static void lyrics_editor_base_init(LyricsEditorInterface *klass) {
+ static gboolean initialized = FALSE;
+
+ if (!initialized) {
+ klass->edit_lyrics = NULL;
+ initialized = TRUE;
+ }
+}
+
+GType lyrics_editor_get_type(void) {
+ static GType type = 0;
+ if (!type) {
+ static const GTypeInfo info =
+ { sizeof(LyricsEditorInterface), (GBaseInitFunc)
lyrics_editor_base_init, NULL, NULL, NULL, NULL, 0, 0, NULL };
+ type = g_type_register_static(G_TYPE_INTERFACE,
"LyricsEditorInterface", &info, 0);
+ g_type_interface_add_prerequisite(type, G_TYPE_OBJECT);
+ }
+ return type;
+}
diff --git a/libgtkpod/lyrics_editor_iface.h b/libgtkpod/lyrics_editor_iface.h
new file mode 100644
index 0000000..0b5d382
--- /dev/null
+++ b/libgtkpod/lyrics_editor_iface.h
@@ -0,0 +1,54 @@
+/*
+ | Copyright (C) 2002-2009 Paul Richardson <phantom_sf at users sourceforge
net>
+ | Part of the gtkpod project.
+ |
+ | URL: http://www.gtkpod.org/
+ | URL: http://gtkpod.sourceforge.net/
+ |
+ | This program 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
+ | (at your option) any later version.
+ |
+ | This program 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, write to the Free Software
+ | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ |
+ | iTunes and iPod are trademarks of Apple
+ |
+ | This product is not supported/written/published by Apple!
+ |
+ | $Id$
+ */
+#ifndef LYRICS_EDITOR_IFACE_H_
+#define LYRICS_EDITOR_IFACE_H_
+
+#ifdef HAVE_CONFIG_H
+ #include <config.h>
+#endif
+
+#include <gtk/gtk.h>
+#include "itdb.h"
+
+typedef struct _LyricsEditor LyricsEditor;
+typedef struct _LyricsEditorInterface LyricsEditorInterface;
+
+struct _LyricsEditorInterface {
+ GTypeInterface g_iface;
+
+ void (*edit_lyrics)(GList *selected_tracks);
+};
+
+GType lyrics_editor_get_type(void);
+
+#define LYRICS_EDITOR_TYPE (lyrics_editor_get_type ())
+#define LYRICS_EDITOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj),
LYRICS_EDITOR_TYPE, LyricsEditor))
+#define LYRICS_EDITOR_IS_EDITOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE
((obj), LYRICS_EDITOR_TYPE))
+#define LYRICS_EDITOR_GET_INTERFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE
((inst), LYRICS_EDITOR_TYPE, LyricsEditorInterface))
+
+#endif /* LYRICS_EDITOR_IFACE_H_ */
diff --git a/plugins/details_editor/plugin.c b/plugins/details_editor/plugin.c
index ab6a382..6edae1b 100644
--- a/plugins/details_editor/plugin.c
+++ b/plugins/details_editor/plugin.c
@@ -72,6 +72,7 @@ static gboolean activate_plugin(AnjutaPlugin *plugin) {
g_return_val_if_fail(DETAILS_EDITOR_IS_EDITOR(details_editor_plugin),
TRUE);
gtkpod_register_details_editor (DETAILS_EDITOR(details_editor_plugin));
+ gtkpod_register_lyrics_editor(LYRICS_EDITOR(details_editor_plugin));
g_signal_connect (gtkpod_app, SIGNAL_TRACK_REMOVED, G_CALLBACK
(details_editor_track_removed_cb), NULL);
g_signal_connect (gtkpod_app, SIGNAL_TRACKS_SELECTED, G_CALLBACK
(details_editor_set_tracks_cb), NULL);
@@ -87,6 +88,11 @@ static gboolean deactivate_plugin(AnjutaPlugin *plugin) {
destroy_details_editor();
+ details_editor_plugin->details_window = NULL;
+ details_editor_plugin->details_view = NULL;
+ details_editor_plugin->details_notebook = NULL;
+
+ gtkpod_unregister_lyrics_editor();
gtkpod_unregister_details_editor();
ui = anjuta_shell_get_ui(plugin->shell, NULL);
@@ -120,8 +126,13 @@ static void
details_editor_iface_init(DetailsEditorInterface *iface) {
iface->edit_details = details_edit;
}
+static void lyrics_editor_iface_init(LyricsEditorInterface *iface) {
+ iface->edit_lyrics = lyrics_edit;
+}
+
ANJUTA_PLUGIN_BEGIN (DetailsEditorPlugin, details_editor_plugin);
ANJUTA_PLUGIN_ADD_INTERFACE(details_editor, DETAILS_EDITOR_TYPE);
+ANJUTA_PLUGIN_ADD_INTERFACE(lyrics_editor, LYRICS_EDITOR_TYPE);
ANJUTA_PLUGIN_END;
ANJUTA_SIMPLE_PLUGIN (DetailsEditorPlugin, details_editor_plugin)
;
diff --git a/plugins/details_editor/plugin.h b/plugins/details_editor/plugin.h
index 8fbcb0c..f38f572 100644
--- a/plugins/details_editor/plugin.h
+++ b/plugins/details_editor/plugin.h
@@ -44,6 +44,7 @@ struct _DetailsEditorPlugin {
gint uiid;
GtkWidget *details_window;
GtkWidget *details_view;
+ GtkWidget *details_notebook;
GtkActionGroup *action_group;
};
diff --git a/src/details.c b/src/details.c
index f214693..dd893a1 100644
--- a/src/details.c
+++ b/src/details.c
@@ -1416,6 +1416,8 @@ static void create_details_editor_view() {
gtk_widget_ref(details_editor_plugin->details_window);
details_editor_plugin->details_view = viewport;
gtk_widget_ref(details_editor_plugin->details_view);
+ details_editor_plugin->details_notebook =
gtkpod_xml_get_widget(details_view->xml, "details_notebook");
+ gtk_widget_ref(details_editor_plugin->details_notebook);
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW
(details_editor_plugin->details_window), GTK_POLICY_AUTOMATIC,
GTK_POLICY_AUTOMATIC);
gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW
(details_editor_plugin->details_window), GTK_SHADOW_IN);
@@ -1506,27 +1508,35 @@ static void create_details_editor_view() {
NULL);
}
+void lyrics_edit(GList *selected_tracks) {
+ gint num_pages;
+ details_edit(selected_tracks);
+
+ num_pages = gtk_notebook_get_n_pages(GTK_NOTEBOOK
(details_editor_plugin->details_notebook));
+ if (num_pages > 0 && DETAILS_LYRICS_NOTEBOOK_PAGE < num_pages) {
+ gtk_notebook_set_current_page(GTK_NOTEBOOK
(details_editor_plugin->details_notebook), DETAILS_LYRICS_NOTEBOOK_PAGE);
+ }
+}
+
/* Open the details window and display the selected tracks, starting
* with the first track
*/
void details_edit(GList *selected_tracks) {
- GtkWidget *w;
gint page, num_pages;
if (!details_view || !details_view->window) {
create_details_editor_view();
}
- else {
+ else if (! GTK_WIDGET_REALIZED(details_view->window)) {
gtkpod_display_widget(details_view->window);
}
details_set_tracks(selected_tracks);
/* set notebook page */
- w = gtkpod_xml_get_widget(details_view->xml, "details_notebook");
page = prefs_get_int(DETAILS_WINDOW_NOTEBOOK_PAGE);
- num_pages = gtk_notebook_get_n_pages(GTK_NOTEBOOK (w));
+ num_pages = gtk_notebook_get_n_pages(GTK_NOTEBOOK
(details_editor_plugin->details_notebook));
if ((page >= 0) && (page < num_pages))
- gtk_notebook_set_current_page(GTK_NOTEBOOK (w), page);
+ gtk_notebook_set_current_page(GTK_NOTEBOOK
(details_editor_plugin->details_notebook), page);
gtk_widget_show_all(details_view->window);
}
diff --git a/src/details.h b/src/details.h
index 1301dcb..464e778 100644
--- a/src/details.h
+++ b/src/details.h
@@ -38,6 +38,8 @@
#include <glade/glade.h>
#include "libgtkpod/itdb.h"
+#define DETAILS_LYRICS_NOTEBOOK_PAGE 3
+
struct _Detail
{
GladeXML *xml; /* XML info */
@@ -53,14 +55,14 @@ struct _Detail
typedef struct _Detail Detail;
-extern const gchar *DETAILS_WINDOW_NOTEBOOK_PAGE;
-
/* details window */
void details_edit (GList *selected_tracks);
void details_remove_track (Track *track);
Detail *details_get_selected_detail ();
void destroy_details_editor();
+void lyrics_edit (GList *selected_tracks);
+
void details_editor_track_removed_cb(GtkPodApp *app, gpointer tk, gpointer
data);
void details_editor_set_tracks_cb(GtkPodApp *app, gpointer tks, gpointer data);
diff --git a/src/display_itdb.c b/src/display_itdb.c
index 6b1682d..827f706 100644
--- a/src/display_itdb.c
+++ b/src/display_itdb.c
@@ -141,10 +141,8 @@ iTunesDB *gp_itdb_new(void) {
/* Free itdb and take care of dependencies */
void gp_itdb_free(iTunesDB *itdb) {
- g_message("TODO signal all things such as conversions to cancel");
- // /* cancel all pending conversions */
- // file_convert_cancel_itdb (itdb);
-
+ /* cancel all pending conversions */
+ file_convert_cancel_itdb (itdb);
itdb_free(itdb);
}
diff --git a/src/display_tracks.c b/src/display_tracks.c
index 8543b0b..9e044e9 100644
--- a/src/display_tracks.c
+++ b/src/display_tracks.c
@@ -1209,11 +1209,7 @@ static void tm_cell_toggled(GtkCellRendererToggle
*renderer, gchar *arg1, gpoint
}
if ((column == TM_COLUMN_LYRICS) && (selected_tracks != NULL)) {
- /* set displayed page to the lyrics page */
- //FIXME
- g_message("TODO - display_tracks: set displayed page to the lyrics
page in details window");
- // prefs_set_int (DETAILS_WINDOW_NOTEBOOK_PAGE, 3);
- // details_edit (selected_tracks);
+ gtkpod_edit_lyrics(selected_tracks);
g_list_free(selected_tracks);
}
diff --git a/src/misc_playlist.c b/src/misc_playlist.c
index 83dc050..0964aa2 100644
--- a/src/misc_playlist.c
+++ b/src/misc_playlist.c
@@ -1112,14 +1112,9 @@ static void delete_playlist_ok(struct DeleteData *dd) {
}
if (itdb_playlist_is_mpl(dd->pl)) {
msg = g_strdup_printf(_("Removed all %d tracks from the
iPod"), n);
- g_message("TODO: reset display");
- // display_reset(0);
}
else if (itdb_playlist_is_podcasts(dd->pl)) {
msg = g_strdup_printf(_("Removed all podcasts from the iPod"));
- if (gtkpod_get_current_playlist() == dd->pl)
- g_message("TODO: reset only sorttabs");
- // st_redisplay(0);
}
else {
/* first use playlist name */
@@ -1175,8 +1170,6 @@ static void delete_playlist_ok(struct DeleteData *dd) {
}
if (itdb_playlist_is_mpl(dd->pl)) {
msg = g_strdup_printf(_("Removed all %d tracks from the
database"), n);
- g_message("TODO: reset display");
- // display_reset(0);
}
else {
/* first use playlist name */
------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
_______________________________________________
gtkpod-cvs2 mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gtkpod-cvs2