37 | 37 |
from sugar3.graphics.alert import NotifyAlert
|
38 | 38 |
from logcollect import LogCollect
|
39 | 39 |
from sugar3.graphics.toolbarbox import ToolbarBox
|
|
40 |
from sugar3.graphics.toolbarbox import ToolbarButton
|
40 | 41 |
from sugar3.activity.widgets import CopyButton, StopButton
|
41 | 42 |
from sugar3.datastore import datastore
|
42 | 43 |
|
|
423 | 424 |
self.clipboard = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD)
|
424 | 425 |
self.show()
|
425 | 426 |
|
|
427 |
self._configure_cb(None)
|
|
428 |
|
|
429 |
Gdk.Screen.get_default().connect('size-changed', self._configure_cb)
|
|
430 |
|
426 | 431 |
def _build_toolbox(self):
|
427 | 432 |
toolbar_box = ToolbarBox()
|
428 | 433 |
|
|
431 | 436 |
activity_button = ActivityToolbarButton(self)
|
432 | 437 |
activity_toolbar = activity_button.page
|
433 | 438 |
|
434 | |
toolbar_box.toolbar.insert(activity_button, -1)
|
|
439 |
self._toolbar = toolbar_box.toolbar
|
|
440 |
self._toolbar.insert(activity_button, -1)
|
|
441 |
|
|
442 |
self._secondary_toolbar = Gtk.Toolbar()
|
|
443 |
self._secondary_toolbar_button = ToolbarButton(
|
|
444 |
page=self._secondary_toolbar,
|
|
445 |
icon_name='system-search')
|
|
446 |
self._secondary_toolbar.show()
|
|
447 |
self._toolbar.insert(self._secondary_toolbar_button, -1)
|
|
448 |
self._secondary_toolbar_button.hide()
|
435 | 449 |
|
436 | 450 |
show_list = ToggleToolButton('view-list')
|
437 | 451 |
show_list.set_active(True)
|
438 | 452 |
show_list.set_tooltip(_('Show list of files'))
|
439 | 453 |
show_list.connect('toggled', self._list_toggled_cb)
|
440 | |
toolbar_box.toolbar.insert(show_list, -1)
|
|
454 |
self._toolbar.insert(show_list, -1)
|
441 | 455 |
show_list.show()
|
442 | 456 |
|
443 | 457 |
copy = CopyButton()
|
444 | 458 |
copy.connect('clicked', self.__copy_clicked_cb)
|
445 | |
toolbar_box.toolbar.insert(copy, -1)
|
|
459 |
self._toolbar.insert(copy, -1)
|
446 | 460 |
|
447 | 461 |
wrap_btn = ToggleToolButton("format-wrap")
|
448 | 462 |
wrap_btn.set_tooltip(_('Word Wrap'))
|
449 | 463 |
wrap_btn.connect('clicked', self._wrap_cb)
|
450 | |
toolbar_box.toolbar.insert(wrap_btn, -1)
|
|
464 |
self._toolbar.insert(wrap_btn, -1)
|
451 | 465 |
|
452 | 466 |
self.search_entry = iconentry.IconEntry()
|
453 | 467 |
self.search_entry.set_size_request(Gdk.Screen.width() / 3, -1)
|
|
456 | 470 |
self.search_entry.add_clear_button()
|
457 | 471 |
self.search_entry.connect('activate', self._search_entry_activate_cb)
|
458 | 472 |
self.search_entry.connect('changed', self._search_entry_changed_cb)
|
459 | |
search_item = Gtk.ToolItem()
|
460 | |
search_item.add(self.search_entry)
|
461 | |
toolbar_box.toolbar.insert(search_item, -1)
|
|
473 |
self._search_item = Gtk.ToolItem()
|
|
474 |
self._search_item.add(self.search_entry)
|
|
475 |
self._toolbar.insert(self._search_item, -1)
|
462 | 476 |
|
463 | 477 |
self._search_prev = ToolButton('go-previous-paired')
|
464 | 478 |
self._search_prev.set_tooltip(_('Previous'))
|
465 | 479 |
self._search_prev.connect('clicked', self._search_prev_cb)
|
466 | |
toolbar_box.toolbar.insert(self._search_prev, -1)
|
|
480 |
self._toolbar.insert(self._search_prev, -1)
|
467 | 481 |
|
468 | 482 |
self._search_next = ToolButton('go-next-paired')
|
469 | 483 |
self._search_next.set_tooltip(_('Next'))
|
470 | 484 |
self._search_next.connect('clicked', self._search_next_cb)
|
471 | |
toolbar_box.toolbar.insert(self._search_next, -1)
|
|
485 |
self._toolbar.insert(self._search_next, -1)
|
472 | 486 |
|
473 | 487 |
self._update_search_buttons()
|
474 | 488 |
|
|
479 | 493 |
collector_btn.show()
|
480 | 494 |
activity_toolbar.insert(collector_btn, -1)
|
481 | 495 |
|
482 | |
delete_btn = ToolButton('list-remove')
|
483 | |
delete_btn.set_tooltip(_('Delete Log File'))
|
484 | |
delete_btn.connect('clicked', self._delete_log_cb)
|
485 | |
toolbar_box.toolbar.insert(delete_btn, -1)
|
486 | |
|
487 | |
separator = Gtk.SeparatorToolItem()
|
488 | |
separator.set_expand(True)
|
489 | |
separator.set_draw(False)
|
490 | |
toolbar_box.toolbar.insert(separator, -1)
|
491 | |
|
492 | |
toolbar_box.toolbar.insert(StopButton(self), -1)
|
|
496 |
self._delete_btn = ToolButton('list-remove')
|
|
497 |
self._delete_btn.set_tooltip(_('Delete Log File'))
|
|
498 |
self._delete_btn.connect('clicked', self._delete_log_cb)
|
|
499 |
self._toolbar.insert(self._delete_btn, -1)
|
|
500 |
|
|
501 |
self._separator = Gtk.SeparatorToolItem()
|
|
502 |
self._separator.set_expand(True)
|
|
503 |
self._separator.set_draw(False)
|
|
504 |
self._toolbar.insert(self._separator, -1)
|
|
505 |
|
|
506 |
self._stop_btn = StopButton(self)
|
|
507 |
self._toolbar.insert(self._stop_btn, -1)
|
493 | 508 |
|
494 | 509 |
toolbar_box.show_all()
|
495 | 510 |
self.set_toolbar_box(toolbar_box)
|
|
511 |
|
|
512 |
def _configure_cb(self, event=None):
|
|
513 |
for control in [self._stop_btn, self._separator, self._delete_btn]:
|
|
514 |
if control in self._toolbar:
|
|
515 |
self._toolbar.remove(control)
|
|
516 |
|
|
517 |
if Gdk.Screen.width() < Gdk.Screen.height():
|
|
518 |
self._secondary_toolbar_button.show()
|
|
519 |
self._secondary_toolbar_button.set_expanded(True)
|
|
520 |
self._remove_controls(self._toolbar)
|
|
521 |
self._add_controls(self._secondary_toolbar)
|
|
522 |
else:
|
|
523 |
self._secondary_toolbar_button.set_expanded(False)
|
|
524 |
self._secondary_toolbar_button.hide()
|
|
525 |
self._remove_controls(self._secondary_toolbar)
|
|
526 |
self._add_controls(self._toolbar)
|
|
527 |
|
|
528 |
for control in [self._delete_btn, self._separator, self._stop_btn]:
|
|
529 |
if not control in self._toolbar:
|
|
530 |
self._toolbar.insert(control, -1)
|
|
531 |
|
|
532 |
def _remove_controls(self, toolbar):
|
|
533 |
for control in [self._search_item, self._search_prev,
|
|
534 |
self._search_next]:
|
|
535 |
if control in toolbar:
|
|
536 |
toolbar.remove(control)
|
|
537 |
|
|
538 |
def _add_controls(self, toolbar):
|
|
539 |
for control in [self._search_item, self._search_prev,
|
|
540 |
self._search_next]:
|
|
541 |
if not control in toolbar:
|
|
542 |
toolbar.insert(control, -1)
|
|
543 |
control.show()
|
496 | 544 |
|
497 | 545 |
def _list_toggled_cb(self, widget):
|
498 | 546 |
if widget.get_active():
|