File 0001-Sort-locations-by-timezone.patch of Package gnome-clocks
From be29ec89cd8a6c187f6e5731bdafaac5361e7c56 Mon Sep 17 00:00:00 2001
From: Mike Gorse <mgorse@suse.com>
Date: Wed, 23 Jul 2014 12:22:51 -0500
Subject: [PATCH] Sort locations by timezone
https://bugzilla.gnome.org/show_bug.cgi?id=701169
---
src/widgets.vala | 4 ++--
src/world.vala | 29 +++++++++++++++++++++++++++--
2 files changed, 29 insertions(+), 4 deletions(-)
diff --git a/src/widgets.vala b/src/widgets.vala
index 44b6034..2eaffc1 100644
--- a/src/widgets.vala
+++ b/src/widgets.vala
@@ -249,7 +249,7 @@ public interface ContentItem : GLib.Object {
public abstract void get_thumb_properties (out string text, out string subtext, out Gdk.Pixbuf? pixbuf, out string css_class);
}
-private class IconView : Gtk.IconView {
+protected class IconView : Gtk.IconView {
public enum Mode {
NORMAL,
SELECTION
@@ -429,7 +429,7 @@ public class ContentView : Gtk.Bin {
public bool empty { get; private set; default = true; }
private Gtk.Widget empty_page;
- private IconView icon_view;
+ protected IconView icon_view;
private HeaderBar header_bar;
private Gtk.Button select_button;
private Gtk.Button cancel_button;
diff --git a/src/world.vala b/src/world.vala
index d73daa1..35253c9 100644
--- a/src/world.vala
+++ b/src/world.vala
@@ -262,7 +262,7 @@ public class MainPanel : Gtk.Stack, Clocks.Clock {
private Gtk.Button back_button;
private Gdk.Pixbuf? day_pixbuf;
private Gdk.Pixbuf? night_pixbuf;
- private ContentView content_view;
+ private WorldContentView content_view;
private StandalonePanel standalone;
public MainPanel (HeaderBar header_bar) {
@@ -293,7 +293,7 @@ public class MainPanel : Gtk.Stack, Clocks.Clock {
var builder = Utils.load_ui ("world.ui");
var empty_view = builder.get_object ("empty_panel") as Gtk.Widget;
- content_view = new ContentView (empty_view, header_bar);
+ content_view = new WorldContentView (empty_view, header_bar);
add (content_view);
content_view.item_activated.connect ((item) => {
@@ -436,5 +436,30 @@ public class MainPanel : Gtk.Stack, Clocks.Clock {
}
}
+public class WorldContentView : ContentView {
+ public WorldContentView (Gtk.Widget e, HeaderBar b) {
+ base(e, b);
+ var model = icon_view.get_model ();
+ var sortable = model as Gtk.TreeSortable;
+ sortable.set_sort_column_id (1, Gtk.SortType.ASCENDING);
+ sortable.set_sort_func(1, item_compare);
+ }
+
+ private int item_compare(Gtk.TreeModel model, Gtk.TreeIter i1, Gtk.TreeIter i2) {
+ Object item;
+ model.get (i1, 1, out item);
+ var item1 = item as Item;
+ model.get (i2, 1, out item);
+ var item2 = item as Item;
+ var offset1 = item1.location.get_timezone().get_offset();
+ var offset2 = item2.location.get_timezone().get_offset();
+ if (offset1 < offset2)
+ return -1;
+ if (offset1 > offset2)
+ return 1;
+ return 0;
+ }
+}
+
} // namespace World
} // namespace Clocks
--
1.8.4