[PATCH 15/17] grilo-test-ui.py: Media can be stored
- From: Simón Pena <spenap gmail com>
- To: grilo-list gnome org
- Subject: [PATCH 15/17] grilo-test-ui.py: Media can be stored
- Date: Sat, 14 Aug 2010 22:07:46 +0200
---
tools/python/grilo-test-ui.py | 77 +++++++++++++++++++++++++++++++++++++++-
1 files changed, 75 insertions(+), 2 deletions(-)
diff --git a/tools/python/grilo-test-ui.py b/tools/python/grilo-test-ui.py
index 01df50d..ba18423 100644
--- a/tools/python/grilo-test-ui.py
+++ b/tools/python/grilo-test-ui.py
@@ -255,10 +255,33 @@ class MainWindow(Gtk.Window):
{'source':self._ui_state.last_url})
def _back_btn_clicked_cb(self, *args):
- pass
+ self._cancel_current_operation()
+
+ prev_source, prev_container = self._browse_history_pop()
+ self.browse(prev_source, prev_container)
def _store_btn_clicked_cb(self, *args):
- pass
+ selection = self._browser_window.get_browser().get_selection()
+ success, model, iter = selection.get_selected()
+ if success:
+ source = model.get_value(iter, BrowserListStore.SOURCE_COLUMN)
+ container = model.get_value(iter, BrowserListStore.CONTENT_COLUMN)
+#
+ dialog = StoreContentDialog(self)
+ if dialog.run() == Gtk.ResponseType.OK:
+ url = dialog.get_url()
+ if url:
+ media = Grl.Media()
+ media.set_url(url)
+ else:
+ media = Grl.MediaBox()
+ media.set_title(dialog.get_title())
+ media.set_description(dialog.get_description())
+ source.store(container,
+ media,
+ self._store_cb,
+ None)
+ dialog.destroy()
def _remove_btn_clicked_cb(self, *args):
pass
@@ -374,10 +397,22 @@ class MainWindow(Gtk.Window):
else:
self._show_btn.set_sensitive(False)
+ def _store_cb(source, box, media, user_data, error):
+ print 'Media stored'
+
def _browse_history_push (self, source, media):
self._ui_state.source_stack.append(source)
self._ui_state.container_stack.append(media)
+ def _browse_history_pop(self):
+ prev_source, prev_container = (None, None)
+ if self._ui_state.source_stack and \
+ self._ui_state.container_stack:
+ prev_source = self._ui_state.source_stack.pop()
+ prev_container = self._ui_state.container_stack.pop()
+
+ return prev_source, prev_container
+
def _cancel_current_operation(self):
if self._ui_state.op_ongoing:
if not self._ui_state.multiple:
@@ -460,6 +495,44 @@ class MainWindow(Gtk.Window):
def _quit(self, *args):
Gtk.main_quit()
+class StoreContentDialog(Gtk.Dialog):
+ def __init__(self, parent):
+ super(StoreContentDialog, self).__init__(title='Store content',
+ parent=parent,
+ flags=Gtk.DialogFlags.MODAL |
+ Gtk.DialogFlags.DESTROY_WITH_PARENT,
+ buttons=(Gtk.STOCK_OK, Gtk.ResponseType.OK,
+ Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL))
+ self._setup_ui()
+ self.show_all()
+
+ def _setup_ui(self):
+ self.vbox = self.get_child()
+
+ self._title_entry = Gtk.Entry()
+ self._url_entry = Gtk.Entry()
+ self._description_entry = Gtk.Entry()
+
+ entries = [self._title_entry, self._url_entry, self._description_entry]
+ labels = ['Title:', 'URL:', 'Description:']
+
+ for i in range(3):
+ box = Gtk.HBox()
+ label = Gtk.Label(label=labels[i])
+ entry = entries[i]
+ box.add(label)
+ box.add(entry)
+ self.vbox.add(box)
+
+ def get_title(self):
+ return self._title_entry.get_text()
+
+ def get_url(self):
+ return self._url_entry.get_text()
+
+ def get_description(self):
+ return self._description_entry.get_text()
+
class UriLaunchers(object):
def __init__(self):
self.eog = Gio.app_info_create_from_commandline('eog',
--
1.7.0.4
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]