Merge lp:~david4dev/start-hacking/gtk into lp:start-hacking

Proposed by David Green
Status: Merged
Merged at revision: 5
Proposed branch: lp:~david4dev/start-hacking/gtk
Merge into: lp:start-hacking
Diff against target: 159 lines (+155/-0)
1 file modified
bin/hack-on-gtk (+155/-0)
To merge this branch: bzr merge lp:~david4dev/start-hacking/gtk
Reviewer Review Type Date Requested Status
start-hacking-dev Pending
Review via email: mp+40918@code.launchpad.net

Description of the change

Addresses bug #668521.

Creates a GUI using Gtk. This provides all of the functionality of the command line program.

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

Wow! Thanks so much for doing this. The last thing I expected was actual patches :)

I'll get around to reviewing this real soon now.

Revision history for this message
Jonathan Lange (jml) wrote :

Hey David,

Thanks so much for this patch. I'm sorry it has taken me this long to get around to reviewing it.

The UI is a good first step, especially since there's no other functionality in the app at the moment.

Code-wise, I'd like to move the bulk of the code in your script into the 'hackon' package so its easier to re-use.

Boring copyright stuff. I'd like to run the project with a project-wide copyright ownership by all of the contributors, with an MIT license. If this is OK with you, I'll add a standard header to the top of all of the code files pointing to a more detailed LICENSE file in the root, and remove your custom header from hack-on-gtk.

If you're OK about the copyright stuff, I'll merge this in. Let me know.

Thanks again,
jml

Revision history for this message
David Green (david4dev) wrote :

The copyright stuff is fine by me so you can merge it.

I agree that it would be better to move most of the code to a shared location.

Revision history for this message
Jonathan Lange (jml) wrote :

Thanks. I'll merge now.

On Sun, Jan 2, 2011 at 2:56 PM, David Green <email address hidden> wrote:
> The copyright stuff is fine by me so you can merge it.
>
> I agree that it would be better to move most of the code to a shared location.
> --
> https://code.launchpad.net/~david4dev/start-hacking/gtk/+merge/40918
> You are subscribed to branch lp:start-hacking.
>

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'bin/hack-on-gtk'
2--- bin/hack-on-gtk 1970-01-01 00:00:00 +0000
3+++ bin/hack-on-gtk 2010-11-15 23:28:33 +0000
4@@ -0,0 +1,155 @@
5+#!/usr/bin/env python
6+# -*- coding: utf-8 -*-
7+#
8+# untitled.py
9+#
10+# Copyright 2010 David Green <david4dev@gmail.com>
11+#
12+# This program is free software; you can redistribute it and/or modify
13+# it under the terms of the GNU General Public License as published by
14+# the Free Software Foundation; either version 3 of the License, or
15+# (at your option) any later version.
16+#
17+# This program is distributed in the hope that it will be useful,
18+# but WITHOUT ANY WARRANTY; without even the implied warranty of
19+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20+# GNU General Public License for more details.
21+#
22+# You should have received a copy of the GNU General Public License
23+# along with this program; if not, write to the Free Software
24+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
25+# MA 02110-1301, USA.
26+
27+# This makes sure that users don't have to set up their environment
28+# specially in order to run these programs from bin/.
29+import sys, os
30+script_path = os.path.abspath(sys.argv[0])
31+if 'start-hacking' in script_path.split(os.sep):
32+ sys.path.insert(
33+ 0, os.path.dirname(os.path.dirname(script_path)))
34+### end of preamble
35+
36+from hackon import script
37+
38+import gtk
39+import gettext
40+gettext.bindtextdomain('hack-on')
41+_ = gettext.gettext
42+
43+class HackOnGUI(gtk.Window):
44+ def __init__(self):
45+ cls = self.__class__
46+ super(cls, self).__init__()
47+
48+ self.set_title(_('Start Hacking!'))
49+ self.resize(400, 200)
50+ self.connect("delete_event", self.delete_event)
51+ self.connect("destroy", self.destroy)
52+
53+ self.intro_label = gtk.Label(_(
54+ "Start Hacking! Click the 'Go' button then\n" +
55+ "click on the window of an application to get\n" +
56+ "details about the software package it belongs to."
57+ ))
58+ self.intro_label.show()
59+
60+ self.go_button = gtk.Button()
61+ self.go_button_label = gtk.Label(_('Go'))
62+ self.go_button_label.show()
63+ self.go_button.add(self.go_button_label)
64+ self.go_button.show()
65+ self.go_button.connect('clicked', self.go_button_clicked)
66+
67+ self.container = gtk.VBox()
68+ self.container.add(self.intro_label)
69+ self.container.add(self.go_button)
70+ self.container.show
71+
72+ self.first = True
73+
74+ self.add(self.container)
75+
76+ self.show_all()
77+
78+
79+ def go_button_clicked(self, w):
80+ self.pid = script.get_pid_of_window()
81+
82+ if self.first:
83+ self.container.remove(self.intro_label)
84+ self.container.remove(self.go_button)
85+
86+ self.label_output = gtk.Label(_('Gathering information...'))
87+ self.label_output.show()
88+ self.container.add(self.label_output)
89+
90+ self.button_go_again = gtk.Button()
91+ self.button_go_again_label = gtk.Label(_("Go Again"))
92+ self.button_go_again_label.show()
93+ self.button_go_again.add(self.button_go_again_label)
94+ self.button_go_again.show()
95+ self.container.add(self.button_go_again)
96+ self.button_go_again.connect('clicked', self.go_button_clicked)
97+
98+ self.first = False
99+ else:
100+ self.label_output.set_text(_('Gathering information...'))
101+
102+ self.source_package_name = script.pid_to_package(self.pid)
103+
104+ if self.source_package_name:
105+ self.package = script.SourcePackage(self.source_package_name)
106+ s = ''.join([
107+ _("Source package: "),
108+ str(self.package),
109+ "\n",
110+ _("Source package branch: "),
111+ self.package.get_package_branch_url(),
112+ "\n\n"
113+ ])
114+ self.label_output.set_text(s)
115+
116+ self.upstream = self.package.upstream
117+ if self.upstream:
118+ s += ''.join([
119+ _("Upstream project: "),
120+ self.upstream.name,
121+ "\n",
122+ _("Upstream branch: "),
123+ str(script.get_upstream_branch_url(self.upstream)),
124+ "\n"
125+ ])
126+ self.label_output.set_text(s)
127+ else:
128+ gtk.MessageDialog(
129+ self,
130+ gtk.DIALOG_DESTROY_WITH_PARENT,
131+ gtk.MESSAGE_ERROR,
132+ gtk.BUTTONS_CLOSE,
133+ _("We don't know what the upstream is")
134+ )
135+ else:
136+ gtk.MessageDialog(
137+ self,
138+ gtk.DIALOG_DESTROY_WITH_PARENT,
139+ gtk.MESSAGE_ERROR,
140+ gtk.BUTTONS_CLOSE,
141+ _("Can't figure out what the package is")
142+ )
143+
144+
145+ def destroy(self, widget, data=None):
146+ gtk.main_quit()
147+
148+
149+ def delete_event(self, widget, event, data=None):
150+ return False
151+
152+
153+ def main(self):
154+ gtk.main()
155+
156+
157+if __name__ == '__main__':
158+ HackOnGUI().main()
159+

Subscribers

People subscribed via source and target branches

to all changes: