22
22
const Clutter = imports.gi.Clutter;
23
23
const EvView = imports.gi.EvinceView;
24
const Gd = imports.gi.Gd;
24
const GdPrivate = imports.gi.GdPrivate;
25
25
const Gdk = imports.gi.Gdk;
26
26
const GLib = imports.gi.GLib;
27
27
const GObject = imports.gi.GObject;
34
34
const Global = imports.global;
35
35
const Manager = imports.manager;
36
36
const Notifications = imports.notifications;
37
const Properties = imports.properties;
37
38
const Query = imports.query;
38
39
const Tweener = imports.util.tweener;
39
40
const Utils = imports.utils;
483
484
this._viewCol.add_attribute(this._rendererText,
484
485
'text', OrganizeModelColumns.NAME);
486
this._rendererDetail = new Gd.StyledTextRenderer({ xpad: 16 });
487
this._rendererDetail = new GdPrivate.StyledTextRenderer({ xpad: 16 });
487
488
this._rendererDetail.add_class('dim-label');
488
489
this._viewCol.pack_start(this._rendererDetail, false);
489
490
this._viewCol.set_cell_data_func(this._rendererDetail,
716
717
Signals.addSignalMethods(SelectionController.prototype);
719
const _SELECTION_TOOLBAR_DEFAULT_WIDTH = 500;
718
721
const SelectionToolbar = new Lang.Class({
719
722
Name: 'SelectionToolbar',
726
729
this.widget = new Gtk.Toolbar({ show_arrow: false,
727
730
icon_size: Gtk.IconSize.LARGE_TOOLBAR });
728
731
this.widget.get_style_context().add_class('osd');
732
this.widget.set_size_request(_SELECTION_TOOLBAR_DEFAULT_WIDTH, -1);
730
734
this.actor = new GtkClutter.Actor({ contents: this.widget,
731
735
show_on_set_parent: false,
733
737
Utils.alphaGtkWidget(this.actor.get_widget());
735
let widthConstraint =
736
new Clutter.BindConstraint({ source: this._parentActor,
737
coordinate: Clutter.BindCoordinate.WIDTH,
739
this.actor.add_constraint(widthConstraint);
740
this.actor.connect('notify::width', Lang.bind(this,
742
let width = this._parentActor.width;
746
offset += (width - 1000);
747
else if (width < 600)
748
offset -= (600 - width);
750
widthConstraint.offset = - offset;
753
739
this.actor.add_constraint(
754
740
new Clutter.AlignConstraint({ align_axis: Clutter.AlignAxis.X_AXIS,
755
741
source: this._parentActor,
763
749
this._leftGroup = new Gtk.ToolItem({ child: this._leftBox });
764
750
this.widget.insert(this._leftGroup, -1);
766
this._toolbarFavorite = new Gtk.ToggleButton({ child: new Gtk.Image ({ icon_name: 'emblem-favorite-symbolic',
768
this._leftBox.add(this._toolbarFavorite);
769
this._toolbarFavorite.connect('clicked', Lang.bind(this, this._onToolbarFavorite));
753
this._toolbarOpen = new Gtk.Button({ child: new Gtk.Image ({ icon_name: 'folder-symbolic',
755
this._leftBox.add(this._toolbarOpen);
756
this._toolbarOpen.connect('clicked', Lang.bind(this, this._onToolbarOpen));
771
759
this._toolbarPrint = new Gtk.Button({ child: new Gtk.Image ({ icon_name: 'printer-symbolic',
773
761
this._toolbarPrint.set_tooltip_text(_("Print"));
774
762
this._leftBox.add(this._toolbarPrint);
775
763
this._toolbarPrint.connect('clicked', Lang.bind(this, this._onToolbarPrint));
766
this._toolbarTrash = new Gtk.Button({ child: new Gtk.Image ({ icon_name: 'user-trash-symbolic',
768
this._toolbarTrash.set_tooltip_text(_("Delete"));
769
this._leftBox.add(this._toolbarTrash);
770
this._toolbarTrash.connect('clicked', Lang.bind(this, this._onToolbarTrash));
777
772
this._separator = new Gtk.SeparatorToolItem({ draw: false,
778
773
visible: true });
779
774
this._separator.set_expand(true);
783
778
this._rightGroup = new Gtk.ToolItem({ child: this._rightBox });
784
779
this.widget.insert(this._rightGroup, -1);
786
782
this._toolbarCollection = new Gtk.Button({ child: new Gtk.Image ({ icon_name: 'list-add-symbolic',
788
784
this._toolbarCollection.set_tooltip_text(_("Organize"));
789
785
this._rightBox.add(this._toolbarCollection);
790
786
this._toolbarCollection.connect('clicked', Lang.bind(this, this._onToolbarCollection));
791
787
this._toolbarCollection.show_all();
793
this._toolbarTrash = new Gtk.Button({ child: new Gtk.Image ({ icon_name: 'user-trash-symbolic',
795
this._toolbarTrash.set_tooltip_text(_("Delete"));
796
this._rightBox.add(this._toolbarTrash);
797
this._toolbarTrash.connect('clicked', Lang.bind(this, this._onToolbarTrash));
799
this._toolbarOpen = new Gtk.Button({ child: new Gtk.Image ({ icon_name: 'document-open-symbolic',
801
this._rightBox.add(this._toolbarOpen);
802
this._toolbarOpen.connect('clicked', Lang.bind(this, this._onToolbarOpen));
790
this._toolbarProperties = new Gtk.Button({ child: new Gtk.Image ({ icon_name: 'document-properties-symbolic',
792
this._toolbarProperties.set_tooltip_text(_("Properties"));
793
this._rightBox.add(this._toolbarProperties);
794
this._toolbarProperties.connect('clicked', Lang.bind(this, this._onToolbarProperties));
804
796
this.widget.show_all();
872
860
showPrint &= !doc.collection;
875
showFavorite &= ((favCount == 0) || (favCount == selection.length));
876
863
showOpen = (apps.length > 0);
878
if (selection.length > 1)
865
if (selection.length > 1) {
879
866
showPrint = false;
867
showProperties = false;
881
870
let openLabel = null;
882
871
if (apps.length == 1) {
889
878
this._toolbarOpen.set_tooltip_text(openLabel);
892
let isFavorite = (favCount == selection.length);
893
let favoriteLabel = '';
896
favoriteLabel = _("Remove from favorites");
897
this._toolbarFavorite.set_active(true);
898
this._toolbarFavorite.get_style_context().add_class('documents-favorite');
900
favoriteLabel = _("Add to favorites");
901
this._toolbarFavorite.set_active(false);
902
this._toolbarFavorite.get_style_context().remove_class('documents-favorite');
905
this._toolbarFavorite.reset_style();
906
this._toolbarFavorite.set_tooltip_text(favoriteLabel);
909
880
this._toolbarPrint.set_visible(showPrint);
881
this._toolbarProperties.set_visible(showProperties);
910
882
this._toolbarTrash.set_visible(showTrash);
911
883
this._toolbarOpen.set_visible(showOpen);
912
this._toolbarFavorite.set_visible(showFavorite);
914
885
this._insideRefresh = false;
944
_onToolbarFavorite: function(widget) {
945
if (this._insideRefresh)
948
let selection = Global.selectionController.getSelection();
950
selection.forEach(Lang.bind(this,
952
let doc = Global.documentManager.getItemById(urn);
953
doc.setFavorite(!doc.favorite);
957
915
_onToolbarTrash: function(widget) {
958
916
let selection = Global.selectionController.getSelection();
925
_onToolbarProperties: function(widget) {
926
let selection = Global.selectionController.getSelection();
927
let dialog = new Properties.PropertiesDialog(selection[0]);
930
dialog.widget.connect('response', Lang.bind(this,
931
function(widget, response) {
932
dialog.widget.destroy();
967
937
_onToolbarPrint: function(widget) {
968
938
let selection = Global.selectionController.getSelection();