[california] Improve Show Event dialog
- From: Jim Nelson <jnelson src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [california] Improve Show Event dialog
- Date: Wed, 4 Jun 2014 01:52:34 +0000 (UTC)
commit 374f4ccb045cc3d6177182e2181a2da4ae5162e5
Author: Jim Nelson <jim yorba org>
Date: Tue Jun 3 18:51:03 2014 -0700
Improve Show Event dialog
Show Event used to be a scrolling text label with all the details
inserted as markup. It wasn't very well organized and didn't look
very pleasing.
This new design isn't a radical improvement but it does make the
pertinent details (where, when) more obvious and easier to locate.
This patch also enables selection throughout the dialog, closing
bug #730394.
src/component/component-event.vala | 11 ++-
src/host/host-show-event.vala | 62 +++++++++-----
src/rc/show-event.ui | 157 ++++++++++++++++++++++++++++++------
3 files changed, 178 insertions(+), 52 deletions(-)
---
diff --git a/src/component/component-event.vala b/src/component/component-event.vala
index ac47026..8b157f1 100644
--- a/src/component/component-event.vala
+++ b/src/component/component-event.vala
@@ -263,8 +263,13 @@ public class Event : Instance, Gee.Comparable<Event> {
/**
* Returns a prettified string describing the { link Event}'s time span in as concise and
* economical manner possible.
+ *
+ * @return null if no time/date information is specified
*/
- public string get_event_time_pretty_string(Calendar.Timezone timezone) {
+ public string? get_event_time_pretty_string(Calendar.Timezone timezone) {
+ if (date_span == null && exact_time_span == null)
+ return null;
+
// if any dates are not in current year, display year in all dates
Calendar.Date.PrettyFlag date_flags = Calendar.Date.PrettyFlag.NONE;
Calendar.DateSpan date_span = get_event_date_span(timezone);
@@ -281,9 +286,7 @@ public class Event : Instance, Gee.Comparable<Event> {
// current year
span = date_span.start_date.to_pretty_string(date_flags);
} else {
- // All-day event spanning days, print "<abbrev date> to <abbrev date>"
- date_flags |= Calendar.Date.PrettyFlag.ABBREV;
- // Prints a span of dates, i.e. "January 3 to January 6"
+ // Prints a span of dates, i.e. "Monday, January 3 to Thursday, January 6"
span = _("%s to %s").printf(date_span.start_date.to_pretty_string(date_flags),
date_span.end_date.to_pretty_string(date_flags));
}
diff --git a/src/host/host-show-event.vala b/src/host/host-show-event.vala
index 07742ac..39acd37 100644
--- a/src/host/host-show-event.vala
+++ b/src/host/host-show-event.vala
@@ -19,7 +19,22 @@ public class ShowEvent : Gtk.Grid, Toolkit.Card {
public Gtk.Widget? initial_focus { get { return close_button; } }
[GtkChild]
- private Gtk.Label text_label;
+ private Gtk.Label summary_text;
+
+ [GtkChild]
+ private Gtk.Label when_label;
+
+ [GtkChild]
+ private Gtk.Label when_text;
+
+ [GtkChild]
+ private Gtk.Label where_label;
+
+ [GtkChild]
+ private Gtk.Label where_text;
+
+ [GtkChild]
+ private Gtk.Label description_text;
[GtkChild]
private Gtk.Button update_button;
@@ -55,26 +70,17 @@ public class ShowEvent : Gtk.Grid, Toolkit.Card {
}
private void build_display() {
- // Each string should end without whitespace; add_lf_lf will ensure each section is
- // separated as long as there's preceding text
- StringBuilder builder = new StringBuilder();
-
// summary
- if (!String.is_empty(event.summary))
- add_lf_lf(builder).append_printf("<b>%s</b>", Markup.escape_text(event.summary));
+ set_label(null, summary_text, event.summary);
// location
- if (!String.is_empty(event.location))
- add_lf_lf(builder).append_printf(_("Location: %s"), Markup.escape_text(event.location));
-
- // description
- if (!String.is_empty(event.description))
- add_lf_lf(builder).append_printf("%s", Markup.escape_text(event.description));
+ set_label(where_label, where_text, event.location);
- add_lf_lf(builder).append_printf("<small>%s</small>",
- Markup.escape_text(event.get_event_time_pretty_string(Calendar.Timezone.local)));
+ // time
+ set_label(when_label, when_text, event.get_event_time_pretty_string(Calendar.Timezone.local));
- text_label.label = builder.str;
+ // description
+ set_label(null, description_text, escape(event.description));
// don't current support updating or removing recurring events properly; see
// https://bugzilla.gnome.org/show_bug.cgi?id=725786
@@ -87,12 +93,24 @@ public class ShowEvent : Gtk.Grid, Toolkit.Card {
remove_button.no_show_all = !visible;
}
- // Adds two linefeeds if there's existing text
- private unowned StringBuilder add_lf_lf(StringBuilder builder) {
- if (!String.is_empty(builder.str))
- builder.append("\n\n");
-
- return builder;
+ private string? escape(string? plain) {
+ return !String.is_empty(plain) ? Markup.escape_text(plain) : plain;
+ }
+
+ // Note that text is not escaped, up to caller to determine if necessary or not.
+ private void set_label(Gtk.Label? label, Gtk.Label text, string? str) {
+ if (!String.is_empty(str)) {
+ text.label = str;
+ } else {
+ text.visible = false;
+ text.no_show_all = true;
+
+ // hide its associated label as well
+ if (label != null) {
+ label.visible = false;
+ label.no_show_all = true;
+ }
+ }
}
[GtkCallback]
diff --git a/src/rc/show-event.ui b/src/rc/show-event.ui
index 41b82bb..0763e8e 100644
--- a/src/rc/show-event.ui
+++ b/src/rc/show-event.ui
@@ -9,6 +9,69 @@
<property name="margin_right">8</property>
<property name="margin_top">8</property>
<property name="margin_bottom">8</property>
+ <property name="row_spacing">6</property>
+ <child>
+ <object class="GtkLabel" id="summary_text">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="margin_bottom">6</property>
+ <property name="xalign">0</property>
+ <property name="label">(empty)</property>
+ <property name="selectable">True</property>
+ <property name="ellipsize">start</property>
+ <attributes>
+ <attribute name="weight" value="bold"/>
+ </attributes>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">0</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkScrolledWindow" id="scrolledwindow1">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="margin_top">6</property>
+ <property name="hexpand">True</property>
+ <property name="vexpand">True</property>
+ <property name="min_content_width">350</property>
+ <property name="min_content_height">200</property>
+ <child>
+ <object class="GtkViewport" id="viewport1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="hexpand">True</property>
+ <property name="vexpand">True</property>
+ <property name="shadow_type">none</property>
+ <child>
+ <object class="GtkLabel" id="description_text">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="hexpand">True</property>
+ <property name="vexpand">True</property>
+ <property name="xalign">0</property>
+ <property name="yalign">0</property>
+ <property name="label">Event...</property>
+ <property name="use_markup">True</property>
+ <property name="wrap">True</property>
+ <property name="selectable">True</property>
+ <property name="width_chars">32</property>
+ <property name="max_width_chars">64</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">2</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
<child>
<object class="GtkButtonBox" id="button_box">
<property name="visible">True</property>
@@ -79,47 +142,89 @@
</object>
<packing>
<property name="left_attach">0</property>
- <property name="top_attach">1</property>
+ <property name="top_attach">3</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
- <object class="GtkScrolledWindow" id="scrolledwindow1">
+ <object class="GtkGrid" id="grid1">
<property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="hexpand">True</property>
- <property name="vexpand">True</property>
- <property name="min_content_width">350</property>
- <property name="min_content_height">200</property>
+ <property name="can_focus">False</property>
+ <property name="row_spacing">6</property>
+ <property name="column_spacing">6</property>
<child>
- <object class="GtkViewport" id="viewport1">
+ <object class="GtkLabel" id="when_label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">1</property>
+ <property name="yalign">0</property>
+ <property name="label" translatable="yes">When</property>
+ <style>
+ <class name="dim-label"/>
+ </style>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">0</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="where_label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">1</property>
+ <property name="yalign">0</property>
+ <property name="label" translatable="yes">Where</property>
+ <style>
+ <class name="dim-label"/>
+ </style>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">1</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="when_text">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
- <property name="vexpand">True</property>
- <property name="shadow_type">none</property>
- <child>
- <object class="GtkLabel" id="text_label">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="hexpand">True</property>
- <property name="vexpand">True</property>
- <property name="xalign">0</property>
- <property name="yalign">0</property>
- <property name="label">Event...</property>
- <property name="use_markup">True</property>
- <property name="wrap">True</property>
- <property name="width_chars">32</property>
- <property name="max_width_chars">64</property>
- </object>
- </child>
+ <property name="xalign">0</property>
+ <property name="label">(empty)</property>
+ <property name="selectable">True</property>
</object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">0</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="where_text">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="hexpand">True</property>
+ <property name="xalign">0</property>
+ <property name="label">(empty)</property>
+ <property name="selectable">True</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">1</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
</child>
</object>
<packing>
<property name="left_attach">0</property>
- <property name="top_attach">0</property>
+ <property name="top_attach">1</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]