From b25168933d598de2cc7911b539f6829ad581fcf5 Mon Sep 17 00:00:00 2001 From: Walter Bender Date: Fri, 28 Sep 2012 19:29:35 +0000 Subject: cleanup of misc conversion bugs --- diff --git a/VisualMatchActivity.py b/VisualMatchActivity.py index 2ce6d3c..9c249a1 100644 --- a/VisualMatchActivity.py +++ b/VisualMatchActivity.py @@ -81,7 +81,7 @@ class VisualMatchActivity(activity.Activity): self.ready_to_play = False self._prompt = '' self._read_journal_data() - self._setup_toolbars(_NEW_SUGAR_SYSTEM) + self._setup_toolbars() canvas = self._setup_canvas() self._setup_presence_service() @@ -243,7 +243,7 @@ class VisualMatchActivity(activity.Activity): jscores += '%s: %s\n' % (str(i + 1), s) Gtk.Clipboard().set_text(jscores) - def _setup_toolbars(self, new_sugar_system): + def _setup_toolbars(self): ''' Setup the toolbars.. ''' games_toolbar = Gtk.Toolbar() @@ -451,25 +451,25 @@ class VisualMatchActivity(activity.Activity): group=self.beginner_button) LEVEL_BUTTONS[EXPERT] = self.expert_button - self.level_label = label_factory(toolbar, self.calc_level_label( - self._low_score, self._play_level)) + self.level_label = label_factory(self.calc_level_label( + self._low_score, self._play_level), toolbar) def _set_labels(self, toolbar): ''' Add labels to toolbar toolbar ''' - self.status_label = label_factory(toolbar, _('Find a match.')) + self.status_label = label_factory(_('Find a match.'), toolbar) separator_factory(toolbar, False, True) self.deck_label = label_factory( - toolbar, '%d %s' % (LEVEL_DECKSIZE[self._play_level] - DEAL, - _('cards'))) + '%d %s' % (LEVEL_DECKSIZE[self._play_level] - DEAL, _('cards')), + toolbar) separator_factory(toolbar, False, True) - self.match_label = label_factory(toolbar, '%d %s' % (0, _('matches'))) + self.match_label = label_factory('%d %s' % (0, _('matches')), toolbar) separator_factory(toolbar, False, True) - self.clock_label = label_factory(toolbar, '-') + self.clock_label = label_factory('-', toolbar) def _setup_canvas(self): ''' Create a canvas.. ''' canvas = Gtk.DrawingArea() - canvas.set_size_request(Gdk.screen.width(), Gdk.screen.height()) + canvas.set_size_request(Gdk.Screen.width(), Gdk.Screen.height()) self.set_canvas(canvas) canvas.show() self.show_all() @@ -564,12 +564,9 @@ class VisualMatchActivity(activity.Activity): return self._data_dumper(data) def _data_dumper(self, data): - if _OLD_SUGAR_SYSTEM: - return json.write(data) - else: - io = StringIO() - jdump(data, io) - return io.getvalue() + io = StringIO() + jdump(data, io) + return io.getvalue() def read_file(self, file_path): ''' Read data from the Journal. ''' @@ -584,11 +581,8 @@ class VisualMatchActivity(activity.Activity): self._saved_state = saved_state def _data_loader(self, data): - if _OLD_SUGAR_SYSTEM: - return json.read(data) - else: - io = StringIO(data) - return jload(io) + io = StringIO(data) + return jload(io) def _notify_new_game(self, prompt): ''' Called from New Game button since loading a new game can @@ -612,8 +606,8 @@ class VisualMatchActivity(activity.Activity): help_buttons[name] = button help_windows[name] = Gtk.ScrolledWindow() help_windows[name].set_size_request( - int(Gdk.screen.width() / 3), - Gdk.screen.height() - style.GRID_CELL_SIZE * 3) + int(Gdk.Screen.width() / 3), + Gdk.Screen.height() - style.GRID_CELL_SIZE * 3) help_windows[name].set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC) help_windows[name].add_with_viewport(help_palettes[name]) diff --git a/helpbutton.py b/helpbutton.py index 4ab5543..cea6110 100644 --- a/helpbutton.py +++ b/helpbutton.py @@ -86,7 +86,7 @@ class HelpButton(Gtk.ToolItem): def add_section(help_box, section_text, icon=None): ''' Add a section to the help palette. From helpbutton.py by Gonzalo Odiard ''' - max_text_width = int(Gdk.screen.width() / 3) - 20 + max_text_width = int(Gdk.Screen.width() / 3) - 20 hbox = Gtk.HBox() label = Gtk.Label() label.set_use_markup(True) @@ -108,7 +108,7 @@ def add_section(help_box, section_text, icon=None): def add_paragraph(help_box, text, icon=None): ''' Add an entry to the help palette. From helpbutton.py by Gonzalo Odiard ''' - max_text_width = int(Gdk.screen.width() / 3) - 20 + max_text_width = int(Gdk.Screen.width() / 3) - 20 hbox = Gtk.HBox() label = Gtk.Label(label=text) label.set_justify(Gtk.Justification.LEFT) diff --git a/toolbar_utils.py b/toolbar_utils.py index b6fa1a1..5a1fa7c 100644 --- a/toolbar_utils.py +++ b/toolbar_utils.py @@ -29,7 +29,7 @@ def button_factory(icon_name, toolbar, callback, cb_arg=None, tooltip=None, if cb_arg is None: button.connect('clicked', callback) else: - button.connect('clicked', cb_arg) + button.connect('clicked', callback, cb_arg) if hasattr(toolbar, 'insert'): # the main toolbar toolbar.insert(button, -1) else: # or a secondary toolbar -- cgit v0.9.1