From 737f0b034453ee10e1cacc80cd0d2c574aad3812 Mon Sep 17 00:00:00 2001 From: Julio Biason Date: Sat, 13 Feb 2010 20:20:02 -0200 Subject: [PATCH] show/hide the update area --- mitterlib/ui/ui_pygtk.py | 43 +++++++++++++++++++++++++++++++--------- 1 file changed, 34 insertions(+), 9 deletions(-) diff --git a/mitterlib/ui/ui_pygtk.py b/mitterlib/ui/ui_pygtk.py index bfef90c..d6856fc 100644 --- a/mitterlib/ui/ui_pygtk.py +++ b/mitterlib/ui/ui_pygtk.py @@ -353,6 +353,7 @@ class Interface(object): + @@ -380,6 +381,7 @@ class Interface(object): + @@ -455,6 +457,11 @@ class Interface(object): action_group.add_action(settings_action) # Message actions + new_action = gtk.Action('New', _('_New'), + _('Post a new message'), gtk.STOCK_ADD) + new_action.connect('activate', self._new_message) + action_group.add_action_with_accel(new_action, 'n') + self._delete_action = gtk.Action('Delete', _('_Delete'), _('Delete a post'), gtk.STOCK_DELETE) self._delete_action.set_property('sensitive', False) @@ -521,6 +528,7 @@ class Interface(object): close_button = gtk.Button(stock=gtk.STOCK_CLOSE) close_button.set_relief(gtk.RELIEF_NONE) + close_button.connect('clicked', self._clear_text) status_bar = gtk.HBox(False, 0) status_bar.pack_start(self._update_status, expand=True, fill=True, @@ -533,9 +541,11 @@ class Interface(object): padding=0) update_bar.pack_start(avatar, expand=False, fill=False, padding=0) - update = gtk.VBox(False, 0) - update.pack_start(status_bar, expand=False, fill=True, padding=0) - update.pack_start(update_bar, expand=False, fill=True, padding=0) + self._update_box = gtk.VBox(False, 0) + self._update_box.pack_start(status_bar, expand=False, fill=True, + padding=0) + self._update_box.pack_start(update_bar, expand=False, fill=True, + padding=0) # Spell checking the update box spell_check_enabled = self._options[self.NAMESPACE]['spell_check'] @@ -554,7 +564,7 @@ class Interface(object): _log.debug('Error initializing spell checking: ' \ 'spell checking disabled') - return update + return self._update_box def _create_statusbar(self): """Create the statusbar.""" @@ -682,7 +692,6 @@ class Interface(object): should have the same property, so whenever you need to disable/enable them, use this function.""" - #self._update_button.set_property('sensitive', enabled) self._update_action.set_property('sensitive', enabled) return @@ -787,6 +796,16 @@ class Interface(object): store.sort_column_changed() return + def _show_update_box(self): + """Enables the update box.""" + self._update_box.show_all() + self._update_text.grab_focus() + return + + def _hide_update_box(self): + """Hides de update box.""" + self._update_box.hide_all() + return # ------------------------------------------------------------ # Widget callback functions @@ -838,6 +857,7 @@ class Interface(object): self._delete_info = None self._clear_reply() self._remove_count_status() + self._hide_update_box() # change the focus to the grid. page = self._main_tabs.get_current_page() @@ -1000,7 +1020,7 @@ class Interface(object): self._update_text.get_buffer().set_text( self._connection.reply_prefix(message)) self._reply_message_id = message - self._update_text.grab_focus() + self._show_update_box() return @@ -1029,8 +1049,7 @@ class Interface(object): display = _('Removing message from %s from favorites...') else: display = _('Marking message from %s as favorite...') - self._update_status(display % (message.username)) - + self._update_statusbar(display % (message.username)) self._threads.add_work(self._post_favourite_message, self._exception_favourite_message, self._connection.favourite, @@ -1219,6 +1238,11 @@ class Interface(object): self._favourite_action.set_property('sensitive', False) return + def _new_message(self, widget, user_data=None): + """Opens the text area for a new message.""" + self._show_update_box() + return + # ------------------------------------------------------------ # Network related functions # ------------------------------------------------------------ @@ -1331,6 +1355,7 @@ class Interface(object): self._update_statusbar(_('Your status was updated.')) self._update_sensitivity(False) self._clear_text(None) + self._hide_update_box() return def _exception_update_status(self, widget, exception): @@ -1598,4 +1623,4 @@ class Interface(object): 'protected/private.', metavar='CHAR', default=_('(protected)'), - is_cmd_option=False) + is_cmd_option=False) \ No newline at end of file