diff options
author | Denis Fomin <fominde@gmail.com> | 2012-12-07 22:53:43 +0400 |
---|---|---|
committer | Denis Fomin <fominde@gmail.com> | 2012-12-07 22:53:43 +0400 |
commit | f30c180c143485adb84f202a7525bb0aeca305b7 (patch) | |
tree | 24abdead01dd5e288cb447e30882e4b4279228b1 /now_listen | |
parent | 744fe3f3be8bc5e98f95b816497021421c8b9157 (diff) |
NowListenPlugin. Add %url to legend
Diffstat (limited to 'now_listen')
-rw-r--r-- | now_listen/config_dialog.ui | 38 | ||||
-rw-r--r-- | now_listen/manifest.ini | 2 | ||||
-rw-r--r-- | now_listen/now_listen.py | 21 |
3 files changed, 55 insertions, 6 deletions
diff --git a/now_listen/config_dialog.ui b/now_listen/config_dialog.ui index 3090eba..73bde25 100644 --- a/now_listen/config_dialog.ui +++ b/now_listen/config_dialog.ui @@ -40,6 +40,36 @@ </packing> </child> <child> + <object class="GtkHBox" id="hbox2"> + <property name="visible">True</property> + <child> + <object class="GtkLabel" id="label4"> + <property name="visible">True</property> + <property name="label" translatable="yes">Format string for not local files(MPRIS2 only):</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkEntry" id="format_sting_http"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="invisible_char">●</property> + </object> + <packing> + <property name="position">1</property> + </packing> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="position">1</property> + </packing> + </child> + <child> <object class="GtkFrame" id="frame1"> <property name="visible">True</property> <property name="label_xalign">0</property> @@ -55,7 +85,11 @@ <property name="yalign">0</property> <property name="label" translatable="yes">%title - song name %artist - artist -%album - album</property> +%album - album + +<b>For MPRIS2:</b> +%url - the URL of the file. Local files use the file:// schema</property> + <property name="use_markup">True</property> </object> </child> </object> @@ -71,7 +105,7 @@ <packing> <property name="expand">False</property> <property name="fill">False</property> - <property name="position">1</property> + <property name="position">2</property> </packing> </child> </object> diff --git a/now_listen/manifest.ini b/now_listen/manifest.ini index ea37189..d3ffb3f 100644 --- a/now_listen/manifest.ini +++ b/now_listen/manifest.ini @@ -1,7 +1,7 @@ [info] name: Now Listen short_name: now-listen -version: 0.1.1 +version: 0.2 description: Copy tune info to conversation input box (alt + n) at cursor position authors = Denis Fomin <fominde@gmail.com> homepage = http://trac-plugins.gajim.org/wiki/NowListenPlugin diff --git a/now_listen/now_listen.py b/now_listen/now_listen.py index 0a29427..de8ce45 100644 --- a/now_listen/now_listen.py +++ b/now_listen/now_listen.py @@ -24,7 +24,8 @@ class NowListenPlugin(GajimPlugin): (self.connect_with_chat_control, self.disconnect_from_chat_control)} self.config_default_values = { - 'format_string': ('Now listen:"%title" by %artist from %album', '')} + 'format_string': ('Now listen:"%title" by %artist from %album', ''), + 'format_string_http': ('Now listen:"%title" by %artist', ''),} self.controls = [] self.first_run = True @@ -83,6 +84,11 @@ class NowListenPlugin(GajimPlugin): self.artist = music_track_info.artist self.title = music_track_info.title self.source = music_track_info.album + if hasattr(music_track_info, 'url'): + self.url = music_track_info.url + self.albumartist = music_track_info.albumartist + else: + self.url = '' class Base(object): @@ -93,6 +99,8 @@ class Base(object): self.id_ = chat_control.msg_textview.connect('mykeypress', self.on_insert) self.chat_control.handlers[self.id_] = self.chat_control.msg_textview + self.plugin.artist = self.plugin.title = self.plugin.source = '' + self.plugin.url = self.plugin.albumartist = '' def disconnect_from_chat_control(self): if self.id_ not in self.chat_control.handlers: @@ -119,9 +127,13 @@ class Base(object): if self.plugin.artist == self.plugin.title == self.plugin.source == '': tune_string = 'paused or stopped' else: - tune_string = self.plugin.config['format_string'].replace( + format_string = self.plugin.config['format_string'] + if self.plugin.url and not self.plugin.url.startswith('file://'): + format_string = self.plugin.config['format_string_http'] + tune_string = format_string.replace( '%artist', self.plugin.artist).replace( - '%title', self.plugin.title).replace('%album',self.plugin.source) + '%title', self.plugin.title).replace('%album',self.plugin.source).\ + replace('%url', self.plugin.url) message_buffer = self.chat_control.msg_textview.get_buffer() message_buffer.insert_at_cursor(tune_string) @@ -141,11 +153,14 @@ class NowListenPluginConfigDialog(GajimPluginConfigDialog): self.child.pack_start(self.config_vbox) self.format_sting = self.xml.get_object('format_sting') + self.format_sting_http = self.xml.get_object('format_sting_http') self.xml.connect_signals(self) self.connect('hide', self.on_hide) def on_run(self): self.format_sting.set_text(self.plugin.config['format_string']) + self.format_sting_http.set_text(self.plugin.config['format_string_http']) def on_hide(self, widget): self.plugin.config['format_string'] = self.format_sting.get_text() + self.plugin.config['format_string_http'] = self.format_sting_http.get_text() |