-
Notifications
You must be signed in to change notification settings - Fork 119
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
lyrics: Restore GTK support #151
lyrics: Restore GTK support #151
Conversation
radioactiveman
commented
Feb 1, 2024
- Make it possible to reuse most code with the Qt plugin
- Rename to lyrics since lyricwiki is no longer used as source
@jlindgren90: This is still a draft, but I would like to get some feedback and also help regarding Autotools. It is possible to use a single Makefile and directory? My current approach with referencing relative paths is not ideal. Something like this does not work unfortunately. SRCS = chart_lyrics_provider.cc \
file_provider.cc \
lyrics_ovh_provider.cc \
utils.cc
include ../../buildsys.mk
include ../../extra.mk
plugindir := ${plugindir}/${GENERAL_PLUGIN_DIR}
LD = ${CXX}
CFLAGS += ${PLUGIN_CFLAGS}
ifeq ($(USE_GTK),yes)
PLUGIN = lyrics${PLUGIN_SUFFIX}
SRCS += lyrics.cc
CPPFLAGS += ${PLUGIN_CPPFLAGS} ${GTK_CFLAGS} ${GLIB_CFLAGS} ${JSON_GLIB_CFLAGS} ${XML_CFLAGS} -I../..
LIBS += ${GTK_LIBS} ${GLIB_LIBS} ${JSON_GLIB_LIBS} ${XML_LIBS} -laudgui
endif
ifeq ($(USE_QT),yes)
PLUGIN = lyrics-qt${PLUGIN_SUFFIX}
SRCS += lyrics-qt.cc
CPPFLAGS += ${PLUGIN_CPPFLAGS} ${QT_CFLAGS} ${GLIB_CFLAGS} ${XML_CFLAGS} -I../..
LIBS += ${QT_LIBS} ${GLIB_LIBS} ${XML_LIBS}
endif |
src/lyrics/lyrics-qt.cc
Outdated
WidgetLabel (N_("<b>Local Storage</b>")), | ||
WidgetCheck (N_("Load lyric files (.lrc) from local storage"), | ||
WidgetBool (CFG_SECTION, "enable-file-provider")) | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could defaults
and widgets
be also shared between Qt and GTK somehow?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, you could put them in preferences.h
. They can be static
and don't need to be members of Lyrics
or LyricsQt
.
src/lyrics/lyrics-qt.cc
Outdated
QJsonDocument doc = QJsonDocument::fromJson (json); | ||
|
||
if (doc.isNull () || ! doc.isObject ()) | ||
return false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we call output = String();
in error cases explicitly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think that's necessary. It's fine to leave output
unchanged in error cases.
src/lyrics/lyrics.cc
Outdated
WidgetLabel (N_("<b>Local Storage</b>")), | ||
WidgetCheck (N_("Load lyric files (.lrc) from local storage"), | ||
WidgetBool (CFG_SECTION, "enable-file-provider")) | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
libaudgui does not show all widgets for some reason. This needs further verification.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like libaudgui does not support nested WidgetTable
. See fill_table()
in prefs-widget.cc.
src/lyrics/lyrics.cc
Outdated
if (edit_uri && edit_uri[0]) | ||
append_item_to_menu (menu, _("Edit Lyrics ..."), | ||
(GCallback) edit_lyrics_cb, aud::to_ptr ((const char *) edit_uri)); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How would you pass edit_uri
to the callback function?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would make a copy of the string with g_strdup()
, then instead of g_signal_connect()
use g_signal_connect_data()
and pass g_free()
as the destroy_data
parameter.
src/lyrics/lyrics.h
Outdated
None, | ||
Embedded, | ||
Local, | ||
LyricWiki, // TODO: Can this be safely removed? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is no longer used, but affects the value of entries below. Can we remove it anyway?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can remove LyricWiki
. It doesn't look like enum Source
is used directly in the config file.
Thanks. I'll take a look at this when I can and try to answer the specific questions. I know in advance it will be good quality, your work always is :) |
d919bd6
to
8cb90d4
Compare
src/lyrics/lyrics.cc
Outdated
|
||
// TODO: Are these reassignments safe and not leaking memory? | ||
artist = CharPtr (truncate_by_pattern (artist, artist_pattern)); | ||
title = CharPtr (truncate_by_pattern (title, title_pattern)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume the results of g_match_info_fetch()
are leaked here. Is this correct? If yes, what's the cleanest way to free and reassign the strings?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is actually fine, nothing is leaked. CharPtr
has overloaded operator=
which handles freeing the previous pointer.
Thanks John. :) It's sufficient if you review the GTK plugin plus the shared utils and answer my questions. All other code was extracted from the Qt plugin and is unchanged. When I know how to structure the directory/files, I will split the changes into multiple commits (prepare code sharing + restore GTK plugin). |
8cb90d4
to
344ba72
Compare
For directory structure, what you have already is okay, but my suggestion is to have 3 folders:
It's fine for the Makefiles to use relative paths to access the source files in |
I guess an advantage of your current approach is that there's just a single I think I'd slightly prefer to split the |
344ba72
to
e8243ee
Compare
It is no longer available as mingw32 package. Workaround: Skip this package until we find a fix for our Windows autotools pipeline to succeed on mingw64. See also: https://www.msys2.org/news/#2023-12-13-starting-to-drop-some-32-bit-packages
Also remove all lyricwiki references since it is no longer used.
- Based on the original code of Audacious 4.0 - Backport all new features from the Qt lyrics plugin - Use new dependency "json-glib" to parse JSON strings
e8243ee
to
5793bd8
Compare
e33ce89
into
audacious-media-player:master
Thanks again @jlindgren90 for the review and suggestions. I went ahead and merged it myself with the suggested changes. If you have an idea how to make autotools work on mingw64 (see pull request #152), please let me know. |