Skip to content

Commit

Permalink
statusbar improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
eyelash committed Oct 21, 2023
1 parent 44140a9 commit bf757bb
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 14 deletions.
3 changes: 0 additions & 3 deletions data/one-dark.scss
Original file line number Diff line number Diff line change
Expand Up @@ -444,8 +444,5 @@ window {
background-color: $level-3-color;
border-top: 1px solid $base-border-color;
color: $text-color;
label {
padding: 0 0.75em;
}
}
}
1 change: 1 addition & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ executable(
'src/window.vala',
'src/notebook.vala',
'src/text-editor-container.vala',
'src/statusbar.vala',
'src/atom.vapi',
'src/text-editor-widget.cc',
import('gnome').compile_resources(
Expand Down
37 changes: 37 additions & 0 deletions src/statusbar.vala
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
namespace Atom {

class Statusbar : Gtk.Box {
static construct {
set_css_name("statusbar");
}

public Statusbar(Atom.TextEditorWidget text_editor_widget) {
Object(orientation: Gtk.Orientation.HORIZONTAL, spacing: 2);

var cursor_position_label = new Gtk.Label(null);
text_editor_widget.bind_property("cursor-position", cursor_position_label, "label", BindingFlags.SYNC_CREATE);
pack_start(pack(cursor_position_label), false);

var grammar_label = new Gtk.Label(null);
text_editor_widget.bind_property("grammar", grammar_label, "label", BindingFlags.SYNC_CREATE);
pack_end(pack(grammar_label), false);

var encoding_label = new Gtk.Label("UTF-8");
encoding_label.tooltip_text = "This file uses UTF-8 encoding";
pack_end(pack(encoding_label), false);
}

private static Gtk.Widget pack(Gtk.Widget child) {
var frame = new Gtk.Frame(null);
frame.shadow_type = Gtk.ShadowType.NONE;
var box = new Gtk.Box(Gtk.Orientation.HORIZONTAL, 4);
box.margin = 4;
box.margin_start = 11;
box.margin_end = 11;
box.add(child);
frame.add(box);
return frame;
}
}

}
11 changes: 1 addition & 10 deletions src/text-editor-container.vala
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,7 @@ class TextEditorContainer : Gtk.Box {
text_editor_widget = new Atom.TextEditorWidget(file);
scrolled_window.add(text_editor_widget);
pack_start(scrolled_window, true);
var status_bar = new Gtk.Statusbar();
status_bar.margin = 0;
var cursor_position_label = new Gtk.Label(null);
text_editor_widget.bind_property("cursor-position", cursor_position_label, "label", BindingFlags.SYNC_CREATE);
status_bar.pack_start(cursor_position_label, false);
status_bar.reorder_child(cursor_position_label, 0);
var grammar_label = new Gtk.Label(null);
text_editor_widget.bind_property("grammar", grammar_label, "label", BindingFlags.SYNC_CREATE);
status_bar.pack_end(grammar_label, false);
status_bar.pack_end(new Gtk.Label("UTF-8"), false);
var status_bar = new Atom.Statusbar(text_editor_widget);
pack_start(status_bar, false);
}

Expand Down

0 comments on commit bf757bb

Please sign in to comment.