Merge lp:~sense/lernid/browserbuttons-sensitivity into lp:lernid

Proposed by Sense Egbert Hofstede
Status: Merged
Merged at revision: not available
Proposed branch: lp:~sense/lernid/browserbuttons-sensitivity
Merge into: lp:lernid
Diff against target: 108 lines (+57/-1)
2 files modified
bin/lernid (+55/-1)
data/ui/LernidWindow.ui (+2/-0)
To merge this branch: bzr merge lp:~sense/lernid/browserbuttons-sensitivity
Reviewer Review Type Date Requested Status
Jono Bacon Pending
Review via email: mp+16556@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Sense Egbert Hofstede (sense) wrote :

This branch makes the browser toolbar and the stop and reload buttons grey out (and in) when they should by listening to the 'hide', 'net-start', 'net-stop' and 'show' signals of self.browser.
Now you can't press Reload when a page is being loaded and you can only press Stop when something actually is being loaded.

If self.browser is being hidden the toolbar is made completely insensitive.

The browser toolbar and the stop button have been set to insensitive by default in the .ui files.

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-23 16:33:59 +0000
3+++ bin/lernid 2009-12-23 21:20:25 +0000
4@@ -122,6 +122,12 @@
5
6 # create browser widget
7 self.browser = gtkmozembed.MozEmbed()
8+
9+ # Connect the signals
10+ self.browser.connect("hide", self.browser_hidden)
11+ self.browser.connect("net-start", self.browser_loading)
12+ self.browser.connect("net-stop", self.browser_loaded)
13+ self.browser.connect("show", self.browser_shown)
14 self.browser.connect("title", self.update_browser_title_combo)
15
16 self.chat = gtkmozembed.MozEmbed()
17@@ -382,7 +388,12 @@
18 def browser_stop(self, widget):
19 """Stop the current page loading in the browser view."""
20
21+ refresh_button = self.builder.get_object("browser_refresh")
22+ stop_button = self.builder.get_object("browser_stop")
23+
24+ stop_button.set_sensitive(False)
25 self.browser.stop_load()
26+ refresh_button.set_sensitive(True)
27
28 def send_notification(self, s):
29 """Send a message to notify-osd."""
30@@ -483,6 +494,49 @@
31 if match == 0:
32 self.browser.load_url(url)
33 self.tabs.set_current_page(self.TAB_BROWSER)
34+
35+ def browser_hidden(self, widget):
36+ """Make all buttons on the brower's toolbar insensitive"""
37+
38+ # We make the toolbar insensitive, and thereby its children as well
39+ toolbar = self.builder.get_object("hbox1")
40+ toolbar.set_sensitive(False)
41+
42+ print "hidden!\n"
43+
44+ def browser_loaded(self, widget):
45+ """Mess with the stop and reload buttons
46+ Stop -> insensitive
47+ Reload -> sensitive"""
48+
49+ refresh_button = self.builder.get_object("browser_refresh")
50+ stop_button = self.builder.get_object("browser_stop")
51+
52+ # Enable the refresh button and disnable the stop button now the
53+ # webpage has been loaded
54+ refresh_button.set_sensitive(True)
55+ stop_button.set_sensitive(False)
56+
57+ def browser_loading(self, widget):
58+ """Mess with the stop and reload buttons
59+ Stop -> sensitive
60+ Reload -> insensitive"""
61+
62+ refresh_button = self.builder.get_object("browser_refresh")
63+ stop_button = self.builder.get_object("browser_stop")
64+
65+ # Disable the refresh button and enable the stop button when loading
66+ # the webpage
67+ refresh_button.set_sensitive(False)
68+ stop_button.set_sensitive(True)
69+
70+ def browser_shown(self, widget):
71+ """Make all buttons on the brower's toolbar sensitive"""
72+
73+ # We make the toolbar sensitive, and thereby restore its children
74+ toolbar = self.builder.get_object("hbox1")
75+ toolbar.set_sensitive(True)
76+ print "shown!\n"
77
78 def update_browser_title_combo(self, widget):
79 """Update the browser title combo box with the new title."""
80@@ -504,7 +558,7 @@
81
82 def select_browser_title(self, widget):
83 """Select an item from the browser combo box."""
84-
85+
86 self.browser.load_url(self.browser_liststore[self.browser_combo.get_active()][1])
87
88 def about(self, widget, data=None):
89
90=== modified file 'data/ui/LernidWindow.ui'
91--- data/ui/LernidWindow.ui 2009-12-23 14:52:49 +0000
92+++ data/ui/LernidWindow.ui 2009-12-23 21:20:25 +0000
93@@ -215,6 +215,7 @@
94 <child>
95 <object class="GtkHBox" id="hbox1">
96 <property name="visible">True</property>
97+ <property name="sensitive">False</property>
98 <child>
99 <object class="GtkButton" id="browser_refresh">
100 <property name="visible">True</property>
101@@ -238,6 +239,7 @@
102 <child>
103 <object class="GtkButton" id="browser_stop">
104 <property name="visible">True</property>
105+ <property name="sensitive">False</property>
106 <property name="can_focus">True</property>
107 <property name="receives_default">True</property>
108 <property name="relief">none</property>

Subscribers

People subscribed via source and target branches