Skip to content

Commit b671816

Browse files
authored
Merge branch 'master' into danirabbit/sourcedialog
2 parents b935d34 + a7d8e87 commit b671816

5 files changed

Lines changed: 96 additions & 116 deletions

File tree

po/POTFILES

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,5 @@ src/Widgets/DateTimePicker.vala
4949
src/Widgets/DynamicSpinner.vala
5050
src/Widgets/DeleteDialog.vala
5151
src/Widgets/EventMenu.vala
52-
src/Widgets/HeaderBar.vala
5352
src/Widgets/SourcePopover.vala
5453
src/Widgets/SourceRow.vala

src/Grid/CalendarView.vala

Lines changed: 61 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,11 @@ public class Maya.View.CalendarView : Gtk.Box {
2929
public signal void on_event_add (DateTime date);
3030
public signal void selection_changed (DateTime new_date);
3131

32-
public Hdy.HeaderBar header_bar { get; construct; }
32+
public Gtk.SearchEntry search_bar;
33+
private Calendar.Widgets.DateSwitcher month_switcher;
34+
private Calendar.Widgets.DateSwitcher year_switcher;
35+
36+
public Hdy.HeaderBar header_bar { get; private set; }
3337
public DateTime? selected_date { get; private set; }
3438

3539
private WeekLabels weeks { get; private set; }
@@ -67,7 +71,49 @@ public class Maya.View.CalendarView : Gtk.Box {
6771

6872
var info_bar = new Calendar.Widgets.ConnectivityInfoBar ();
6973

70-
header_bar = new Calendar.Widgets.HeaderBar ();
74+
var application_instance = ((Gtk.Application) GLib.Application.get_default ());
75+
76+
var button_today = new Gtk.Button.from_icon_name ("calendar-go-today", Gtk.IconSize.LARGE_TOOLBAR) {
77+
action_name = Maya.MainWindow.ACTION_PREFIX + Maya.MainWindow.ACTION_SHOW_TODAY
78+
};
79+
button_today.tooltip_markup = Granite.markup_accel_tooltip (
80+
application_instance.get_accels_for_action (button_today.action_name),
81+
_("Go to today's date")
82+
);
83+
84+
month_switcher = new Calendar.Widgets.DateSwitcher (10) {
85+
valign = CENTER
86+
};
87+
year_switcher = new Calendar.Widgets.DateSwitcher (-1) {
88+
valign = CENTER
89+
};
90+
91+
var calmodel = Calendar.EventStore.get_default ();
92+
set_switcher_date (calmodel.month_start);
93+
94+
var spinner = new Maya.View.Widgets.DynamicSpinner ();
95+
96+
var contractor = new Maya.View.Widgets.ContractorButtonWithMenu (_("Export or Share the default Calendar"));
97+
98+
var source_popover = new Calendar.Widgets.SourcePopover ();
99+
100+
var menu_button = new Gtk.MenuButton () {
101+
image = new Gtk.Image.from_icon_name ("open-menu", Gtk.IconSize.LARGE_TOOLBAR),
102+
popover = source_popover,
103+
tooltip_text = _("Manage Calendars")
104+
};
105+
106+
header_bar = new Hdy.HeaderBar () {
107+
show_close_button = true
108+
};
109+
header_bar.pack_start (month_switcher);
110+
header_bar.pack_start (year_switcher);
111+
header_bar.pack_start (button_today);
112+
header_bar.pack_end (menu_button);
113+
header_bar.pack_end (contractor);
114+
header_bar.pack_end (spinner);
115+
116+
header_bar.get_style_context ().add_class (Gtk.STYLE_CLASS_FLAT);
71117

72118
stack = new Gtk.Stack ();
73119
stack.expand = true;
@@ -115,6 +161,19 @@ public class Maya.View.CalendarView : Gtk.Box {
115161
return false;
116162
});
117163
});
164+
165+
month_switcher.left_clicked.connect (() => Calendar.EventStore.get_default ().change_month (-1));
166+
month_switcher.right_clicked.connect (() => Calendar.EventStore.get_default ().change_month (1));
167+
year_switcher.left_clicked.connect (() => Calendar.EventStore.get_default ().change_year (-1));
168+
year_switcher.right_clicked.connect (() => Calendar.EventStore.get_default ().change_year (1));
169+
calmodel.parameters_changed.connect (() => {
170+
set_switcher_date (calmodel.month_start);
171+
});
172+
}
173+
174+
private void set_switcher_date (DateTime date) {
175+
month_switcher.text = date.format ("%OB");
176+
year_switcher.text = date.format ("%Y");
118177
}
119178

