Commit 6930f6c0 authored by Nick Schermer's avatar Nick Schermer
Browse files

* plugins/launcher/launcher-exec.c: Define WAIT_ANY if it's not

	  loading (and yes this might break internal plugins, but the plugin's

(Old svn revision: 25890)
parent 8899fa4e
2007-07-06 10:50 nick
* plugins/clock/*: Import code.
* NEWS: update.
* Configure.in.in: Bump GTK dependency to 2.8.0 and add cairo as
new dependency.
* po/*: Merge new strings.
2007-05-27 10:50 nick
* plugins/launcher/launcher-exec.c: Define WAIT_ANY if it's not
* plugins/launcher/launcher-exec.c: Define WAIT_ANY if it's not
available in wait.h. Reported by Daichi.
2007-05-26 12:25 nick
......@@ -19,7 +27,7 @@
* panel/panel-item-manager.c: Rewrite some code, internal plugins
now need the X-XFCE-Module-Path entry in the desktop file. A
warning is shown if they don't have it. This to avoid wrong module
loading (and yes this might break internal plugins, but the plugin's
loading (and yes this might break internal plugins, but the plugin's
desktop file needs to be fixed instead!). Also fixes bug #3279.
2007-05-24 14:00 nick
......
......@@ -4,8 +4,7 @@
(Jasper)
- Separator can have different styles: space, expanded space, line (default),
handle and old-style dotted handle. Initial patch by Landry Breuil. (Jasper)
- Make sure tooltips are set for more than 1 clock instance (bug #3109).
(Jasper)
- Complete rewrite of the clock plugin. (Nick)
- Fix area that is off-limits to other windows (_NET_WM_STRUT hints) for a
Xinerama setup with differently sized monitors (Bug #3097). (Jasper)
- Completely rewritten launcher (Bugs 2336, 2365, 1323, 2262 and 1225)
......
......@@ -90,7 +90,7 @@ dnl ************************************
dnl *** Check for standard functions ***
dnl ************************************
AC_FUNC_MMAP()
AC_CHECK_FUNCS([sigaction])
AC_CHECK_FUNCS([sigaction localtime_r])
dnl ******************************
dnl *** Check for i18n support ***
......@@ -107,11 +107,12 @@ dnl ***********************************
dnl *** Check for required packages ***
dnl ***********************************
XDT_CHECK_PACKAGE([LIBXFCE4UTIL], [libxfce4util-1.0], [4.4.0])
XDT_CHECK_PACKAGE([GTK], [gtk+-2.0], [2.6.4])
XDT_CHECK_PACKAGE([GTHREAD], [gthread-2.0], [2.6.4])
XDT_CHECK_PACKAGE([GMODULE], [gmodule-2.0], [2.6.4])
XDT_CHECK_PACKAGE([GTK], [gtk+-2.0], [2.8.0])
XDT_CHECK_PACKAGE([GTHREAD], [gthread-2.0], [2.8.0])
XDT_CHECK_PACKAGE([GMODULE], [gmodule-2.0], [2.8.0])
XDT_CHECK_PACKAGE([LIBXFCEGUI4], [libxfcegui4-1.0], [4.4.0])
XDT_CHECK_PACKAGE([LIBEXO], [exo-0.3], [0.3.1.11])
XDT_CHECK_PACKAGE([CAIRO], [cairo], [1.0.0])
dnl ***********************************
dnl *** Check for optional packages ***
......
......@@ -13,11 +13,23 @@ plugin_LTLIBRARIES = \
libclock.la
libclock_la_SOURCES = \
clock.c
clock.c \
clock.h \
clock-analog.c \
clock-analog.h \
clock-binary.c \
clock-binary.h \
clock-dialog.c \
clock-dialog.h \
clock-digital.c \
clock-digital.h \
clock-lcd.c \
clock-lcd.h
libclock_la_CFLAGS = \
$(GTK_CFLAGS) \
$(LIBXFCE4UTIL_CFLAGS) \
$(CAIRO_CFLAGS) \
$(LIBXFCEGUI4_CFLAGS) \
$(PLATFORM_CFLAGS)
......@@ -34,6 +46,7 @@ endif
libclock_la_LIBADD = \
$(top_builddir)/libxfce4panel/libxfce4panel.la \
$(GTK_LIBS) \
$(CAIRO_LIBS) \
$(LIBXFCE4UTIL_LIBS) \
$(LIBXFCEGUI4_LIBS)
......
/* $Id$ */
/*
* Copyright (c) 2007 Nick Schermer <nick@xfce.org>
*
* 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
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#ifdef HAVE_MATH_H
#include <math.h>
#endif
#ifdef HAVE_TIME_H
#include <time.h>
#endif
#include <gtk/gtk.h>
#include <cairo/cairo.h>
#include "clock.h"
#include "clock-analog.h"
#ifndef M_PI
#define M_PI 3.141592654
#endif
#define CLOCK_SCALE 0.1
#define TICKS_TO_RADIANS(x) (M_PI - (M_PI / 30.0) * (x))
#define HOURS_TO_RADIANS(x,y) (M_PI - (M_PI / 6.0) * (((x) > 12 ? (x) - 12 : (x)) + (y) / 60.0))
/* prototypes */
static void xfce_clock_analog_class_init (XfceClockAnalogClass *klass);
static void xfce_clock_analog_init (XfceClockAnalog *clock);
static void xfce_clock_analog_finalize (GObject *object);
static void xfce_clock_analog_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec);
static void xfce_clock_analog_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec);
static void xfce_clock_analog_size_request (GtkWidget *widget,
GtkRequisition *requisition);
static gboolean xfce_clock_analog_expose_event (GtkWidget *widget,
GdkEventExpose *event);
static void xfce_clock_analog_draw_ticks (cairo_t *cr,
gdouble xc,
gdouble yc,
gdouble radius);
static void xfce_clock_analog_draw_pointer (cairo_t *cr,
gdouble xc,
gdouble yc,
gdouble radius,
gdouble angle,
gdouble scale,
gboolean line);
enum
{
PROP_0,
PROP_SHOW_SECONDS
};
struct _XfceClockAnalogClass
{
GtkImageClass __parent__;
};
struct _XfceClockAnalog
{
GtkImage __parent__;
/* draw seconds */
guint show_seconds : 1;
};
static GObjectClass *xfce_clock_analog_parent_class;
GType
xfce_clock_analog_get_type (void)
{
static GType type = G_TYPE_INVALID;
if (G_UNLIKELY (type == G_TYPE_INVALID))
{
type = g_type_register_static_simple (GTK_TYPE_IMAGE,
I_("XfceClockAnalog"),
sizeof (XfceClockAnalogClass),
(GClassInitFunc) xfce_clock_analog_class_init,
sizeof (XfceClockAnalog),
(GInstanceInitFunc) xfce_clock_analog_init,
0);
}
return type;
}
static void
xfce_clock_analog_class_init (XfceClockAnalogClass *klass)
{
GObjectClass *gobject_class;
GtkWidgetClass *gtkwidget_class;
xfce_clock_analog_parent_class = g_type_class_peek_parent (klass);
gobject_class = G_OBJECT_CLASS (klass);
gobject_class->finalize = xfce_clock_analog_finalize;
gobject_class->set_property = xfce_clock_analog_set_property;
gobject_class->get_property = xfce_clock_analog_get_property;
gtkwidget_class = GTK_WIDGET_CLASS (klass);
gtkwidget_class->size_request = xfce_clock_analog_size_request;
gtkwidget_class->expose_event = xfce_clock_analog_expose_event;
/**
* Whether we display seconds
**/
g_object_class_install_property (gobject_class,
PROP_SHOW_SECONDS,
g_param_spec_boolean ("show-seconds", "show-seconds", "show-seconds",
FALSE, PANEL_PARAM_READWRITE));
}
static void
xfce_clock_analog_init (XfceClockAnalog *clock)
{
/* init */
clock->show_seconds = FALSE;
}
static void
xfce_clock_analog_finalize (GObject *object)
{
(*G_OBJECT_CLASS (xfce_clock_analog_parent_class)->finalize) (object);
}
static void
xfce_clock_analog_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
XfceClockAnalog *clock = XFCE_CLOCK_ANALOG (object);
switch (prop_id)
{
case PROP_SHOW_SECONDS:
clock->show_seconds = g_value_get_boolean (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
xfce_clock_analog_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
XfceClockAnalog *clock = XFCE_CLOCK_ANALOG (object);
switch (prop_id)
{
case PROP_SHOW_SECONDS:
g_value_set_boolean (value, clock->show_seconds);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
xfce_clock_analog_size_request (GtkWidget *widget,
GtkRequisition *requisition)
{
gint width, height;
/* get the current widget size */
gtk_widget_get_size_request (widget, &width, &height);
/* square the widget */
requisition->width = requisition->height = MAX (width, height);
}
static gboolean
xfce_clock_analog_expose_event (GtkWidget *widget,
GdkEventExpose *event)
{
XfceClockAnalog *clock = XFCE_CLOCK_ANALOG (widget);
gdouble xc, yc;
gdouble angle, radius;
cairo_t *cr;
time_t now = time (0);
struct tm tm;
g_return_val_if_fail (XFCE_CLOCK_IS_ANALOG (clock), FALSE);
/* get center of the widget and the radius */
xc = (widget->allocation.width / 2.0);
yc = (widget->allocation.height / 2.0);
radius = MIN (xc, yc);
/* add the window offset */
xc += widget->allocation.x;
yc += widget->allocation.y;
/* get the cairo context */
cr = gdk_cairo_create (widget->window);
if (G_LIKELY (cr != NULL))
{
/* get the local time */
localtime_r (&now, &tm);
/* set the line properties */
cairo_set_line_width (cr, 1);
gdk_cairo_set_source_color (cr, &widget->style->fg[GTK_STATE_NORMAL]);
/* draw the ticks */
xfce_clock_analog_draw_ticks (cr, xc, yc, radius);
if (clock->show_seconds)
{
/* second pointer */
angle = TICKS_TO_RADIANS (tm.tm_sec);
xfce_clock_analog_draw_pointer (cr, xc, yc, radius, angle, 0.7, TRUE);
}
/* minute pointer */
angle = TICKS_TO_RADIANS (tm.tm_min);
xfce_clock_analog_draw_pointer (cr, xc, yc, radius, angle, 0.8, FALSE);
/* hour pointer */
angle = HOURS_TO_RADIANS (tm.tm_hour, tm.tm_min);
xfce_clock_analog_draw_pointer (cr, xc, yc, radius, angle, 0.5, FALSE);
/* cleanup */
cairo_destroy (cr);
}
return FALSE;
}
static void
xfce_clock_analog_draw_ticks (cairo_t *cr,
gdouble xc,
gdouble yc,
gdouble radius)
{
gint i;
gdouble x, y, angle;
for (i = 0; i < 12; i++)
{
/* calculate */
angle = HOURS_TO_RADIANS (i, 0);
x = xc + sin (angle) * (radius * (1.0 - CLOCK_SCALE));
y = yc + cos (angle) * (radius * (1.0 - CLOCK_SCALE));
/* draw arc */
cairo_move_to (cr, x, y);
cairo_arc (cr, x, y, radius * CLOCK_SCALE, 0, 2 * M_PI);
cairo_close_path (cr);
}
/* fill the arcs */
cairo_fill (cr);
}
static void
xfce_clock_analog_draw_pointer (cairo_t *cr,
gdouble xc,
gdouble yc,
gdouble radius,
gdouble angle,
gdouble scale,
gboolean line)
{
gdouble xs, ys;
gdouble xt, yt;
/* calculate tip position */
xt = xc + sin (angle) * radius * scale;
yt = yc + cos (angle) * radius * scale;
if (line)
{
/* draw the line */
cairo_move_to (cr, xc, yc);
cairo_line_to (cr, xt, yt);
/* draw the line */
cairo_stroke (cr);
}
else
{
/* calculate start position */
xs = xc + sin (angle - 0.5 * M_PI) * radius * CLOCK_SCALE;
ys = yc + cos (angle - 0.5 * M_PI) * radius * CLOCK_SCALE;
/* draw the pointer */
cairo_move_to (cr, xs, ys);
cairo_arc (cr, xc, yc, radius * CLOCK_SCALE, -angle + M_PI, -angle);
cairo_line_to (cr, xt, yt);
cairo_close_path (cr);
/* fill the pointer */
cairo_fill (cr);
}
}
GtkWidget *
xfce_clock_analog_new (void)
{
return g_object_new (XFCE_CLOCK_TYPE_ANALOG, NULL);
}
gboolean
xfce_clock_analog_update (gpointer user_data)
{
GtkWidget *widget = GTK_WIDGET (user_data);
/* update if the widget if visible */
if (G_LIKELY (GTK_WIDGET_VISIBLE (widget)))
gtk_widget_queue_draw (widget);
return TRUE;
}
/* $Id$ */
/*
* Copyright (c) 2007 Nick Schermer <nick@xfce.org>
*
* 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
*/
#ifndef __CLOCK_ANALOG_H__
#define __CLOCK_ANALOG_H__
G_BEGIN_DECLS
typedef struct _XfceClockAnalogClass XfceClockAnalogClass;
typedef struct _XfceClockAnalog XfceClockAnalog;
#define XFCE_CLOCK_TYPE_ANALOG (xfce_clock_analog_get_type ())
#define XFCE_CLOCK_ANALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XFCE_CLOCK_TYPE_ANALOG, XfceClockAnalog))
#define XFCE_CLOCK_ANALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), XFCE_CLOCK_TYPE_ANALOG, XfceClockAnalogClass))
#define XFCE_CLOCK_IS_ANALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), XFCE_CLOCK_TYPE_ANALOG))
#define XFCE_CLOCK_IS_ANALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), XFCE_CLOCK_TYPE_ANALOG))
#define XFCE_CLOCK_ANALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), XFCE_CLOCK_TYPE_ANALOG, XfceClockAnalogClass))
GType xfce_clock_analog_get_type (void) G_GNUC_CONST G_GNUC_INTERNAL;
GtkWidget *xfce_clock_analog_new (void) G_GNUC_MALLOC G_GNUC_INTERNAL;
gboolean xfce_clock_analog_update (gpointer user_data) G_GNUC_INTERNAL;
G_END_DECLS
#endif /* !__CLOCK_ANALOG_H__ */
/* $Id$ */
/*
* Copyright (c) 2007 Nick Schermer <nick@xfce.org>
*
* 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
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#ifdef HAVE_TIME_H
#include <time.h>
#endif
#ifdef HAVE_MATH_H
#include <math.h>
#endif
#ifndef M_PI
#define M_PI 3.141592654
#endif
#include <gtk/gtk.h>
#include <cairo/cairo.h>
#include "clock.h"
#include "clock-binary.h"
/* class functions */
static void xfce_clock_binary_class_init (XfceClockBinaryClass *klass);
static void xfce_clock_binary_init (XfceClockBinary *clock);
static void xfce_clock_binary_finalize (GObject *object);
static void xfce_clock_binary_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec);
static void xfce_clock_binary_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec);
static void xfce_clock_binary_size_request (GtkWidget *widget,
GtkRequisition *requisition);
static gboolean xfce_clock_binary_expose_event (GtkWidget *widget,
GdkEventExpose *event);
enum
{
PROP_0,
PROP_SHOW_SECONDS,
PROP_TRUE_BINARY
};
struct _XfceClockBinaryClass
{
GtkImageClass __parent__;
};
struct _XfceClockBinary
{
GtkImage __parent__;
/* whether we draw seconds */
guint show_seconds : 1;
/* if this is a true binary clock */
guint true_binary : 1;
};
static GObjectClass *xfce_clock_binary_parent_class;
GType
xfce_clock_binary_get_type (void)
{
static GType type = G_TYPE_INVALID;