Merge lp:~sense/lernid/connection-change into lp:lernid

Proposed by Sense Egbert Hofstede
Status: Rejected
Rejected by: Jono Bacon
Proposed branch: lp:~sense/lernid/connection-change
Merge into: lp:lernid
Diff against target: 748 lines (+245/-341)
6 files modified
bin/lernid (+95/-25)
data/ui/ConnectDialog.ui (+0/-161)
data/ui/LernidWindow.ui (+147/-2)
data/ui/connect_dialog.xml (+0/-9)
lernid/ConnectDialog.py (+0/-143)
lernid/IrcBackend.py (+3/-1)
To merge this branch: bzr merge lp:~sense/lernid/connection-change
Reviewer Review Type Date Requested Status
Jono Bacon Disapprove
Review via email: mp+16571@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Sense Egbert Hofstede (sense) wrote :

This change is a bit radical and solves bug #496516 by removing the Connection dialogue completely. Completely? Yes, completely. However, its content is copied to a separate GtkAlignment that was added in the 'main_vbox' just under the GtkAlignment containing the main content. I've named the first 'alignment_connect' and renamed the latter to 'alignment_loaded'.

From a user perspective you could say that the connection part is loaded 'on top' of the actual window content. By default 'alignment_loaded' is hidden and 'alignment_connect' is shown. When you connect this is inverted. Maybe in the future a nice fade in/out animation could be added! ;)
When pressing "Connect" in the menu, 'alignment_loaded' is hidden again and 'alignment_connect' is shown again. All fields are still in the same state as when the user pressed Connect, so (s)he won't have to enter his/her nickname again.

File->Disconnect is now insensitive when you aren't connected.

I've forgot to mention it in the changelog, but now Lernid also refuses to process the connection request if the nickname field is empty, the Connect button simply doesn't work. (Of course, it does actually work, but it stops all processing when the nickname is empty.)

I realise that the interface change is a large one, so you might not like it. It's just a proposal, so don't feel bad when you decline it!

(Where the small fixes extras to push you over the line? Maybe! But they can probably easily be taken out of the diff and be implemented anyway.)

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

Thanks for the patch, Sense! I am not particularly keen on the user interface change and I don't see what particular usability issues it resolves. Maybe this is something we could investigate post 1.0 if you still feel there is work to be done?

Revision history for this message
Jono Bacon (jonobacon) :
review: Disapprove
Revision history for this message
Sense Egbert Hofstede (sense) wrote :

I understand why you reject it. I'm not that fond of its look as well, but I do think that getting rid of the dialogue is worth it.
Because that was the main reason I did this, instead of two separate windows -- one of which is insensitive -- there is now just one window.
It also provides more space than the connection dialogue does, eventually this stage of the user's participation to an event could be used for explaining Lernid and the used tools.
When there 1.0 has been released there will be more time to investigate different approaches to the UI, maybe then we could have a look at this idea again, that is, if it is still applicable to the Lernid interface.

I'll take the fixes out of this branch and submit a separate merge proposal for them.

Unmerged revisions

75. By Sense Egbert Hofstede

