[Sugar-devel] [PATCH sugar] Use the new toolbars in the Journal
Manuel Quiñones
manuq at laptop.org
Mon Aug 27 09:21:38 EDT 2012
Initial patch provided by Gonzalo Odiard for the shell port.
Signed-off-by: Manuel Quiñones <manuq at laptop.org>
---
src/jarabe/journal/journalactivity.py | 20 +++++++-------
src/jarabe/journal/journaltoolbox.py | 49 +++++++++++------------------------
src/jarabe/journal/objectchooser.py | 4 +--
3 files changed, 26 insertions(+), 47 deletions(-)
diff --git a/src/jarabe/journal/journalactivity.py b/src/jarabe/journal/journalactivity.py
index bb1c7f6..1132f82 100644
--- a/src/jarabe/journal/journalactivity.py
+++ b/src/jarabe/journal/journalactivity.py
@@ -181,16 +181,15 @@ class JournalActivity(JournalWindow):
self._volumes_toolbar.connect('volume-error', self.__volume_error_cb)
self._main_view.pack_start(self._volumes_toolbar, expand=False)
- search_toolbar = self._main_toolbox.search_toolbar
- search_toolbar.connect('query-changed', self._query_changed_cb)
- search_toolbar.set_mount_point('/')
+ self._main_toolbox.connect('query-changed', self._query_changed_cb)
+ self._main_toolbox.set_mount_point('/')
def _setup_secondary_view(self):
self._secondary_view = gtk.VBox()
self._detail_toolbox = DetailToolbox()
- self._detail_toolbox.entry_toolbar.connect('volume-error',
- self.__volume_error_cb)
+ self._detail_toolbox.connect('volume-error',
+ self.__volume_error_cb)
self._detail_view = DetailView()
self._detail_view.connect('go-back-clicked', self.__go_back_clicked_cb)
@@ -206,7 +205,7 @@ class JournalActivity(JournalWindow):
self._show_secondary_view(object_id)
def __clear_clicked_cb(self, list_view):
- self._main_toolbox.search_toolbar.clear_query()
+ self._main_toolbox.clear_query()
def __go_back_clicked_cb(self, detail_view):
self.show_main_view()
@@ -227,7 +226,7 @@ class JournalActivity(JournalWindow):
def _show_secondary_view(self, object_id):
metadata = model.get(object_id)
try:
- self._detail_toolbox.entry_toolbar.set_metadata(metadata)
+ self._detail_toolbox.set_metadata(metadata)
except Exception:
logging.exception('Exception while displaying entry:')
@@ -252,12 +251,12 @@ class JournalActivity(JournalWindow):
def __volume_changed_cb(self, volume_toolbar, mount_point):
logging.debug('Selected volume: %r.', mount_point)
- self._main_toolbox.search_toolbar.set_mount_point(mount_point)
+ self._main_toolbox.set_mount_point(mount_point)
self._main_toolbox.set_current_toolbar(0)
def __model_created_cb(self, sender, **kwargs):
self._check_for_bundle(kwargs['object_id'])
- self._main_toolbox.search_toolbar.refresh_filters()
+ self._main_toolbox.refresh_filters()
self._check_available_space()
def __model_updated_cb(self, sender, **kwargs):
@@ -315,8 +314,7 @@ class JournalActivity(JournalWindow):
model.write(metadata)
def search_grab_focus(self):
- search_toolbar = self._main_toolbox.search_toolbar
- search_toolbar.give_entry_focus()
+ self._main_toolbox.give_entry_focus()
def __window_state_event_cb(self, window, event):
logging.debug('window_state_event_cb %r', self)
diff --git a/src/jarabe/journal/journaltoolbox.py b/src/jarabe/journal/journaltoolbox.py
index 9a5f5a2..70e58ac 100644
--- a/src/jarabe/journal/journaltoolbox.py
+++ b/src/jarabe/journal/journaltoolbox.py
@@ -28,7 +28,7 @@ import glib
import gtk
from sugar.graphics.palette import Palette
-from sugar.graphics.toolbox import Toolbox
+from sugar.graphics.toolbarbox import ToolbarBox
from sugar.graphics.toolcombobox import ToolComboBox
from sugar.graphics.toolbutton import ToolButton
from sugar.graphics.toggletoolbutton import ToggleToolButton
@@ -65,17 +65,7 @@ _ACTION_MY_FRIENDS = 1
_ACTION_MY_CLASS = 2
-class MainToolbox(Toolbox):
- def __init__(self):
- Toolbox.__init__(self)
-
- self.search_toolbar = SearchToolbar()
- self.search_toolbar.set_size_request(-1, style.GRID_CELL_SIZE)
- self.add_toolbar(_('Search'), self.search_toolbar)
- self.search_toolbar.show()
-
-
-class SearchToolbar(gtk.Toolbar):
+class MainToolbox(ToolbarBox):
__gtype_name__ = 'SearchToolbar'
__gsignals__ = {
@@ -84,7 +74,7 @@ class SearchToolbar(gtk.Toolbar):
}
def __init__(self):
- gtk.Toolbar.__init__(self)
+ ToolbarBox.__init__(self)
self._mount_point = None
@@ -100,25 +90,25 @@ class SearchToolbar(gtk.Toolbar):
self._favorite_button = ToggleToolButton('emblem-favorite')
self._favorite_button.connect('toggled',
self.__favorite_button_toggled_cb)
- self.insert(self._favorite_button, -1)
+ self.toolbar.insert(self._favorite_button, -1)
self._favorite_button.show()
self._what_search_combo = ComboBox()
self._what_combo_changed_sid = self._what_search_combo.connect(
'changed', self._combo_changed_cb)
tool_item = ToolComboBox(self._what_search_combo)
- self.insert(tool_item, -1)
+ self.toolbar.insert(tool_item, -1)
tool_item.show()
self._when_search_combo = self._get_when_search_combo()
tool_item = ToolComboBox(self._when_search_combo)
- self.insert(tool_item, -1)
+ self.toolbar.insert(tool_item, -1)
tool_item.show()
self._sorting_button = SortingButton()
self._sorting_button.connect('clicked',
self.__sorting_button_clicked_cb)
- self.insert(self._sorting_button, -1)
+ self.toolbar.insert(self._sorting_button, -1)
self._sorting_button.connect('sort-property-changed',
self.__sort_changed_cb)
self._sorting_button.show()
@@ -175,7 +165,7 @@ class SearchToolbar(gtk.Toolbar):
tool_item.add(widget)
widget.show()
- self.insert(tool_item, -1)
+ self.toolbar.insert(tool_item, -1)
tool_item.show()
def _build_query(self):
@@ -363,30 +353,21 @@ class SearchToolbar(gtk.Toolbar):
self._favorite_button.props.active = False
-class DetailToolbox(Toolbox):
- def __init__(self):
- Toolbox.__init__(self)
-
- self.entry_toolbar = EntryToolbar()
- self.add_toolbar('', self.entry_toolbar)
- self.entry_toolbar.show()
-
-
-class EntryToolbar(gtk.Toolbar):
+class DetailToolbox(ToolbarBox):
__gsignals__ = {
'volume-error': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE,
([str, str])),
}
def __init__(self):
- gtk.Toolbar.__init__(self)
+ ToolbarBox.__init__(self)
self._metadata = None
self._temp_file_path = None
self._resume = ToolButton('activity-start')
self._resume.connect('clicked', self._resume_clicked_cb)
- self.add(self._resume)
+ self.toolbar.insert(self._resume, -1)
self._resume.show()
client = gconf.client_get_default()
@@ -397,7 +378,7 @@ class EntryToolbar(gtk.Toolbar):
icon.show()
self._copy.set_tooltip(_('Copy to'))
self._copy.connect('clicked', self._copy_clicked_cb)
- self.add(self._copy)
+ self.toolbar.insert(self._copy, -1)
self._copy.show()
self._duplicate = ToolButton()
@@ -405,16 +386,16 @@ class EntryToolbar(gtk.Toolbar):
self._duplicate.set_icon_widget(icon)
self._duplicate.set_tooltip(_('Duplicate'))
self._duplicate.connect('clicked', self._duplicate_clicked_cb)
- self.add(self._duplicate)
+ self.toolbar.insert(self._duplicate, -1)
separator = gtk.SeparatorToolItem()
- self.add(separator)
+ self.toolbar.insert(separator, -1)
separator.show()
erase_button = ToolButton('list-remove')
erase_button.set_tooltip(_('Erase'))
erase_button.connect('clicked', self._erase_button_clicked_cb)
- self.add(erase_button)
+ self.toolbar.insert(erase_button, -1)
erase_button.show()
def set_metadata(self, metadata):
diff --git a/src/jarabe/journal/objectchooser.py b/src/jarabe/journal/objectchooser.py
index ecb8ecf..175aa0f 100644
--- a/src/jarabe/journal/objectchooser.py
+++ b/src/jarabe/journal/objectchooser.py
@@ -26,7 +26,7 @@ from sugar.graphics.toolbutton import ToolButton
from jarabe.journal.listview import BaseListView
from jarabe.journal.listmodel import ListModel
-from jarabe.journal.journaltoolbox import SearchToolbar
+from jarabe.journal.journaltoolbox import MainToolbox
from jarabe.journal.volumestoolbar import VolumesToolbar
@@ -77,7 +77,7 @@ class ObjectChooser(gtk.Window):
vbox.pack_start(separator, expand=False)
separator.show()
- self._toolbar = SearchToolbar()
+ self._toolbar = MainToolbox()
self._toolbar.connect('query-changed', self.__query_changed_cb)
self._toolbar.set_size_request(-1, style.GRID_CELL_SIZE)
vbox.pack_start(self._toolbar, expand=False)
--
1.7.11.4
More information about the Sugar-devel
mailing list