Skip to content

Commit

Permalink
avoid rebuilding guitoots
Browse files Browse the repository at this point in the history
  • Loading branch information
donpdonp committed Aug 7, 2019
1 parent ea6b16b commit 011ac99
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
1 change: 1 addition & 0 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ pub fn build(b: *Builder) void {

// Ubuntu-x86_64
exe.addIncludeDir("/usr/include");
//exe.addIncludeDir("/usr/include/linux");
exe.addIncludeDir("/usr/include/x86_64-linux-gnu");
exe.addLibPath("/usr/lib");
exe.addLibPath("/usr/lib/x86_64-linux-gnu");
Expand Down
18 changes: 12 additions & 6 deletions src/gui/gtk.zig
Original file line number Diff line number Diff line change
Expand Up @@ -287,22 +287,28 @@ pub fn update_column_toots(column: *Column) void {
const column_toot_zone = builder_get_widget(column.builder, c"toot_zone");
const column_footer_count_label = builder_get_widget(column.builder, c"column_footer_count");
var gtk_context = c.gtk_widget_get_style_context(column_footer_count_label);
c.gtk_container_foreach(@ptrCast([*c]c.GtkContainer, column_toot_zone), widget_destroy, null); // todo: avoid this
if(column.main.inError) {
c.gtk_style_context_add_class(gtk_context, c"net_error");
} else {
c.gtk_style_context_remove_class(gtk_context, c"net_error");
}
var current = column.main.toots.first();
var idx = c_int(0);
if (current != null) {
while(current) |node| {
const toot = node.data;
const tootbuilder = makeTootBox(toot, column.main.config);
var tootbox = builder_get_widget(tootbuilder, c"tootbox");
c.gtk_box_pack_start(@ptrCast([*c]c.GtkBox, column_toot_zone), tootbox,
c.gtk_true(), c.gtk_true(), 0);
_ = column.guitoots.put(toot.id(), tootbuilder) catch unreachable;
var tootbuilderMaybe = column.guitoots.get(toot.id());
if(tootbuilderMaybe) |kv| {
} else {
const tootbuilder = makeTootBox(toot, column.main.config);
var tootbox = builder_get_widget(tootbuilder, c"tootbox");
_ = column.guitoots.put(toot.id(), tootbuilder) catch unreachable;
c.gtk_box_pack_start(@ptrCast([*c]c.GtkBox, column_toot_zone), tootbox,
c.gtk_true(), c.gtk_true(), 0);
c.gtk_box_reorder_child(@ptrCast([*c]c.GtkBox, column_toot_zone), tootbox, idx);
}
current = node.next;
idx += 1;
}
} else {
// help? logo?
Expand Down

0 comments on commit 011ac99

Please sign in to comment.