Skip to content

Commit

Permalink
Preparations for Gtk4 (#360)
Browse files Browse the repository at this point in the history
  • Loading branch information
lenemter committed Jun 10, 2023
1 parent d8c7b2f commit acf44ab
Show file tree
Hide file tree
Showing 13 changed files with 154 additions and 310 deletions.
25 changes: 5 additions & 20 deletions data/EntryPopover.css
Original file line number Diff line number Diff line change
@@ -1,24 +1,9 @@
/*
* Copyright 2020 elementary, Inc. (https://elementary.io)
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA
*
*/
* Copyright 2020-2023 elementary, Inc. (https://elementary.io)
* SPDX-License-Identifier: GPL-3.0-or-later
*/

entry-popover grid {
entry-popover box {
border-radius: 3px;
background: @SILVER_300;
}
Expand All @@ -29,7 +14,7 @@ entry-popover button {
font-weight: 600;
}

entry-popover.error grid {
entry-popover.error box {
background: alpha (@error_color, 0.2);
}

Expand Down
2 changes: 1 addition & 1 deletion meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ executable(
'src/Widgets/EntryPopover/Location.vala',
'src/Widgets/ScheduledRow.vala',
'src/Widgets/SourceRow.vala',
'src/Widgets/ScheduledTaskListGrid.vala',
'src/Widgets/ScheduledTaskListBox.vala',
'src/Widgets/TaskListGrid.vala',
'src/Widgets/TaskRow.vala',
'src/Widgets/ListSettingsPopover.vala',
Expand Down
64 changes: 24 additions & 40 deletions src/MainWindow.vala
Original file line number Diff line number Diff line change
@@ -1,22 +1,7 @@
/*
* Copyright 2019 elementary, Inc. (https://elementary.io)
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA
*
*/
* Copyright 2019-2023 elementary, Inc. (https://elementary.io)
* SPDX-License-Identifier: GPL-3.0-or-later
*/

public class Tasks.MainWindow : Hdy.ApplicationWindow {
public const string ACTION_GROUP_PREFIX = "win";
Expand Down Expand Up @@ -95,7 +80,8 @@ public class Tasks.MainWindow : Hdy.ApplicationWindow {
listbox.add (scheduled_row);

var scrolledwindow = new Gtk.ScrolledWindow (null, null) {
expand = true,
hexpand = true,
vexpand = true,
hscrollbar_policy = Gtk.PolicyType.NEVER
};
scrolledwindow.add (listbox);
Expand All @@ -108,18 +94,17 @@ public class Tasks.MainWindow : Hdy.ApplicationWindow {
text = _("Online Accounts Settings…")
};

var add_tasklist_grid = new Gtk.Grid () {
var add_tasklist_box = new Gtk.Box (Gtk.Orientation.VERTICAL, 3) {
margin_top = 3,
margin_bottom = 3,
row_spacing = 3
margin_bottom = 3
};
add_tasklist_grid.attach (add_tasklist_buttonbox, 0, 0);
add_tasklist_grid.attach (new Gtk.Separator (Gtk.Orientation.HORIZONTAL), 0, 1);
add_tasklist_grid.attach (online_accounts_button, 0, 2);
add_tasklist_grid.show_all ();
add_tasklist_box.add (add_tasklist_buttonbox);
add_tasklist_box.add (new Gtk.Separator (Gtk.Orientation.HORIZONTAL));
add_tasklist_box.add (online_accounts_button);
add_tasklist_box.show_all ();

var add_tasklist_popover = new Gtk.Popover (null);
add_tasklist_popover.add (add_tasklist_grid);
add_tasklist_popover.add (add_tasklist_box);

var add_tasklist_button = new Gtk.MenuButton () {
label = _("Add Task List…"),
Expand All @@ -134,24 +119,23 @@ public class Tasks.MainWindow : Hdy.ApplicationWindow {
unowned Gtk.StyleContext actionbar_style_context = actionbar.get_style_context ();
actionbar_style_context.add_class (Gtk.STYLE_CLASS_FLAT);

var sidebar = new Gtk.Grid ();
sidebar.attach (sidebar_header, 0, 0);
sidebar.attach (scrolledwindow, 0, 1);
sidebar.attach (actionbar, 0, 2);
var sidebar = new Gtk.Box (Gtk.Orientation.VERTICAL, 0);
sidebar.get_style_context ().add_class (Gtk.STYLE_CLASS_SIDEBAR);
sidebar.add (sidebar_header);
sidebar.add (scrolledwindow);
sidebar.add (actionbar);

unowned Gtk.StyleContext sidebar_style_context = sidebar.get_style_context ();
sidebar_style_context.add_class (Gtk.STYLE_CLASS_SIDEBAR);

task_list_grid_stack = new Gtk.Stack ();

var main_grid = new Gtk.Grid ();
main_grid.get_style_context ().add_class (Gtk.STYLE_CLASS_BACKGROUND);
main_grid.attach (main_header, 0, 0);
main_grid.attach (task_list_grid_stack, 0, 1);
var main_box = new Gtk.Box (Gtk.Orientation.VERTICAL, 0);
main_box.get_style_context ().add_class (Gtk.STYLE_CLASS_BACKGROUND);
main_box.add (main_header);
main_box.add (task_list_grid_stack);

var paned = new Gtk.Paned (Gtk.Orientation.HORIZONTAL);
paned.pack1 (sidebar, false, false);
paned.pack2 (main_grid, true, false);
paned.pack2 (main_box, true, false);

add (paned);

Expand Down Expand Up @@ -207,9 +191,9 @@ public class Tasks.MainWindow : Hdy.ApplicationWindow {
((SimpleAction) lookup_action (ACTION_DELETE_SELECTED_LIST)).set_enabled (Tasks.Application.model.is_remove_task_list_supported (source));

} else if (row is Tasks.Widgets.ScheduledRow) {
var scheduled_task_list_grid = (Tasks.Widgets.ScheduledTaskListGrid) task_list_grid_stack.get_child_by_name (SCHEDULED_LIST_UID);
var scheduled_task_list_grid = (Tasks.Widgets.ScheduledTaskListBox) task_list_grid_stack.get_child_by_name (SCHEDULED_LIST_UID);
if (scheduled_task_list_grid == null) {
scheduled_task_list_grid = new Tasks.Widgets.ScheduledTaskListGrid (Tasks.Application.model);
scheduled_task_list_grid = new Tasks.Widgets.ScheduledTaskListBox (Tasks.Application.model);
task_list_grid_stack.add_named (scheduled_task_list_grid, SCHEDULED_LIST_UID);
}

Expand Down
38 changes: 11 additions & 27 deletions src/Widgets/EditableLabel.vala
Original file line number Diff line number Diff line change
@@ -1,23 +1,8 @@
/*
* Copyright (c) 2016 elementary LLC. (https://github.com/elementary/photos)
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA
*
* Authored by: Corentin Noël <corentin@elementary.io>
*/
* Copyright 2016-2023 elementary, Inc. (https://elementary.io)
* Copyright 2016 Corentin Noël <corentin@elementary.io>
* SPDX-License-Identifier: LGPL-2.1-or-later
*/

public class Tasks.Widgets.EditableLabel : Gtk.EventBox {
public signal void changed ();
Expand All @@ -27,7 +12,7 @@ public class Tasks.Widgets.EditableLabel : Gtk.EventBox {
private Gtk.Label title;
private Gtk.Entry entry;
private Gtk.Stack stack;
private Gtk.Grid grid;
private Gtk.Box box;

public string text { get; set; }

Expand All @@ -44,7 +29,7 @@ public class Tasks.Widgets.EditableLabel : Gtk.EventBox {
changed ();
}

stack.set_visible_child (grid);
stack.set_visible_child (box);
}
}
}
Expand Down Expand Up @@ -81,12 +66,11 @@ public class Tasks.Widgets.EditableLabel : Gtk.EventBox {
};
button_revealer.add (edit_button);

grid = new Gtk.Grid () {
valign = Gtk.Align.CENTER,
column_spacing = 12
box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 12) {
valign = Gtk.Align.CENTER
};
grid.add (title);
grid.add (button_revealer);
box.add (title);
box.add (button_revealer);

entry = new Gtk.Entry () {
hexpand = true
Expand All @@ -97,7 +81,7 @@ public class Tasks.Widgets.EditableLabel : Gtk.EventBox {
hhomogeneous = false,
transition_type = Gtk.StackTransitionType.CROSSFADE
};
stack.add (grid);
stack.add (box);
stack.add (entry);

add (stack);
Expand Down
50 changes: 20 additions & 30 deletions src/Widgets/EntryPopover/DateTime.vala
Original file line number Diff line number Diff line change
@@ -1,21 +1,7 @@
/*
* Copyright 2021 elementary, Inc. (https://elementary.io)
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA
*/
* Copyright 2021-2023 elementary, Inc. (https://elementary.io)
* SPDX-License-Identifier: GPL-3.0-or-later
*/

public class Tasks.Widgets.EntryPopover.DateTime : Generic<GLib.DateTime?> {
private Gtk.Calendar calendar;
Expand All @@ -31,18 +17,22 @@ public class Tasks.Widgets.EntryPopover.DateTime : Generic<GLib.DateTime?> {

construct {
calendar = new Gtk.Calendar () {
margin = 6
margin_top = 6,
margin_bottom = 6,
margin_start = 6,
margin_end = 6
};
calendar.get_style_context ().add_class (Gtk.STYLE_CLASS_BACKGROUND);

timepicker = new Granite.Widgets.TimePicker () {
margin = 12,
margin_top = 0
margin_top = 0,
margin_bottom = 12,
margin_start = 12,
margin_end = 12
};

timepicker_revealer = new Gtk.Revealer () {
reveal_child = true,
margin = 0
reveal_child = true
};

timepicker_revealer.add (timepicker);
Expand All @@ -56,16 +46,16 @@ public class Tasks.Widgets.EntryPopover.DateTime : Generic<GLib.DateTime?> {
text = _("Today")
};

var grid = new Gtk.Grid () {
margin_top= 3
var box = new Gtk.Box (Gtk.Orientation.VERTICAL, 0) {
margin_top = 3
};
grid.attach (today_button, 0, 0);
grid.attach (today_separator, 0, 1);
grid.attach (calendar, 0, 2);
grid.attach (timepicker_revealer, 0, 3);
grid.show_all ();
box.add (today_button);
box.add (today_separator);
box.add (calendar);
box.add (timepicker_revealer);
box.show_all ();

popover.add (grid);
popover.add (box);

popover.show.connect (on_popover_show);

Expand Down
22 changes: 4 additions & 18 deletions src/Widgets/EntryPopover/Generic.vala
Original file line number Diff line number Diff line change
@@ -1,21 +1,7 @@
/*
* Copyright 2021 elementary, Inc. (https://elementary.io)
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA
*/
* Copyright 2021-2023 elementary, Inc. (https://elementary.io)
* SPDX-License-Identifier: GPL-3.0-or-later
*/

public abstract class Tasks.Widgets.EntryPopover.Generic<T> : Gtk.EventBox {
public signal string? value_format (T value);
Expand Down Expand Up @@ -77,7 +63,7 @@ public abstract class Tasks.Widgets.EntryPopover.Generic<T> : Gtk.EventBox {
};
delete_button_revealer.add (delete_button);

var button_box = new Gtk.Grid ();
var button_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0);
button_box.add (popover_button);
button_box.add (delete_button_revealer);
button_box.get_style_context ().add_provider (style_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
Expand Down
18 changes: 10 additions & 8 deletions src/Widgets/EntryPopover/Location.vala
Original file line number Diff line number Diff line change
Expand Up @@ -61,17 +61,19 @@ public class Tasks.Widgets.EntryPopover.Location : Generic<Tasks.Location?> {
hexpand = true
};

var grid = new Gtk.Grid () {
margin = 12,
row_spacing = 12
var box = new Gtk.Box (Gtk.Orientation.VERTICAL, 12) {
margin_top = 12,
margin_bottom = 12,
margin_start = 12,
margin_end = 12
};

grid.attach (search_entry, 0, 0);
grid.attach (location_mode, 0, 1);
grid.attach (map_frame, 0, 2);
grid.show_all ();
box.add (search_entry);
box.add (location_mode);
box.add (map_frame);
box.show_all ();

popover.add (grid);
popover.add (box);
popover.show.connect (on_popover_show);

notify["value"].connect (on_value_changed);
Expand Down
Loading

0 comments on commit acf44ab

Please sign in to comment.