Skip to content

Commit

Permalink
improve css styles and quick find
Browse files Browse the repository at this point in the history
  • Loading branch information
alainm23 committed May 17, 2024
1 parent 7acae9f commit e5f1546
Show file tree
Hide file tree
Showing 31 changed files with 118 additions and 115 deletions.
2 changes: 1 addition & 1 deletion core/Layouts/HeaderItem.vala
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ public class Layouts.HeaderItem : Adw.Bin {
};

placeholder_label.add_css_class ("dim-label");
placeholder_label.add_css_class ("small-label");
placeholder_label.add_css_class ("caption");

var content_box = new Adw.Bin () {
margin_top = 12,
Expand Down
4 changes: 2 additions & 2 deletions core/Widgets/DateTimePicker/ScheduleButton.vala
Original file line number Diff line number Diff line change
Expand Up @@ -141,15 +141,15 @@ public class Widgets.ScheduleButton : Gtk.Grid {

var title_label = new Gtk.Label (_("Schedule")) {
halign = START,
css_classes = { "title-4", "small-label" }
css_classes = { "title-4", "caption" }
};

due_label = new Gtk.Label (_("Set a Due Date")) {
xalign = 0,
use_markup = true,
halign = START,
ellipsize = Pango.EllipsizeMode.END,
css_classes = { "small-label" }
css_classes = { "caption" }
};

var card_grid = new Gtk.Grid () {
Expand Down
2 changes: 1 addition & 1 deletion core/Widgets/ItemLabelChild.vala
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public class Widgets.ItemLabelChild : Gtk.FlowBoxChild {

name_label = new Gtk.Label (null);
name_label.valign = Gtk.Align.CENTER;
name_label.add_css_class ("small-label");
name_label.add_css_class ("caption");

var labelrow_grid = new Adw.Bin () {
child = name_label
Expand Down
4 changes: 2 additions & 2 deletions core/Widgets/LabelPicker/LabelButton.vala
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,15 @@ public class Widgets.LabelPicker.LabelButton : Adw.Bin {
if (is_board) {
var title_label = new Gtk.Label (_("Labels")) {
halign = START,
css_classes = { "title-4", "small-label" }
css_classes = { "title-4", "caption" }
};

labels_label = new Gtk.Label (_("Select Labels")) {
xalign = 0,
use_markup = true,
halign = START,
ellipsize = Pango.EllipsizeMode.END,
css_classes = { "small-label" }
css_classes = { "caption" }
};

var card_grid = new Gtk.Grid () {
Expand Down
2 changes: 1 addition & 1 deletion core/Widgets/LabelsPickerCore.vala
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ public class Widgets.LabelsPickerCore : Adw.Bin {
placeholder_message_label = new Gtk.Label (PLACEHOLDER_MESSAGE) {
wrap = true,
justify = Gtk.Justification.CENTER,
css_classes = { "dim-label", "small-label" }
css_classes = { "dim-label", "caption" }
};

var spinner = new Gtk.Spinner () {
Expand Down
4 changes: 2 additions & 2 deletions core/Widgets/PriorityButton.vala
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,14 @@ public class Widgets.PriorityButton : Adw.Bin {

var title_label = new Gtk.Label (_("Priority")) {
halign = START,
css_classes = { "title-4", "small-label" }
css_classes = { "title-4", "caption" }
};

priority_label = new Gtk.Label (_("Priority 4: None")) {
xalign = 0,
use_markup = true,
halign = START,
css_classes = { "small-label" }
css_classes = { "caption" }
};

var card_grid = new Gtk.Grid () {
Expand Down
4 changes: 2 additions & 2 deletions core/Widgets/ReminderPicker/ReminderButton.vala
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,15 @@ public class Widgets.ReminderPicker.ReminderButton : Adw.Bin {
if (is_board) {
var title_label = new Gtk.Label (_("Reminders")) {
halign = START,
css_classes = { "title-4", "small-label" }
css_classes = { "title-4", "caption" }
};

value_label = new Gtk.Label (_("Add Reminders")) {
xalign = 0,
use_markup = true,
halign = START,
ellipsize = Pango.EllipsizeMode.END,
css_classes = { "small-label" }
css_classes = { "caption" }
};

var card_grid = new Gtk.Grid () {
Expand Down
4 changes: 2 additions & 2 deletions core/Widgets/SectionPicker/SectionButton.vala
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ public class Widgets.SectionPicker.SectionButton : Adw.Bin {
construct {
var title_label = new Gtk.Label (_("Section")) {
halign = START,
css_classes = { "title-4", "small-label" }
css_classes = { "title-4", "caption" }
};

section_label = new Gtk.Label (_("Select Section")) {
xalign = 0,
use_markup = true,
halign = START,
ellipsize = Pango.EllipsizeMode.END,
css_classes = { "small-label" }
css_classes = { "caption" }
};

var card_grid = new Gtk.Grid () {
Expand Down
4 changes: 2 additions & 2 deletions core/Widgets/StatusButton.vala
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@ public class Widgets.StatusButton : Adw.Bin {

var title_label = new Gtk.Label (_("Status")) {
halign = START,
css_classes = { "title-4", "small-label" }
css_classes = { "title-4", "caption" }
};

value_label = new Gtk.Label (_("To Do")) {
xalign = 0,
use_markup = true,
halign = START,
css_classes = { "small-label" }
css_classes = { "caption" }
};

var card_grid = new Gtk.Grid () {
Expand Down
4 changes: 0 additions & 4 deletions data/resources/stylesheet/typography.css
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
.small-label {
font-size: 0.85em;
}

.dim-label,
:visited {
opacity: 0.75;
Expand Down
2 changes: 1 addition & 1 deletion src/Dialogs/Preferences/Pages/Sidebar.vala
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public class Dialogs.Preferences.Pages.Sidebar : Adw.Bin {
content_box.append (count_group);
content_box.append (views_group);
content_box.append (new Gtk.Label (_("You can sort your views by dragging and dropping")) {
css_classes = { "small-label", "dim-label" },
css_classes = { "caption", "dim-label" },
halign = START,
margin_start = 12,
margin_top = 3
Expand Down
6 changes: 3 additions & 3 deletions src/Dialogs/Preferences/PreferencesWindow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public class Dialogs.Preferences.PreferencesWindow : Adw.PreferencesDialog {
xalign = 0,
yalign = 0,
wrap = true,
css_classes = { "small-label", "banner-text" }
css_classes = { "caption", "banner-text" }
};

var banner_button = new Gtk.Button.with_label (_("Supporting Us")) {
Expand Down Expand Up @@ -1162,7 +1162,7 @@ public class Dialogs.Preferences.PreferencesWindow : Adw.PreferencesDialog {
var command_entry = new Adw.ActionRow ();
command_entry.add_suffix (copy_button);
command_entry.title = quick_add_command;
command_entry.add_css_class ("small-label");
command_entry.add_css_class ("caption");
command_entry.add_css_class ("monospace");

var command_group = new Adw.PreferencesGroup () {
Expand Down Expand Up @@ -1870,7 +1870,7 @@ private class ValidationMessage : Gtk.Box {
wrap = true,
xalign = 1
};
label_widget.add_css_class ("small-label");
label_widget.add_css_class ("caption");

var revealer = new Gtk.Revealer () {
child = label_widget,
Expand Down
108 changes: 54 additions & 54 deletions src/Dialogs/QuickFind/QuickFind.vala
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,16 @@
* Authored by: Alain M. <[email protected]>
*/

public class Dialogs.QuickFind.QuickFind : Adw.Window {
public class Dialogs.QuickFind.QuickFind : Adw.Dialog {
private Gtk.SearchEntry search_entry;
private Gtk.ListBox listbox;
private Gee.ArrayList<Dialogs.QuickFind.QuickFindItem> items;

public QuickFind () {
Object (
transient_for: Planify.instance.main_window,
deletable: false,
modal: true,
margin_bottom: 164,
width_request: 350,
height_request: 325
content_width: 350,
content_height: 325,
presentation_mode: Adw.DialogPresentationMode.FLOATING
);
}

Expand All @@ -50,15 +48,19 @@ public class Dialogs.QuickFind.QuickFind : Adw.Window {
var headerbar_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 6) {
hexpand = true,
margin_top = 6,
margin_bottom = 6
margin_bottom = 6,
margin_start = 6
};

headerbar_box.append (search_entry);
headerbar_box.append (cancel_button);

var headerbar = new Adw.HeaderBar ();
headerbar.add_css_class ("flat");
headerbar.title_widget = headerbar_box;
var headerbar = new Adw.HeaderBar () {
title_widget = headerbar_box,
show_start_title_buttons = false,
show_end_title_buttons = false,
css_classes = { "flat" }
};

listbox = new Gtk.ListBox () {
hexpand = true,
Expand All @@ -69,57 +71,28 @@ public class Dialogs.QuickFind.QuickFind : Adw.Window {
listbox.set_placeholder (get_placeholder ());
listbox.set_header_func (header_function);

var listbox_content = new Adw.Bin () {
margin_bottom = 6,
child = listbox
};

var listbox_scrolled = new Gtk.ScrolledWindow () {
hexpand = true,
vexpand = true,
hscrollbar_policy = Gtk.PolicyType.NEVER,
child = listbox_content
child = listbox
};

var toolbar_view = new Adw.ToolbarView ();
toolbar_view.add_top_bar (headerbar);
toolbar_view.content = listbox_scrolled;

content = toolbar_view;

Timeout.add (250, () => {
search_entry.grab_focus ();
return GLib.Source.REMOVE;
});
child = toolbar_view;
default_widget = search_entry;
Services.EventBus.get_default ().disconnect_typing_accel ();

search_entry.search_changed.connect (() => {
search_changed ();
});

var controller_key = new Gtk.EventControllerKey ();
content.add_controller (controller_key);

controller_key.key_pressed.connect ((keyval, keycode, state) => {
var key = Gdk.keyval_name (keyval).replace ("KP_", "");

if (key == "Up" || key == "Down") {
return false;
} else if (key == "Enter" || key == "Return" || key == "KP_Enter") {
row_activated (listbox.get_selected_row ());
return false;
} else {
if (!search_entry.has_focus) {
search_entry.grab_focus ();
if (search_entry.cursor_position < search_entry.text.length) {
search_entry.set_position (search_entry.text.length);
}
}

return false;
}

return true;
});
var listbox_controller_key = new Gtk.EventControllerKey ();
listbox.add_controller (listbox_controller_key);
listbox_controller_key.key_pressed.connect (key_pressed);

listbox.row_activated.connect ((row) => {
row_activated (row);
Expand Down Expand Up @@ -148,6 +121,36 @@ public class Dialogs.QuickFind.QuickFind : Adw.Window {
cancel_button.clicked.connect (() => {
hide_destroy ();
});

var destroy_controller = new Gtk.EventControllerKey ();
add_controller (destroy_controller);
destroy_controller.key_released.connect ((keyval, keycode, state) => {
if (keyval == 65307) {
hide_destroy ();
}
});

closed.connect (() => {
Services.EventBus.get_default ().connect_typing_accel ();
});
}

private bool key_pressed (uint keyval, uint keycode, Gdk.ModifierType state) {
var key = Gdk.keyval_name (keyval).replace ("KP_", "");

if (key == "Up" || key == "Down") {
} else if (key == "Enter" || key == "Return" || key == "KP_Enter") {
row_activated (listbox.get_selected_row ());
} else {
if (!search_entry.has_focus) {
search_entry.grab_focus ();
if (search_entry.cursor_position < search_entry.text.length) {
search_entry.set_position (search_entry.text.length);
}
}
}

return false;
}

private void search_changed () {
Expand Down Expand Up @@ -262,12 +265,7 @@ public class Dialogs.QuickFind.QuickFind : Adw.Window {
}

private void hide_destroy () {
hide ();

Timeout.add (500, () => {
destroy ();
return GLib.Source.REMOVE;
});
close ();
}

private void clean_results () {
Expand All @@ -288,7 +286,9 @@ public class Dialogs.QuickFind.QuickFind : Adw.Window {
}
}

var header_label = new Granite.HeaderLabel (row.base_object.object_type.get_header ()) {
var header_label = new Gtk.Label (row.base_object.object_type.get_header ()) {
css_classes = { "heading", "h4" },
halign = Gtk.Align.START,
margin_start = 12,
margin_bottom = 6,
margin_top = 6
Expand Down
4 changes: 2 additions & 2 deletions src/Dialogs/QuickFind/QuickFindItem.vala
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public class Dialogs.QuickFind.QuickFindItem : Gtk.ListBoxRow {
var project_label = new Gtk.Label (section.project.name) {
ellipsize = Pango.EllipsizeMode.END,
xalign = 0,
css_classes = { "dim-label", "small-label" }
css_classes = { "dim-label", "caption" }
};

main_grid.attach (section_icon, 0, 0, 1, 2);
Expand All @@ -98,7 +98,7 @@ public class Dialogs.QuickFind.QuickFindItem : Gtk.ListBoxRow {
var project_label = new Gtk.Label (item.project.name) {
ellipsize = Pango.EllipsizeMode.END,
xalign = 0,
css_classes = { "dim-label", "small-label" }
css_classes = { "dim-label", "caption" }
};

main_grid.attach (checked_button, 0, 0, 1, 2);
Expand Down
Loading

0 comments on commit e5f1546

Please sign in to comment.