Add initial implementation of date/time panel
|
@ -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
|
||||
|
|
|
@ -4,4 +4,5 @@ SUBDIRS=display \
|
|||
network \
|
||||
default-applications \
|
||||
keybindings \
|
||||
universal-access
|
||||
universal-access \
|
||||
datetime
|
||||
|
|
73
panels/datetime/Makefile.am
Normal file
|
@ -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
|
113
panels/datetime/cc-datetime-panel.c
Normal file
|
@ -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);
|
||||
}
|
||||
|
74
panels/datetime/cc-datetime-panel.h
Normal file
|
@ -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 */
|
384
panels/datetime/cc-timezone-map.c
Normal file
|
@ -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);
|
||||
}
|
74
panels/datetime/cc-timezone-map.h
Normal file
|
@ -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 */
|
BIN
panels/datetime/data/bg.png
Normal file
After Width: | Height: | Size: 173 KiB |
BIN
panels/datetime/data/cc.png
Normal file
After Width: | Height: | Size: 53 KiB |
BIN
panels/datetime/data/timezone_-1.png
Normal file
After Width: | Height: | Size: 7.8 KiB |
BIN
panels/datetime/data/timezone_-10.png
Normal file
After Width: | Height: | Size: 7.6 KiB |
BIN
panels/datetime/data/timezone_-11.png
Normal file
After Width: | Height: | Size: 7.2 KiB |
BIN
panels/datetime/data/timezone_-2.png
Normal file
After Width: | Height: | Size: 4.2 KiB |
BIN
panels/datetime/data/timezone_-3.5.png
Normal file
After Width: | Height: | Size: 740 B |
BIN
panels/datetime/data/timezone_-3.png
Normal file
After Width: | Height: | Size: 13 KiB |
BIN
panels/datetime/data/timezone_-4.5.png
Normal file
After Width: | Height: | Size: 1.9 KiB |
BIN
panels/datetime/data/timezone_-4.png
Normal file
After Width: | Height: | Size: 15 KiB |
BIN
panels/datetime/data/timezone_-5.5.png
Normal file
After Width: | Height: | Size: 437 B |
BIN
panels/datetime/data/timezone_-5.png
Normal file
After Width: | Height: | Size: 19 KiB |
BIN
panels/datetime/data/timezone_-6.png
Normal file
After Width: | Height: | Size: 13 KiB |
BIN
panels/datetime/data/timezone_-7.png
Normal file
After Width: | Height: | Size: 12 KiB |
BIN
panels/datetime/data/timezone_-8.png
Normal file
After Width: | Height: | Size: 6.6 KiB |
BIN
panels/datetime/data/timezone_-9.5.png
Normal file
After Width: | Height: | Size: 437 B |
BIN
panels/datetime/data/timezone_-9.png
Normal file
After Width: | Height: | Size: 7.7 KiB |
BIN
panels/datetime/data/timezone_0.png
Normal file
After Width: | Height: | Size: 11 KiB |
BIN
panels/datetime/data/timezone_1.png
Normal file
After Width: | Height: | Size: 15 KiB |
BIN
panels/datetime/data/timezone_10.5.png
Normal file
After Width: | Height: | Size: 421 B |
BIN
panels/datetime/data/timezone_10.png
Normal file
After Width: | Height: | Size: 12 KiB |
BIN
panels/datetime/data/timezone_11.5.png
Normal file
After Width: | Height: | Size: 446 B |
BIN
panels/datetime/data/timezone_11.png
Normal file
After Width: | Height: | Size: 12 KiB |
BIN
panels/datetime/data/timezone_12.75.png
Normal file
After Width: | Height: | Size: 409 B |
BIN
panels/datetime/data/timezone_12.png
Normal file
After Width: | Height: | Size: 7 KiB |
BIN
panels/datetime/data/timezone_13.png
Normal file
After Width: | Height: | Size: 621 B |
BIN
panels/datetime/data/timezone_2.png
Normal file
After Width: | Height: | Size: 13 KiB |
BIN
panels/datetime/data/timezone_3.5.png
Normal file
After Width: | Height: | Size: 2.1 KiB |
BIN
panels/datetime/data/timezone_3.png
Normal file
After Width: | Height: | Size: 17 KiB |
BIN
panels/datetime/data/timezone_4.5.png
Normal file
After Width: | Height: | Size: 1.7 KiB |
BIN
panels/datetime/data/timezone_4.png
Normal file
After Width: | Height: | Size: 4.8 KiB |
BIN
panels/datetime/data/timezone_5.5.png
Normal file
After Width: | Height: | Size: 6 KiB |
BIN
panels/datetime/data/timezone_5.75.png
Normal file
After Width: | Height: | Size: 2.8 KiB |
BIN
panels/datetime/data/timezone_5.png
Normal file
After Width: | Height: | Size: 14 KiB |
BIN
panels/datetime/data/timezone_6.5.png
Normal file
After Width: | Height: | Size: 1.6 KiB |
BIN
panels/datetime/data/timezone_6.png
Normal file
After Width: | Height: | Size: 8.2 KiB |
BIN
panels/datetime/data/timezone_7.png
Normal file
After Width: | Height: | Size: 14 KiB |
BIN
panels/datetime/data/timezone_8.png
Normal file
After Width: | Height: | Size: 16 KiB |
BIN
panels/datetime/data/timezone_9.5.png
Normal file
After Width: | Height: | Size: 1.9 KiB |
BIN
panels/datetime/data/timezone_9.png
Normal file
After Width: | Height: | Size: 12 KiB |
41
panels/datetime/datetime-module.c
Normal file
|
@ -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)
|
||||
{
|
||||
}
|
11
panels/datetime/gnome-datetime-panel.desktop.in.in
Normal file
|
@ -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;
|
||||
|