From: Andrea Zagli Date: Fri, 3 Dec 2010 14:20:04 +0000 (+0100) Subject: Now it renders the GooCanvas in the right way. X-Git-Url: https://saetta.ns0.it/gitweb?a=commitdiff_plain;h=977adb32cfee5b7fd4160f780f3f6437d3ae2018;p=libgtkcalendarex Now it renders the GooCanvas in the right way. --- diff --git a/src/gtkcalex.c b/src/gtkcalex.c index 89820ed..7451adb 100644 --- a/src/gtkcalex.c +++ b/src/gtkcalex.c @@ -35,14 +35,6 @@ enum static void gtk_calex_class_init (GtkCalExClass *klass); static void gtk_calex_init (GtkCalEx *gtk_calex); -static void gtk_calex_add (GtkContainer *container, - GtkWidget *widget); - -static void gtk_calex_forall (GtkContainer *container, - gboolean include_internals, - GtkCallback callback, - gpointer callback_data); - static void gtk_calex_set_property (GObject *object, guint property_id, const GValue *value, @@ -52,24 +44,17 @@ static void gtk_calex_get_property (GObject *object, GValue *value, GParamSpec *pspec); -static void gtk_calex_realize (GtkWidget *widget); -static void gtk_calex_unrealize (GtkWidget *widget); -static void gtk_calex_map (GtkWidget *widget); static void gtk_calex_size_request (GtkWidget *widget, GtkRequisition *requisition); static void gtk_calex_size_allocate (GtkWidget *widget, GtkAllocation *allocation); -static void gtk_calex_clean_canvas (GtkCalEx *gtk_calex); - #define GTK_CALEX_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TYPE_GTK_CALEX, GtkCalExPrivate)) typedef struct _GtkCalExPrivate GtkCalExPrivate; struct _GtkCalExPrivate { - GdkWindow *event_window; - GtkCalExViewType view_type; GDate *date; @@ -87,21 +72,14 @@ gtk_calex_class_init (GtkCalExClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); GtkWidgetClass *widget_class = (GtkWidgetClass*) klass; - GtkContainerClass *container_class = (GtkContainerClass*) klass; g_type_class_add_private (object_class, sizeof (GtkCalExPrivate)); object_class->set_property = gtk_calex_set_property; object_class->get_property = gtk_calex_get_property; - widget_class->realize = gtk_calex_realize; - widget_class->unrealize = gtk_calex_unrealize; - widget_class->map = gtk_calex_map; widget_class->size_request = gtk_calex_size_request; widget_class->size_allocate = gtk_calex_size_allocate; - - container_class->add = gtk_calex_add; - container_class->forall = gtk_calex_forall; } static void @@ -194,8 +172,6 @@ gtk_calex_set_view_type (GtkCalEx *calex, GtkCalExViewType type) if (priv->view_type == type) return; - gtk_calex_clean_canvas (calex); - priv->view_type = type; switch (priv->view_type) @@ -284,120 +260,6 @@ gtk_calex_set_date (GtkCalEx *calex, GDate *date) gtk_calex_view_day_set_date (GTK_CALEX_VIEW_DAY (priv->view), priv->date); } -static void -gtk_calex_add (GtkContainer *container, - GtkWidget *child) -{ - GtkCalEx *gtkcalex; - GtkBin *bin; - - bin = GTK_BIN (container); - g_return_if_fail (bin->child == NULL); - - gtkcalex = GTK_CALEX (container); - - bin->child = child; - gtk_widget_set_parent (child, GTK_WIDGET (bin)); -} - -static void -gtk_calex_forall (GtkContainer *container, - gboolean include_internals, - GtkCallback callback, - gpointer callback_data) -{ - GtkBin *bin; - - g_return_if_fail (IS_GTK_CALEX (container)); - g_return_if_fail (callback != NULL); - - bin = GTK_BIN (container); - - if (bin->child) - { - (* callback) (bin->child, callback_data); - } -} - -static void -gtk_calex_realize (GtkWidget *widget) -{ - GdkWindowAttr attributes; - gint attributes_mask; - - GtkCalExPrivate *priv; - - GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED); - - priv = GTK_CALEX_GET_PRIVATE (GTK_CALEX (widget)); - - attributes.x = widget->allocation.x; - attributes.y = widget->allocation.y; - attributes.width = widget->allocation.width; - attributes.height = widget->allocation.height; - attributes.window_type = GDK_WINDOW_CHILD; - attributes.wclass = GDK_INPUT_OUTPUT; - attributes.visual = gtk_widget_get_visual (widget); - attributes.colormap = gtk_widget_get_colormap (widget); - attributes.event_mask = gtk_widget_get_events (widget) - | GDK_BUTTON_MOTION_MASK - | GDK_BUTTON_PRESS_MASK - | GDK_BUTTON_RELEASE_MASK - | GDK_POINTER_MOTION_MASK - | GDK_POINTER_MOTION_HINT_MASK; - - attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP; - - widget->window = gdk_window_new (gtk_widget_get_parent_window (widget), - &attributes, attributes_mask); - gdk_window_set_user_data (widget->window, widget); - - attributes.wclass = GDK_INPUT_ONLY; - attributes_mask = 0; - - priv->event_window = gdk_window_new (widget->window, - &attributes, attributes_mask); - gdk_window_set_user_data (priv->event_window, widget); - - widget->style = gtk_style_attach (widget->style, widget->window); - - gdk_window_set_back_pixmap (widget->window, NULL, FALSE); -} - -static void -gtk_calex_unrealize (GtkWidget *widget) -{ - GtkCalExPrivate *priv; - - priv = GTK_CALEX_GET_PRIVATE (widget); - - if (priv->event_window != NULL) - { - gdk_window_set_user_data (priv->event_window, NULL); - gdk_window_destroy (priv->event_window); - priv->event_window = NULL; - } - - GTK_WIDGET_CLASS (gtk_calex_parent_class)->unrealize (widget); -} - -static void -gtk_calex_map (GtkWidget *widget) -{ - GtkCalExPrivate *priv; - - g_return_if_fail (IS_GTK_CALEX (widget)); - - priv = GTK_CALEX_GET_PRIVATE (GTK_CALEX (widget)); - - GTK_WIDGET_SET_FLAGS (widget, GTK_MAPPED); - - GTK_WIDGET_CLASS (gtk_calex_parent_class)->map (widget); - - gdk_window_show (priv->event_window); - gdk_window_show (widget->window); -} - static void gtk_calex_size_request (GtkWidget *widget, GtkRequisition *requisition) @@ -467,20 +329,3 @@ g_message("gtkcalex allocation %d %d %d %d",allocation->x,allocation->y,allocati gtk_widget_size_allocate (bin->child, &child_allocation); } } - -static void -gtk_calex_clean_canvas (GtkCalEx *gtk_calex) -{ - gint children; - gint i; - - g_return_if_fail (IS_GTK_CALEX (gtk_calex)); - - GtkCalExPrivate *priv = GTK_CALEX_GET_PRIVATE (gtk_calex); - - /*children = goo_canvas_item_get_n_children (priv->goo_canvas_root); - for (i = children - 1; i >= 0; i--) - { - goo_canvas_item_remove (goo_canvas_item_get_child (priv->goo_canvas_root, i)); - }*/ -} diff --git a/src/gtkcalexviewday.c b/src/gtkcalexviewday.c index 02e7b5c..b3e71ea 100644 --- a/src/gtkcalexviewday.c +++ b/src/gtkcalexviewday.c @@ -32,17 +32,6 @@ enum static void gtk_calex_view_day_class_init (GtkCalExViewDayClass *klass); static void gtk_calex_view_day_init (GtkCalExViewDay *gtk_calex_view_day); -static void gtk_calex_view_day_add (GtkContainer *container, - GtkWidget *widget); - -static void gtk_calex_view_day_forall (GtkContainer *container, - gboolean include_internals, - GtkCallback callback, - gpointer callback_data); - -static void gtk_calex_view_day_realize (GtkWidget *widget); -static void gtk_calex_view_day_unrealize (GtkWidget *widget); -static void gtk_calex_view_day_map (GtkWidget *widget); static void gtk_calex_view_day_size_request (GtkWidget *widget, GtkRequisition *requisition); static void gtk_calex_view_day_size_allocate (GtkWidget *widget, @@ -93,14 +82,8 @@ gtk_calex_view_day_class_init (GtkCalExViewDayClass *klass) object_class->set_property = gtk_calex_view_day_set_property; object_class->get_property = gtk_calex_view_day_get_property; - widget_class->realize = gtk_calex_view_day_realize; - widget_class->unrealize = gtk_calex_view_day_unrealize; - widget_class->map = gtk_calex_view_day_map; widget_class->size_request = gtk_calex_view_day_size_request; widget_class->size_allocate = gtk_calex_view_day_size_allocate; - - container_class->add = gtk_calex_view_day_add; - container_class->forall = gtk_calex_view_day_forall; } static void @@ -108,16 +91,12 @@ gtk_calex_view_day_init (GtkCalExViewDay *gtk_calex_view_day) { GtkCalExViewDayPrivate *priv = GTK_CALEX_VIEW_DAY_GET_PRIVATE (gtk_calex_view_day); - GTK_WIDGET_SET_FLAGS (gtk_calex_view_day, GTK_CAN_FOCUS); - GTK_WIDGET_UNSET_FLAGS (gtk_calex_view_day, GTK_NO_WINDOW); - priv->scrolledw = gtk_scrolled_window_new (NULL, NULL); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (priv->scrolledw), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); gtk_container_add (GTK_CONTAINER (gtk_calex_view_day), priv->scrolledw); priv->goo_canvas = goo_canvas_new (); - gtk_widget_set_size_request (priv->goo_canvas, 600, 450); goo_canvas_set_bounds (GOO_CANVAS (priv->goo_canvas), 0, 0, 1000, 1000); gtk_container_add (GTK_CONTAINER (priv->scrolledw), priv->goo_canvas); @@ -302,116 +281,6 @@ gtk_calex_view_day_draw (GtkCalExViewDay *gtk_calex_view_day) } } -static void -gtk_calex_view_day_add (GtkContainer *container, - GtkWidget *child) -{ - GtkCalExViewDay *gtkcalexvd; - GtkBin *bin; - - bin = GTK_BIN (container); - g_return_if_fail (bin->child == NULL); - - gtkcalexvd = GTK_CALEX_VIEW_DAY (container); - - bin->child = child; - gtk_widget_set_parent (child, GTK_WIDGET (bin)); -} - -static void -gtk_calex_view_day_forall (GtkContainer *container, - gboolean include_internals, - GtkCallback callback, - gpointer callback_data) -{ - g_return_if_fail (IS_GTK_CALEX_VIEW_DAY (container)); - g_return_if_fail (callback != NULL); - - GTK_CONTAINER_CLASS (gtk_calex_view_day_parent_class)->forall (container, - include_internals, - callback, - callback_data); -} - -static void -gtk_calex_view_day_realize (GtkWidget *widget) -{ - GdkWindowAttr attributes; - gint attributes_mask; - - GtkCalExViewDayPrivate *priv; - - GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED); - - priv = GTK_CALEX_VIEW_DAY_GET_PRIVATE (GTK_CALEX_VIEW_DAY (widget)); - - attributes.x = widget->allocation.x; - attributes.y = widget->allocation.y; - attributes.width = widget->allocation.width; - attributes.height = widget->allocation.height; - attributes.window_type = GDK_WINDOW_CHILD; - attributes.wclass = GDK_INPUT_OUTPUT; - attributes.visual = gtk_widget_get_visual (widget); - attributes.colormap = gtk_widget_get_colormap (widget); - attributes.event_mask = gtk_widget_get_events (widget) - | GDK_BUTTON_MOTION_MASK - | GDK_BUTTON_PRESS_MASK - | GDK_BUTTON_RELEASE_MASK - | GDK_POINTER_MOTION_MASK - | GDK_POINTER_MOTION_HINT_MASK; - - attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP; - - widget->window = gdk_window_new (gtk_widget_get_parent_window (widget), - &attributes, attributes_mask); - gdk_window_set_user_data (widget->window, widget); - - attributes.wclass = GDK_INPUT_ONLY; - attributes_mask = 0; - - priv->event_window = gdk_window_new (widget->window, - &attributes, attributes_mask); - gdk_window_set_user_data (priv->event_window, widget); - - widget->style = gtk_style_attach (widget->style, widget->window); - - gdk_window_set_back_pixmap (widget->window, NULL, FALSE); -} - -static void -gtk_calex_view_day_unrealize (GtkWidget *widget) -{ - GtkCalExViewDayPrivate *priv; - - priv = GTK_CALEX_VIEW_DAY_GET_PRIVATE (widget); - - if (priv->event_window != NULL) - { - gdk_window_set_user_data (priv->event_window, NULL); - gdk_window_destroy (priv->event_window); - priv->event_window = NULL; - } - - GTK_WIDGET_CLASS (gtk_calex_view_day_parent_class)->unrealize (widget); -} - -static void -gtk_calex_view_day_map (GtkWidget *widget) -{ - GtkCalExViewDayPrivate *priv; - - g_return_if_fail (IS_GTK_CALEX_VIEW_DAY (widget)); - - priv = GTK_CALEX_VIEW_DAY_GET_PRIVATE (GTK_CALEX_VIEW_DAY (widget)); - - GTK_WIDGET_SET_FLAGS (widget, GTK_MAPPED); - - GTK_WIDGET_CLASS (gtk_calex_view_day_parent_class)->map (widget); - - gdk_window_show (priv->event_window); - gdk_window_show (widget->window); -} - static void gtk_calex_view_day_size_request (GtkWidget *widget, GtkRequisition *requisition)