#define CALENDAR_MONTH_Y_POSITION_RATIO 0.40
#define CALENDAR_DAYOFMONTH_Y_POSITION_RATIO 0.92
-struct hvclock_gtk_t {
- GtkDrawingArea parent;
-};
-
-struct hvclock_gtk_class_t {
- GtkDrawingAreaClass parent_class;
-};
-
-typedef struct hvclock_gtk_t HvClock;
-typedef struct hvclock_gtk_class_t HvClockClass;
-
-#define HVCLOCK(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), hvclock_get_type(), \
- HvClock))
-
-G_DEFINE_TYPE(HvClock, hvclock, GTK_TYPE_DRAWING_AREA);
-
/* Starting mode is clock mode */
static int hvclock_mode = CLOCK_MODE;
get_clock_face_radius(GtkWidget *clock)
{
/* Compute clock face radius */
- return (MIN(clock->allocation.width, clock->allocation.height) / 2) - 1;
+ return (MIN(clock->allocation.width, clock->allocation.height) / 2) - 3;
}
static struct tm *
}
static void
-hvclock_redraw_canvas(HvClock *clock)
+hvclock_redraw_canvas(GtkWidget *widget)
{
- GtkWidget *widget;
GdkRegion *region;
- widget = GTK_WIDGET(clock);
-
if (!widget->window)
return;
}
/* Update clock/calendar... */
- hvclock_redraw_canvas(HVCLOCK(clock));
+ hvclock_redraw_canvas(clock);
return FALSE;
}
-static void
-hvclock_class_init(struct hvclock_gtk_class_t *class)
-{
- GObjectClass *obj_class;
- GtkWidgetClass *widget_class;
-
- obj_class = G_OBJECT_CLASS(class);
- widget_class = GTK_WIDGET_CLASS(class);
-
- /* GtkWidget signals */
- widget_class->expose_event = hvclock_expose;
- widget_class->button_release_event = hvclock_button_release;
-}
-
static gboolean
hvclock_update(gpointer data)
{
- HvClock *clock;
-
- clock = HVCLOCK(data);
+ GtkWidget *clock = GTK_WIDGET(data);
hvclock_redraw_canvas(clock);
return TRUE; /* keep running this event */
}
-static void
-hvclock_init(HvClock *clock)
+void
+hvclock_init(GtkWidget *dockwin, GtkWidget *iconwin)
{
- gtk_widget_add_events(GTK_WIDGET(clock), GDK_BUTTON_PRESS_MASK |
+ gtk_widget_add_events(dockwin, GDK_BUTTON_PRESS_MASK |
GDK_BUTTON_RELEASE_MASK |
GDK_POINTER_MOTION_MASK);
+ gtk_widget_add_events(iconwin, GDK_BUTTON_PRESS_MASK |
+ GDK_BUTTON_RELEASE_MASK |
+ GDK_POINTER_MOTION_MASK);
+
+ g_signal_connect(G_OBJECT(dockwin), "expose-event",
+ G_CALLBACK(hvclock_expose), NULL);
+ g_signal_connect(G_OBJECT(iconwin), "expose-event",
+ G_CALLBACK(hvclock_expose), NULL);
- hvclock_update(clock);
+ g_signal_connect(G_OBJECT(dockwin), "button-press-event",
+ G_CALLBACK(hvclock_button_release), NULL);
+ g_signal_connect(G_OBJECT(iconwin), "button-press-event",
+ G_CALLBACK(hvclock_button_release), NULL);
+ g_signal_connect(G_OBJECT(dockwin), "button-release-event",
+ G_CALLBACK(hvclock_button_release), NULL);
+ g_signal_connect(G_OBJECT(iconwin), "button-release-event",
+ G_CALLBACK(hvclock_button_release), NULL);
/* update the clock once a second */
- g_timeout_add(1000, hvclock_update, clock);
-}
+ g_timeout_add(1000, hvclock_update, iconwin);
-GtkWidget *
-hvclock_widget_new(void)
-{
- return g_object_new(hvclock_get_type(), NULL);
+ hvclock_redraw_canvas(iconwin);
}
dockwin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_default_size(GTK_WINDOW(dockwin), ICON_SIZE, ICON_SIZE);
- iconwin = hvclock_widget_new();
- gtk_container_add(GTK_CONTAINER(dockwin), iconwin);
- gtk_container_set_border_width(GTK_CONTAINER(dockwin), BWIDTH);
+ iconwin = gtk_window_new(GTK_WINDOW_POPUP);
g_signal_connect(dockwin, "destroy", G_CALLBACK(gtk_main_quit), NULL);
+ gtk_widget_realize(dockwin);
+ gtk_widget_realize(iconwin);
+
+ hvclock_init(dockwin, iconwin);
+
gtk_widget_show_all(dockwin);
if (hvclock_infos.dockapp_mode == true) {