Commit b20af7b1 authored by Christian Persch's avatar Christian Persch
Browse files

Initial port to gtk3

It Compiles!
It shows some problems at runtime.

This commit also contains the patches from Benjamin Otte from bug #627455.
parent 4641d42f
......@@ -9,7 +9,8 @@ SUBDIRS = \
po
if HAVE_BONOBO
SUBDIRS += bonobo
# FIXMEchpe port this
#SUBDIRS += bonobo
endif
ACLOCAL_AMFLAGS = -I m4
......
SUBDIRS = \
clock \
fish \
notification_area \
wncklet
#SUBDIRS += fish
-include $(top_srcdir)/git.mk
......@@ -59,7 +59,7 @@ CLOCK_CPPFLAGS = \
-DGWEATHER_I_KNOW_THIS_IS_UNSTABLE
CLOCK_LDADD = \
../../libpanel-applet/libpanel-applet-3.la \
../../libpanel-applet/libpanel-applet-4.la \
$(CLOCK_LIBS) \
$(LIBPANEL_APPLET_LIBS) \
libsystem-timezone.la \
......
......@@ -1808,7 +1808,7 @@ calendar_window_set_property (GObject *object,
}
static void
calendar_window_destroy (GtkObject *object)
calendar_window_dispose (GObject *object)
{
#ifdef HAVE_LIBECAL
CalendarWindow *calwin;
......@@ -1848,20 +1848,18 @@ calendar_window_destroy (GtkObject *object)
calwin->priv->gconfclient = NULL;
#endif /* HAVE_LIBECAL */
GTK_OBJECT_CLASS (calendar_window_parent_class)->destroy (object);
G_OBJECT_CLASS (calendar_window_parent_class)->dispose (object);
}
static void
calendar_window_class_init (CalendarWindowClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
GtkObjectClass *gtkobject_class = GTK_OBJECT_CLASS (klass);
gobject_class->constructor = calendar_window_constructor;
gobject_class->get_property = calendar_window_get_property;
gobject_class->set_property = calendar_window_set_property;
gtkobject_class->destroy = calendar_window_destroy;
gobject_class->dispose = calendar_window_dispose;
g_type_class_add_private (klass, sizeof (CalendarWindowPrivate));
......
......@@ -22,12 +22,10 @@
static GHashTable *pixbuf_cache = NULL;
#define CLOCK_FACE_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), INTL_TYPE_CLOCK_FACE, ClockFacePrivate))
G_DEFINE_TYPE (ClockFace, clock_face, GTK_TYPE_WIDGET)
static void clock_face_finalize (GObject *);
static gboolean clock_face_expose (GtkWidget *clock, GdkEventExpose *event);
static gboolean clock_face_draw (GtkWidget *clock, cairo_t *cr);
static void clock_face_size_request (GtkWidget *clock,
GtkRequisition *requisition);
static void clock_face_size_allocate (GtkWidget *clock,
......@@ -38,8 +36,6 @@ static void update_time_and_face (ClockFace *this,
static void clock_face_load_face (ClockFace *this,
gint width, gint height);
typedef struct _ClockFacePrivate ClockFacePrivate;
typedef enum {
CLOCK_FACE_MORNING,
CLOCK_FACE_DAY,
......@@ -70,7 +66,7 @@ clock_face_class_init (ClockFaceClass *class)
widget_class = GTK_WIDGET_CLASS (class);
/* GtkWidget signals */
widget_class->expose_event = clock_face_expose;
widget_class->draw = clock_face_draw;
widget_class->size_request = clock_face_size_request;
widget_class->size_allocate = clock_face_size_allocate;
......@@ -83,7 +79,9 @@ clock_face_class_init (ClockFaceClass *class)
static void
clock_face_init (ClockFace *this)
{
ClockFacePrivate *priv = CLOCK_FACE_GET_PRIVATE (this);
ClockFacePrivate *priv;
priv = this->priv = G_TYPE_INSTANCE_GET_PRIVATE (this, INTL_TYPE_CLOCK_FACE, ClockFacePrivate);
priv->size = CLOCK_FACE_SMALL;
priv->timeofday = CLOCK_FACE_INVALID;
......@@ -93,19 +91,19 @@ clock_face_init (ClockFace *this)
gtk_widget_set_has_window (GTK_WIDGET (this), FALSE);
}
static void
draw (GtkWidget *this, cairo_t *cr)
static gboolean
clock_face_draw (GtkWidget *this, cairo_t *cr)
{
ClockFacePrivate *priv;
GtkAllocation allocation;
ClockFacePrivate *priv = CLOCK_FACE (this)->priv;
int width, height;
double x, y;
double radius;
int hours, minutes, seconds;
/* Hand lengths as a multiple of the clock radius */
double hour_length, min_length, sec_length;
priv = CLOCK_FACE_GET_PRIVATE (this);
if (GTK_WIDGET_CLASS (clock_face_parent_class)->draw)
GTK_WIDGET_CLASS (clock_face_parent_class)->draw (this, cr);
if (priv->size == CLOCK_FACE_LARGE) {
hour_length = 0.45;
......@@ -117,31 +115,21 @@ draw (GtkWidget *this, cairo_t *cr)
sec_length = 0.8; /* not drawn currently */
}
gtk_widget_get_allocation (this, &allocation);
x = allocation.x + allocation.width / 2;
y = allocation.y + allocation.height / 2;
radius = MIN (allocation.width / 2,
allocation.height / 2) - 5;
width = gtk_widget_get_allocated_width (this);
height = gtk_widget_get_allocated_width (this);
cairo_save (cr);
cairo_translate (cr, allocation.x, allocation.y);
x = width / 2;
y = height / 2;
radius = MIN (width / 2, height / 2) - 5;
/* clock back */
if (priv->face_pixbuf) {
GdkWindow *window = gtk_widget_get_window (this);
gdk_draw_pixbuf (GDK_DRAWABLE (window),
NULL,
priv->face_pixbuf,
0, 0,
allocation.x,
allocation.y,
allocation.width,
allocation.height,
GDK_RGB_DITHER_NONE, 0, 0);
}
cairo_save (cr);
cairo_restore (cr);
gdk_cairo_set_source_pixbuf (cr, priv->face_pixbuf, 0, 0);
cairo_paint (cr);
cairo_restore (cr);
}
/* clock hands */
hours = priv->time.tm_hour;
......@@ -182,24 +170,6 @@ draw (GtkWidget *this, cairo_t *cr)
cairo_stroke (cr);
cairo_restore (cr);
}
}
static gboolean
clock_face_expose (GtkWidget *this, GdkEventExpose *event)
{
cairo_t *cr;
/* get a cairo_t */
cr = gdk_cairo_create (gtk_widget_get_window (this));
cairo_rectangle (cr,
event->area.x, event->area.y,
event->area.width, event->area.height);
cairo_clip (cr);
draw (this, cr);
cairo_destroy (cr);
return FALSE;
}
......@@ -214,7 +184,7 @@ static void
clock_face_size_request (GtkWidget *this,
GtkRequisition *requisition)
{
ClockFacePrivate *priv = CLOCK_FACE_GET_PRIVATE (this);
ClockFacePrivate *priv = CLOCK_FACE (this)->priv;
if (priv->size_widget != NULL) {
GtkRequisition req;
......@@ -278,7 +248,7 @@ update_time_and_face (ClockFace *this,
ClockFacePrivate *priv;
ClockFaceTimeOfDay timeofday;
priv = CLOCK_FACE_GET_PRIVATE (this);
priv = this->priv;
/* update the time */
if (priv->location) {
......@@ -339,7 +309,7 @@ GtkWidget *
clock_face_new (ClockFaceSize size)
{
GObject *obj = g_object_new (INTL_TYPE_CLOCK_FACE, NULL);
ClockFacePrivate *priv = CLOCK_FACE_GET_PRIVATE (obj);
ClockFacePrivate *priv = CLOCK_FACE (obj)->priv;
priv->size = size;
......@@ -352,7 +322,7 @@ clock_face_new_with_location (ClockFaceSize size,
GtkWidget *size_widget)
{
GObject *obj = g_object_new (INTL_TYPE_CLOCK_FACE, NULL);
ClockFacePrivate *priv = CLOCK_FACE_GET_PRIVATE (obj);
ClockFacePrivate *priv = CLOCK_FACE (obj)->priv;
priv->size = size;
priv->location = g_object_ref (loc);
......@@ -364,7 +334,8 @@ clock_face_new_with_location (ClockFaceSize size,
static void
clock_face_finalize (GObject *obj)
{
ClockFacePrivate *priv = CLOCK_FACE_GET_PRIVATE (obj);
ClockFace *face = CLOCK_FACE (obj);
ClockFacePrivate *priv = face->priv;
if (priv->location) {
g_object_unref (priv->location);
......@@ -400,7 +371,7 @@ remove_pixbuf_from_cache (const char *key,
static void
clock_face_load_face (ClockFace *this, gint width, gint height)
{
ClockFacePrivate *priv = CLOCK_FACE_GET_PRIVATE (this);
ClockFacePrivate *priv = this->priv;
const gchar *size_string[2] = { "small", "large" };
const gchar *daytime_string[4] = { "morning", "day", "evening", "night" };
gchar *cache_name;
......
......@@ -27,6 +27,7 @@ G_BEGIN_DECLS
#define CLOCK_FACE_GET_CLASS (G_TYPE_INSTANCE_GET_CLASS ((obj), INTL_TYPE_CLOCK_FACE, ClockFaceClass))
typedef struct _ClockFace ClockFace;
typedef struct _ClockFacePrivate ClockFacePrivate;
typedef struct _ClockFaceClass ClockFaceClass;
struct _ClockFace
......@@ -34,6 +35,7 @@ struct _ClockFace
GtkWidget parent;
/* < private > */
ClockFacePrivate *priv;
};
struct _ClockFaceClass
......
......@@ -707,6 +707,7 @@ rad2dms (gfloat lat, gfloat lon)
static GList *locations = NULL;
#ifdef HAVE_NETWORK_MANAGER
static void
update_weather_infos (void)
{
......@@ -721,7 +722,6 @@ update_weather_infos (void)
}
}
#ifdef HAVE_NETWORK_MANAGER
static void
state_notify (DBusPendingCall *pending, gpointer data)
{
......
......@@ -60,8 +60,8 @@ static void clock_map_size_request (GtkWidget *this,
GtkRequisition *requisition);
static void clock_map_size_allocate (GtkWidget *this,
GtkAllocation *allocation);
static gboolean clock_map_expose (GtkWidget *this,
GdkEventExpose *expose);
static gboolean clock_map_draw (GtkWidget *this,
cairo_t *cr);
static void clock_map_place_locations (ClockMap *this);
static void clock_map_render_shadow (ClockMap *this);
......@@ -90,7 +90,7 @@ clock_map_class_init (ClockMapClass *this_class)
/* GtkWidget signals */
widget_class->size_request = clock_map_size_request;
widget_class->size_allocate = clock_map_size_allocate;
widget_class->expose_event = clock_map_expose;
widget_class->draw = clock_map_draw;
g_type_class_add_private (this_class, sizeof (ClockMapPrivate));
......@@ -217,62 +217,33 @@ clock_map_refresh (ClockMap *this)
}
static gboolean
clock_map_expose (GtkWidget *this, GdkEventExpose *event)
clock_map_draw (GtkWidget *this, cairo_t *cr)
{
ClockMapPrivate *priv = PRIVATE (this);
GdkWindow *window;
GtkStyle *style;
GtkAllocation allocation;
GdkRectangle region;
cairo_t *cr;
int width, height;
window = gtk_widget_get_window (this);
style = gtk_widget_get_style (this);
gtk_widget_get_allocation (this, &allocation);
width = gdk_pixbuf_get_width (priv->shadow_map_pixbuf);
height = gdk_pixbuf_get_height (priv->shadow_map_pixbuf);
// FIXMEchpe fix this!
if (!priv->shadow_map_pixbuf) {
g_warning ("Needed to refresh the map in expose event.");
g_warning ("Needed to refresh the map in draw event.");
clock_map_refresh (CLOCK_MAP (this));
}
cr = gdk_cairo_create (window);
region.x = allocation.x;
region.y = allocation.y;
region.width = gdk_pixbuf_get_width (priv->shadow_map_pixbuf);
region.height = gdk_pixbuf_get_height (priv->shadow_map_pixbuf);
gdk_rectangle_intersect (&region, &(event->area), &region);
gdk_draw_pixbuf (window,
style->black_gc,
priv->shadow_map_pixbuf,
region.x - allocation.x,
region.y - allocation.y,
region.x,
region.y,
region.width,
region.height,
GDK_RGB_DITHER_NORMAL,
0, 0);
gdk_cairo_set_source_pixbuf (cr, priv->shadow_map_pixbuf, 0, 0);
cairo_rectangle (cr, 0, 0, width, height);
cairo_paint (cr);
/* draw a simple outline */
cairo_rectangle (
cr,
allocation.x + 0.5, allocation.y + 0.5,
gdk_pixbuf_get_width (priv->shadow_map_pixbuf) - 1,
gdk_pixbuf_get_height (priv->shadow_map_pixbuf) - 1);
cairo_set_source_rgb (
cr,
style->mid [GTK_STATE_ACTIVE].red / 65535.0,
style->mid [GTK_STATE_ACTIVE].green / 65535.0,
style->mid [GTK_STATE_ACTIVE].blue / 65535.0);
cairo_rectangle (cr, 0.5, 0.5, width - 1, height - 1);
gdk_cairo_set_source_color (cr, &style->mid [GTK_STATE_ACTIVE]);
cairo_set_line_width (cr, 1.0);
cairo_stroke (cr);
cairo_destroy (cr);
return FALSE;
}
......
......@@ -804,7 +804,7 @@ close_on_escape (GtkWidget *widget,
GdkEventKey *event,
GtkToggleButton *toggle_button)
{
if (event->keyval == GDK_Escape) {
if (event->keyval == GDK_KEY_Escape) {
gtk_toggle_button_set_active (toggle_button, FALSE);
return TRUE;
}
......@@ -3385,6 +3385,7 @@ fill_prefs_window (ClockData *cd)
GtkCellRenderer *renderer;
GtkTreeViewColumn *col;
GtkListStore *store;
GtkTreeIter iter;
int i;
/* Set the 12 hour / 24 hour widget */
......@@ -3451,8 +3452,9 @@ fill_prefs_window (ClockData *cd)
gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (widget), renderer, "text", 0, NULL);
for (i = 0; temperatures[i] != -1; i++)
gtk_combo_box_append_text (GTK_COMBO_BOX (widget),
gweather_prefs_get_temp_display_name (temperatures[i]));
gtk_list_store_insert_with_values (store, &iter, -1,
0, gweather_prefs_get_temp_display_name (temperatures[i]),
-1);
update_temperature_combo (cd);
g_signal_connect (widget, "changed",
......@@ -3467,8 +3469,9 @@ fill_prefs_window (ClockData *cd)
gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (widget), renderer, "text", 0, NULL);
for (i = 0; speeds[i] != -1; i++)
gtk_combo_box_append_text (GTK_COMBO_BOX (widget),
gweather_prefs_get_speed_display_name (speeds[i]));
gtk_list_store_insert_with_values (store, &iter, -1,
0, gweather_prefs_get_speed_display_name (speeds[i]),
-1);
update_speed_combo (cd);
g_signal_connect (widget, "changed",
......
......@@ -1578,6 +1578,7 @@ fish_applet_expose_event (GtkWidget *widget,
GtkStateType state;
int width, height;
int src_x, src_y;
cairo_t *cr;
g_return_val_if_fail (fish->pixmap != NULL, FALSE);
......@@ -1589,25 +1590,27 @@ fish_applet_expose_event (GtkWidget *widget,
gdk_drawable_get_size (fish->pixmap, &width, &height);
src_x = event->area.x;
src_y = event->area.y;
src_x = 0;
src_y = 0;
if (fish->rotate) {
if (fish->orientation == PANEL_APPLET_ORIENT_RIGHT)
src_y += ((height * (fish->n_frames - 1 - fish->current_frame)) / fish->n_frames);
src_y = ((height * (fish->n_frames - 1 - fish->current_frame)) / fish->n_frames);
else if (fish->orientation == PANEL_APPLET_ORIENT_LEFT)
src_y += ((height * fish->current_frame) / fish->n_frames);
src_y = ((height * fish->current_frame) / fish->n_frames);
else
src_x += ((width * fish->current_frame) / fish->n_frames);
src_x = ((width * fish->current_frame) / fish->n_frames);
} else
src_x += ((width * fish->current_frame) / fish->n_frames);
gdk_draw_drawable (window,
style->fg_gc [state],
fish->pixmap,
src_x, src_y,
event->area.x, event->area.y,
event->area.width, event->area.height);
src_x = ((width * fish->current_frame) / fish->n_frames);
cr = gdk_cairo_create (event->window);
gdk_cairo_region (cr, event->region);
cairo_clip (cr);
gdk_cairo_set_source_pixmap (cr, fish->pixmap, -src_x, -src_y);
cairo_paint (cr);
cairo_destroy (cr);
return FALSE;
}
......
......@@ -29,7 +29,7 @@ libtray_la_SOURCES = \
NOTIFICATION_AREA_SOURCES = main.c
NOTIFICATION_AREA_LDADD = \
../../libpanel-applet/libpanel-applet-3.la \
../../libpanel-applet/libpanel-applet-4.la \
$(X_LIBS) \
$(NOTIFICATION_AREA_LIBS) \
$(LIBPANEL_APPLET_LIBS) \
......
......@@ -52,17 +52,18 @@ button_press_handler (GtkWidget *fixedtip,
}
static gboolean
expose_handler (GtkWidget *fixedtip)
na_fixed_tip_draw (GtkWidget *widget, cairo_t *cr)
{
GtkRequisition req;
int width, height;
gtk_widget_size_request (fixedtip, &req);
width = gtk_widget_get_allocated_width (widget);
height = gtk_widget_get_allocated_height (widget);
gtk_paint_flat_box (gtk_widget_get_style (fixedtip),
gtk_widget_get_window (fixedtip),
gtk_paint_flat_box (gtk_widget_get_style (widget),
cr,
GTK_STATE_NORMAL, GTK_SHADOW_OUT,
NULL, fixedtip, "tooltip",
0, 0, req.width, req.height);
widget, "tooltip",
0, 0, width, height);
return FALSE;
}
......@@ -70,6 +71,10 @@ expose_handler (GtkWidget *fixedtip)
static void
na_fixed_tip_class_init (NaFixedTipClass *class)
{
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
widget_class->draw = na_fixed_tip_draw;
fixedtip_signals[CLICKED] =
g_signal_new ("clicked",
G_OBJECT_CLASS_TYPE (class),
......@@ -106,11 +111,8 @@ na_fixed_tip_init (NaFixedTip *fixedtip)
gtk_container_add (GTK_CONTAINER (fixedtip), label);
fixedtip->priv->label = label;
g_signal_connect (fixedtip, "expose_event",
G_CALLBACK (expose_handler), NULL);
gtk_widget_add_events (GTK_WIDGET (fixedtip), GDK_BUTTON_PRESS_MASK);
g_signal_connect (fixedtip, "button_press_event",
G_CALLBACK (button_press_handler), NULL);
......@@ -138,8 +140,8 @@ na_fixed_tip_position (NaFixedTip *fixedtip)
gtk_widget_size_request (GTK_WIDGET (fixedtip), &req);
gdk_window_get_origin (parent_window, &root_x, &root_y);
gdk_drawable_get_size (GDK_DRAWABLE (parent_window),
&parent_width, &parent_height);
parent_width = gdk_window_get_width (parent_window);
parent_height = gdk_window_get_height (parent_window);
screen_width = gdk_screen_get_width (screen);
screen_height = gdk_screen_get_height (screen);
......
......@@ -177,11 +177,9 @@ static const GtkActionEntry menu_actions [] = {
};
static void
applet_change_background (PanelApplet *applet,
PanelAppletBackgroundType type,
GdkColor *color,
GdkPixmap *pixmap,
AppletData *data)
applet_change_background (PanelApplet *applet,
cairo_pattern_t *pattern,
AppletData *data)
{
na_tray_force_redraw (data->tray);
}
......
......@@ -60,11 +60,12 @@ na_tray_child_realize (GtkWidget *widget)
child->parent_relative_bg = FALSE;
}
else if (visual == gdk_drawable_get_visual (GDK_DRAWABLE (gdk_window_get_parent (window))))
else if (visual == gdk_window_get_visual (gdk_window_get_parent (window)))
{
/* Otherwise, if the visual matches the visual of the parent window, we
* can use a parent-relative background and fake transparency. */
gdk_window_set_back_pixmap (window, NULL, TRUE);
// FIXMEchpe
gdk_window_set_background_pattern (window, NULL);
child->parent_relative_bg = TRUE;
}
......@@ -176,28 +177,27 @@ na_tray_child_size_allocate (GtkWidget *widget,
* expose handler draws with real or fake transparency.
*/
static gboolean
na_tray_child_expose_event (GtkWidget *widget,
GdkEventExpose *event)
na_tray_child_draw (GtkWidget *widget,
cairo_t *cr)
{
NaTrayChild *child = NA_TRAY_CHILD (widget);
GdkWindow *window = gtk_widget_get_window (widget);
if (na_tray_child_has_alpha (child))
{
/* Clear to transparent */
cairo_t *cr = gdk_cairo_create (window);
cairo_set_source_rgba (cr, 0, 0, 0, 0);
cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
gdk_cairo_region (cr, event->region);
cairo_fill (cr);
cairo_destroy (cr);
}
else if (child->parent_relative_bg)
{
/* Clear to parent-relative pixmap */
// FIXMEchpe
#if 0
gdk_window_clear_area (window,
event->area.x, event->area.y,
event->area.width, event->area.height);
#endif
}
return FALSE;
......@@ -221,7 +221,7 @@ na_tray_child_class_init (NaTrayChildClass *klass)
widget_class->style_set = na_tray_child_style_set;
widget_class->realize = na_tray_child_realize;
widget_class->size_allocate = na_tray_child_size_allocate;
widget_class->expose_event = na_tray_child_expose_event;
widget_class->draw = na_tray_child_draw;
}
GtkWidget *
......@@ -233,8 +233,6 @@ na_tray_child_new (GdkScreen *screen,
NaTrayChild *child;
GdkVisual *visual;
gboolean visual_has_alpha;
GdkColormap *colormap;
gboolean new_colormap;