Ticket #4398: 0001-PDF-view-Use-MessageBox-SL-4398.patch
File 0001-PDF-view-Use-MessageBox-SL-4398.patch, 5.0 KB (added by manuq, 11 years ago) |
---|
-
pdfviewer.py
From e456fa822c80558ed2b3f3bcfd8d73147c311cce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20Qui=C3=B1ones?= <manuq@laptop.org> Date: Fri, 25 Jan 2013 17:33:42 -0300 Subject: [PATCH Browse] PDF view: Use MessageBox - SL #4398 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Mail-Followup-To: <sugar-devel@lists.sugarlabs.org> Replace the custom one and use the new toolkit widget. Signed-off-by: Manuel Quiñones <manuq@laptop.org> --- pdfviewer.py | 70 ++++++++++++++++++------------------------------------------ 1 file changed, 21 insertions(+), 49 deletions(-) diff --git a/pdfviewer.py b/pdfviewer.py index e0030ef..9493293 100644
a b from gettext import gettext as _ 22 22 23 23 from gi.repository import GObject 24 24 from gi.repository import Gtk 25 from gi.repository import GLib26 25 from gi.repository import EvinceDocument 27 26 from gi.repository import EvinceView 28 27 from gi.repository import WebKit … … from sugar3.graphics.toolbutton import ToolButton 32 31 from sugar3.graphics.icon import Icon 33 32 from sugar3.graphics.progressicon import ProgressIcon 34 33 from sugar3.graphics import style 34 from sugar3.graphics.messagebox import MessageBox 35 35 from sugar3.datastore import datastore 36 36 from sugar3.activity import activity 37 37 … … class DummyBrowser(GObject.GObject): 301 301 pass 302 302 303 303 304 class PDFMessageBox(Gtk.EventBox):305 def __init__(self, message, button_callback):306 Gtk.EventBox.__init__(self)307 308 self.modify_bg(Gtk.StateType.NORMAL,309 style.COLOR_WHITE.get_gdk_color())310 311 alignment = Gtk.Alignment.new(0.5, 0.5, 0.1, 0.1)312 self.add(alignment)313 alignment.show()314 315 box = Gtk.VBox()316 alignment.add(box)317 box.show()318 319 icon = ProgressIcon(icon_name='book',320 pixel_size=style.LARGE_ICON_SIZE,321 stroke_color=style.COLOR_BUTTON_GREY.get_svg(),322 fill_color=style.COLOR_SELECTION_GREY.get_svg())323 self.progress_icon = icon324 325 box.pack_start(icon, expand=True, fill=False, padding=0)326 icon.show()327 328 label = Gtk.Label()329 color = style.COLOR_BUTTON_GREY.get_html()330 label.set_markup('<span weight="bold" color="%s">%s</span>' % ( \331 color, GLib.markup_escape_text(message)))332 box.pack_start(label, expand=True, fill=False, padding=0)333 label.show()334 335 button_box = Gtk.HButtonBox()336 button_box.set_layout(Gtk.ButtonBoxStyle.CENTER)337 box.pack_start(button_box, False, True, 0)338 button_box.show()339 340 button = Gtk.Button(label=_('Cancel'))341 button.connect('clicked', button_callback)342 button.props.image = Icon(icon_name='dialog-cancel',343 icon_size=Gtk.IconSize.BUTTON)344 button_box.pack_start(button, expand=True, fill=False, padding=0)345 button.show()346 347 348 304 class PDFTabPage(Gtk.HBox): 349 305 """Shows a basic PDF viewer, download the file first if the PDF is 350 306 in a remote location. … … class PDFTabPage(Gtk.HBox): 355 311 def __init__(self): 356 312 GObject.GObject.__init__(self) 357 313 self._browser = DummyBrowser(self) 314 self._progress_icon = None 358 315 self._message_box = None 359 316 self._evince_viewer = None 360 317 self._pdf_uri = None … … class PDFTabPage(Gtk.HBox): 428 385 """Download the PDF from a remote location to a temporal file.""" 429 386 430 387 # Display a message 431 self._message_box = PDFMessageBox( 432 message=_("Downloading document..."), 433 button_callback=self.cancel_download) 388 389 self._progress_icon = ProgressIcon( 390 icon_name='book', 391 pixel_size=style.LARGE_ICON_SIZE, 392 stroke_color=style.COLOR_BUTTON_GREY.get_svg(), 393 fill_color=style.COLOR_SELECTION_GREY.get_svg()) 394 395 self._message_box = MessageBox( 396 title = _("Downloading document..."), 397 icon = self._progress_icon) 398 434 399 self.pack_start(self._message_box, True, True, 0) 435 400 self._message_box.show() 436 401 402 cancel_button = Gtk.Button(label=_('Cancel')) 403 cancel_button.connect('clicked', self.cancel_download) 404 cancel_button.props.image = Icon(icon_name='dialog-cancel', 405 icon_size=Gtk.IconSize.BUTTON) 406 self._message_box.add_button(cancel_button) 407 cancel_button.show() 408 437 409 # Figure out download URI 438 410 temp_path = os.path.join(activity.get_activity_root(), 'instance') 439 411 if not os.path.exists(temp_path): … … class PDFTabPage(Gtk.HBox): 456 428 def __download_progress_cb(self, download, data): 457 429 progress = download.get_progress() 458 430 self._browser.props.progress = progress 459 self._ message_box.progress_icon.update(progress)431 self._progress_icon.update(progress) 460 432 461 433 def __download_status_cb(self, download, data): 462 434 status = download.get_status()