Skip to content

Commit 36d04dd

Browse files
committed
Update layout widgets to GTK4
1 parent fa327fa commit 36d04dd

File tree

4 files changed

+25
-23
lines changed

4 files changed

+25
-23
lines changed

src/Application.vala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ public class Obliviate.Application : Gtk.Application {
5252

5353
var provider = new Gtk.CssProvider ();
5454
provider.load_from_resource ("/com/github/elfenware/obliviate/Application.css");
55-
Gtk.StyleContext.add_provider_for_screen (
56-
Gdk.Screen.get_default (),
55+
Gtk.StyleContext.add_provider_for_display (
56+
Gdk.Display.get_default (),
5757
provider,
5858
Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION
5959
);

src/MainView.vala

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,10 @@ public class Obliviate.MainView : Gtk.Overlay {
3838
grid = new Gtk.Grid () {
3939
row_spacing = 4,
4040
column_spacing = 4,
41-
margin = 30,
41+
margin_top = 30,
42+
margin_bottom = 30,
43+
margin_start = 30,
44+
margin_end = 30,
4245
halign = Gtk.Align.CENTER
4346
};
4447

@@ -53,15 +56,13 @@ public class Obliviate.MainView : Gtk.Overlay {
5356
};
5457

5558
site = new Gtk.Entry () {
56-
placeholder_text = _ ("GitHub")
59+
placeholder_text = _ ("GitHub"),
60+
primary_icon_name = "dialog-information-symbolic",
61+
primary_icon_tooltip_text = "Site is not case-sensitive. “GitHub” equals “github”."
5762
};
5863

5964
site.changed.connect (handle_generate_password);
6065

61-
var site_info = new Gtk.Image.from_icon_name ("dialog-information-symbolic", Gtk.IconSize.MENU) {
62-
tooltip_text = _ ("Site is not case-sensitive. “GitHubequalsgithub”.")
63-
};
64-
6566
var cipher_key_label = new Gtk.Label (_ ("Cipher key:")) {
6667
halign = Gtk.Align.END,
6768
margin_end = 4
@@ -103,8 +104,8 @@ public class Obliviate.MainView : Gtk.Overlay {
103104
});
104105

105106
var button_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 6);
106-
button_box.pack_start (copy_btn);
107-
button_box.pack_end (copy_without_symbols_btn);
107+
button_box.prepend (copy_btn);
108+
button_box.append (copy_without_symbols_btn);
108109

109110
clearing_label = new Gtk.Label (ngettext (
110111
"Clearing clipboard in %.0f second",
@@ -123,14 +124,13 @@ public class Obliviate.MainView : Gtk.Overlay {
123124
clearing_progress.add_css_class (Granite.STYLE_CLASS_FLAT);
124125

125126
var plus_label = new Gtk.Label ("+");
126-
plus_label.get_style_context ().add_class ("sign");
127+
plus_label.add_css_class ("sign");
127128

128129
var equals_label = new Gtk.Label ("=");
129-
equals_label.get_style_context ().add_class ("sign");
130+
equals_label.add_css_class ("sign");
130131

131132
grid.attach (site_label, 0, 0, 1, 1);
132133
grid.attach_next_to (site, site_label, Gtk.PositionType.RIGHT);
133-
grid.attach_next_to (site_info, site, Gtk.PositionType.RIGHT);
134134

135135
grid.attach_next_to (plus_label, site, Gtk.PositionType.BOTTOM);
136136

src/MainWindow.vala

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@ public class Obliviate.MainWindow : Gtk.Window {
2626
}
2727

2828
construct {
29-
var header = get_header ();
29+
var headerbar = get_headerbar ();
3030

3131
var main = new MainView ();
3232

3333
var box = new Gtk.Box (Gtk.Orientation.VERTICAL, 0);
34-
box.add (header);
35-
box.add (main);
34+
box.append (headerbar);
35+
box.append (main);
3636
set_child (box);
3737

3838
set_size_request (440, 280);
@@ -48,15 +48,15 @@ public class Obliviate.MainWindow : Gtk.Window {
4848
});
4949
}
5050

51-
private Gtk.HeaderBar get_header () {
51+
private Gtk.HeaderBar get_headerbar () {
5252
set_title (_("Obliviate"));
5353
Gtk.Label title_widget = new Gtk.Label (_("Obliviate"));
5454
title_widget.add_css_class (Granite.STYLE_CLASS_TITLE_LABEL);
5555

56-
var header = new Gtk.HeaderBar ();
57-
header.set_title_widget (title_widget);
58-
header.add_css_class (Granite.STYLE_CLASS_FLAT);
59-
set_titlebar (header);
56+
var headerbar = new Gtk.HeaderBar ();
57+
headerbar.set_title_widget (title_widget);
58+
headerbar.add_css_class (Granite.STYLE_CLASS_FLAT);
59+
set_titlebar (headerbar);
6060

6161
var help_btn = new Gtk.Button.from_icon_name ("help-contents") {
6262
tooltip_text = _("Help and FAQ")
@@ -70,9 +70,9 @@ public class Obliviate.MainWindow : Gtk.Window {
7070
}
7171
});
7272

73-
header.pack_end (help_btn);
73+
headerbar.pack_end (help_btn);
7474

75-
return header;
75+
return headerbar;
7676
}
7777

7878
private bool before_destroy () {

src/Service.vala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,5 +70,7 @@ public class Obliviate.Service : GLib.Object {
7070
} catch (Error e) {
7171
debug ("Error removing symbols.");
7272
}
73+
74+
return str;
7375
}
7476
}

0 commit comments

Comments
 (0)