Ticket #4398: 0001-Adapt-Sugar-to-new-MessageBox-widget-in-toolkit-with.patch
File 0001-Adapt-Sugar-to-new-MessageBox-widget-in-toolkit-with.patch, 7.0 KB (added by svineet, 9 years ago) |
---|
-
src/jarabe/desktop/activitieslist.py
From 3e6b40e0ef726e6b5fa90912ba5c8c2b9cf4e215 Mon Sep 17 00:00:00 2001 From: Sai Vineet <saivineet89@gmail.com> Date: Tue, 2 Dec 2014 12:30:18 +0530 Subject: [PATCH 1/1] Adapt Sugar to new MessageBox widget in toolkit (with manuq) --- src/jarabe/desktop/activitieslist.py | 62 ++++++++++-------------------------- src/jarabe/journal/listview.py | 51 ++++++++++------------------- 2 files changed, 34 insertions(+), 79 deletions(-) diff --git a/src/jarabe/desktop/activitieslist.py b/src/jarabe/desktop/activitieslist.py index 88bfb0e..e3a69fa 100644
a b from gi.repository import Gdk 31 31 from sugar3 import profile 32 32 from sugar3 import util 33 33 from sugar3.graphics import style 34 from sugar3.graphics.messagebox import MessageBox 34 35 from sugar3.graphics.icon import Icon, CellRendererIcon 35 36 from sugar3.graphics.xocolor import XoColor 36 37 from sugar3.graphics.alert import Alert … … class CellRendererActivityIcon(CellRendererIcon): 347 348 self.emit('erase-activated', bundle_id) 348 349 349 350 350 class ClearMessageBox(Gtk.EventBox):351 def __init__(self, message, button_callback):352 Gtk.EventBox.__init__(self)353 354 self.modify_bg(Gtk.StateType.NORMAL,355 style.COLOR_WHITE.get_gdk_color())356 357 alignment = Gtk.Alignment.new(0.5, 0.5, 0.1, 0.1)358 self.add(alignment)359 alignment.show()360 361 box = Gtk.VBox()362 alignment.add(box)363 box.show()364 365 icon = Icon(pixel_size=style.LARGE_ICON_SIZE,366 icon_name='system-search',367 stroke_color=style.COLOR_BUTTON_GREY.get_svg(),368 fill_color=style.COLOR_TRANSPARENT.get_svg())369 box.pack_start(icon, expand=True, fill=False, padding=0)370 icon.show()371 372 label = Gtk.Label()373 color = style.COLOR_BUTTON_GREY.get_html()374 label.set_markup('<span weight="bold" color="%s">%s</span>' % (375 color, GLib.markup_escape_text(message)))376 box.pack_start(label, expand=True, fill=False, padding=0)377 label.show()378 379 button_box = Gtk.HButtonBox()380 button_box.set_layout(Gtk.ButtonBoxStyle.CENTER)381 box.pack_start(button_box, False, True, 0)382 button_box.show()383 384 button = Gtk.Button(label=_('Clear search'))385 button.connect('clicked', button_callback)386 button.props.image = Icon(icon_name='dialog-cancel',387 pixel_size=style.SMALL_ICON_SIZE)388 button_box.pack_start(button, expand=True, fill=False, padding=0)389 button.show()390 391 392 351 class ActivitiesList(Gtk.VBox): 393 352 __gtype_name__ = 'SugarActivitiesList' 394 353 … … class ActivitiesList(Gtk.VBox): 464 423 if self._scrolled_window in self.get_children(): 465 424 self.remove(self._scrolled_window) 466 425 467 self._clear_message_box = ClearMessageBox( 468 message=_('No matching activities'), 469 button_callback=self.__clear_button_clicked_cb) 426 # Create MessageBox 427 self._clear_message_box = MessageBox( 428 title=_('No matching activities'), 429 icon=Icon( 430 pixel_size=style.LARGE_ICON_SIZE, 431 icon_name='system-search', 432 stroke_color=style.COLOR_BUTTON_GREY.get_svg(), 433 fill_color=style.COLOR_TRANSPARENT.get_svg()) 434 ) 470 435 471 436 self.pack_end(self._clear_message_box, True, True, 0) 472 437 self._clear_message_box.show() 473 438 439 clear_button = Gtk.Button(label=_('Clear search')) 440 clear_button.connect('clicked', self.__clear_button_clicked_cb) 441 clear_button.props.image = Icon(icon_name='dialog-cancel', 442 icon_size=Gtk.IconSize.BUTTON) 443 self._clear_message_box.add_button(clear_button) 444 clear_button.show() 445 474 446 def __clear_button_clicked_cb(self, button): 475 447 self.emit('clear-clicked') 476 448 -
src/jarabe/journal/listview.py
diff --git a/src/jarabe/journal/listview.py b/src/jarabe/journal/listview.py index 46f3259..1faed5e 100644
a b import logging 18 18 from gettext import gettext as _ 19 19 import time 20 20 21 from gi.repository import GLib22 21 from gi.repository import GObject 23 22 from gi.repository import Gtk 24 23 from gi.repository import Gdk 25 24 from gi.repository import Pango 26 25 27 26 from sugar3.graphics import style 27 from sugar3.graphics.messagebox import MessageBox 28 28 from sugar3.graphics.icon import Icon, CellRendererIcon 29 29 from sugar3 import util 30 30 from sugar3 import profile … … class BaseListView(Gtk.Bin): 446 446 def _show_message(self, message, show_clear_query=False): 447 447 self.remove(self.get_child()) 448 448 449 background_box = Gtk.EventBox() 450 background_box.modify_bg(Gtk.StateType.NORMAL, 451 style.COLOR_WHITE.get_gdk_color()) 452 self.add(background_box) 449 message_box = MessageBox( 450 title=message, 451 icon=Icon( 452 pixel_size=style.LARGE_ICON_SIZE, 453 icon_name='activity-journal', 454 stroke_color=style.COLOR_BUTTON_GREY.get_svg(), 455 fill_color=style.COLOR_TRANSPARENT.get_svg()) 456 ) 453 457 454 alignment = Gtk.Alignment.new(0.5, 0.5, 0.1, 0.1) 455 background_box.add(alignment) 456 457 box = Gtk.VBox() 458 alignment.add(box) 459 460 icon = Icon(pixel_size=style.LARGE_ICON_SIZE, 461 icon_name='activity-journal', 462 stroke_color=style.COLOR_BUTTON_GREY.get_svg(), 463 fill_color=style.COLOR_TRANSPARENT.get_svg()) 464 box.pack_start(icon, expand=True, fill=False, padding=0) 465 466 label = Gtk.Label() 467 color = style.COLOR_BUTTON_GREY.get_html() 468 label.set_markup('<span weight="bold" color="%s">%s</span>' % ( 469 color, GLib.markup_escape_text(message))) 470 box.pack_start(label, expand=True, fill=False, padding=0) 458 self.add(message_box) 459 message_box.show() 471 460 472 461 if show_clear_query: 473 button_box = Gtk.HButtonBox() 474 button_box.set_layout(Gtk.ButtonBoxStyle.CENTER) 475 box.pack_start(button_box, False, True, 0) 476 button_box.show() 477 478 button = Gtk.Button(label=_('Clear search')) 479 button.connect('clicked', self.__clear_button_clicked_cb) 480 button.props.image = Icon(icon_name='dialog-cancel', 481 pixel_size=style.SMALL_ICON_SIZE) 482 button_box.pack_start(button, expand=True, fill=False, padding=0) 483 484 background_box.show_all() 462 clear_button = Gtk.Button(label=_('Clear search')) 463 clear_button.connect('clicked', self.__clear_button_clicked_cb) 464 clear_button.props.image = Icon(icon_name='dialog-cancel', 465 icon_size=Gtk.IconSize.BUTTON) 466 message_box.add_button(clear_button) 467 clear_button.show() 485 468 486 469 def __clear_button_clicked_cb(self, button): 487 470 self.emit('clear-clicked')