Merge lp:~mac9416/keryx/keryx-1.0 into lp:~excid3/keryx/keryx-1.0

Proposed by mac9416
Status: Merged
Merged at revision: 30
Proposed branch: lp:~mac9416/keryx/keryx-1.0
Merge into: lp:~excid3/keryx/keryx-1.0
Diff against target: 197 lines (+97/-23)
4 files modified
.bzrignore (+6/-0)
bin/keryx (+23/-20)
data/ui/KeryxWindow.ui (+3/-3)
keryx/MessageDialogs.py (+65/-0)
To merge this branch: bzr merge lp:~mac9416/keryx/keryx-1.0
Reviewer Review Type Date Requested Status
Chris Oliver Approve
Review via email: mp+32035@code.launchpad.net

Description of the change

I dropped in a module I wrote for 0.92.5 to make it easier to make Message Dialogs.

To post a comment you must log in.
Revision history for this message
mac9416 (mac9416) wrote :

It's going to take a lot of dialogs for the MessageDialogs module to pay for itself in saved lines of code. Maybe you can think of a good way to make MessageDialogs more concise.

Revision history for this message
Chris Oliver (excid3) wrote :

Already on it.

On Sat, Aug 7, 2010 at 10:44 AM, mac9416 <email address hidden> wrote:

> It's going to take a lot of dialogs for the MessageDialogs module to pay
> for itself in saved lines of code. Maybe you can think of a good way to make
> MessageDialogs more concise.
> --
> https://code.launchpad.net/~mac9416/keryx/keryx-1.0/+merge/32035
> You are requested to review the proposed merge of
> lp:~mac9416/keryx/keryx-1.0 into lp:~excid3/keryx/keryx-1.0.
>

--
Chris Oliver
http://excid3.com

Revision history for this message
Chris Oliver (excid3) wrote :

Refactored in commit after merge.

review: Approve
lp:~mac9416/keryx/keryx-1.0 updated
29. By Chris Oliver

Added todo

30. By Chris Oliver

merge lp:~mac9416/keryx/keryx-1.0

Revision history for this message
mac9416 (mac9416) wrote :

You're a good man. Chuck that diff at me when you're done. I'd like to see what you do.

Revision history for this message
Chris Oliver (excid3) wrote :

Done dealio. Check out revision 31 for the sweet update. Might give you some nifty ideas for shortening code.

Revision history for this message
Chris Oliver (excid3) wrote :

Also I've been pushing to both lp:~excid3/keryx/keryx-1.0 AND lp:keryx/unstable so it's available in both. Just merge request to unstable now instead. It's best not to have our main branch a personal one.

Revision history for this message
Chris Oliver (excid3) wrote :