120179
public override bool scroll_event (Gdk.EventScroll event) {

src/Widgets/CalendarChooser.vala

Lines changed: 35 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
* Authored by: Corentin Noël <corentin@elementaryos.org>
1818
*/
1919

20-
public class Maya.View.Widgets.CalendarChooser : Gtk.Grid {
20+
public class Maya.View.Widgets.CalendarChooser : Gtk.Box {
2121

2222
/** A searchable list of calendars for the user to choose from.
2323
*
@@ -45,10 +45,13 @@ public class Maya.View.Widgets.CalendarChooser : Gtk.Grid {
4545

4646
current_source = registry.default_calendar;
4747

48-
search_entry = new Gtk.SearchEntry ();
49-
search_entry.margin = 12;
50-
search_entry.margin_bottom = 6;
51-
search_entry.placeholder_text = _("Search Calendars");
48+
search_entry = new Gtk.SearchEntry () {
49+
margin_top = 12,
50+
margin_end = 12,
51+
margin_bottom = 6,
52+
margin_start = 12,
53+
placeholder_text = _("Search Calendars")
54+
};
5255

5356
var placeholder = new Granite.Widgets.AlertView (
5457
_("No Results"),
@@ -57,19 +60,22 @@ public class Maya.View.Widgets.CalendarChooser : Gtk.Grid {
5760
);
5861
placeholder.show_all ();
5962

60-
var list_box = new Gtk.ListBox ();
61-
list_box.activate_on_single_click = true;
63+
var list_box = new Gtk.ListBox () {
64+
activate_on_single_click = true
65+
};
6266
list_box.set_placeholder (placeholder);
6367

64-
var scrolled = new Gtk.ScrolledWindow (null, null);
65-
scrolled.hscrollbar_policy = Gtk.PolicyType.NEVER;
66-
scrolled.add (list_box);
67-
scrolled.max_content_height = 300;
68-
scrolled.propagate_natural_height = true;
68+
var scrolled = new Gtk.ScrolledWindow (null, null) {
69+
child = list_box,
70+
hscrollbar_policy = NEVER,
71+
max_content_height = 300,
72+
propagate_natural_height = true
73+
};
6974

7075
margin_bottom = 6;
71-
attach (search_entry, 0, 0);
72-
attach (scrolled, 0, 1);
76+
orientation = VERTICAL;
77+
add (search_entry);
78+
add (scrolled);
7379
show_all ();
7480

7581
list_box.set_filter_func (filter_function);
@@ -125,12 +131,16 @@ public class Maya.View.Widgets.CalendarChooser : Gtk.Grid {
125131

126132
// Populate list_box
127133
foreach (var source in sources) {
128-
var calrow = new CalendarRow (source);
129-
calrow.margin = 6;
130-
calrow.margin_start = 12;
131-
132-
var row = new Gtk.ListBoxRow ();
133-
row.add (calrow);
134+
var calrow = new CalendarRow (source) {
135+
margin_top = 6,
136+
margin_end = 6,
137+
margin_bottom = 6,
138+
margin_start = 12
139+
};
140+
141+
var row = new Gtk.ListBoxRow () {
142+
child = calrow
143+
};
134144
row.show_all ();
135145

136146
list_box.add (row);
@@ -163,9 +173,11 @@ public class Maya.View.Widgets.CalendarChooser : Gtk.Grid {
163173
}
164174
}
165175

166-
var header = new Granite.HeaderLabel (row_location);
167-
header.margin = 6;
168-
header.margin_bottom = 0;
176+
var header = new Granite.HeaderLabel (row_location) {
177+
margin_top = 6,
178+
margin_end = 6,
179+
margin_start = 6
180+
};
169181

170182
row.set_header (header);
171183

src/Widgets/HeaderBar.vala

Lines changed: 0 additions & 89 deletions
This file was deleted.

src/meson.build

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ calendar_files = files(
3535
'Widgets/DeleteDialog.vala',
3636
'Widgets/DynamicSpinner.vala',
3737
'Widgets/EventMenu.vala',
38-
'Widgets/HeaderBar.vala',
3938
'Widgets/SourcePopover.vala',
4039
'Widgets/SourceRow.vala',
4140
'Widgets/ConnectivityInfoBar.vala'

0 commit comments

Comments
 (0)