Ticket #4398: 0006-Use-MessageBox-widget-and-remove-duplicated-code-SL-.patch
File 0006-Use-MessageBox-widget-and-remove-duplicated-code-SL-.patch, 7.6 KB (added by manuq, 11 years ago) |
---|
-
src/jarabe/desktop/activitieslist.py
From dc18602b338d2e001639d68a2831f8f3b534345c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20Qui=C3=B1ones?= <manuq@laptop.org> Date: Fri, 25 Jan 2013 17:37:10 -0300 Subject: [PATCH shell 6/6] Use MessageBox widget and remove duplicated code - 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 messages in Journal and Home list view for the new toolkit widget. Signed-off-by: Manuel Quiñones <manuq@laptop.org> --- src/jarabe/desktop/activitieslist.py | 64 ++++++++++-------------------------- src/jarabe/journal/listview.py | 51 ++++++++++------------------ 2 files changed, 35 insertions(+), 80 deletions(-) diff --git a/src/jarabe/desktop/activitieslist.py b/src/jarabe/desktop/activitieslist.py index 1cf67ab..12af6dd 100644
a b import os 19 19 import logging 20 20 from gettext import gettext as _ 21 21 22 from gi.repository import GLib23 22 from gi.repository import GObject 24 23 from gi.repository import Pango 25 24 from gi.repository import GConf … … from gi.repository import Gdk 28 27 29 28 from sugar3 import util 30 29 from sugar3.graphics import style 30 from sugar3.graphics.messagebox import MessageBox 31 31 from sugar3.graphics.icon import Icon, CellRendererIcon 32 32 from sugar3.graphics.xocolor import XoColor 33 33 from sugar3.graphics.alert import Alert … … class CellRendererActivityIcon(CellRendererIcon): 316 316 self.emit('erase-activated', bundle_id) 317 317 318 318 319 class ClearMessageBox(Gtk.EventBox):320 def __init__(self, message, button_callback):321 Gtk.EventBox.__init__(self)322 323 self.modify_bg(Gtk.StateType.NORMAL,324 style.COLOR_WHITE.get_gdk_color())325 326 alignment = Gtk.Alignment.new(0.5, 0.5, 0.1, 0.1)327 self.add(alignment)328 alignment.show()329 330 box = Gtk.VBox()331 alignment.add(box)332 box.show()333 334 icon = Icon(pixel_size=style.LARGE_ICON_SIZE,335 icon_name='system-search',336 stroke_color=style.COLOR_BUTTON_GREY.get_svg(),337 fill_color=style.COLOR_TRANSPARENT.get_svg())338 box.pack_start(icon, expand=True, fill=False, padding=0)339 icon.show()340 341 label = Gtk.Label()342 color = style.COLOR_BUTTON_GREY.get_html()343 label.set_markup('<span weight="bold" color="%s">%s</span>' % ( \344 color, GLib.markup_escape_text(message)))345 box.pack_start(label, expand=True, fill=False, padding=0)346 label.show()347 348 button_box = Gtk.HButtonBox()349 button_box.set_layout(Gtk.ButtonBoxStyle.CENTER)350 box.pack_start(button_box, False, True, 0)351 button_box.show()352 353 button = Gtk.Button(label=_('Clear search'))354 button.connect('clicked', button_callback)355 button.props.image = Icon(icon_name='dialog-cancel',356 icon_size=Gtk.IconSize.BUTTON)357 button_box.pack_start(button, expand=True, fill=False, padding=0)358 button.show()359 360 361 319 class ActivitiesList(Gtk.VBox): 362 320 __gtype_name__ = 'SugarActivitiesList' 363 321 … … class ActivitiesList(Gtk.VBox): 422 380 if self._scrolled_window in self.get_children(): 423 381 self.remove(self._scrolled_window) 424 382 425 self._clear_message_box = ClearMessageBox( 426 message=_('No matching activities'), 427 button_callback=self.__clear_button_clicked_cb) 383 # Create MessageBox. 384 385 self._clear_message_box = MessageBox( 386 title=_('No matching activities'), 387 icon = Icon( 388 pixel_size=style.LARGE_ICON_SIZE, 389 icon_name='system-search', 390 stroke_color=style.COLOR_BUTTON_GREY.get_svg(), 391 fill_color=style.COLOR_TRANSPARENT.get_svg()) 392 ) 428 393 429 394 self.pack_end(self._clear_message_box, True, True, 0) 430 395 self._clear_message_box.show() 431 396 397 clear_button = Gtk.Button(label=_('Clear search')) 398 clear_button.connect('clicked', self.__clear_button_clicked_cb) 399 clear_button.props.image = Icon(icon_name='dialog-cancel', 400 icon_size=Gtk.IconSize.BUTTON) 401 self._clear_message_box.add_button(clear_button) 402 clear_button.show() 403 432 404 def __clear_button_clicked_cb(self, button): 433 405 self.emit('clear-clicked') 434 406 -
src/jarabe/journal/listview.py
diff --git a/src/jarabe/journal/listview.py b/src/jarabe/journal/listview.py index 3005d2f..9544c26 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 … … from gi.repository import GConf 26 25 from gi.repository import Pango 27 26 28 27 from sugar3.graphics import style 28 from sugar3.graphics.messagebox import MessageBox 29 29 from sugar3.graphics.icon import Icon, CellRendererIcon 30 30 from sugar3.graphics.xocolor import XoColor 31 31 from sugar3 import util … … class BaseListView(Gtk.Bin): 393 393 def _show_message(self, message, show_clear_query=False): 394 394 self.remove(self.get_child()) 395 395 396 background_box = Gtk.EventBox() 397 background_box.modify_bg(Gtk.StateType.NORMAL, 398 style.COLOR_WHITE.get_gdk_color()) 399 self.add(background_box) 396 message_box = MessageBox( 397 title = message, 398 icon = Icon( 399 pixel_size=style.LARGE_ICON_SIZE, 400 icon_name='activity-journal', 401 stroke_color=style.COLOR_BUTTON_GREY.get_svg(), 402 fill_color=style.COLOR_TRANSPARENT.get_svg()) 403 ) 400 404 401 alignment = Gtk.Alignment.new(0.5, 0.5, 0.1, 0.1) 402 background_box.add(alignment) 403 404 box = Gtk.VBox() 405 alignment.add(box) 406 407 icon = Icon(pixel_size=style.LARGE_ICON_SIZE, 408 icon_name='activity-journal', 409 stroke_color=style.COLOR_BUTTON_GREY.get_svg(), 410 fill_color=style.COLOR_TRANSPARENT.get_svg()) 411 box.pack_start(icon, expand=True, fill=False, padding=0) 412 413 label = Gtk.Label() 414 color = style.COLOR_BUTTON_GREY.get_html() 415 label.set_markup('<span weight="bold" color="%s">%s</span>' % ( \ 416 color, GLib.markup_escape_text(message))) 417 box.pack_start(label, expand=True, fill=False, padding=0) 405 self.add(message_box) 406 message_box.show() 418 407 419 408 if show_clear_query: 420 button_box = Gtk.HButtonBox() 421 button_box.set_layout(Gtk.ButtonBoxStyle.CENTER) 422 box.pack_start(button_box, False, True, 0) 423 button_box.show() 424 425 button = Gtk.Button(label=_('Clear search')) 426 button.connect('clicked', self.__clear_button_clicked_cb) 427 button.props.image = Icon(icon_name='dialog-cancel', 428 icon_size=Gtk.IconSize.BUTTON) 429 button_box.pack_start(button, expand=True, fill=False, padding=0) 430 431 background_box.show_all() 409 clear_button = Gtk.Button(label=_('Clear search')) 410 clear_button.connect('clicked', self.__clear_button_clicked_cb) 411 clear_button.props.image = Icon(icon_name='dialog-cancel', 412 icon_size=Gtk.IconSize.BUTTON) 413 message_box.add_button(clear_button) 414 clear_button.show() 432 415 433 416 def __clear_button_clicked_cb(self, button): 434 417 self.emit('clear-clicked')