[gnome-builder/wip/beniofel/media-controls] Add media controller plugin (spotify only for now)
- From: Ben Iofel <beniofel src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/beniofel/media-controls] Add media controller plugin (spotify only for now)
- Date: Wed, 20 Jan 2016 05:19:47 +0000 (UTC)
commit 9208047b68a5c132a71c5701330415c4687201fe
Author: Ben Iofel <iofelben gmail com>
Date: Wed Jan 20 00:19:23 2016 -0500
Add media controller plugin (spotify only for now)
configure.ac | 1 +
plugins/Makefile.am | 1 +
plugins/media-controls/Makefile.am | 37 ++++++++++++++
plugins/media-controls/configure.ac | 15 ++++++
plugins/media-controls/media-controls.plugin | 8 +++
plugins/media-controls/media-controls.vala | 67 ++++++++++++++++++++++++++
6 files changed, 129 insertions(+), 0 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 66b8bb3..72f83a3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -241,6 +241,7 @@ m4_include([plugins/gnome-code-assistance/configure.ac])
m4_include([plugins/html-completion/configure.ac])
m4_include([plugins/html-preview/configure.ac])
m4_include([plugins/jedi/configure.ac])
+m4_include([plugins/media-controls/configure.ac])
m4_include([plugins/mingw/configure.ac])
m4_include([plugins/project-tree/configure.ac])
m4_include([plugins/python-gi-imports-completion/configure.ac])
diff --git a/plugins/Makefile.am b/plugins/Makefile.am
index 7e9628a..2de209e 100644
--- a/plugins/Makefile.am
+++ b/plugins/Makefile.am
@@ -17,6 +17,7 @@ SUBDIRS = \
jedi \
project-tree \
python-gi-imports-completion \
+ media-controls \
mingw \
python-pack \
support \
diff --git a/plugins/media-controls/Makefile.am b/plugins/media-controls/Makefile.am
new file mode 100644
index 0000000..5471cde
--- /dev/null
+++ b/plugins/media-controls/Makefile.am
@@ -0,0 +1,37 @@
+if ENABLE_MEDIA_CONTROLS_PLUGIN
+
+EXTRA_DIST = $(plugin_DATA)
+
+plugindir = $(libdir)/gnome-builder/plugins
+plugin_LTLIBRARIES = libmedia-controls-plugin.la
+dist_plugin_DATA = media-controls.plugin
+
+libmedia_controls_plugin_la_SOURCES = \
+ media-controls.vala
+
+libmedia_controls_plugin_la_VALAFLAGS = \
+ --vapidir $(top_builddir)/libide \
+ --pkg gtk+-3.0 \
+ --pkg gio-2.0 \
+ --pkg libide-1.0 \
+ --pkg libpeas-1.0
+
+libmedia_controls_plugin_la_CFLAGS = \
+ -DG_LOG_DOMAIN=\"media-controls-plugin\" \
+ $(LIBIDE_CFLAGS) \
+ $(VALA_CFLAGS) \
+ -I$(top_srcdir)/libide \
+ -I$(top_srcdir)/contrib/egg \
+ -w
+
+libmedia_controls_plugin_la_LDFLAGS = \
+ $(OPTIMIZE_LDFLAGS) \
+ $(VALA_LIBS) \
+ -avoid-version \
+ -module
+
+include $(top_srcdir)/plugins/Makefile.plugin
+
+endif
+
+-include $(top_srcdir)/git.mk
diff --git a/plugins/media-controls/configure.ac b/plugins/media-controls/configure.ac
new file mode 100644
index 0000000..2827658
--- /dev/null
+++ b/plugins/media-controls/configure.ac
@@ -0,0 +1,15 @@
+AC_ARG_ENABLE([media-controls-plugin],
+ [AS_HELP_STRING([--enable-media-controls-plugin=@<:@auto/yes/no@:>@],
+ [Build with the media controls plugin.])],
+ [enable_media_controls_plugin=$enableval],
+ [enable_media_controls_plugin=auto])
+
+AS_IF([test x$enable_media_controls_plugin = xauto],
+ [enable_media_controls_plugin=yes],
+ [enable_media_controls_plugin=no]
+)
+
+AM_CONDITIONAL(ENABLE_MEDIA_CONTROLS_PLUGIN, test x$enable_media_controls_plugin = xyes)
+
+# Ensure our makefile is generated by autoconf
+AC_CONFIG_FILES([plugins/media-controls/Makefile])
diff --git a/plugins/media-controls/media-controls.plugin b/plugins/media-controls/media-controls.plugin
new file mode 100644
index 0000000..8856872
--- /dev/null
+++ b/plugins/media-controls/media-controls.plugin
@@ -0,0 +1,8 @@
+[Plugin]
+Module=media-controls-plugin
+Name=Media Controls
+Description=Provides media control buttons
+Authors=Ben Iofel <iofelben gmail com>
+Copyright=Copyright © 2016 Ben Iofel
+Builtin=true
+Depends=editor
diff --git a/plugins/media-controls/media-controls.vala b/plugins/media-controls/media-controls.vala
new file mode 100644
index 0000000..eb75a43
--- /dev/null
+++ b/plugins/media-controls/media-controls.vala
@@ -0,0 +1,67 @@
+[DBus (name="org.mpris.MediaPlayer2.Player")]
+public interface Mpris : Object {
+ // public abstract string playback_status { get; }
+
+ public abstract void previous () throws IOError;
+ public abstract void play_pause () throws IOError;
+ public abstract void next () throws IOError;
+}
+
+public class Ide.MediaControls : GLib.Object, Ide.WorkbenchAddin {
+ public bool can_open (Ide.Uri uri, string? content_type, out int priority) {
+ return false;
+ }
+
+ public string get_id () {
+ return typeof (Ide.MediaControls).name ();
+ }
+
+ public void load (Ide.Workbench workbench) {
+ var _titlebar = workbench.get_perspective_by_name ("editor").get_titlebar ();
+ if (_titlebar is Gtk.HeaderBar) {
+ var titlebar = (Gtk.HeaderBar) _titlebar;
+ var box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0);
+ box.get_style_context ().add_class ("linked");
+
+ var back = new Gtk.Button.from_icon_name ("media-seek-backward-symbolic");
+ var play = new Gtk.Button.from_icon_name ("media-playback-start-symbolic");
+ var forward = new Gtk.Button.from_icon_name ("media-seek-forward-symbolic");
+
+ Mpris? mpris = null;
+ Bus.get_proxy.begin<Mpris> (BusType.SESSION,
+
"org.mpris.MediaPlayer2.spotify",
+ "/org/mpris/MediaPlayer2",
+ 0, null,
+ (obj, res) => {
+ mpris = Bus.get_proxy.end (res);
+ back.clicked.connect (button => mpris.previous ());
+ play.clicked.connect (button => mpris.play_pause ());
+ forward.clicked.connect (button => mpris.next ());
+ });
+
+ box.add (back);
+ box.add (play);
+ box.add (forward);
+
+ box.show_all ();
+ titlebar.pack_end (box);
+ }
+ }
+
+ public async bool open_async (Ide.Uri uri, string content_type, Cancellable? cancel) throws Error {
+ assert_not_reached ();
+ return false;
+ }
+
+ public void unload (Ide.Workbench workbench) {
+ // TODO
+ }
+}
+
+[ModuleInit]
+public void peas_register_types (TypeModule module)
+{
+ Peas.ObjectModule peas = (Peas.ObjectModule)module;
+
+ peas.register_extension_type (typeof (Ide.WorkbenchAddin), typeof (Ide.MediaControls));
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]