* Moved the definition of self.irc to LernidWindow.finish_initializing() and added 'self.conn = None' to IrcBackend.Irc.__init__(); this is part of the fix for LP #496516
* Removed ConnectDialog, replacing its functionality with an GtkAlignment added to LeridWindow. The connection form now sits 'on top' of the window content; this is the rest of the fix for LP #496516
* 'menu_disconnect' is now insensitive when there is no connection and sensitive when there is

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bin/lernid'
2--- bin/lernid 2009-12-24 01:34:45 +0000
3+++ bin/lernid 2009-12-24 15:49:12 +0000
4@@ -25,6 +25,7 @@
5 import pynotify
6 import gettext
7 import gio
8+import gobject
9 import vobject
10 import time
11 import datetime
12@@ -46,7 +47,7 @@
13 fullPath = os.getcwd()
14 sys.path.insert(0, os.path.dirname(fullPath))
15
16-from lernid import AboutLernidDialog, PreferencesLernidDialog, ConnectDialog, IrcBackend
17+from lernid import AboutLernidDialog, PreferencesLernidDialog, IrcBackend
18 from lernid.lernidconfig import getdatapath, save_cache_path
19
20 class LernidWindow(gtk.Window):
21@@ -78,12 +79,9 @@
22 #dlg = PreferencesLernidDialog.NewPreferencesLernidDialog()
23 #self.preferences = dlg.get_preferences()
24
25- #code for other initialization actions should be added here
26-
27- # set up configuration file directory
28-
29 self.setup_notifications()
30-
31+
32+ # set up data, configuration and cache directories
33 self.lernidcachefolder = save_cache_path('lernid')
34 self.lerniddatafolder = xdg.BaseDirectory.save_data_path('lernid')
35 self.lernidcachefolder_events = os.path.join(self.lernidcachefolder, "events")
36@@ -95,12 +93,15 @@
37 self.monitor.connect("changed", self.classroom_log_changed)
38
39 # set up views
40-
41+
42+ self.alignment_connect = self.builder.get_object("alignment_connect")
43+ self.alignment_loaded = self.builder.get_object("alignment_loaded")
44 self.browser_scroll = self.builder.get_object("browser_scroll")
45 self.classroom_textview = self.builder.get_object("classroom_textview")
46 self.classroom_scroll = self.builder.get_object("classroom_scroll")
47 self.classroom_scrollbar = self.builder.get_object("adjustment1")
48- self.chat_scroll = self.builder.get_object("chat_scroll")
49+ self.chat_scroll = self.builder.get_object("chat_scroll")
50+ self.irc = IrcBackend.Irc()
51 self.main_window = self.builder.get_object("lernid_window")
52 self.browser_combo = self.builder.get_object("browser_combo")
53 self.slide_scroll = self.builder.get_object("slide_scroll")
54@@ -141,8 +142,6 @@
55 self.eventhomepage = None
56
57 self.chat.grab_focus()
58-
59- self.main_window.show_all()
60
61 self.browser.hide()
62 self.chat.hide()
63@@ -177,7 +176,8 @@
64 self.tvcolumn.set_attributes(self.cell_time, text=2)
65 self.tvcolumn.set_attributes(self.cell_title, text=3)
66
67- self.connect_dialog(None)
68+ # ready the connection selector for use
69+ self.populate_connection_view()
70
71 def change_slide(self, slidenumber):
72 firstpage = "-dFirstPage=" + str(slidenumber)
73@@ -345,6 +345,42 @@
74 urllib.urlretrieve(sess['slides'], os.path.join(self.lerniddatafolder, "slides.pdf"))
75 self.currentsession_downloadedslides = True
76
77+ def populate_connection_view(self):
78+ # download event data
79+ config = ConfigParser.ConfigParser()
80+
81+ urllib.urlretrieve('http://www.jonobacon.org/files/lernid/ubuntu.lernid', os.path.join(self.lernidcachefolder_events, "config.lernid"))
82+ #output = open(os.path.join(self.lernidcachefolder_events, "temp.txt"),'wb')
83+
84+ #output.write(response.read())
85+ #output.close
86+
87+ # copy file
88+
89+ #shutil.copy(os.path.join(self.lernidcachefolder_events, "temp.txt"),os.path.join(self.lernidcachefolder_events, "ubuntu.txt"))
90+
91+ # read file
92+
93+ config.read(os.path.join(self.lernidcachefolder_events, "config.lernid"))
94+
95+ sections = config.sections()
96+ logging.debug(sections)
97+
98+ store = gtk.ListStore(gobject.TYPE_STRING)
99+
100+ logging.debug("sections")
101+ for s in sections:
102+ logging.debug(s)
103+ store.append([s])
104+
105+ self.event_combo = self.builder.get_object("event_combo")
106+
107+ self.event_combo.set_model(store)
108+ cell = gtk.CellRendererText()
109+ self.event_combo.pack_start(cell, True)
110+ self.event_combo.add_attribute(cell, 'text',0)
111+ self.event_combo.set_active(0)
112+
113 def populate_schedule_view(self):
114 """Populate the schedule Treeview with events"""
115
116@@ -417,19 +453,40 @@
117 n = pynotify.Notification(s)
118 n.show()
119
120+ def connect_cancel(self, widget):
121+ """Connection was canceled, either return to the previous session
122+ or exit Lernid"""
123+
124+ if self.firstrun == True:
125+ # No previous connection, exiting the application
126+ self.destroy()
127+ else:
128+ # return to the previous session
129+ # hide the connection selector and show the session thing
130+ self.alignment_connect.hide()
131+ self.alignment_loaded.show()
132+
133 def connect_dialog(self, widget):
134- """Show the connect dialog and connect to the resources."""
135-
136- connectdialog = ConnectDialog.NewConnectDialog()
137- result = connectdialog.run()
138-
139- if result == gtk.RESPONSE_OK:
140- logging.debug("ok")
141- self.nick = connectdialog.builder.get_object("nick_textentry").get_text()
142- self.event = connectdialog.builder.get_object("event_combo").get_active_text()
143+ """Show the connection selector once again"""
144+ self.alignment_connect.show()
145+ self.alignment_loaded.hide()
146+
147+ def connect_ok(self, widget):
148+ """Create a new selection"""
149+
150+ nick = self.builder.get_object("nick_textentry").get_text()
151+ if nick is not None and nick is not "":
152+ # a nickname was provided, so we can continue
153+ self.nick = nick
154+ self.event = self.builder.get_object("event_combo").get_active_text()
155 self.connect_to_resources()
156- else:
157- self.destroy()
158+
159+ # we now have had a first run
160+ self.firstrun = False
161+
162+ # hide the connection selector and show the session thing
163+ self.alignment_connect.hide()
164+ self.alignment_loaded.show()
165
166 def setup_notifications(self):
167 """Set up notification settings."""
168@@ -465,6 +522,9 @@
169 context_id = self.statusbar.get_context_id('event')
170 self.statusbar.push(context_id, _('Connected to ') + self.event)
171 self.send_notification(_("Connected to ") + self.event)
172+
173+ # set the disconnect menu item to sensitive
174+ self.builder.get_object("menu_disconnect").set_sensitive(True)
175
176 config = ConfigParser.ConfigParser()
177 config.read(os.path.join(self.lernidcachefolder_events, "config.lernid"))
178@@ -475,7 +535,7 @@
179
180 urllib.urlretrieve(config.get(self.event, "icalurl"), os.path.join(self.lernidcachefolder_events, "schedule.ical"))
181
182- self.irc = IrcBackend.Irc()
183+ # Connect to the classroom IRC channel
184 self.irc.tp_connect("lernid_" + self.nick, "irc.freenode.net", config.get(self.event, "classroom"))
185
186 self.browser.show()
187@@ -491,6 +551,10 @@
188 """Disconnect from the currently selected event."""
189
190 logging.debug("Disconnecting from %s" % self.event)
191+
192+ # set the disconnect menu item to insensitive
193+ self.builder.get_object("menu_disconnect").set_sensitive(False)
194+
195 self.irc.disconnect()
196
197 self.send_notification(_("Disconnecting from ") + self.event)
198@@ -594,13 +658,20 @@
199
200 def quit(self, widget, data=None):
201 """quit - signal handler for closing the LernidWindow"""
202+ # properly disconnect from IRC first
203 self.irc.disconnect()
204+
205+ # now end the GTK+ MainLoop
206 gtk.main_quit()
207
208 def on_destroy(self, widget, data=None):
209- """on_destroy - called when the LernidWindow is close. """
210+ """on_destroy - called when the LernidWindow is closed """
211 #clean up code for saving application state should be added here
212+
213+ # properly disconnect from IRC first
214 self.irc.disconnect()
215+
216+ # now end the GTK+ MainLoop
217 gtk.main_quit()
218
219 def toggle_fullscreen(self, menuitem):
220@@ -653,4 +724,3 @@
221 window.show()
222 gtk.main()
223
224-
225
226=== removed file 'data/ui/ConnectDialog.ui'
227--- data/ui/ConnectDialog.ui 2009-12-23 13:29:26 +0000
228+++ data/ui/ConnectDialog.ui 1970-01-01 00:00:00 +0000
229@@ -1,161 +0,0 @@
230-<?xml version="1.0"?>
231-<interface>
232- <requires lib="gtk+" version="2.16"/>
233- <!-- interface-requires connect_dialog 1.0 -->
234- <!-- interface-naming-policy project-wide -->
235- <object class="ConnectDialog" id="connect_dialog">
236- <property name="border_width">6</property>
237- <property name="title" translatable="yes">Choose an event</property>
238- <property name="resizable">False</property>
239- <property name="modal">True</property>
240- <property name="window_position">center-on-parent</property>
241- <property name="destroy_with_parent">True</property>
242- <property name="icon">../media/icon.png</property>
243- <property name="type_hint">normal</property>
244- <property name="skip_taskbar_hint">True</property>
245- <property name="has_separator">False</property>
246- <signal name="close" handler="cancel"/>
247- <signal name="delete_event" handler="cancel"/>
248- <child internal-child="vbox">
249- <object class="GtkVBox" id="dialog-vbox1">
250- <property name="visible">True</property>
251- <property name="orientation">vertical</property>
252- <child>
253- <object class="GtkVBox" id="vbox1">
254- <property name="visible">True</property>
255- <property name="border_width">6</property>
256- <property name="orientation">vertical</property>
257- <child>
258- <object class="GtkImage" id="image1">
259- <property name="pixbuf">logo.png</property>
260- </object>
261- <packing>
262- <property name="position">0</property>
263- </packing>
264- </child>
265- <child>
266- <object class="GtkTable" id="table1">
267- <property name="visible">True</property>
268- <property name="n_rows">2</property>
269- <property name="n_columns">2</property>
270- <property name="column_spacing">12</property>
271- <property name="row_spacing">6</property>
272- <child>
273- <object class="GtkLabel" id="label1">
274- <property name="visible">True</property>
275- <property name="xalign">0</property>
276- <property name="xpad">3</property>
277- <property name="ypad">3</property>
278- <property name="label" translatable="yes">Event:</property>
279- </object>
280- <packing>
281- <property name="x_options">GTK_FILL</property>
282- <property name="y_options"></property>
283- </packing>
284- </child>
285- <child>
286- <object class="GtkLabel" id="label2">
287- <property name="visible">True</property>
288- <property name="xalign">0</property>
289- <property name="xpad">3</property>
290- <property name="ypad">3</property>
291- <property name="label" translatable="yes">Nickname:</property>
292- </object>
293- <packing>
294- <property name="top_attach">1</property>
295- <property name="bottom_attach">2</property>
296- <property name="x_options">GTK_FILL</property>
297- <property name="y_options"></property>
298- </packing>
299- </child>
300- <child>
301- <object class="GtkComboBox" id="event_combo">
302- <property name="visible">True</property>
303- <signal name="changed" handler="check_ready_to_connect"/>
304- </object>
305- <packing>
306- <property name="left_attach">1</property>
307- <property name="right_attach">2</property>
308- <property name="y_options"></property>
309- </packing>
310- </child>
311- <child>
312- <object class="GtkEntry" id="nick_textentry">
313- <property name="visible">True</property>
314- <property name="can_focus">True</property>
315- <property name="invisible_char">&#x25CF;</property>
316- <property name="activates_default">True</property>
317- <signal name="changed" handler="check_ready_to_connect"/>
318- </object>
319- <packing>
320- <property name="left_attach">1</property>
321- <property name="right_attach">2</property>
322- <property name="top_attach">1</property>
323- <property name="bottom_attach">2</property>
324- <property name="y_options"></property>
325- </packing>
326- </child>
327- </object>
328- <packing>
329- <property name="expand">False</property>
330- <property name="position">1</property>
331- </packing>
332- </child>
333- </object>
334- <packing>
335- <property name="position">1</property>
336- </packing>
337- </child>
338- <child internal-child="action_area">
339- <object class="GtkHButtonBox" id="dialog-action_area1">
340- <property name="visible">True</property>
341- <property name="layout_style">end</property>
342- <child>
343- <object class="GtkButton" id="button_cancel">
344- <property name="label">gtk-cancel</property>
345- <property name="visible">True</property>
346- <property name="can_focus">True</property>
347- <property name="receives_default">True</property>
348- <property name="use_stock">True</property>
349- <signal name="clicked" handler="cancel"/>
350- </object>
351- <packing>
352- <property name="expand">False</property>
353- <property name="fill">False</property>
354- <property name="position">0</property>
355- </packing>
356- </child>
357- <child>
358- <object class="GtkButton" id="button_connect">
359- <property name="label">gtk-connect</property>
360- <property name="visible">True</property>
361- <property name="sensitive">False</property>
362- <property name="can_focus">True</property>
363- <property name="can_default">True</property>
364- <property name="has_default">True</property>
365- <property name="receives_default">True</property>
366- <property name="use_stock">True</property>
367- <signal name="clicked" handler="ok"/>
368- </object>
369- <packing>
370- <property name="expand">False</property>
371- <property name="fill">False</property>
372- <property name="position">1</property>
373- </packing>
374- </child>
375- </object>
376- <packing>
377- <property name="expand">False</property>
378- <property name="pack_type">end</property>
379- <property name="position">0</property>
380- </packing>
381- </child>
382- </object>
383- </child>
384- <action-widgets>
385- <action-widget response="-6">button_cancel</action-widget>
386- <action-widget response="-5">button_connect</action-widget>
387- </action-widgets>
388- </object>
389- <object class="GtkListStore" id="liststore1"/>
390-</interface>
391
392=== modified file 'data/ui/LernidWindow.ui'
393--- data/ui/LernidWindow.ui 2009-12-24 01:34:45 +0000
394+++ data/ui/LernidWindow.ui 2009-12-24 15:49:12 +0000
395@@ -42,6 +42,7 @@
396 <object class="GtkImageMenuItem" id="menu_disconnect">
397 <property name="label">gtk-disconnect</property>
398 <property name="visible">True</property>
399+ <property name="sensitive">False</property>
400 <property name="use_underline">True</property>
401 <property name="use_stock">True</property>
402 <signal name="activate" handler="disconnect_from_resources"/>
403@@ -123,8 +124,7 @@
404 </packing>
405 </child>
406 <child>
407- <object class="GtkAlignment" id="alignment1">
408- <property name="visible">True</property>
409+ <object class="GtkAlignment" id="alignment_loaded">
410 <property name="top_padding">6</property>
411 <property name="bottom_padding">6</property>
412 <property name="left_padding">6</property>
413@@ -448,6 +448,151 @@
414 </packing>
415 </child>
416 <child>
417+ <object class="GtkAlignment" id="alignment_connect">
418+ <property name="visible">True</property>
419+ <child>
420+ <object class="GtkVBox" id="vbox2">
421+ <property name="visible">True</property>
422+ <property name="orientation">vertical</property>
423+ <child>
424+ <object class="GtkVBox" id="vbox3">
425+ <property name="visible">True</property>
426+ <property name="border_width">6</property>
427+ <property name="orientation">vertical</property>
428+ <child>
429+ <object class="GtkImage" id="image3">
430+ <property name="pixbuf">logo.png</property>
431+ </object>
432+ <packing>
433+ <property name="position">0</property>
434+ </packing>
435+ </child>
436+ <child>
437+ <object class="GtkTable" id="table1">
438+ <property name="visible">True</property>
439+ <property name="n_rows">2</property>
440+ <property name="n_columns">2</property>
441+ <property name="column_spacing">12</property>
442+ <property name="row_spacing">6</property>
443+ <child>
444+ <object class="GtkLabel" id="label1">
445+ <property name="visible">True</property>
446+ <property name="xalign">0</property>
447+ <property name="xpad">3</property>
448+ <property name="ypad">3</property>
449+ <property name="label" translatable="yes">Event:</property>
450+ </object>
451+ <packing>
452+ <property name="x_options">GTK_FILL</property>
453+ <property name="y_options"></property>
454+ </packing>
455+ </child>
456+ <child>
457+ <object class="GtkLabel" id="label2">
458+ <property name="visible">True</property>
459+ <property name="xalign">0</property>
460+ <property name="xpad">3</property>
461+ <property name="ypad">3</property>
462+ <property name="label" translatable="yes">Nickname:</property>
463+ </object>
464+ <packing>
465+ <property name="top_attach">1</property>
466+ <property name="bottom_attach">2</property>
467+ <property name="x_options">GTK_FILL</property>
468+ <property name="y_options"></property>
469+ </packing>
470+ </child>
471+ <child>
472+ <object class="GtkComboBox" id="event_combo">
473+ <property name="visible">True</property>
474+ </object>
475+ <packing>
476+ <property name="left_attach">1</property>
477+ <property name="right_attach">2</property>
478+ <property name="y_options"></property>
479+ </packing>
480+ </child>
481+ <child>
482+ <object class="GtkEntry" id="nick_textentry">
483+ <property name="visible">True</property>
484+ <property name="can_focus">True</property>
485+ <property name="has_focus">True</property>
486+ <property name="can_default">True</property>
487+ <property name="invisible_char">&#x25CF;</property>
488+ <property name="activates_default">True</property>
489+ </object>
490+ <packing>
491+ <property name="left_attach">1</property>
492+ <property name="right_attach">2</property>
493+ <property name="top_attach">1</property>
494+ <property name="bottom_attach">2</property>
495+ <property name="y_options"></property>
496+ </packing>
497+ </child>
498+ </object>
499+ <packing>
500+ <property name="fill">False</property>
501+ <property name="position">1</property>
502+ </packing>
503+ </child>
504+ </object>
505+ <packing>
506+ <property name="expand">False</property>
507+ <property name="fill">False</property>
508+ <property name="position">0</property>
509+ </packing>
510+ </child>
511+ <child>
512+ <object class="GtkHButtonBox" id="hbuttonbox1">
513+ <property name="visible">True</property>
514+ <property name="layout_style">center</property>
515+ <child>
516+ <object class="GtkButton" id="button_cancel">
517+ <property name="label">gtk-cancel</property>
518+ <property name="visible">True</property>
519+ <property name="can_focus">True</property>
520+ <property name="receives_default">True</property>
521+ <property name="use_stock">True</property>
522+ <signal name="clicked" handler="connect_cancel"/>
523+ </object>
524+ <packing>
525+ <property name="expand">False</property>
526+ <property name="fill">False</property>
527+ <property name="position">0</property>
528+ </packing>
529+ </child>
530+ <child>
531+ <object class="GtkButton" id="button_connect">
532+ <property name="label">gtk-connect</property>
533+ <property name="visible">True</property>
534+ <property name="can_focus">True</property>
535+ <property name="can_default">True</property>
536+ <property name="has_default">True</property>
537+ <property name="receives_default">True</property>
538+ <property name="use_stock">True</property>
539+ <signal name="clicked" handler="connect_ok"/>
540+ </object>
541+ <packing>
542+ <property name="expand">False</property>
543+ <property name="fill">False</property>
544+ <property name="position">1</property>
545+ </packing>
546+ </child>
547+ </object>
548+ <packing>
549+ <property name="expand">False</property>
550+ <property name="fill">False</property>
551+ <property name="position">1</property>
552+ </packing>
553+ </child>
554+ </object>
555+ </child>
556+ </object>
557+ <packing>
558+ <property name="position">2</property>
559+ </packing>
560+ </child>
561+ <child>
562 <object class="GtkStatusbar" id="statusbar">
563 <property name="visible">True</property>
564 <property name="spacing">2</property>
565
566=== removed file 'data/ui/connect_dialog.xml'
567--- data/ui/connect_dialog.xml 2009-11-25 03:46:57 +0000
568+++ data/ui/connect_dialog.xml 1970-01-01 00:00:00 +0000
569@@ -1,9 +0,0 @@
570-<glade-catalog name="connect_dialog" domain="glade-3"
571- depends="gtk+" version="1.0">
572- <glade-widget-classes>
573- <glade-widget-class title="sentence_name Dialog" name="ConnectDialog"
574- generic-name="connect_dialog" parent="GtkDialog"
575- icon-name="widget-gtk-dialog"/>
576- </glade-widget-classes>
577-
578-</glade-catalog>
579
580=== removed file 'lernid/ConnectDialog.py'
581--- lernid/ConnectDialog.py 2009-12-23 20:25:36 +0000
582+++ lernid/ConnectDialog.py 1970-01-01 00:00:00 +0000
583@@ -1,143 +0,0 @@
584-# -*- coding: utf-8 -*-
585-### BEGIN LICENSE
586-# Copyright (C) 2009 <Jono Bacon> <jono@ubuntu.com>
587-#This program is free software: you can redistribute it and/or modify it
588-#under the terms of the GNU General Public License version 3, as published
589-#by the Free Software Foundation.
590-#
591-#This program is distributed in the hope that it will be useful, but
592-#WITHOUT ANY WARRANTY; without even the implied warranties of
593-#MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
594-#PURPOSE. See the GNU General Public License for more details.
595-#
596-#You should have received a copy of the GNU General Public License along
597-#with this program. If not, see <http://www.gnu.org/licenses/>.
598-### END LICENSE
599-
600-import os
601-import gtk
602-import ConfigParser
603-import gobject
604-import urllib
605-import xdg.BaseDirectory
606-import logging
607-
608-from lernid.lernidconfig import getdatapath, save_cache_path
609-
610-class ConnectDialog(gtk.Dialog):
611- __gtype_name__ = "ConnectDialog"
612-
613- def __init__(self):
614- """__init__ - This function is typically not called directly.
615- Creation of a ConnectDialog requires redeading the associated ui
616- file and parsing the ui definition extrenally,
617- and then calling ConnectDialog.finish_initializing().
618-
619- Use the convenience function NewConnectDialog to create
620- a ConnectDialog object.
621-
622- """
623- pass
624-
625- def finish_initializing(self, builder):
626- """finish_initalizing should be called after parsing the ui definition
627- and creating a ConnectDialog object with it in order to finish
628- initializing the start of the new ConnectDialog instance.
629-
630- """
631- #get a reference to the builder and set up the signals
632- self.builder = builder
633- self.builder.connect_signals(self)
634-
635- # create config folder
636- self.lernidcachefolder = save_cache_path('lernid')
637- self.lerniddatafolder = xdg.BaseDirectory.save_data_path('lernid')
638- self.lernidcachefolder_events = os.path.join(self.lernidcachefolder, "events")
639-
640- try:
641- os.mkdir(self.lernidcachefolder_events)
642- except:
643- pass
644-
645- # download event data
646-
647- config = ConfigParser.ConfigParser()
648-
649- urllib.urlretrieve('http://www.jonobacon.org/files/lernid/ubuntu.lernid', os.path.join(self.lernidcachefolder_events, "config.lernid"))
650- #output = open(os.path.join(self.lernidcachefolder_events, "temp.txt"),'wb')
651-
652- #output.write(response.read())
653- #output.close
654-
655- # copy file
656-
657- #shutil.copy(os.path.join(self.lernidcachefolder_events, "temp.txt"),os.path.join(self.lernidcachefolder_events, "ubuntu.txt"))
658-
659- # read file
660-
661- config.read(os.path.join(self.lernidcachefolder_events, "config.lernid"))
662-
663- sections = config.sections()
664- logging.debug(sections)
665-
666- store = gtk.ListStore(gobject.TYPE_STRING)
667-
668- logging.debug("sections")
669- for s in sections:
670- logging.debug(s)
671- store.append([s])
672-
673- self.event_combo = self.builder.get_object("event_combo")
674-
675- self.event_combo.set_model(store)
676- cell = gtk.CellRendererText()
677- self.event_combo.pack_start(cell, True)
678- self.event_combo.add_attribute(cell, 'text',0)
679- self.event_combo.set_active(0)
680-
681- def ok(self, widget, data=None):
682- """ok - The user has elected to save the changes.
683- Called before the dialog returns gtk.RESONSE_OK from run().
684-
685- """
686-
687- self.destroy()
688-
689- def cancel(self, widget, data=None):
690- """cancel - The user has elected cancel changes.
691- Called before the dialog returns gtk.RESPONSE_CANCEL for run()
692-
693- """
694- self.destroy()
695-
696- def check_ready_to_connect(self, widget):
697- event_combo = self.builder.get_object("event_combo")
698- nick_textentry = self.builder.get_object("nick_textentry")
699- if (nick_textentry.get_text() != "") and (event_combo.get_active() != -1) :
700- self.builder.get_object("button_connect").set_sensitive(True)
701- else:
702- self.builder.get_object("button_connect").set_sensitive(False)
703-
704-def NewConnectDialog():
705- """NewConnectDialog - returns a fully instantiated
706- dialog-camel_case_nameDialog object. Use this function rather than
707- creating ConnectDialog instance directly.
708-
709- """
710-
711- #look for the ui file that describes the ui
712- ui_filename = os.path.join(getdatapath(), 'ui', 'ConnectDialog.ui')
713- if not os.path.exists(ui_filename):
714- ui_filename = None
715-
716- builder = gtk.Builder()
717- builder.add_from_file(ui_filename)
718- dialog = builder.get_object("connect_dialog")
719- dialog.finish_initializing(builder)
720- return dialog
721-
722-if __name__ == "__main__":
723- dialog = NewConnectDialog()
724- dialog.show()
725- gtk.main()
726-
727
728=== modified file 'lernid/IrcBackend.py'
729--- lernid/IrcBackend.py 2009-12-23 20:57:03 +0000
730+++ lernid/IrcBackend.py 2009-12-24 15:49:12 +0000
731@@ -127,6 +127,7 @@
732 reg = telepathy.client.ManagerRegistry()
733 reg.LoadManagers()
734
735+ self.conn = None
736 self.cm = reg.GetManager('idle') # IRC
737 self.room = None
738
739@@ -146,7 +147,8 @@
740 self.conn.room = self.room
741
742 def disconnect(self):
743- self.conn.disconnect()
744+ if self.conn is not None:
745+ self.conn.disconnect()
746
747 def error(self, *args):
748 logging.debug("ERROR", self, args)

Subscribers

People subscribed via source and target branches