Another note, this isn't thoroughly tested. May be typos. Could you test it if you get a chance?

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file '.bzrignore'
2--- .bzrignore 2010-08-03 03:20:46 +0000
3+++ .bzrignore 2010-08-07 15:39:46 +0000
4@@ -12,3 +12,9 @@
5 .git/objects
6 .git/refs
7 .git
8+data/projects/amanda
9+data/projects/amandasd
10+data/downloads
11+data/downloads
12+data/keryx.conf
13+data/projects
14
15=== modified file 'bin/keryx'
16--- bin/keryx 2010-08-06 04:15:53 +0000
17+++ bin/keryx 2010-08-07 15:39:46 +0000
18@@ -44,6 +44,8 @@
19
20 from keryx import (
21 AboutKeryxDialog, keryxconfig)
22+from keryx.MessageDialogs import (error_dialog, info_dialog, question_dialog,
23+ warning_dialog)
24 from keryx.helpers import create_tab, create_closeable_tab, get_builder
25
26
27@@ -160,25 +162,23 @@
28
29 if not platform.system() == "Linux" or \
30 not os.path.exists(status_file) or \
31- not os.path.exists(sources_file):
32- md = gtk.MessageDialog(self,
33- gtk.DIALOG_DESTROY_WITH_PARENT, gtk.MESSAGE_ERROR,
34- gtk.BUTTONS_OK, "Sorry, you can only add Debian based Linux distros.\nPlease use Keryx on your offline machine.")
35- md.set_title("Error Adding Computer")
36- md.run()
37- md.destroy()
38+ not os.path.exists(sources_file): # FIXME: Not everyone has a main sources_file.
39+ error_dialog(self,
40+ "Sorry, you can only add Debian based Linux " \
41+ "distros.\nPlease use Keryx on your offline " \
42+ "machine.",
43+ "Error adding computer")
44 return
45
46 name = self._get("add_computer_name_entry").get_text()
47
48 path = os.path.join(self.config.get("projects"), name)
49 if os.path.exists(path):
50- md = gtk.MessageDialog(self,
51- gtk.DIALOG_DESTROY_WITH_PARENT, gtk.MESSAGE_ERROR,
52- gtk.BUTTONS_OK, "The computer appears to have already been added.\nMake sure you to use a different name for each computer.")
53- md.set_title("Error Adding Computer")
54- md.run()
55- md.destroy()
56+ error_dialog(self,
57+ "The computer appears to have already been added.\n" \
58+ "Make sure you to use a different name for each " \
59+ "computer.",
60+ "Error Adding Computer")
61 print path
62 return
63
64@@ -196,12 +196,12 @@
65 platform.release()))
66 f.close()
67
68- md = gtk.MessageDialog(self,
69- gtk.DIALOG_DESTROY_WITH_PARENT, gtk.MESSAGE_INFO,
70- gtk.BUTTONS_OK, "Computer added successfully!\nNow you can click Manage to select some packages to download later or you can move Keryx to a computer with internet access to get started.")
71- md.set_title("Everything Went Better Than Expected")
72- md.run()
73- md.destroy()
74+ info_dialog(self,
75+ "Computer added successfully!\nNow you can click Manage " \
76+ "to select some packages to download later or you can " \
77+ "move Keryx to a computer with internet access to get " \
78+ "started.",
79+ "Everything Went Better Than Expected")
80
81 def about(self, widget, data=None):
82 """Display the about box for keryx."""
83@@ -228,7 +228,10 @@
84
85 def on_proxy_manual_radiobutton_toggled(self, widget, data=None):
86 """Called when Manual proxy configuration is toggled"""
87- widgets = ["proxy_entry", "proxy_port_spinbutton", "proxy_username_entry", "proxy_password_entry"]
88+ widgets = ["proxy_entry",
89+ "proxy_port_spinbutton",
90+ "proxy_username_entry",
91+ "proxy_password_entry"]
92 s = widget.get_active()
93
94 # Set manual proxy entries sensitive as necessary
95
96=== modified file 'data/ui/KeryxWindow.ui'
97--- data/ui/KeryxWindow.ui 2010-08-05 18:23:18 +0000
98+++ data/ui/KeryxWindow.ui 2010-08-07 15:39:46 +0000
99@@ -30,7 +30,7 @@
100 <object class="KeryxWindow" id="keryx_window">
101 <property name="title" translatable="yes">Keryx</property>
102 <property name="window_position">center</property>
103- <property name="icon">../media/icon.png</property>
104+ <property name="icon">../media/keryx_64x64.png</property>
105 <signal name="destroy" handler="on_destroy"/>
106 <child>
107 <object class="GtkVBox" id="vbox1">
108@@ -710,8 +710,8 @@
109 <child>
110 <object class="GtkFileChooserButton" id="projects_filechooserbutton">
111 <property name="visible">True</property>
112+ <property name="action">select-folder</property>
113 <property name="show_hidden">True</property>
114- <property name="action">select-folder</property>
115 </object>
116 <packing>
117 <property name="expand">False</property>
118@@ -743,8 +743,8 @@
119 <child>
120 <object class="GtkFileChooserButton" id="downloads_filechooserbutton">
121 <property name="visible">True</property>
122+ <property name="action">select-folder</property>
123 <property name="show_hidden">True</property>
124- <property name="action">select-folder</property>
125 </object>
126 <packing>
127 <property name="expand">False</property>
128
129=== added file 'keryx/MessageDialogs.py'
130--- keryx/MessageDialogs.py 1970-01-01 00:00:00 +0000
131+++ keryx/MessageDialogs.py 2010-08-07 15:39:46 +0000
132@@ -0,0 +1,65 @@
133+"""We have here several simple dialogs for convenience."""
134+
135+import gtk
136+
137+
138+def error_dialog(parent, text, title=None, buttons=gtk.BUTTONS_OK):
139+ md = gtk.MessageDialog(parent,
140+ gtk.DIALOG_DESTROY_WITH_PARENT,
141+ gtk.MESSAGE_ERROR,
142+ buttons,
143+ text)
144+ if title:
145+ md.set_title(title)
146+ result = md.run()
147+ md.destroy()
148+
149+ if result == gtk.RESPONSE_CLOSE:
150+ return False
151+
152+
153+def info_dialog(parent, text, title=None, buttons=gtk.BUTTONS_OK):
154+ md = gtk.MessageDialog(parent,
155+ gtk.DIALOG_DESTROY_WITH_PARENT,
156+ gtk.MESSAGE_INFO,
157+ buttons,
158+ text)
159+ if title:
160+ md.set_title(title)
161+ result = md.run()
162+ md.destroy()
163+
164+ if result == gtk.RESPONSE_CLOSE:
165+ return False
166+
167+
168+def question_dialog(parent, text, title=None, buttons=gtk.BUTTONS_YES_NO):
169+ md = gtk.MessageDialog(parent,
170+ gtk.DIALOG_DESTROY_WITH_PARENT,
171+ gtk.MESSAGE_QUESTION,
172+ buttons,
173+ text)
174+ if title:
175+ md.set_title(title)
176+ result = md.run()
177+ md.destroy()
178+
179+ if result == gtk.RESPONSE_YES:
180+ return True
181+ else:
182+ return False
183+
184+
185+def warning_dialog(parent, text, title=None, buttons=gtk.BUTTONS_OK):
186+ md = gtk.MessageDialog(parent,
187+ gtk.DIALOG_DESTROY_WITH_PARENT,
188+ gtk.MESSAGE_WARNING,
189+ buttons,
190+ text)
191+ if title:
192+ md.set_title(title)
193+ result = md.run()
194+ md.destroy()
195+
196+ if result == gtk.RESPONSE_CLOSE:
197+ return False

Subscribers

People subscribed via source and target branches