Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[GtkPrep] Cleanup treeviews contd #2379

Merged
merged 4 commits into from
Jan 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/View/AbstractDirectoryView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ namespace Files {
debug ("ADV destruct"); // Cannot reference slot here as it is already invalid
}

protected virtual void set_up_name_renderer () {
protected void set_up_name_renderer () {
name_renderer.editable = false;
name_renderer.edited.connect (on_name_edited);
name_renderer.editing_canceled.connect (on_name_editing_canceled);
Expand Down
65 changes: 29 additions & 36 deletions src/View/AbstractTreeView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,42 @@ namespace Files {
debug ("ATV destruct");
}

protected virtual void create_and_set_up_name_column () {
protected abstract void set_up_icon_renderer ();

protected override void connect_tree_signals () {
tree.get_selection ().changed.connect (on_view_selection_changed);
}

protected override void disconnect_tree_signals () {
tree.get_selection ().changed.disconnect (on_view_selection_changed);
}

protected override Gtk.Widget? create_view () {
tree = new Files.TreeView () {
model = model,
headers_visible = false,
rubber_banding = true
};

tree.get_selection ().set_mode (Gtk.SelectionMode.MULTIPLE);

name_column = new Gtk.TreeViewColumn () {
sort_column_id = Files.ListModel.ColumnID.FILENAME,
expand = true,
resizable = true
};

name_renderer = new Files.TextRenderer (ViewMode.LIST);
name_renderer = new Files.TextRenderer (ViewMode.LIST) {
wrap_width = -1,
zoom_level = ZoomLevel.NORMAL,
ellipsize_set = true,
ellipsize = Pango.EllipsizeMode.END,
xalign = 0.0f,
yalign = 0.5f
};
set_up_name_renderer ();


set_up_icon_renderer ();
var emblem_renderer = new Files.EmblemRenderer ();
emblem_renderer.yalign = 0.5f;
Expand All @@ -58,46 +85,12 @@ namespace Files {
"file", Files.ListModel.ColumnID.FILE_COLUMN);

tree.append_column (name_column);
}

protected abstract void set_up_icon_renderer ();

protected void set_up_view () {
connect_tree_signals ();
tree.realize.connect ((w) => {
tree.grab_focus ();
tree.columns_autosize ();
tree.zoom_level = zoom_level;
});
}

protected override void set_up_name_renderer () {
base.set_up_name_renderer ();
name_renderer.@set ("wrap-width", -1);
name_renderer.@set ("zoom-level", ZoomLevel.NORMAL);
name_renderer.@set ("ellipsize-set", true);
name_renderer.@set ("ellipsize", Pango.EllipsizeMode.END);
name_renderer.xalign = 0.0f;
name_renderer.yalign = 0.5f;
}

protected override void connect_tree_signals () {
tree.get_selection ().changed.connect (on_view_selection_changed);
}
protected override void disconnect_tree_signals () {
tree.get_selection ().changed.disconnect (on_view_selection_changed);
}

protected override Gtk.Widget? create_view () {
tree = new Files.TreeView () {
model = model,
headers_visible = false,
rubber_banding = true
};

tree.get_selection ().set_mode (Gtk.SelectionMode.MULTIPLE);
create_and_set_up_name_column ();
set_up_view ();

return tree as Gtk.Widget;
}
Expand Down