diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 55e6e211..66aba732 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -24,7 +24,7 @@ jobs: - name: Install Dependencies run: | apt update - apt install -y gobject-introspection libecal2.0-dev libhandy-1-dev libedataserver1.2-dev libical-dev libgranite-dev libwingpanel-dev meson valac + apt install -y gobject-introspection libecal2.0-dev libadwaita-1-dev libedataserver1.2-dev libical-dev libgranite-7-dev libwingpanel-8-dev meson valac - name: Build env: DESTDIR: out diff --git a/README.md b/README.md index ee5a21d2..a2150629 100644 --- a/README.md +++ b/README.md @@ -9,11 +9,12 @@ You'll need the following dependencies: * gobject-introspection +* libadwaita-1-dev * libecal1.2-dev * libedataserver1.2-dev * libical-dev -* libgranite-dev >= 6.0.0 -* libwingpanel-dev +* libgranite-7-dev >= 7.6.0 +* libwingpanel-8-dev * meson (>= 0.57.0) * valac >= 0.40.3 diff --git a/data/io.elementary.desktop.wingpanel.datetime.gschema.xml b/data/datetime.gschema.xml similarity index 100% rename from data/io.elementary.desktop.wingpanel.datetime.gschema.xml rename to data/datetime.gschema.xml diff --git a/data/datetime.metainfo.xml.in b/data/datetime.metainfo.xml.in index 97c0867a..59b2d86c 100644 --- a/data/datetime.metainfo.xml.in +++ b/data/datetime.metainfo.xml.in @@ -1,9 +1,9 @@ - io.elementary.wingpanel.datetime + io.elementary.panel.datetime io.elementary.wingpanel - datetime-indicator + io.elementary.panel.datetime CC0-1.0 GPL-3.0+ diff --git a/data/meson.build b/data/meson.build index 48776390..25016c58 100644 --- a/data/meson.build +++ b/data/meson.build @@ -1,6 +1,6 @@ i18n.merge_file( input: 'datetime.metainfo.xml.in', - output: 'io.elementary.wingpanel.datetime.metainfo.xml', + output: gettext_name + '.metainfo.xml', po_dir: meson.project_source_root() / 'po' / 'extra', type: 'xml', install: true, @@ -8,6 +8,7 @@ i18n.merge_file( ) install_data( - 'io.elementary.desktop.wingpanel.datetime.gschema.xml', - install_dir: get_option('datadir') / 'glib-2.0' / 'schemas' + 'datetime.gschema.xml', + install_dir: get_option('datadir') / 'glib-2.0' / 'schemas', + rename: gettext_name + '.gschema.xml' ) diff --git a/meson.build b/meson.build index e1868355..d90d2c22 100644 --- a/meson.build +++ b/meson.build @@ -8,14 +8,14 @@ project( i18n = import('i18n') gnome = import('gnome') -gettext_name = meson.project_name() + '-indicator' +gettext_name = 'io.elementary.panel.' + meson.project_name() prefix = get_option('prefix') libdir = prefix / get_option('libdir') add_global_arguments('-DGETTEXT_PACKAGE="@0@"'.format(gettext_name), language:'c') add_project_arguments(['--vapidir', meson.current_source_dir() / 'vapi'], language: 'vala') -add_project_arguments('-DG_LOG_DOMAIN="io.elementary.wingpanel.datetime"', language:'c') +add_project_arguments('-DG_LOG_DOMAIN="io.elementary.panel.datetime"', language:'c') gresource = gnome.compile_resources( 'gresource', @@ -23,7 +23,7 @@ gresource = gnome.compile_resources( source_dir: 'data' ) -wingpanel_dep = dependency('wingpanel') +wingpanel_dep = dependency('wingpanel-8') wingpanel_indicatorsdir = wingpanel_dep.get_variable('indicatorsdir', pkgconfig_define: ['libdir', libdir]) libecal_dep = dependency('libecal-2.0', required: false) @@ -64,11 +64,11 @@ shared_module( dependencies: [ dependency('glib-2.0'), dependency('gobject-2.0'), - dependency('granite', version: '>=6.0.0'), - dependency('gtk+-3.0'), + dependency('granite-7', version: '>=7.6.0'), + dependency('gtk4'), libecal_dep, dependency('libedataserver-1.2'), - dependency('libhandy-1'), + dependency('libadwaita-1'), libical_dep, wingpanel_dep, ], diff --git a/po/datetime-indicator.pot b/po/io.elementary.panel.datetime.pot similarity index 100% rename from po/datetime-indicator.pot rename to po/io.elementary.panel.datetime.pot diff --git a/src/Indicator.vala b/src/Indicator.vala index a5e86af5..2f1345aa 100644 --- a/src/Indicator.vala +++ b/src/Indicator.vala @@ -71,10 +71,9 @@ public class DateTime.Indicator : Wingpanel.Indicator { max_width_chars = 20, justify = Gtk.Justification.CENTER }; - placeholder_label.show_all (); var placeholder_style_context = placeholder_label.get_style_context (); - placeholder_style_context.add_class (Gtk.STYLE_CLASS_DIM_LABEL); + placeholder_style_context.add_class (Granite.STYLE_CLASS_DIM_LABEL); placeholder_style_context.add_class (Granite.STYLE_CLASS_H3_LABEL); component_listbox = new Gtk.ListBox () { @@ -84,14 +83,12 @@ public class DateTime.Indicator : Wingpanel.Indicator { component_listbox.set_placeholder (placeholder_label); component_listbox.set_sort_func (sort_function); - var scrolled_window = new Gtk.ScrolledWindow (null, null) { + var scrolled_window = new Gtk.ScrolledWindow () { hscrollbar_policy = Gtk.PolicyType.NEVER, child = component_listbox }; - var settings_button = new Gtk.ModelButton () { - text = _("Date & Time Settings…") - }; + var settings_button = new Wingpanel.PopoverMenuItem.with_text (_("Date & Time Settings…")); var sep = new Gtk.Separator (Gtk.Orientation.HORIZONTAL) { margin_bottom = 3, @@ -213,9 +210,7 @@ public class DateTime.Indicator : Wingpanel.Indicator { } private bool update_components () { - foreach (unowned Gtk.Widget widget in component_listbox.get_children ()) { - widget.destroy (); - } + component_listbox.remove_all (); if (calendar.selected_date == null) { update_components_idle_source = 0; @@ -237,7 +232,7 @@ public class DateTime.Indicator : Wingpanel.Indicator { if (!components_on_day.has_key (component_uid)) { components_on_day[component_uid] = new DateTime.ComponentRow (date, ical, source); - component_listbox.add (components_on_day[component_uid]); + component_listbox.append (components_on_day[component_uid]); } } } @@ -251,13 +246,12 @@ public class DateTime.Indicator : Wingpanel.Indicator { if (!components_on_day.has_key (component_uid)) { components_on_day[component_uid] = new DateTime.ComponentRow (date, ical, source); - component_listbox.add (components_on_day[component_uid]); + component_listbox.append (components_on_day[component_uid]); } } } }); - component_listbox.show_all (); update_components_idle_source = 0; return GLib.Source.REMOVE; } diff --git a/src/Widgets/ComponentRow.vala b/src/Widgets/ComponentRow.vala index a4d5632d..debec274 100644 --- a/src/Widgets/ComponentRow.vala +++ b/src/Widgets/ComponentRow.vala @@ -87,7 +87,7 @@ public class DateTime.ComponentRow : Gtk.ListBoxRow { icon_name = "alarm-symbolic"; } - component_image = new Gtk.Image.from_icon_name (icon_name, Gtk.IconSize.MENU) { + component_image = new Gtk.Image.from_icon_name (icon_name) { valign = Gtk.Align.START }; @@ -112,7 +112,7 @@ public class DateTime.ComponentRow : Gtk.ListBoxRow { use_markup = true, xalign = 0, }; - time_label.get_style_context ().add_class (Gtk.STYLE_CLASS_DIM_LABEL); + time_label.get_style_context ().add_class (Granite.STYLE_CLASS_DIM_LABEL); grid = new Gtk.Grid () { column_spacing = 6, @@ -131,7 +131,7 @@ public class DateTime.ComponentRow : Gtk.ListBoxRow { grid_context.add_class ("event"); grid_context.add_provider (css_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); - add (grid); + child = grid; set_color (); source_selectable.notify["color"].connect (set_color); diff --git a/src/Widgets/PanelLabel.vala b/src/Widgets/PanelLabel.vala index 51086621..cc47678f 100644 --- a/src/Widgets/PanelLabel.vala +++ b/src/Widgets/PanelLabel.vala @@ -26,25 +26,23 @@ public class DateTime.Widgets.PanelLabel : Gtk.Box { public bool clock_show_seconds { get; set; } public bool clock_show_weekday { get; set; } - private Gtk.GestureMultiPress gesture_click; - construct { date_label = new Gtk.Label (null) { margin_end = 12 }; var date_revealer = new Gtk.Revealer () { - transition_type = Gtk.RevealerTransitionType.SLIDE_LEFT + transition_type = Gtk.RevealerTransitionType.SLIDE_LEFT, + child = date_label }; - date_revealer.add (date_label); time_label = new Gtk.Label (null) { use_markup = true }; valign = Gtk.Align.CENTER; - add (date_revealer); - add (time_label); + append (date_revealer); + append (time_label); var clock_settings = new GLib.Settings ("io.elementary.desktop.wingpanel.datetime"); clock_settings.bind ("clock-format", this, "clock-format", SettingsBindFlags.DEFAULT); @@ -60,10 +58,11 @@ public class DateTime.Widgets.PanelLabel : Gtk.Box { time_manager.minute_changed.connect (update_labels); time_manager.notify["is-12h"].connect (update_labels); - gesture_click = new Gtk.GestureMultiPress (this) { + var gesture_click = new Gtk.GestureClick () { button = Gdk.BUTTON_MIDDLE }; gesture_click.pressed.connect (on_pressed); + add_controller (gesture_click); } private void update_labels () { diff --git a/src/Widgets/calendar/CalendarView.vala b/src/Widgets/calendar/CalendarView.vala index 5bb077ec..6070f1aa 100644 --- a/src/Widgets/calendar/CalendarView.vala +++ b/src/Widgets/calendar/CalendarView.vala @@ -25,7 +25,7 @@ public class DateTime.Widgets.CalendarView : Gtk.Grid { public GLib.DateTime? selected_date { get; private set; } - private Hdy.Carousel carousel; + private Adw.Carousel carousel; private uint position; private int rel_postion; private CalendarModel events_model; @@ -61,10 +61,10 @@ public class DateTime.Widgets.CalendarView : Gtk.Grid { margin_end = 6, valign = Gtk.Align.CENTER }; - box_buttons.get_style_context ().add_class (Gtk.STYLE_CLASS_LINKED); - box_buttons.add (left_button); - box_buttons.add (center_button); - box_buttons.add (right_button); + box_buttons.get_style_context ().add_class (Granite.STYLE_CLASS_LINKED); + box_buttons.append (left_button); + box_buttons.append (center_button); + box_buttons.append (right_button); events_model = CalendarModel.get_default (ECal.ClientSourceType.EVENTS); tasks_model = CalendarModel.get_default (ECal.ClientSourceType.TASKS); @@ -88,24 +88,22 @@ public class DateTime.Widgets.CalendarView : Gtk.Grid { events_model.change_month (-1); tasks_model.change_month (-1); - carousel = new Hdy.Carousel () { + carousel = new Adw.Carousel () { interactive = true, hexpand = true, vexpand = true, spacing = 15 }; - carousel.add (left_grid); - carousel.add (start_month_grid); - carousel.add (right_grid); - carousel.scroll_to (start_month_grid); + carousel.append (left_grid); + carousel.append (start_month_grid); + carousel.append (right_grid); + carousel.scroll_to (start_month_grid, false); position = 1; rel_postion = 0; showtoday = false; - carousel.show_all (); - column_spacing = 6; row_spacing = 6; margin_start = margin_end = 10; @@ -114,11 +112,11 @@ public class DateTime.Widgets.CalendarView : Gtk.Grid { attach (carousel, 0, 1, 2); left_button.clicked.connect (() => { - carousel.switch_child ((int) carousel.get_position () - 1, carousel.get_animation_duration ()); + carousel.scroll_to (carousel.get_nth_page ((uint) Math.round (carousel.position) - 1), true); }); right_button.clicked.connect (() => { - carousel.switch_child ((int) carousel.get_position () + 1, carousel.get_animation_duration ()); + carousel.scroll_to (carousel.get_nth_page ((uint) Math.round (carousel.position) + 1), true); }); center_button.clicked.connect (() => { @@ -158,7 +156,7 @@ public class DateTime.Widgets.CalendarView : Gtk.Grid { var grid = create_grid (); grid.set_range (events_model.data_range, events_model.month_start); grid.update_weeks (events_model.data_range.first_dt, events_model.num_weeks); - carousel.add (grid); + carousel.append (grid); events_model.change_month (-1); tasks_model.change_month (-1); @@ -179,7 +177,6 @@ public class DateTime.Widgets.CalendarView : Gtk.Grid { private DateTime.Widgets.Grid create_grid () { var grid = new DateTime.Widgets.Grid (); - grid.show_all (); grid.on_event_add.connect ((date) => { show_date_in_maya (date); @@ -201,12 +198,11 @@ public class DateTime.Widgets.CalendarView : Gtk.Grid { selected_date = today; if (start.equal (start_month) && !refresh) { position -= rel_postion; - carousel.switch_child (position, carousel.get_animation_duration ()); + carousel.scroll_to (carousel.get_nth_page (position), true); } else { /*reset Carousel if center_child != the grid of the month of today*/ - carousel.no_show_all = true; - foreach (unowned Gtk.Widget grid in carousel.get_children ()) { - carousel.remove (grid); + for (var child = carousel.get_first_child (); child != null; child = carousel.get_first_child ()) { + carousel.remove (child); } start_month = Util.get_start_of_month (); @@ -230,17 +226,15 @@ public class DateTime.Widgets.CalendarView : Gtk.Grid { events_model.change_month (-1); tasks_model.change_month (-1); - carousel.add (left_grid); - carousel.add (start_month_grid); - carousel.add (right_grid); - carousel.scroll_to (start_month_grid); + carousel.append (left_grid); + carousel.append (start_month_grid); + carousel.append (right_grid); + carousel.scroll_to (start_month_grid, false); label.label = events_model.month_start.format (_("%OB, %Y")); position = 1; rel_postion = 0; } - - carousel.no_show_all = false; } // TODO: As far as maya supports it use the Dbus Activation feature to run the calendar-app. @@ -257,8 +251,8 @@ public class DateTime.Widgets.CalendarView : Gtk.Grid { "dialog-error" ); dialog.show_error_details (e.message); - dialog.run (); - dialog.destroy (); + dialog.response.connect (dialog.destroy); + dialog.present (); } } diff --git a/src/Widgets/calendar/Grid.vala b/src/Widgets/calendar/Grid.vala index f5e5440e..4a9b6d2c 100644 --- a/src/Widgets/calendar/Grid.vala +++ b/src/Widgets/calendar/Grid.vala @@ -92,8 +92,6 @@ namespace DateTime.Widgets { data[date_hash].add_component_dot (source, ical); } } - - show_all (); } private void remove_component_dots (E.Source source, Gee.Collection components) { @@ -187,14 +185,12 @@ namespace DateTime.Widgets { /* Still update_day to get the color of etc. right */ day = update_day (new GridDay (new_date), new_date, today, month_start); day.on_event_add.connect ((date) => on_event_add (date)); - day.focus_in_event.connect ((event) => { - on_day_focus_in (day); - return false; - }); + var focus_controller = new Gtk.EventControllerFocus (); + focus_controller.enter.connect ((controller) => on_day_focus_in ((GridDay) controller.widget)); + day.add_controller (focus_controller); attach (day, col + 2, row); - day.show_all (); } col = (col + 1) % 7; @@ -258,7 +254,6 @@ namespace DateTime.Widgets { transition_type = Gtk.RevealerTransitionType.SLIDE_LEFT, child = week_label }; - week_labels[c].show_all (); DateTime.Indicator.settings.bind ("show-weeks", week_labels[c], "reveal-child", GLib.SettingsBindFlags.DEFAULT); @@ -287,12 +282,10 @@ namespace DateTime.Widgets { day.name = "today"; day.get_style_context ().add_class (Granite.STYLE_CLASS_ACCENT); day.receives_default = true; - day.show_all (); } else if (day.name == "today") { day.name = ""; day.get_style_context ().remove_class (Granite.STYLE_CLASS_ACCENT); day.receives_default = false; - day.show_all (); } } diff --git a/src/Widgets/calendar/GridDay.vala b/src/Widgets/calendar/GridDay.vala index c4b1b19b..70bc47e6 100644 --- a/src/Widgets/calendar/GridDay.vala +++ b/src/Widgets/calendar/GridDay.vala @@ -21,7 +21,7 @@ /** * Represents a single day on the grid. */ -public class DateTime.Widgets.GridDay : Gtk.EventBox { +public class DateTime.Widgets.GridDay : Granite.Bin { /* * Event emitted when the day is double clicked or the ENTER key is pressed. */ @@ -36,9 +36,6 @@ public class DateTime.Widgets.GridDay : Gtk.EventBox { private Gtk.Label label; private bool valid_grab = false; - private Gtk.GestureMultiPress click_gesture; - private Gtk.EventControllerKey key_controller; - public GridDay (GLib.DateTime date) { Object (date: date); } @@ -65,25 +62,24 @@ public class DateTime.Widgets.GridDay : Gtk.EventBox { valign = Gtk.Align.CENTER }; - box.add (label); - box.add (event_box); + box.append (label); + box.append (event_box); - can_focus = true; - events |= Gdk.EventMask.BUTTON_PRESS_MASK; - events |= Gdk.EventMask.KEY_PRESS_MASK; + focusable = true; set_css_name ("grid-day"); halign = Gtk.Align.CENTER; hexpand = true; get_style_context ().add_provider (provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); - add (box); - show_all (); + child = box; // Signals and handlers - click_gesture = new Gtk.GestureMultiPress (this); + var click_gesture = new Gtk.GestureClick (); click_gesture.pressed.connect (on_button_press); + add_controller (click_gesture); - key_controller = new Gtk.EventControllerKey (this); + var key_controller = new Gtk.EventControllerKey (); key_controller.key_pressed.connect (on_key_press); + add_controller (key_controller); bind_property ("date", label, "label", GLib.BindingFlags.SYNC_CREATE, (binding, from_value, ref to_value) => { unowned var new_date = (GLib.DateTime) from_value.get_boxed (); @@ -120,7 +116,7 @@ public class DateTime.Widgets.GridDay : Gtk.EventBox { component_dots[component_uid] = event_dot; - event_box.add (event_dot); + event_box.append (event_dot); } } @@ -145,11 +141,14 @@ public class DateTime.Widgets.GridDay : Gtk.EventBox { grab_focus (); } - public override void grab_focus () { + public override bool grab_focus () { if (valid_grab) { base.grab_focus (); valid_grab = false; + return true; } + + return false; } public void sensitive_container (bool sens) { diff --git a/src/Widgets/calendar/Util.vala b/src/Widgets/calendar/Util.vala index 090912ac..edbd7ce5 100644 --- a/src/Widgets/calendar/Util.vala +++ b/src/Widgets/calendar/Util.vala @@ -114,14 +114,10 @@ namespace Util { @define-color accent_color %s; """.printf (color); - try { - var style_provider = new Gtk.CssProvider (); - style_provider.load_from_data (style, style.length); + var style_provider = new Gtk.CssProvider (); + style_provider.load_from_string (style); - providers[color] = style_provider; - } catch (Error e) { - critical ("Unable to set calendar color: %s", e.message); - } + providers[color] = style_provider; } unowned Gtk.StyleContext style_context = widget.get_style_context ();