[gnome-control-center/wip/datetime-panel: 1/10] Add initial implementation of date/time panel



commit e35b73abb52190b173a74e6c37ead41b75869f1c
Author: Thomas Wood <thomas wood intel com>
Date:   Fri May 21 17:36:27 2010 +0100

    Add initial implementation of date/time panel

 configure.ac                                       |    2 +
 panels/Makefile.am                                 |    3 +-
 panels/datetime/Makefile.am                        |   73 ++++
 panels/datetime/cc-datetime-panel.c                |  113 ++++++
 panels/datetime/cc-datetime-panel.h                |   74 ++++
 panels/datetime/cc-timezone-map.c                  |  384 ++++++++++++++++++++
 panels/datetime/cc-timezone-map.h                  |   74 ++++
 panels/datetime/data/bg.png                        |  Bin 0 -> 177324 bytes
 panels/datetime/data/cc.png                        |  Bin 0 -> 53948 bytes
 panels/datetime/data/timezone_-1.png               |  Bin 0 -> 8012 bytes
 panels/datetime/data/timezone_-10.png              |  Bin 0 -> 7783 bytes
 panels/datetime/data/timezone_-11.png              |  Bin 0 -> 7406 bytes
 panels/datetime/data/timezone_-2.png               |  Bin 0 -> 4333 bytes
 panels/datetime/data/timezone_-3.5.png             |  Bin 0 -> 740 bytes
 panels/datetime/data/timezone_-3.png               |  Bin 0 -> 13615 bytes
 panels/datetime/data/timezone_-4.5.png             |  Bin 0 -> 1900 bytes
 panels/datetime/data/timezone_-4.png               |  Bin 0 -> 15084 bytes
 panels/datetime/data/timezone_-5.5.png             |  Bin 0 -> 437 bytes
 panels/datetime/data/timezone_-5.png               |  Bin 0 -> 19166 bytes
 panels/datetime/data/timezone_-6.png               |  Bin 0 -> 13764 bytes
 panels/datetime/data/timezone_-7.png               |  Bin 0 -> 11977 bytes
 panels/datetime/data/timezone_-8.png               |  Bin 0 -> 6801 bytes
 panels/datetime/data/timezone_-9.5.png             |  Bin 0 -> 437 bytes
 panels/datetime/data/timezone_-9.png               |  Bin 0 -> 7908 bytes
 panels/datetime/data/timezone_0.png                |  Bin 0 -> 11074 bytes
 panels/datetime/data/timezone_1.png                |  Bin 0 -> 15458 bytes
 panels/datetime/data/timezone_10.5.png             |  Bin 0 -> 421 bytes
 panels/datetime/data/timezone_10.png               |  Bin 0 -> 12829 bytes
 panels/datetime/data/timezone_11.5.png             |  Bin 0 -> 446 bytes
 panels/datetime/data/timezone_11.png               |  Bin 0 -> 12113 bytes
 panels/datetime/data/timezone_12.75.png            |  Bin 0 -> 409 bytes
 panels/datetime/data/timezone_12.png               |  Bin 0 -> 7130 bytes
 panels/datetime/data/timezone_13.png               |  Bin 0 -> 621 bytes
 panels/datetime/data/timezone_2.png                |  Bin 0 -> 12854 bytes
 panels/datetime/data/timezone_3.5.png              |  Bin 0 -> 2142 bytes
 panels/datetime/data/timezone_3.png                |  Bin 0 -> 17475 bytes
 panels/datetime/data/timezone_4.5.png              |  Bin 0 -> 1773 bytes
 panels/datetime/data/timezone_4.png                |  Bin 0 -> 4954 bytes
 panels/datetime/data/timezone_5.5.png              |  Bin 0 -> 6099 bytes
 panels/datetime/data/timezone_5.75.png             |  Bin 0 -> 2885 bytes
 panels/datetime/data/timezone_5.png                |  Bin 0 -> 14539 bytes
 panels/datetime/data/timezone_6.5.png              |  Bin 0 -> 1609 bytes
 panels/datetime/data/timezone_6.png                |  Bin 0 -> 8441 bytes
 panels/datetime/data/timezone_7.png                |  Bin 0 -> 14412 bytes
 panels/datetime/data/timezone_8.png                |  Bin 0 -> 16725 bytes
 panels/datetime/data/timezone_9.5.png              |  Bin 0 -> 1959 bytes
 panels/datetime/data/timezone_9.png                |  Bin 0 -> 12608 bytes
 panels/datetime/datetime-module.c                  |   41 ++
 panels/datetime/gnome-datetime-panel.desktop.in.in |   11 +
 49 files changed, 774 insertions(+), 1 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 3d5657a..bc56f23 100644
--- a/configure.ac
+++ b/configure.ac
@@ -403,6 +403,8 @@ libgnome-control-center/libgnome-control-center.pc
 libwindow-settings/Makefile
 libwindow-settings/gnome-window-settings-2.0.pc
 panels/Makefile
