Merge lp:~sil/lolocopter/save-in-couch into lp:lolocopter

Proposed by Stuart Langridge
Status: Merged
Approved by: Jono Bacon
Approved revision: not available
Merged at revision: not available
Proposed branch: lp:~sil/lolocopter/save-in-couch
Merge into: lp:lolocopter
Diff against target: 211 lines (+109/-15)
3 files modified
bin/lolocopter (+49/-6)
data/ui/LolocopterWindow.ui (+50/-8)
lolocopter/AddSoundLolocopterDialog.py (+10/-1)
To merge this branch: bzr merge lp:~sil/lolocopter/save-in-couch
Reviewer Review Type Date Requested Status
Jono Bacon Approve
Review via email: mp+14899@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Stuart Langridge (sil) wrote :

Make the lolocopter part of the mighty desktopcouch empire

Revision history for this message
Jono Bacon (jonobacon) wrote :

Looks great.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'bin/lolocopter'
--- bin/lolocopter 2009-11-14 18:50:55 +0000
+++ bin/lolocopter 2009-11-15 21:55:18 +0000
@@ -19,6 +19,7 @@
19import os19import os
20import gtk20import gtk
21import gst21import gst
22import xdg.BaseDirectory
2223
23# Check if we are working in the source tree or from the installed 24# Check if we are working in the source tree or from the installed
24# package and mangle the python path accordingly25# package and mangle the python path accordingly
@@ -35,6 +36,8 @@
35from lolocopter.lolocopterconfig import getdatapath36from lolocopter.lolocopterconfig import getdatapath
36from lolocopter.lolocopter_server import CopterDiscoverer, LolocopterServer37from lolocopter.lolocopter_server import CopterDiscoverer, LolocopterServer
3738
39from desktopcouch.records.server import CouchDatabase
40
38gtk.gdk.threads_init()41gtk.gdk.threads_init()
3942
40class LolocopterWindow(gtk.Window):43class LolocopterWindow(gtk.Window):
@@ -68,19 +71,60 @@
6871
69 #code for other initialization actions should be added here72 #code for other initialization actions should be added here
70 self.pipeline = gst.Pipeline("mypipeline")73 self.pipeline = gst.Pipeline("mypipeline")
71 self.builder.get_object("play_trombone").connect("clicked",self.playFile,"/home/jono/Desktop/sadtrombone.mp3")
72 self.builder.get_object("play_keyboardcat").connect("clicked",self.playFile,"/home/jono/Desktop/keyboardcat.mp3")
73 74
74 # Start the CopterDiscoverer75 # Start the CopterDiscoverer
75 disc = CopterDiscoverer(self.newLolocopterAppears, None)76 disc = CopterDiscoverer(self.newLolocopterAppears, None)
76 disc.start()77 disc.start()
7778
78 # Start a background server (remove this later)79 self.mylol_vbox = self.builder.get_object("mylols")
79 srv = LolocopterServer(1, "foo", "bar", None)80 self.otherlol_vbox = self.builder.get_object("otherlols")
80 srv.start_server()81
82 self.loadMyLOLs()
83
84 def loadMyLOLs(self):
85 # query couch
86 db = CouchDatabase("lolocopter", create=True)
87 for record in db.get_records(create_view=True,
88 record_type="http://launchpad.net/lolocopter/saved_sound"):
89 self.loadOneMyLOL(record.value["filename"], record.value["label"])
90
91 def loadOneMyLOL(self, filename, name):
92 print "loading", filename, name
93 hbox = gtk.HBox()
94 lbl = gtk.Label(name)
95 playbtn = gtk.Button(stock=gtk.STOCK_MEDIA_PLAY)
96 playbtn.connect("clicked", self.playFile,
97 os.path.join(
98 xdg.BaseDirectory.save_data_path('lolocopter'),
99 "sounds",
100 filename))
101 sharebtn = gtk.ToggleButton(label="Share")
102 sharebtn.connect("toggled", self.shareTheLOL, filename, name)
103 hbox.pack_start(lbl)
104 hbox.pack_start(playbtn)
105 hbox.pack_start(sharebtn)
106 self.mylol_vbox.pack_end(hbox)
107 hbox.show_all()
81 108
82 def newLolocopterAppears(self, lolname, personname, host, port):109 def newLolocopterAppears(self, lolname, personname, host, port):
83 print "As if by magic, a lolocopter appears!", lolname, personname, host, port110 print "As if by magic, a lolocopter appears!", lolname, personname, host, port
111 description = "%s, provided by %s" % (lolname, personname)
112 hbox = gtk.HBox()
113 lbl = gtk.Label("<big>%s</big> by %s" % (lolname, personname))
114 joinbtn = gtk.Button(label="Join the Denial of LOL")
115 joinbtn.connect("clicked", self.joinTheLOL, host, port)
116 hbox.pack_start(lbl)
117 hbox.pack_start(joinbtn)
118 self.otherlol_vbox.pack_end(hbox)
119 hbox.show_all()
120
121 def joinTheLOL(self, host, port):
122 print "joining lol on host/port", host, port
123
124 def shareTheLOL(self, widget, filename, name):
125 srv = LolocopterServer(10000, name, "Someone's Computer", None)
126 srv.start_server()
127
84128
85 def about(self, widget, data=None):129 def about(self, widget, data=None):
86 """about - display the about box for lolocopter """130 """about - display the about box for lolocopter """
@@ -90,7 +134,6 @@
90134
91 def addSounds(self, widget, data=None):135 def addSounds(self, widget, data=None):
92 """add sounds to the lolocopter"""136 """add sounds to the lolocopter"""
93 print "Add Sounds dialog box"
94 addsound = AddSoundLolocopterDialog.NewAddSoundLolocopterDialog()137 addsound = AddSoundLolocopterDialog.NewAddSoundLolocopterDialog()
95 response = addsound.run()138 response = addsound.run()
96 if response == gtk.RESPONSE_OK:139 if response == gtk.RESPONSE_OK:
97140
=== modified file 'data/ui/LolocopterWindow.ui'
--- data/ui/LolocopterWindow.ui 2009-11-14 17:18:08 +0000
+++ data/ui/LolocopterWindow.ui 2009-11-15 21:55:18 +0000
@@ -75,26 +75,68 @@
75 </packing>75 </packing>
76 </child>76 </child>
77 <child>77 <child>
78 <object class="GtkButton" id="play_trombone">78 <object class="GtkExpander" id="expander1">
79 <property name="label" translatable="yes">Trombone</property>
80 <property name="visible">True</property>79 <property name="visible">True</property>
81 <property name="can_focus">True</property>80 <property name="can_focus">True</property>
82 <property name="receives_default">True</property>81 <property name="expanded">True</property>
82 <child>
83 <object class="GtkScrolledWindow" id="scrolledwindow1">
84 <property name="visible">True</property>
85 <property name="can_focus">True</property>
86 <property name="hscrollbar_policy">automatic</property>
87 <property name="vscrollbar_policy">automatic</property>
88 <child>
89 <object class="GtkVBox" id="mylols">
90 <property name="visible">True</property>
91 <property name="orientation">vertical</property>
92 <child>
93 <placeholder/>
94 </child>
95 </object>
96 </child>
97 </object>
98 </child>
99 <child type="label">
100 <object class="GtkLabel" id="label1">
101 <property name="visible">True</property>
102 <property name="label" translatable="yes">My LOLs</property>
103 </object>
104 </child>
83 </object>105 </object>
84 <packing>106 <packing>
85 <property name="expand">False</property>
86 <property name="position">1</property>107 <property name="position">1</property>
87 </packing>108 </packing>
88 </child>109 </child>
89 <child>110 <child>
90 <object class="GtkButton" id="play_keyboardcat">111 <object class="GtkExpander" id="expander2">
91 <property name="label" translatable="yes">Keyboard Cat</property>
92 <property name="visible">True</property>112 <property name="visible">True</property>
93 <property name="can_focus">True</property>113 <property name="can_focus">True</property>
94 <property name="receives_default">True</property>114 <property name="expanded">True</property>
115 <child>
116 <object class="GtkScrolledWindow" id="scrolledwindow2">
117 <property name="visible">True</property>
118 <property name="can_focus">True</property>
119 <property name="hscrollbar_policy">automatic</property>
120 <property name="vscrollbar_policy">automatic</property>
121 <child>
122 <object class="GtkVBox" id="otherlols">
123 <property name="visible">True</property>
124 <property name="orientation">vertical</property>
125 <child>
126 <placeholder/>
127 </child>
128 </object>
129 </child>
130 </object>
131 </child>
132 <child type="label">
133 <object class="GtkLabel" id="label2">
134 <property name="visible">True</property>
135 <property name="label" translatable="yes">LOLs from around the network</property>
136 </object>
137 </child>
95 </object>138 </object>
96 <packing>139 <packing>
97 <property name="expand">False</property>
98 <property name="position">2</property>140 <property name="position">2</property>
99 </packing>141 </packing>
100 </child>142 </child>
101143
=== modified file 'lolocopter/AddSoundLolocopterDialog.py'
--- lolocopter/AddSoundLolocopterDialog.py 2009-11-14 19:22:56 +0000
+++ lolocopter/AddSoundLolocopterDialog.py 2009-11-15 21:55:18 +0000
@@ -21,6 +21,8 @@
21import shutil21import shutil
2222
23from lolocopter.lolocopterconfig import getdatapath23from lolocopter.lolocopterconfig import getdatapath
24from desktopcouch.records.server import CouchDatabase
25from desktopcouch.records.record import Record
2426
25class AddSoundLolocopterDialog(gtk.Dialog):27class AddSoundLolocopterDialog(gtk.Dialog):
26 __gtype_name__ = "AddSoundLolocopterDialog"28 __gtype_name__ = "AddSoundLolocopterDialog"
@@ -63,6 +65,7 @@
63 """ok - The user has elected to save the changes.65 """ok - The user has elected to save the changes.
64 Called before the dialog returns gtk.RESONSE_OK from run().66 Called before the dialog returns gtk.RESONSE_OK from run().
65 Copies the sound over to the 'lolocopter/sounds' folder67 Copies the sound over to the 'lolocopter/sounds' folder
68 and adds it to the database
66 """69 """
6770
68 # copy the file to the sounds folder71 # copy the file to the sounds folder
@@ -71,7 +74,13 @@
71 # this is the label of the sound74 # this is the label of the sound
72 self.lol_name = self.lolname.get_text()75 self.lol_name = self.lolname.get_text()
73 76
74 77 # Add sound to the database
78 db = CouchDatabase("lolocopter", create=True)
79 record = Record({
80 "label": self.lol_name,
81 "filename": os.path.split(self.lolfile.get_filename())[1]
82 }, record_type="http://launchpad.net/lolocopter/saved_sound") # FIXME
83 rid = db.put_record(record)
7584
76 def cancel(self, widget, data=None):85 def cancel(self, widget, data=None):
77 """cancel - The user has elected cancel changes.86 """cancel - The user has elected cancel changes.

Subscribers

People subscribed via source and target branches

to all changes: