~stefan-schwarzburg/qreator/fix_bug_1006635_selection

« back to all changes in this revision

Viewing changes to qreator/QreatorWindow.py

  • Committer: Stefan Schwarzburg
  • Date: 2012-06-07 07:01:54 UTC
  • Revision ID: stefan.schwarzburg@googlemail.com-20120607070154-chg6e16wxtvyz4g8
Basic idea behind this modification:

1) keep the IconView and the on_selection_changed signal
2) instead of directly switching to the QR code screen, shedule an "activate" function (with idle_add) of the QR code, when the activate function is ready, shedule the actual switching.
3) add a line that removes the selection when 'new' is clicked.

This is help to mimik the gnome-control-center behaviour.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
import cairo
18
18
import math
19
 
from gi.repository import Gtk, Gdk, GdkPixbuf  # pylint: disable=E0611
 
19
from gi.repository import Gtk, Gdk, GdkPixbuf, GObject  # pylint: disable=E0611
20
20
import logging
21
21
logger = logging.getLogger('qreator')
22
22
 
166
166
 
167
167
    def on_toolbuttonNew_clicked(self, widget, data=None):
168
168
        '''Shows the home page'''
 
169
        self.ui.qr_types_view.unselect_all()
169
170
        self.ui.notebook1.set_current_page(PAGE_NEW)
170
171
 
171
172
    def on_toolbuttonHistory_clicked(self, widget, data=None):
178
179
 
179
180
##########################################
180
181
    def on_qr_types_view_selection_changed(self, widget):
181
 
        self.on_qr_types_view_item_activated(widget, widget.get_selected_items()[0])
 
182
        if len(widget.get_selected_items()) > 0:
 
183
            GObject.idle_add(self.on_qr_types_view_item_activated,
 
184
                             widget, widget.get_selected_items()[0])
182
185
 
183
186
    def on_qr_types_view_item_activated(self, widget, item):
184
187
        '''Loads the UI for the appropriate QR type'''
187
190
        qr_id = model[item][COL_ID]
188
191
        self.qr_types[qr_id].widget.on_activated()
189
192
 
190
 
        self.ui.notebook1.set_current_page(PAGE_QR)
 
193
        GObject.idle_add(self.ui.notebook1.set_current_page, PAGE_QR)
191
194
 
192
195
        for child in self.ui.qr_input_box.get_children():
193
196
            child.hide()