+panels/datetime/Makefile
+panels/datetime/gnome-datetime-panel.desktop.in
 panels/mouse/Makefile
 panels/mouse/gnome-mouse-panel.desktop.in
 panels/keyboard/Makefile
diff --git a/panels/Makefile.am b/panels/Makefile.am
index 22aa0d9..66a22e3 100644
--- a/panels/Makefile.am
+++ b/panels/Makefile.am
@@ -4,4 +4,5 @@ SUBDIRS=display \
 	network \
 	default-applications \
 	keybindings \
-	universal-access
+	universal-access \
+	datetime
diff --git a/panels/datetime/Makefile.am b/panels/datetime/Makefile.am
new file mode 100644
index 0000000..49af8fb
--- /dev/null
+++ b/panels/datetime/Makefile.am
@@ -0,0 +1,73 @@
+uidir = $(datadir)/ui
+ui_DATA = data/bg.png \
+	data/cc.png \
+	data/timezone_0.png \
+	data/timezone_-10.png \
+	data/timezone_10.png \
+	data/timezone_10.5.png \
+	data/timezone_-1.png \
+	data/timezone_1.png \
+	data/timezone_-11.png \
+	data/timezone_11.png \
+	data/timezone_11.5.png \
+	data/timezone_12.png \
+	data/timezone_12.75.png \
+	data/timezone_13.png \
+	data/timezone_-2.png \
+	data/timezone_2.png \
+	data/timezone_-3.png \
+	data/timezone_3.png \
+	data/timezone_-3.5.png \
+	data/timezone_3.5.png \
+	data/timezone_-4.png \
+	data/timezone_4.png \
+	data/timezone_-4.5.png \
+	data/timezone_4.5.png \
+	data/timezone_-5.png \
+	data/timezone_5.png \
+	data/timezone_-5.5.png \
+	data/timezone_5.5.png \
+	data/timezone_5.75.png \
+	data/timezone_-6.png \
+	data/timezone_6.png \
+	data/timezone_6.5.png \
+	data/timezone_-7.png \
+	data/timezone_7.png \
+	data/timezone_-8.png \
+	data/timezone_8.png \
+	data/timezone_-9.png \
+	data/timezone_9.png \
+	data/timezone_-9.5.png \
+	data/timezone_9.5.png
+
+
+INCLUDES = 						\
+	$(PANEL_CFLAGS)					\
+	$(GNOMECC_CAPPLETS_CFLAGS)			\
+	-DGNOMELOCALEDIR="\"$(datadir)/locale\""	\
+	-DGNOMECC_DATA_DIR="\"$(pkgdatadir)\""		\
+	-DDATADIR="\"$(uidir)\""			\
+	$(NULL)
+
+ccpanelsdir = $(PANELS_DIR)
+ccpanels_LTLIBRARIES = libdate_time.la
+
+libdate_time_la_SOURCES =		\
+	datetime-module.c	\
+	cc-datetime-panel.c	\
+	cc-datetime-panel.h	\
+	cc-timezone-map.c	\
+	cc-timezone-map.h
+
+libdate_time_la_LIBADD = $(PANEL_LIBS)
+libdate_time_la_LDFLAGS = $(PANEL_LDFLAGS)
+
+ INTLTOOL_DESKTOP_RULE@
+
+desktopdir = $(datadir)/applications
+desktop_in_files = gnome-datetime-panel.desktop.in
+desktop_DATA = $(desktop_in_files:.desktop.in=.desktop)
+
+CLEANFILES = $(desktop_in_files) $(desktop_DATA)
+
+-include $(top_srcdir)/git.mk
diff --git a/panels/datetime/cc-datetime-panel.c b/panels/datetime/cc-datetime-panel.c
new file mode 100644
index 0000000..74e3eb3
--- /dev/null
+++ b/panels/datetime/cc-datetime-panel.c
@@ -0,0 +1,113 @@
+/*
+ * Copyright (C) 2010 Intel, Inc
+ *
+ * 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 2 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * Author: Thomas Wood <thomas wood intel com>
+ *
+ */
+
+#include "cc-datetime-panel.h"
+
+#include "cc-timezone-map.h"
+
+G_DEFINE_DYNAMIC_TYPE (CcDateTimePanel, cc_date_time_panel, CC_TYPE_PANEL)
+
+#define DATE_TIME_PANEL_PRIVATE(o) \
+  (G_TYPE_INSTANCE_GET_PRIVATE ((o), CC_TYPE_DATE_TIME_PANEL, CcDateTimePanelPrivate))
+
+struct _CcDateTimePanelPrivate
+{
+  gpointer dummy;
+};
+
+
+static void
+cc_date_time_panel_get_property (GObject    *object,
+                               guint       property_id,
+                               GValue     *value,
+                               GParamSpec *pspec)
+{
+  switch (property_id)
+    {
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+    }
+}
+
+static void
+cc_date_time_panel_set_property (GObject      *object,
+                               guint         property_id,
+                               const GValue *value,
+                               GParamSpec   *pspec)
+{
+  switch (property_id)
+    {
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+    }
+}
+
+static void
+cc_date_time_panel_dispose (GObject *object)
+{
+  G_OBJECT_CLASS (cc_date_time_panel_parent_class)->dispose (object);
+}
+
+static void
+cc_date_time_panel_finalize (GObject *object)
+{
+  G_OBJECT_CLASS (cc_date_time_panel_parent_class)->finalize (object);
+}
+
+static void
+cc_date_time_panel_class_init (CcDateTimePanelClass *klass)
+{
+  GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+  g_type_class_add_private (klass, sizeof (CcDateTimePanelPrivate));
+
+  object_class->get_property = cc_date_time_panel_get_property;
+  object_class->set_property = cc_date_time_panel_set_property;
+  object_class->dispose = cc_date_time_panel_dispose;
+  object_class->finalize = cc_date_time_panel_finalize;
+}
+
+static void
+cc_date_time_panel_class_finalize (CcDateTimePanelClass *klass)
+{
+}
+
+static void
+cc_date_time_panel_init (CcDateTimePanel *self)
+{
+  GtkWidget *label;
+
+  self->priv = DATE_TIME_PANEL_PRIVATE (self);
+
+  label = cc_timezone_map_new ();
+
+  gtk_container_add (GTK_CONTAINER (self), label);
+}
+
+void
+cc_date_time_panel_register (GIOModule *module)
+{
+  cc_date_time_panel_register_type (G_TYPE_MODULE (module));
+  g_io_extension_point_implement (CC_SHELL_PANEL_EXTENSION_POINT,
+                                  CC_TYPE_DATE_TIME_PANEL,
+                                  "gnome-datetime-panel.desktop", 0);
+}
+
diff --git a/panels/datetime/cc-datetime-panel.h b/panels/datetime/cc-datetime-panel.h
new file mode 100644
index 0000000..27ae9ce
--- /dev/null
+++ b/panels/datetime/cc-datetime-panel.h
@@ -0,0 +1,74 @@
+/*
+ * Copyright (C) 2010 Intel, Inc
+ *
+ * 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 2 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * Author: Thomas Wood <thomas wood intel com>
+ *
+ */
+
+
+#ifndef _CC_DATE_TIME_PANEL_H
+#define _CC_DATE_TIME_PANEL_H
+
+#include <libgnome-control-center/cc-panel.h>
+
+G_BEGIN_DECLS
+
+#define CC_TYPE_DATE_TIME_PANEL cc_date_time_panel_get_type()
+
+#define CC_DATE_TIME_PANEL(obj) \
+  (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
+  CC_TYPE_DATE_TIME_PANEL, CcDateTimePanel))
+
+#define CC_DATE_TIME_PANEL_CLASS(klass) \
+  (G_TYPE_CHECK_CLASS_CAST ((klass), \
+  CC_TYPE_DATE_TIME_PANEL, CcDateTimePanelClass))
+
+#define CC_IS_DATE_TIME_PANEL(obj) \
+  (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
+  CC_TYPE_DATE_TIME_PANEL))
+
+#define CC_IS_DATE_TIME_PANEL_CLASS(klass) \
+  (G_TYPE_CHECK_CLASS_TYPE ((klass), \
+  CC_TYPE_DATE_TIME_PANEL))
+
+#define CC_DATE_TIME_PANEL_GET_CLASS(obj) \
+  (G_TYPE_INSTANCE_GET_CLASS ((obj), \
+  CC_TYPE_DATE_TIME_PANEL, CcDateTimePanelClass))
+
+typedef struct _CcDateTimePanel CcDateTimePanel;
+typedef struct _CcDateTimePanelClass CcDateTimePanelClass;
+typedef struct _CcDateTimePanelPrivate CcDateTimePanelPrivate;
+
+struct _CcDateTimePanel
+{
+  CcPanel parent;
+
+  CcDateTimePanelPrivate *priv;
+};
+
+struct _CcDateTimePanelClass
+{
+  CcPanelClass parent_class;
+};
+
+GType cc_date_time_panel_get_type (void) G_GNUC_CONST;
+
+void  cc_date_time_panel_register (GIOModule *module);
+
+G_END_DECLS
+
+#endif /* _CC_DATE_TIME_PANEL_H */
diff --git a/panels/datetime/cc-timezone-map.c b/panels/datetime/cc-timezone-map.c
new file mode 100644
index 0000000..7c55138
--- /dev/null
+++ b/panels/datetime/cc-timezone-map.c
@@ -0,0 +1,384 @@
+/*
+ * Copyright (C) 2010 Intel, Inc
+ *
+ * Portions from Ubiquity, Copyright (C) 2009 Canonical Ltd.
+ * Written by Evan Dandrea <evand ubuntu com>
+ *
+ * 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 2 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * Author: Thomas Wood <thomas wood intel com>
+ *
+ */
+
+#include "cc-timezone-map.h"
+
+G_DEFINE_TYPE (CcTimezoneMap, cc_timezone_map, GTK_TYPE_WIDGET)
+
+#define TIMEZONE_MAP_PRIVATE(o) \
+  (G_TYPE_INSTANCE_GET_PRIVATE ((o), CC_TYPE_TIMEZONE_MAP, CcTimezoneMapPrivate))
+
+
+typedef struct
+{
+  gdouble offset;
+  guchar red;
+  guchar green;
+  guchar blue;
+  guchar alpha;
+} CcTimezoneMapOffset;
+
+struct _CcTimezoneMapPrivate
+{
+  GdkPixbuf *orig_background;
+  GdkPixbuf *orig_color_map;
+
+  GdkPixbuf *background;
+  GdkPixbuf *color_map;
+
+  guchar *visible_map_pixels;
+  gint visible_map_rowstride;
+
+  gdouble selected_offset;
+};
+
+
+static CcTimezoneMapOffset color_codes[] =
+{
+    {-11.0, 43, 0, 0, 255 },
+    {-10.0, 85, 0, 0, 255 },
+    {-9.5, 102, 255, 0, 255 },
+    {-9.0, 128, 0, 0, 255 },
+    {-8.0, 170, 0, 0, 255 },
+    {-7.0, 212, 0, 0, 255 },
+    {-6.0, 255, 0, 1, 255 }, // north
+    {-6.0, 255, 0, 0, 255 }, // south
+    {-5.0, 255, 42, 42, 255 },
+    {-4.5, 192, 255, 0, 255 },
+    {-4.0, 255, 85, 85, 255 },
+    {-3.5, 0, 255, 0, 255 },
+    {-3.0, 255, 128, 128, 255 },
+    {-2.0, 255, 170, 170, 255 },
+    {-1.0, 255, 213, 213, 255 },
+    {0.0, 43, 17, 0, 255 },
+    {1.0, 85, 34, 0, 255 },
+    {2.0, 128, 51, 0, 255 },
+    {3.0, 170, 68, 0, 255 },
+    {3.5, 0, 255, 102, 255 },
+    {4.0, 212, 85, 0, 255 },
+    {4.5, 0, 204, 255, 255 },
+    {5.0, 255, 102, 0, 255 },
+    {5.5, 0, 102, 255, 255 },
+    {5.75, 0, 238, 207, 247 },
+    {6.0, 255, 127, 42, 255 },
+    {6.5, 204, 0, 254, 254 },
+    {7.0, 255, 153, 85, 255 },
+    {8.0, 255, 179, 128, 255 },
+    {9.0, 255, 204, 170, 255 },
+    {9.5, 170, 0, 68, 250 },
+    {10.0, 255, 230, 213, 255 },
+    {10.5, 212, 124, 21, 250 },
+    {11.0, 212, 170, 0, 255 },
+    {11.5, 249, 25, 87, 253 },
+    {12.0, 255, 204, 0, 255 },
+    {12.75, 254, 74, 100, 248 },
+    {13.0, 255, 85, 153, 250 },
+    {-100, 0, 0, 0, 0 }
+};
+
+
+static void
+cc_timezone_map_get_property (GObject    *object,
+                              guint       property_id,
+                              GValue     *value,
+                              GParamSpec *pspec)
+{
+  switch (property_id)
+    {
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+    }
+}
+
+static void
+cc_timezone_map_set_property (GObject      *object,
+                              guint         property_id,
+                              const GValue *value,
+                              GParamSpec   *pspec)
+{
+  switch (property_id)
+    {
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+    }
+}
+
+static void
+cc_timezone_map_dispose (GObject *object)
+{
+  CcTimezoneMapPrivate *priv = CC_TIMEZONE_MAP (object)->priv;
+
+  if (priv->orig_background)
+    {
+      g_object_unref (priv->orig_background);
+      priv->orig_background = NULL;
+    }
+
+  if (priv->orig_color_map)
+    {
+      g_object_unref (priv->orig_color_map);
+      priv->orig_color_map = NULL;
+    }
+
+  if (priv->background)
+    {
+      g_object_unref (priv->background);
+      priv->background = NULL;
+    }
+
+  if (priv->color_map)
+    {
+      g_object_unref (priv->color_map);
+      priv->color_map = NULL;
+
+      priv->visible_map_pixels = NULL;
+      priv->visible_map_rowstride = 0;
+    }
+
+  G_OBJECT_CLASS (cc_timezone_map_parent_class)->dispose (object);
+}
+
+static void
+cc_timezone_map_finalize (GObject *object)
+{
+  G_OBJECT_CLASS (cc_timezone_map_parent_class)->finalize (object);
+}
+
+/* GtkWidget functions */
+static void
+cc_timezone_map_size_request (GtkWidget      *widget,
+                              GtkRequisition *req)
+{
+  CcTimezoneMapPrivate *priv = CC_TIMEZONE_MAP (widget)->priv;
+
+  req->width = gdk_pixbuf_get_width (priv->orig_background) / 2;
+  req->height = gdk_pixbuf_get_height (priv->orig_background) / 2;
+
+  GTK_WIDGET_CLASS (cc_timezone_map_parent_class)->size_request (widget, req);
+}
+
+static void
+cc_timezone_map_size_allocate (GtkWidget     *widget,
+                               GtkAllocation *allocation)
+{
+  CcTimezoneMapPrivate *priv = CC_TIMEZONE_MAP (widget)->priv;
+  GdkPixbuf *color_map;
+
+  priv->background = gdk_pixbuf_scale_simple (priv->orig_background,
+                                              allocation->width,
+                                              allocation->height,
+                                              GDK_INTERP_BILINEAR);
+  color_map = gdk_pixbuf_scale_simple (priv->orig_color_map,
+                                       allocation->width,
+                                       allocation->height,
+                                       GDK_INTERP_BILINEAR);
+
+  priv->visible_map_pixels = gdk_pixbuf_get_pixels (color_map);
+  priv->visible_map_rowstride = gdk_pixbuf_get_rowstride (color_map);
+
+  GTK_WIDGET_CLASS (cc_timezone_map_parent_class)->size_allocate (widget,
+                                                                  allocation);
+}
+
+static void
+cc_timezone_map_realize (GtkWidget *widget)
+{
+  GdkWindowAttr attr = { 0, };
+  GtkAllocation allocation;
+  GdkCursor *cursor;
+  GdkWindow *window;
+
+  gtk_widget_get_allocation (widget, &allocation);
+
+  GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED);
+
+  attr.window_type = GDK_WINDOW_CHILD;
+  attr.wclass = GDK_INPUT_OUTPUT;
+  attr.width = allocation.width;
+  attr.height = allocation.height;
+  attr.x = allocation.x;
+  attr.y = allocation.y;
+  attr.event_mask = gtk_widget_get_events (widget)
+                                 | GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK;
+
+  window = gdk_window_new (gtk_widget_get_parent_window (widget), &attr,
+                           GDK_WA_X | GDK_WA_Y);
+
+  gtk_widget_set_style (widget,
+                        gtk_style_attach (gtk_widget_get_style (widget),
+                                          window));
+
+  gdk_window_set_user_data (window, widget);
+
+  cursor = gdk_cursor_new (GDK_HAND2);
+  gdk_window_set_cursor (window, cursor);
+
+  gtk_widget_set_window (widget, window);
+}
+
+static gboolean
+cc_timezone_map_expose_event (GtkWidget      *widget,
+                              GdkEventExpose *event)
+{
+  CcTimezoneMapPrivate *priv = CC_TIMEZONE_MAP (widget)->priv;
+  GdkPixbuf *hilight, *orig_hilight;
+  cairo_t *cr;
+  GtkAllocation alloc;
+  gchar *file;
+  GError *err = NULL;
+
+  cr = gdk_cairo_create (gtk_widget_get_window (widget));
+
+  gtk_widget_get_allocation (widget, &alloc);
+
+  /* paint background */
+  gdk_cairo_set_source_pixbuf (cr, priv->background, 0, 0);
+  cairo_paint (cr);
+
+  /* paint hilight */
+  file = g_strdup_printf (DATADIR "/timezone_%g.png",
+                          priv->selected_offset);
+  orig_hilight = gdk_pixbuf_new_from_file (file, &err);
+  if (!orig_hilight)
+    {
+      g_warning ("Could not load hilight: %s",
+                 (err) ? err->message : "Unknown Error");
+      if (err)
+        g_clear_error (&err);
+    }
+
+  hilight = gdk_pixbuf_scale_simple (orig_hilight, alloc.width, alloc.height,
+                                     GDK_INTERP_BILINEAR);
+  gdk_cairo_set_source_pixbuf (cr, hilight, 0, 0);
+
+  cairo_paint (cr);
+
+  cairo_destroy (cr);
+
+  g_object_unref (hilight);
+  g_object_unref (orig_hilight);
+
+  return TRUE;
+}
+
+
+static void
+cc_timezone_map_class_init (CcTimezoneMapClass *klass)
+{
+  GObjectClass *object_class = G_OBJECT_CLASS (klass);
+  GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+
+  g_type_class_add_private (klass, sizeof (CcTimezoneMapPrivate));
+
+  object_class->get_property = cc_timezone_map_get_property;
+  object_class->set_property = cc_timezone_map_set_property;
+  object_class->dispose = cc_timezone_map_dispose;
+  object_class->finalize = cc_timezone_map_finalize;
+
+  widget_class->size_request = cc_timezone_map_size_request;
+  widget_class->size_allocate = cc_timezone_map_size_allocate;
+  widget_class->realize = cc_timezone_map_realize;
+  widget_class->expose_event = cc_timezone_map_expose_event;
+}
+
+gboolean
+button_press_event (GtkWidget      *widget,
+                    GdkEventButton *event)
+{
+  CcTimezoneMapPrivate *priv = CC_TIMEZONE_MAP (widget)->priv;
+  gint x, y;
+  guchar r, g, b, a;
+  guchar *pixels;
+  gint rowstride;
+  gint i;
+
+  x = event->x;
+  y = event->y;
+
+
+  rowstride = priv->visible_map_rowstride;
+  pixels = priv->visible_map_pixels;
+
+  r = pixels[(rowstride * y + x * 4)];
+  g = pixels[(rowstride * y + x * 4) + 1];
+  b = pixels[(rowstride * y + x * 4) + 2];
+  a = pixels[(rowstride * y + x * 4) + 3];
+
+
+  for (i = 0; color_codes[i].offset != -100; i++)
+    {
+       if (color_codes[i].red == r && color_codes[i].green == g
+           && color_codes[i].blue == b && color_codes[i].alpha == a)
+         {
+           priv->selected_offset = color_codes[i].offset;
+         }
+    }
+
+  gtk_widget_queue_draw (widget);
+
+  return TRUE;
+}
+
+static void
+cc_timezone_map_init (CcTimezoneMap *self)
+{
+  CcTimezoneMapPrivate *priv;
+  GError *err = NULL;
+
+  priv = self->priv = TIMEZONE_MAP_PRIVATE (self);
+
+  priv->orig_background = gdk_pixbuf_new_from_file (DATADIR "/bg.png",
+                                                    &err);
+
+  if (!priv->orig_background)
+    {
+      g_warning ("Could not load background image: %s",
+                 (err) ? err->message : "Unknown error");
+      g_clear_error (&err);
+    }
+
+  priv->orig_color_map = gdk_pixbuf_new_from_file (DATADIR "/cc.png",
+                                                   &err);
+  if (!priv->orig_color_map)
+    {
+      g_warning ("Could not load background image: %s",
+                 (err) ? err->message : "Unknown error");
+      g_clear_error (&err);
+    }
+
+
+  g_signal_connect (self, "button-press-event", G_CALLBACK (button_press_event),
+                    NULL);
+
+  /*
+  g_signal_connect (self, "map-event", G_CALLBACK (map_event), NULL);
+  g_signal_connect (self, "unmap-event", G_CALLBACK (unmap_event), NULL);
+  */
+}
+
+CcTimezoneMap *
+cc_timezone_map_new (void)
+{
+  return g_object_new (CC_TYPE_TIMEZONE_MAP, NULL);
+}
diff --git a/panels/datetime/cc-timezone-map.h b/panels/datetime/cc-timezone-map.h
new file mode 100644
index 0000000..8b34161
--- /dev/null
+++ b/panels/datetime/cc-timezone-map.h
@@ -0,0 +1,74 @@
+/*
+ * Copyright (C) 2010 Intel, Inc
+ *
+ * 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 2 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * Author: Thomas Wood <thomas wood intel com>
+ *
+ */
+
+
+#ifndef _CC_TIMEZONE_MAP_H
+#define _CC_TIMEZONE_MAP_H
+
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+#define CC_TYPE_TIMEZONE_MAP cc_timezone_map_get_type()
+
+#define CC_TIMEZONE_MAP(obj) \
+  (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
+  CC_TYPE_TIMEZONE_MAP, CcTimezoneMap))
+
+#define CC_TIMEZONE_MAP_CLASS(klass) \
+  (G_TYPE_CHECK_CLASS_CAST ((klass), \
+  CC_TYPE_TIMEZONE_MAP, CcTimezoneMapClass))
+
+#define CC_IS_TIMEZONE_MAP(obj) \
+  (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
+  CC_TYPE_TIMEZONE_MAP))
+
+#define CC_IS_TIMEZONE_MAP_CLASS(klass) \
+  (G_TYPE_CHECK_CLASS_TYPE ((klass), \
+  CC_TYPE_TIMEZONE_MAP))
+
+#define CC_TIMEZONE_MAP_GET_CLASS(obj) \
+  (G_TYPE_INSTANCE_GET_CLASS ((obj), \
+  CC_TYPE_TIMEZONE_MAP, CcTimezoneMapClass))
+
+typedef struct _CcTimezoneMap CcTimezoneMap;
+typedef struct _CcTimezoneMapClass CcTimezoneMapClass;
+typedef struct _CcTimezoneMapPrivate CcTimezoneMapPrivate;
+
+struct _CcTimezoneMap
+{
+  GtkWidget parent;
+
+  CcTimezoneMapPrivate *priv;
+};
+
+struct _CcTimezoneMapClass
+{
+  GtkWidgetClass parent_class;
+};
+
+GType cc_timezone_map_get_type (void) G_GNUC_CONST;
+
+CcTimezoneMap *cc_timezone_map_new (void);
+
+G_END_DECLS
+
+#endif /* _CC_TIMEZONE_MAP_H */
diff --git a/panels/datetime/data/bg.png b/panels/datetime/data/bg.png
new file mode 100644
index 0000000..d7479bf
Binary files /dev/null and b/panels/datetime/data/bg.png differ
diff --git a/panels/datetime/data/cc.png b/panels/datetime/data/cc.png
new file mode 100644
index 0000000..54fb668
Binary files /dev/null and b/panels/datetime/data/cc.png differ
diff --git a/panels/datetime/data/timezone_-1.png b/panels/datetime/data/timezone_-1.png
new file mode 100644
index 0000000..fb00d83
Binary files /dev/null and b/panels/datetime/data/timezone_-1.png differ
diff --git a/panels/datetime/data/timezone_-10.png b/panels/datetime/data/timezone_-10.png
new file mode 100644
index 0000000..472eb88
Binary files /dev/null and b/panels/datetime/data/timezone_-10.png differ
diff --git a/panels/datetime/data/timezone_-11.png b/panels/datetime/data/timezone_-11.png
new file mode 100644
index 0000000..5f8c5d6
Binary files /dev/null and b/panels/datetime/data/timezone_-11.png differ
diff --git a/panels/datetime/data/timezone_-2.png b/panels/datetime/data/timezone_-2.png
new file mode 100644
index 0000000..30a1ec7
Binary files /dev/null and b/panels/datetime/data/timezone_-2.png differ
diff --git a/panels/datetime/data/timezone_-3.5.png b/panels/datetime/data/timezone_-3.5.png
new file mode 100644
index 0000000..c1df00b
Binary files /dev/null and b/panels/datetime/data/timezone_-3.5.png differ
diff --git a/panels/datetime/data/timezone_-3.png b/panels/datetime/data/timezone_-3.png
new file mode 100644
index 0000000..c22dbb6
Binary files /dev/null and b/panels/datetime/data/timezone_-3.png differ
diff --git a/panels/datetime/data/timezone_-4.5.png b/panels/datetime/data/timezone_-4.5.png
new file mode 100644
index 0000000..9e3c134
Binary files /dev/null and b/panels/datetime/data/timezone_-4.5.png differ
diff --git a/panels/datetime/data/timezone_-4.png b/panels/datetime/data/timezone_-4.png
new file mode 100644
index 0000000..4b5a431
Binary files /dev/null and b/panels/datetime/data/timezone_-4.png differ
diff --git a/panels/datetime/data/timezone_-5.5.png b/panels/datetime/data/timezone_-5.5.png
new file mode 100644
index 0000000..b1c788d
Binary files /dev/null and b/panels/datetime/data/timezone_-5.5.png differ
diff --git a/panels/datetime/data/timezone_-5.png b/panels/datetime/data/timezone_-5.png
new file mode 100644
index 0000000..06c15e6
Binary files /dev/null and b/panels/datetime/data/timezone_-5.png differ
diff --git a/panels/datetime/data/timezone_-6.png b/panels/datetime/data/timezone_-6.png
new file mode 100644
index 0000000..8505fb1
Binary files /dev/null and b/panels/datetime/data/timezone_-6.png differ
diff --git a/panels/datetime/data/timezone_-7.png b/panels/datetime/data/timezone_-7.png
new file mode 100644
index 0000000..fec235d
Binary files /dev/null and b/panels/datetime/data/timezone_-7.png differ
diff --git a/panels/datetime/data/timezone_-8.png b/panels/datetime/data/timezone_-8.png
new file mode 100644
index 0000000..bdad7bf
Binary files /dev/null and b/panels/datetime/data/timezone_-8.png differ
diff --git a/panels/datetime/data/timezone_-9.5.png b/panels/datetime/data/timezone_-9.5.png
new file mode 100644
index 0000000..b1c788d
Binary files /dev/null and b/panels/datetime/data/timezone_-9.5.png differ
diff --git a/panels/datetime/data/timezone_-9.png b/panels/datetime/data/timezone_-9.png
new file mode 100644
index 0000000..04cb3cb
Binary files /dev/null and b/panels/datetime/data/timezone_-9.png differ
diff --git a/panels/datetime/data/timezone_0.png b/panels/datetime/data/timezone_0.png
new file mode 100644
index 0000000..e59b773
Binary files /dev/null and b/panels/datetime/data/timezone_0.png differ
diff --git a/panels/datetime/data/timezone_1.png b/panels/datetime/data/timezone_1.png
new file mode 100644
index 0000000..2053b7e
Binary files /dev/null and b/panels/datetime/data/timezone_1.png differ
diff --git a/panels/datetime/data/timezone_10.5.png b/panels/datetime/data/timezone_10.5.png
new file mode 100644
index 0000000..6ec7f9f
Binary files /dev/null and b/panels/datetime/data/timezone_10.5.png differ
diff --git a/panels/datetime/data/timezone_10.png b/panels/datetime/data/timezone_10.png
new file mode 100644
index 0000000..475dcf4
Binary files /dev/null and b/panels/datetime/data/timezone_10.png differ
diff --git a/panels/datetime/data/timezone_11.5.png b/panels/datetime/data/timezone_11.5.png
new file mode 100644
index 0000000..afdedd7
Binary files /dev/null and b/panels/datetime/data/timezone_11.5.png differ
diff --git a/panels/datetime/data/timezone_11.png b/panels/datetime/data/timezone_11.png
new file mode 100644
index 0000000..6168aa2
Binary files /dev/null and b/panels/datetime/data/timezone_11.png differ
diff --git a/panels/datetime/data/timezone_12.75.png b/panels/datetime/data/timezone_12.75.png
new file mode 100644
index 0000000..4f74a85
Binary files /dev/null and b/panels/datetime/data/timezone_12.75.png differ
diff --git a/panels/datetime/data/timezone_12.png b/panels/datetime/data/timezone_12.png
new file mode 100644
index 0000000..d0b3531
Binary files /dev/null and b/panels/datetime/data/timezone_12.png differ
diff --git a/panels/datetime/data/timezone_13.png b/panels/datetime/data/timezone_13.png
new file mode 100644
index 0000000..fe2f134
Binary files /dev/null and b/panels/datetime/data/timezone_13.png differ
diff --git a/panels/datetime/data/timezone_2.png b/panels/datetime/data/timezone_2.png
new file mode 100644
index 0000000..ec1e874
Binary files /dev/null and b/panels/datetime/data/timezone_2.png differ
diff --git a/panels/datetime/data/timezone_3.5.png b/panels/datetime/data/timezone_3.5.png
new file mode 100644
index 0000000..2dc7399
Binary files /dev/null and b/panels/datetime/data/timezone_3.5.png differ
diff --git a/panels/datetime/data/timezone_3.png b/panels/datetime/data/timezone_3.png
new file mode 100644
index 0000000..eda59dc
Binary files /dev/null and b/panels/datetime/data/timezone_3.png differ
diff --git a/panels/datetime/data/timezone_4.5.png b/panels/datetime/data/timezone_4.5.png
new file mode 100644
index 0000000..e09ed90
Binary files /dev/null and b/panels/datetime/data/timezone_4.5.png differ
diff --git a/panels/datetime/data/timezone_4.png b/panels/datetime/data/timezone_4.png
new file mode 100644
index 0000000..483dc53
Binary files /dev/null and b/panels/datetime/data/timezone_4.png differ
diff --git a/panels/datetime/data/timezone_5.5.png b/panels/datetime/data/timezone_5.5.png
new file mode 100644
index 0000000..f904cc2
Binary files /dev/null and b/panels/datetime/data/timezone_5.5.png differ
diff --git a/panels/datetime/data/timezone_5.75.png b/panels/datetime/data/timezone_5.75.png
new file mode 100644
index 0000000..827ce1a
Binary files /dev/null and b/panels/datetime/data/timezone_5.75.png differ
diff --git a/panels/datetime/data/timezone_5.png b/panels/datetime/data/timezone_5.png
new file mode 100644
index 0000000..1bb6d20
Binary files /dev/null and b/panels/datetime/data/timezone_5.png differ
diff --git a/panels/datetime/data/timezone_6.5.png b/panels/datetime/data/timezone_6.5.png
new file mode 100644
index 0000000..d307bf3
Binary files /dev/null and b/panels/datetime/data/timezone_6.5.png differ
diff --git a/panels/datetime/data/timezone_6.png b/panels/datetime/data/timezone_6.png
new file mode 100644
index 0000000..460f9cf
Binary files /dev/null and b/panels/datetime/data/timezone_6.png differ
diff --git a/panels/datetime/data/timezone_7.png b/panels/datetime/data/timezone_7.png
new file mode 100644
index 0000000..239115a
Binary files /dev/null and b/panels/datetime/data/timezone_7.png differ
diff --git a/panels/datetime/data/timezone_8.png b/panels/datetime/data/timezone_8.png
new file mode 100644
index 0000000..3627686
Binary files /dev/null and b/panels/datetime/data/timezone_8.png differ
diff --git a/panels/datetime/data/timezone_9.5.png b/panels/datetime/data/timezone_9.5.png
new file mode 100644
index 0000000..1c3290c
Binary files /dev/null and b/panels/datetime/data/timezone_9.5.png differ
diff --git a/panels/datetime/data/timezone_9.png b/panels/datetime/data/timezone_9.png
new file mode 100644
index 0000000..65d2e46
Binary files /dev/null and b/panels/datetime/data/timezone_9.png differ
diff --git a/panels/datetime/datetime-module.c b/panels/datetime/datetime-module.c
new file mode 100644
index 0000000..d2a57d7
--- /dev/null
+++ b/panels/datetime/datetime-module.c
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2010 Intel, Inc
+ *
+ * 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 2 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * Author: Thomas Wood <thomas wood intel com>
+ *
+ */
+
+#include <config.h>
+
+#include "cc-datetime-panel.h"
+
+#include <glib/gi18n.h>
+
+void
+g_io_module_load (GIOModule *module)
+{
+  bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
+  bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+
+  /* register the panel */
+  cc_date_time_panel_register (module);
+}
+
+void
+g_io_module_unload (GIOModule *module)
+{
+}
diff --git a/panels/datetime/gnome-datetime-panel.desktop.in.in b/panels/datetime/gnome-datetime-panel.desktop.in.in
new file mode 100644
index 0000000..e613d05
--- /dev/null
+++ b/panels/datetime/gnome-datetime-panel.desktop.in.in
@@ -0,0 +1,11 @@
+[Desktop Entry]
+_Name=DateTime Panel
+_Comment=DateTime preferences panel
+Exec=gnome-date_time-properties
+Icon=application-x-executable
+Terminal=false
+Type=Application
+StartupNotify=true
+Categories=GNOME;GTK;Settings;DesktopSettings;
+OnlyShowIn=GNOME;
+



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]