From 613453b1095e325149b8d37e5731d415e1d5f9bd Mon Sep 17 00:00:00 2001 From: Mike Kestner Date: Thu, 31 Oct 2002 21:30:57 +0000 Subject: merging the gal-2 branch back to the trunk. merging the gal-2 branch back to the trunk. svn path=/trunk/; revision=18471 --- widgets/text/e-completion-match.c | 1 - widgets/text/e-completion-match.h | 5 +- widgets/text/e-completion-view.c | 10 +- widgets/text/e-completion-view.h | 5 +- widgets/text/e-completion.c | 25 +++-- widgets/text/e-completion.h | 5 +- widgets/text/e-entry-test.c | 3 +- widgets/text/e-entry.c | 68 ++++++------ widgets/text/e-entry.h | 10 +- widgets/text/e-table-text-model.c | 3 + widgets/text/e-table-text-model.h | 6 +- widgets/text/e-text-model-test.c | 2 - widgets/text/e-text-model-uri.c | 3 +- widgets/text/e-text-model-uri.h | 5 +- widgets/text/e-text-model.c | 13 ++- widgets/text/e-text-model.h | 5 +- widgets/text/e-text-test.c | 2 - widgets/text/e-text.c | 212 +++++++++++++++++++------------------- widgets/text/e-text.h | 8 +- 19 files changed, 195 insertions(+), 196 deletions(-) (limited to 'widgets/text') diff --git a/widgets/text/e-completion-match.c b/widgets/text/e-completion-match.c index e61362a561..0da197d1fe 100644 --- a/widgets/text/e-completion-match.c +++ b/widgets/text/e-completion-match.c @@ -23,7 +23,6 @@ #include #include -#include #include #include "e-completion-match.h" diff --git a/widgets/text/e-completion-match.h b/widgets/text/e-completion-match.h index ba93e53172..f2773ee094 100644 --- a/widgets/text/e-completion-match.h +++ b/widgets/text/e-completion-match.h @@ -25,10 +25,9 @@ #define __E_COMPLETION_MATCH_H__ #include -#include #include -BEGIN_GNOME_DECLS +G_BEGIN_DECLS typedef struct _ECompletionMatch ECompletionMatch; @@ -63,7 +62,7 @@ ECompletionMatch *e_completion_match_new (const gchar *match_text, co -END_GNOME_DECLS +G_END_DECLS #endif /* __E_COMPLETION_MATCH_H__ */ diff --git a/widgets/text/e-completion-view.c b/widgets/text/e-completion-view.c index 067f89aec8..42b2a53876 100644 --- a/widgets/text/e-completion-view.c +++ b/widgets/text/e-completion-view.c @@ -90,6 +90,7 @@ e_completion_view_paint (GtkWidget *widget, GdkRectangle *area) } +#if 0 static void e_completion_view_draw (GtkWidget *widget, GdkRectangle *area) { @@ -109,6 +110,7 @@ e_completion_view_draw (GtkWidget *widget, GdkRectangle *area) gtk_widget_draw (bin->child, &child_area); } } +#endif static gint e_completion_view_expose_event (GtkWidget *widget, GdkEventExpose *event) @@ -276,7 +278,6 @@ e_completion_view_class_init (ECompletionViewClass *klass) object_class->destroy = e_completion_view_destroy; widget_class->key_press_event = e_completion_view_local_key_press_handler; - widget_class->draw = e_completion_view_draw; widget_class->expose_event = e_completion_view_expose_event; widget_class->size_request = e_completion_view_size_request; widget_class->size_allocate = e_completion_view_size_allocate; @@ -297,16 +298,19 @@ e_completion_view_destroy (GtkObject *object) e_completion_view_disconnect (cv); e_completion_view_clear_choices (cv); - g_ptr_array_free (cv->choices, TRUE); + if (cv->choices) + g_ptr_array_free (cv->choices, TRUE); + cv->choices = NULL; if (cv->key_widget) { gtk_signal_disconnect (GTK_OBJECT (cv->key_widget), cv->key_signal_id); gtk_object_unref (GTK_OBJECT (cv->key_widget)); + cv->key_widget = NULL; } if (cv->completion) gtk_object_unref (GTK_OBJECT (cv->completion)); - + cv->completion = NULL; if (parent_class->destroy) (parent_class->destroy) (object); diff --git a/widgets/text/e-completion-view.h b/widgets/text/e-completion-view.h index f58050a564..f869b92725 100644 --- a/widgets/text/e-completion-view.h +++ b/widgets/text/e-completion-view.h @@ -25,12 +25,11 @@ #ifndef E_COMPLETION_VIEW_H #define E_COMPLETION_VIEW_H -#include #include #include #include "e-completion.h" -BEGIN_GNOME_DECLS +G_BEGIN_DECLS #define E_COMPLETION_VIEW_TYPE (e_completion_view_get_type ()) #define E_COMPLETION_VIEW(o) (GTK_CHECK_CAST ((o), E_COMPLETION_VIEW_TYPE, ECompletionView)) @@ -97,7 +96,7 @@ void e_completion_view_set_uncomplete_key (ECompletionView *cv, gint keyva void e_completion_view_set_width (ECompletionView *cv, gint width); void e_completion_view_set_editable (ECompletionView *cv, gboolean); -END_GNOME_DECLS +G_END_DECLS #endif /* E_COMPLETION_H */ diff --git a/widgets/text/e-completion.c b/widgets/text/e-completion.c index 975bc9e112..f96e4cb258 100644 --- a/widgets/text/e-completion.c +++ b/widgets/text/e-completion.c @@ -26,6 +26,7 @@ #include #include #include +#include #include "e-completion.h" #include "gal/util/e-util.h" @@ -110,7 +111,7 @@ e_completion_class_init (ECompletionClass *klass) GTK_RUN_LAST, E_OBJECT_CLASS_TYPE (object_class), GTK_SIGNAL_OFFSET (ECompletionClass, request_completion), - gtk_marshal_NONE__POINTER_INT_INT, + e_marshal_NONE__POINTER_INT_INT, GTK_TYPE_NONE, 3, GTK_TYPE_POINTER, GTK_TYPE_INT, GTK_TYPE_INT); @@ -119,7 +120,7 @@ e_completion_class_init (ECompletionClass *klass) GTK_RUN_LAST, E_OBJECT_CLASS_TYPE (object_class), GTK_SIGNAL_OFFSET (ECompletionClass, begin_completion), - gtk_marshal_NONE__POINTER_INT_INT, + e_marshal_NONE__POINTER_INT_INT, GTK_TYPE_NONE, 3, GTK_TYPE_POINTER, GTK_TYPE_INT, GTK_TYPE_INT); @@ -189,17 +190,19 @@ e_completion_destroy (GtkObject *object) { ECompletion *complete = E_COMPLETION (object); - g_free (complete->priv->search_text); - complete->priv->search_text = NULL; + if (complete->priv) { + g_free (complete->priv->search_text); + complete->priv->search_text = NULL; - e_completion_clear_matches (complete); - e_completion_clear_search_stack (complete); + e_completion_clear_matches (complete); + e_completion_clear_search_stack (complete); - g_ptr_array_free (complete->priv->matches, TRUE); - complete->priv->matches = NULL; + g_ptr_array_free (complete->priv->matches, TRUE); + complete->priv->matches = NULL; - g_free (complete->priv); - complete->priv = NULL; + g_free (complete->priv); + complete->priv = NULL; + } if (parent_class->destroy) (parent_class->destroy) (object); @@ -393,7 +396,7 @@ e_completion_begin_search (ECompletion *complete, const gchar *text, gint pos, g g_return_if_fail (E_IS_COMPLETION (complete)); g_return_if_fail (text != NULL); - klass = E_COMPLETION_CLASS (GTK_OBJECT (complete)->klass); + klass = E_COMPLETION_CLASS (GTK_OBJECT_GET_CLASS (complete)); if (!complete->priv->searching && complete->priv->done_search) { diff --git a/widgets/text/e-completion.h b/widgets/text/e-completion.h index 9e7b5ab4b3..2f228ac130 100644 --- a/widgets/text/e-completion.h +++ b/widgets/text/e-completion.h @@ -25,11 +25,10 @@ #ifndef E_COMPLETION_H #define E_COMPLETION_H -#include #include #include "e-completion-match.h" -BEGIN_GNOME_DECLS +G_BEGIN_DECLS #define E_COMPLETION_TYPE (e_completion_get_type ()) #define E_COMPLETION(o) (GTK_CHECK_CAST ((o), E_COMPLETION_TYPE, ECompletion)) @@ -96,7 +95,7 @@ void e_completion_lost_match (ECompletion *comp, ECompletionMatch *); void e_completion_clear (ECompletion *comp); void e_completion_end_search (ECompletion *comp); -END_GNOME_DECLS +G_END_DECLS #endif /* E_COMPLETION_H */ diff --git a/widgets/text/e-entry-test.c b/widgets/text/e-entry-test.c index 94f490113b..5dc78364d4 100644 --- a/widgets/text/e-entry-test.c +++ b/widgets/text/e-entry-test.c @@ -21,10 +21,11 @@ * 02111-1307, USA. */ -#include "config.h" +#include #include #include "e-entry.h" +#include static void destroy_callback(GtkWidget *app, gpointer data) { diff --git a/widgets/text/e-entry.c b/widgets/text/e-entry.c index 6e4b6a1949..bb1c8266f6 100644 --- a/widgets/text/e-entry.c +++ b/widgets/text/e-entry.c @@ -28,14 +28,12 @@ #include #include #include -#ifdef HAVE_ALLOCA_H -#include -#endif #include #include #include -#include -#include +#include +#include +#include #include "gal/util/e-util.h" #include "gal/widgets/e-canvas.h" #include "gal/widgets/e-canvas-utils.h" @@ -177,12 +175,12 @@ canvas_size_request (GtkWidget *widget, GtkRequisition *requisition, g_return_if_fail (requisition != NULL); if (entry->priv->draw_borders) { - xthick = 2 * widget->style->klass->xthickness; - ythick = 2 * widget->style->klass->ythickness; + xthick = 2 * widget->style->xthickness; + ythick = 2 * widget->style->ythickness; } else { xthick = ythick = 0; } - + if (entry->priv->emulate_label_resize) { gdouble width; gtk_object_get (GTK_OBJECT (entry->item), @@ -198,8 +196,8 @@ canvas_size_request (GtkWidget *widget, GtkRequisition *requisition, d(g_print("%s: width = %d\n", __FUNCTION__, requisition->width)); - requisition->height = (2 + widget->style->font->ascent + - widget->style->font->descent + + requisition->height = (2 + gtk_style_get_font (widget->style)->ascent + + gtk_style_get_font (widget->style)->descent + ythick); } @@ -278,6 +276,8 @@ e_entry_init (GtkObject *object) entry->priv->emulate_label_resize = FALSE; + entry->priv->emulate_label_resize = FALSE; + entry->canvas = GNOME_CANVAS (e_canvas_new ()); gtk_signal_connect (GTK_OBJECT (entry->canvas), @@ -904,7 +904,7 @@ et_get_arg (GtkObject *o, GtkArg *arg, guint arg_id) case ARG_JUSTIFICATION: gtk_object_get(item, - "justification", >K_VALUE_ENUM (*arg), + "justification", >K_VALUE_INT (*arg), NULL); break; @@ -1061,7 +1061,7 @@ et_set_arg (GtkObject *o, GtkArg *arg, guint arg_id) break; case ARG_JUSTIFICATION: - entry->priv->justification = GTK_VALUE_ENUM (*arg); + entry->priv->justification = GTK_VALUE_INT (*arg); gtk_object_get(item, "clip_width", &width, "clip_height", &height, @@ -1071,8 +1071,8 @@ et_set_arg (GtkObject *o, GtkArg *arg, guint arg_id) xthick = 0; ythick = 0; } else { - xthick = widget->style->klass->xthickness; - ythick = widget->style->klass->ythickness; + xthick = widget->style->xthickness; + ythick = widget->style->ythickness; } switch (entry->priv->justification) { @@ -1210,25 +1210,27 @@ e_entry_destroy (GtkObject *object) { EEntry *entry = E_ENTRY (object); - if (entry->priv->completion_delay_tag) - gtk_timeout_remove (entry->priv->completion_delay_tag); + if (entry->priv) { + if (entry->priv->completion_delay_tag) + gtk_timeout_remove (entry->priv->completion_delay_tag); - if (entry->priv->completion) - gtk_object_unref (GTK_OBJECT (entry->priv->completion)); - if (entry->priv->completion_view_popup) { - gtk_widget_destroy (GTK_WIDGET (entry->priv->completion_view_popup)); - gtk_object_unref (GTK_OBJECT (entry->priv->completion_view_popup)); - } - g_free (entry->priv->pre_browse_text); + if (entry->priv->completion) + gtk_object_unref (GTK_OBJECT (entry->priv->completion)); + if (entry->priv->completion_view_popup) { + gtk_widget_destroy (GTK_WIDGET (entry->priv->completion_view_popup)); + gtk_object_unref (GTK_OBJECT (entry->priv->completion_view_popup)); + } + g_free (entry->priv->pre_browse_text); - if (entry->priv->changed_since_keypress_tag) - gtk_timeout_remove (entry->priv->changed_since_keypress_tag); + if (entry->priv->changed_since_keypress_tag) + gtk_timeout_remove (entry->priv->changed_since_keypress_tag); - if (entry->priv->ptr_grab) - gdk_pointer_ungrab (GDK_CURRENT_TIME); + if (entry->priv->ptr_grab) + gdk_pointer_ungrab (GDK_CURRENT_TIME); - g_free (entry->priv); - entry->priv = NULL; + g_free (entry->priv); + entry->priv = NULL; + } if (GTK_OBJECT_CLASS (parent_class)->destroy) (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); @@ -1290,7 +1292,7 @@ e_entry_class_init (GtkObjectClass *object_class) GTK_RUN_LAST, E_OBJECT_CLASS_TYPE (object_class), GTK_SIGNAL_OFFSET (EEntryClass, popup), - gtk_marshal_NONE__POINTER_INT, + e_marshal_NONE__POINTER_INT, GTK_TYPE_NONE, 2, GTK_TYPE_POINTER, GTK_TYPE_INT); e_entry_signals[E_ENTRY_COMPLETION_POPUP] = @@ -1315,17 +1317,17 @@ e_entry_class_init (GtkObjectClass *object_class) gtk_object_add_arg_type ("EEntry::fontset", GTK_TYPE_STRING, GTK_ARG_WRITABLE, ARG_FONTSET); gtk_object_add_arg_type ("EEntry::font_gdk", - GTK_TYPE_GDK_FONT, GTK_ARG_READWRITE, ARG_FONT_GDK); + GDK_TYPE_FONT, GTK_ARG_READWRITE, ARG_FONT_GDK); gtk_object_add_arg_type ("EEntry::justification", GTK_TYPE_JUSTIFICATION, GTK_ARG_READWRITE, ARG_JUSTIFICATION); gtk_object_add_arg_type ("EEntry::fill_color", GTK_TYPE_STRING, GTK_ARG_WRITABLE, ARG_FILL_COLOR); gtk_object_add_arg_type ("EEntry::fill_color_gdk", - GTK_TYPE_GDK_COLOR, GTK_ARG_READWRITE, ARG_FILL_COLOR_GDK); + GDK_TYPE_COLOR, GTK_ARG_READWRITE, ARG_FILL_COLOR_GDK); gtk_object_add_arg_type ("EEntry::fill_color_rgba", GTK_TYPE_UINT, GTK_ARG_READWRITE, ARG_FILL_COLOR_RGBA); gtk_object_add_arg_type ("EEntry::fill_stipple", - GTK_TYPE_GDK_WINDOW, GTK_ARG_READWRITE, ARG_FILL_STIPPLE); + GDK_TYPE_WINDOW, GTK_ARG_READWRITE, ARG_FILL_STIPPLE); gtk_object_add_arg_type ("EEntry::editable", GTK_TYPE_BOOL, GTK_ARG_READWRITE, ARG_EDITABLE); gtk_object_add_arg_type ("EEntry::use_ellipsis", diff --git a/widgets/text/e-entry.h b/widgets/text/e-entry.h index bd57e862a8..1e073a87e8 100644 --- a/widgets/text/e-entry.h +++ b/widgets/text/e-entry.h @@ -25,15 +25,13 @@ #ifndef _E_ENTRY_H_ #define _E_ENTRY_H_ -#include +#include #include -#include +#include #include #include "e-completion.h" -#include - -BEGIN_GNOME_DECLS +G_BEGIN_DECLS #define E_ENTRY_TYPE (e_entry_get_type ()) #define E_ENTRY(o) (GTK_CHECK_CAST ((o), E_ENTRY_TYPE, EEntry)) @@ -84,6 +82,6 @@ void e_entry_enable_completion_full (EEntry *entry, ECompletion *complet EEntryCompletionHandler handler); gboolean e_entry_completion_popup_is_visible (EEntry *entry); -END_GNOME_DECLS +G_END_DECLS #endif /* _E_ENTRY_H_ */ diff --git a/widgets/text/e-table-text-model.c b/widgets/text/e-table-text-model.c index 6b195136f2..cd47f0ff43 100644 --- a/widgets/text/e-table-text-model.c +++ b/widgets/text/e-table-text-model.c @@ -122,13 +122,16 @@ e_table_text_model_destroy (GtkObject *object) if (model->cell_changed_signal_id) gtk_signal_disconnect (GTK_OBJECT(model->model), model->cell_changed_signal_id); + model->cell_changed_signal_id = 0; if (model->row_changed_signal_id) gtk_signal_disconnect (GTK_OBJECT(model->model), model->row_changed_signal_id); + model->row_changed_signal_id = 0; if (model->model) gtk_object_unref (GTK_OBJECT(model->model)); + model->model = NULL; if (GTK_OBJECT_CLASS (parent_class)->destroy) (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); diff --git a/widgets/text/e-table-text-model.h b/widgets/text/e-table-text-model.h index 4f55b45ccf..1c1a88dd47 100644 --- a/widgets/text/e-table-text-model.h +++ b/widgets/text/e-table-text-model.h @@ -26,10 +26,8 @@ #include #include -#include - -BEGIN_GNOME_DECLS +G_BEGIN_DECLS #define E_TYPE_TABLE_TEXT_MODEL (e_table_text_model_get_type ()) #define E_TABLE_TEXT_MODEL(obj) (GTK_CHECK_CAST ((obj), E_TYPE_TABLE_TEXT_MODEL, ETableTextModel)) @@ -61,6 +59,6 @@ struct _ETableTextModelClass { GtkType e_table_text_model_get_type (void); ETableTextModel *e_table_text_model_new (ETableModel *table_model, int row, int model_col); -END_GNOME_DECLS +G_END_DECLS #endif diff --git a/widgets/text/e-text-model-test.c b/widgets/text/e-text-model-test.c index c364b852c6..4913b7774e 100644 --- a/widgets/text/e-text-model-test.c +++ b/widgets/text/e-text-model-test.c @@ -67,10 +67,8 @@ main (int argc, gchar **argv) for (i=0; i<2; ++i) { win[i] = gtk_window_new (GTK_WINDOW_TOPLEVEL); - gtk_widget_push_visual (gdk_rgb_get_visual ()); gtk_widget_push_colormap (gdk_rgb_get_cmap ()); canvas[i] = e_canvas_new (); - gtk_widget_pop_visual (); gtk_widget_pop_colormap (); item[i] = gnome_canvas_item_new (gnome_canvas_root (GNOME_CANVAS (canvas[i])), diff --git a/widgets/text/e-text-model-uri.c b/widgets/text/e-text-model-uri.c index 765faa05ca..7292d2954e 100644 --- a/widgets/text/e-text-model-uri.c +++ b/widgets/text/e-text-model-uri.c @@ -116,7 +116,6 @@ e_text_model_uri_destroy (GtkObject *object) g_free (iter->data); g_list_free (model_uri->uris); model_uri->uris = NULL; - if (GTK_OBJECT_CLASS (parent_class)->destroy) (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); @@ -345,7 +344,7 @@ e_text_model_uri_activate_nth_object (ETextModel *model, gint i) objectify_idle_flush (E_TEXT_MODEL_URI (model)); obj_str = e_text_model_strdup_nth_object (model, i); - gnome_url_show (obj_str); + gnome_url_show (obj_str, NULL); g_free (obj_str); } diff --git a/widgets/text/e-text-model-uri.h b/widgets/text/e-text-model-uri.h index a4b2f9f80f..9293a8f63f 100644 --- a/widgets/text/e-text-model-uri.h +++ b/widgets/text/e-text-model-uri.h @@ -25,9 +25,8 @@ #define E_TEXT_MODEL_URI_H #include -#include -BEGIN_GNOME_DECLS +G_BEGIN_DECLS #define E_TYPE_TEXT_MODEL_URI (e_text_model_get_type ()) #define E_TEXT_MODEL_URI(obj) (GTK_CHECK_CAST ((obj), E_TYPE_TEXT_MODEL_URI, ETextModelURI)) @@ -52,6 +51,6 @@ struct _ETextModelURIClass { GtkType e_text_model_uri_get_type (void); ETextModel *e_text_model_uri_new (void); -END_GNOME_DECLS +G_END_DECLS #endif diff --git a/widgets/text/e-text-model.c b/widgets/text/e-text-model.c index da8644570b..d761f8e193 100644 --- a/widgets/text/e-text-model.c +++ b/widgets/text/e-text-model.c @@ -27,11 +27,12 @@ #include #include #include +#include #include "e-text-model-repos.h" #include "e-text-model.h" #include "gal/util/e-util.h" -#define CLASS(obj) (E_TEXT_MODEL_CLASS (GTK_OBJECT (obj)->klass)) +#define CLASS(obj) (E_TEXT_MODEL_CLASS (GTK_OBJECT_GET_CLASS (obj))) #define MAX_LENGTH (2047) @@ -121,7 +122,7 @@ e_text_model_class_init (ETextModelClass *klass) GTK_RUN_LAST, E_OBJECT_CLASS_TYPE (object_class), GTK_SIGNAL_OFFSET (ETextModelClass, reposition), - gtk_marshal_NONE__POINTER_POINTER, + e_marshal_NONE__POINTER_POINTER, GTK_TYPE_NONE, 2, GTK_TYPE_POINTER, GTK_TYPE_POINTER); @@ -186,10 +187,12 @@ e_text_model_destroy (GtkObject *object) model = E_TEXT_MODEL (object); - g_free (model->priv->text); + if (model->priv) { + g_free (model->priv->text); - g_free (model->priv); - model->priv = NULL; + g_free (model->priv); + model->priv = NULL; + } if (GTK_OBJECT_CLASS (parent_class)->destroy) GTK_OBJECT_CLASS (parent_class)->destroy (object); diff --git a/widgets/text/e-text-model.h b/widgets/text/e-text-model.h index a3b1caa415..8b5c7aab23 100644 --- a/widgets/text/e-text-model.h +++ b/widgets/text/e-text-model.h @@ -26,9 +26,8 @@ #include #include -#include -BEGIN_GNOME_DECLS +G_BEGIN_DECLS #define E_TYPE_TEXT_MODEL (e_text_model_get_type ()) #define E_TEXT_MODEL(obj) (GTK_CHECK_CAST ((obj), E_TYPE_TEXT_MODEL, ETextModel)) @@ -114,6 +113,6 @@ void e_text_model_activate_nth_object (ETextModel *model, gint n); -END_GNOME_DECLS +G_END_DECLS #endif diff --git a/widgets/text/e-text-test.c b/widgets/text/e-text-test.c index 39572905c8..45b39d3352 100644 --- a/widgets/text/e-text-test.c +++ b/widgets/text/e-text-test.c @@ -105,10 +105,8 @@ main (int argc, gtk_signal_connect (GTK_OBJECT (window), "destroy", GTK_SIGNAL_FUNC (quit_cb), NULL); - gtk_widget_push_visual (gdk_rgb_get_visual ()); gtk_widget_push_colormap (gdk_rgb_get_cmap ()); canvas = e_canvas_new (); - gtk_widget_pop_visual (); gtk_widget_pop_colormap (); scroller = gtk_scrolled_window_new (NULL, NULL); vbox = gtk_vbox_new (FALSE, 2); diff --git a/widgets/text/e-text.c b/widgets/text/e-text.c index 6275235c11..abaa788a98 100644 --- a/widgets/text/e-text.c +++ b/widgets/text/e-text.c @@ -46,8 +46,10 @@ #include #include #include -#include +#include +#include +#include "gal/util/e-util.h" #include "gal/widgets/e-canvas.h" #include "gal/widgets/e-canvas-utils.h" #include "gal/widgets/e-unicode.h" @@ -69,7 +71,7 @@ enum { E_TEXT_LAST_SIGNAL }; -static guint signals[E_TEXT_LAST_SIGNAL] = { 0 }; +static GQuark e_text_signals[E_TEXT_LAST_SIGNAL] = { 0 }; @@ -205,35 +207,48 @@ e_text_destroy (GtkObject *object) text = E_TEXT (object); - if (text->tooltip_owner) { + if (text->tooltip_owner) e_canvas_hide_tooltip (E_CANVAS(GNOME_CANVAS_ITEM(text)->canvas)); - } + text->tooltip_owner = 0; if (text->model_changed_signal_id) gtk_signal_disconnect (GTK_OBJECT (text->model), text->model_changed_signal_id); + text->model_changed_signal_id = 0; if (text->model_repos_signal_id) gtk_signal_disconnect (GTK_OBJECT (text->model), text->model_repos_signal_id); + text->model_repos_signal_id = 0; if (text->model) gtk_object_unref(GTK_OBJECT(text->model)); + text->model = NULL; if (text->tep_command_id) gtk_signal_disconnect(GTK_OBJECT(text->tep), text->tep_command_id); + text->tep_command_id = 0; if (text->tep) gtk_object_unref (GTK_OBJECT(text->tep)); + text->tep = NULL; if (text->invisible) gtk_object_unref (GTK_OBJECT(text->invisible)); + text->invisible = NULL; g_free (text->lines); + text->lines = NULL; + g_free (text->primary_selection); + text->primary_selection = NULL; + g_free (text->clipboard_selection); + text->clipboard_selection = NULL; + g_free (text->revert); + text->revert = NULL; if (text->font) e_font_unref (text->font); @@ -246,6 +261,7 @@ e_text_destroy (GtkObject *object) if (text->stipple) gdk_bitmap_unref (text->stipple); + text->stipple = NULL; if (text->timeout_id) { g_source_remove(text->timeout_id); @@ -293,7 +309,7 @@ e_text_text_model_changed (ETextModel *model, EText *text) e_canvas_item_request_reflow (GNOME_CANVAS_ITEM(text)); gnome_canvas_item_request_update (GNOME_CANVAS_ITEM (text)); - gtk_signal_emit (GTK_OBJECT (text), signals[E_TEXT_CHANGED]); + gtk_signal_emit (GTK_OBJECT (text), e_text_signals[E_TEXT_CHANGED]); } static void @@ -640,6 +656,9 @@ text_draw_with_objects (ETextModel *model, { const gchar *c; + if (text == NULL) + return; + if (text == NULL) return; @@ -682,7 +701,7 @@ text_draw_with_objects (ETextModel *model, typedef void (*LineSplitterFn) (int line_num, const char *start, int length, gpointer user_data); -#define IS_BREAK_CHAR(break_chars, c) (g_unichar_isspace (c) || ((break_chars) && g_utf8_strchr ((break_chars), (c)))) +#define IS_BREAK_CHAR(break_chars, c) (g_unichar_isspace (c) || ((break_chars) && g_utf8_strchr ((break_chars), -1, (c)))) static gint line_splitter (ETextModel *model, EFont *font, EFontStyle style, @@ -773,21 +792,9 @@ line_split_cb (int line_num, const char *start, int length, gpointer user_data) static void split_into_lines (EText *text) { - double clip_width; - - if (text->text == NULL) - return; - /* Free old array of lines */ e_text_free_lines (text); - clip_width = text->clip_width; - if (clip_width >= 0 && text->draw_borders) { - clip_width -= 6; - if (clip_width < 0) - clip_width = 0; - } - /* First, count the number of lines */ text->num_lines = line_splitter (text->model, text->font, text->style, text->break_characters, @@ -883,7 +890,7 @@ e_text_set_arg (GtkObject *object, GtkArg *arg, guint arg_id) e_text_free_lines(text); text->text = e_text_model_get_text(text->model); - gtk_signal_emit (GTK_OBJECT (text), signals[E_TEXT_CHANGED]); + gtk_signal_emit (GTK_OBJECT (text), e_text_signals[E_TEXT_CHANGED]); text->needs_split_into_lines = 1; needs_reflow = 1; @@ -1004,13 +1011,13 @@ e_text_set_arg (GtkObject *object, GtkArg *arg, guint arg_id) break; case ARG_ANCHOR: - text->anchor = GTK_VALUE_ENUM (*arg); + text->anchor = GTK_VALUE_INT (*arg); text->needs_recalc_bounds = 1; needs_update = 1; break; case ARG_JUSTIFICATION: - text->justification = GTK_VALUE_ENUM (*arg); + text->justification = GTK_VALUE_INT (*arg); text->needs_redraw = 1; needs_update = 1; break; @@ -1205,8 +1212,13 @@ e_text_set_arg (GtkObject *object, GtkArg *arg, guint arg_id) } if (color_changed) { +#ifndef NO_WARNINGS +#warning Color stuff ... +#endif +#if 0 if (GNOME_CANVAS_ITEM_REALIZED & GTK_OBJECT_FLAGS(item)) gdk_color_context_query_color (item->canvas->cc, &color); +#endif text->color = color; @@ -1228,7 +1240,6 @@ static void e_text_get_arg (GtkObject *object, GtkArg *arg, guint arg_id) { EText *text; - GdkColor *color; text = E_TEXT (object); @@ -1259,11 +1270,11 @@ e_text_get_arg (GtkObject *object, GtkArg *arg, guint arg_id) break; case ARG_ANCHOR: - GTK_VALUE_ENUM (*arg) = text->anchor; + GTK_VALUE_INT (*arg) = text->anchor; break; case ARG_JUSTIFICATION: - GTK_VALUE_ENUM (*arg) = text->justification; + GTK_VALUE_INT (*arg) = text->justification; break; case ARG_CLIP_WIDTH: @@ -1291,9 +1302,7 @@ e_text_get_arg (GtkObject *object, GtkArg *arg, guint arg_id) break; case ARG_FILL_COLOR_GDK: - color = g_new (GdkColor, 1); - *color = text->color; - GTK_VALUE_BOXED (*arg) = color; + GTK_VALUE_BOXED (*arg) = gdk_color_copy (&text->color); break; case ARG_FILL_COLOR_RGBA: @@ -1510,14 +1519,19 @@ e_text_realize (GnomeCanvasItem *item) (* parent_class->realize) (item); text->gc = gdk_gc_new (item->canvas->layout.bin_window); +#ifndef NO_WARNINGS +#warning Color brokenness ... +#endif +#if 0 gdk_color_context_query_color (item->canvas->cc, &text->color); gdk_gc_set_foreground (text->gc, &text->color); +#endif text->i_cursor = gdk_cursor_new (GDK_XTERM); text->default_cursor = gdk_cursor_new (GDK_LEFT_PTR); if (text->font == NULL) { - gdk_font_ref (GTK_WIDGET (item->canvas)->style->font); - text->font = e_font_from_gdk_font (GTK_WIDGET (item->canvas)->style->font); + gdk_font_ref (gtk_style_get_font (GTK_WIDGET (item->canvas)->style)); + text->font = e_font_from_gdk_font (gtk_style_get_font (GTK_WIDGET (item->canvas)->style)); } } @@ -1732,7 +1746,7 @@ e_text_draw (GnomeCanvasItem *item, GdkDrawable *drawable, * me as to whether it should be: * thiswidth + 2 or thiswidth + 1. */ - gtk_paint_focus (widget->style, drawable, + gtk_paint_focus (widget->style, drawable, GTK_STATE_NORMAL, NULL, widget, "entry", thisx, thisy, thiswidth - 1, thisheight - 1); } @@ -1742,10 +1756,10 @@ e_text_draw (GnomeCanvasItem *item, GdkDrawable *drawable, gtk_paint_flat_box (widget->style, drawable, GTK_WIDGET_STATE(widget), GTK_SHADOW_NONE, NULL, widget, "entry_bg", - thisx + widget->style->klass->xthickness, - thisy + widget->style->klass->ythickness, - thiswidth - widget->style->klass->xthickness * 2, - thisheight - widget->style->klass->ythickness * 2); + thisx + widget->style->xthickness, + thisy + widget->style->ythickness, + thiswidth - widget->style->xthickness * 2, + thisheight - widget->style->ythickness * 2); } } if (text->draw_button) { @@ -1801,8 +1815,8 @@ e_text_draw (GnomeCanvasItem *item, GdkDrawable *drawable, } if (GTK_WIDGET_CAN_DEFAULT (widget)) { - thisx += widget->style->klass->xthickness; - thisy += widget->style->klass->ythickness; + thisx += widget->style->xthickness; + thisy += widget->style->ythickness; thiswidth -= 2 * thisx + default_spacing; thisheight -= 2 * thisy + default_spacing; thisx += (1 + default_spacing) / 2; @@ -1835,14 +1849,13 @@ e_text_draw (GnomeCanvasItem *item, GdkDrawable *drawable, thiswidth += 2; thisheight += 2; - gtk_paint_focus (widget->style, widget->window, + gtk_paint_focus (widget->style, widget->window, GTK_WIDGET_STATE (widget), &area, widget, "button", thisx + xoff, thisy + yoff, thiswidth - 1, thisheight - 1); } } } - if (!text->text || !text->font) return; @@ -2503,9 +2516,10 @@ static gboolean tooltip_event(GtkWidget *tooltip, GdkEvent *event, EText *text) { gint ret_val = FALSE; - if (GTK_OBJECT_DESTROYED (text)) { + + if (!text->model) return FALSE; - } + switch (event->type) { case GDK_LEAVE_NOTIFY: e_canvas_hide_tooltip (E_CANVAS(GNOME_CANVAS_ITEM(text)->canvas)); @@ -2751,6 +2765,35 @@ start_editing (EText *text) g_timer_start(text->timer); } +void +e_text_stop_editing (EText *text) +{ + if (!text->editing) + return; + + g_free (text->revert); + text->revert = NULL; + + text->editing = FALSE; + if ( (!text->default_cursor_shown) && (!text->draw_borders) ) { + gdk_window_set_cursor (GTK_WIDGET (GNOME_CANVAS_ITEM (text)->canvas)->window, text->default_cursor); + text->default_cursor_shown = TRUE; + } + if (text->timer) { + g_timer_stop(text->timer); + g_timer_destroy(text->timer); + text->timer = NULL; + } +} + +void +e_text_cancel_editing (EText *text) +{ + if (text->revert) + e_text_model_set_text(text->model, text->revert); + e_text_stop_editing (text); +} + static gboolean _click (gpointer data) { @@ -2766,7 +2809,7 @@ e_text_event (GnomeCanvasItem *item, GdkEvent *event) gint return_val = 0; - if (GTK_OBJECT_DESTROYED (item)) + if (!text->model) return FALSE; e_tep_event.type = event->type; @@ -2818,7 +2861,7 @@ e_text_event (GnomeCanvasItem *item, GdkEvent *event) ret = e_text_event_processor_handle_event (text->tep, &e_tep_event); if (event->type == GDK_KEY_PRESS) - gtk_signal_emit (GTK_OBJECT (text), signals[E_TEXT_KEYPRESS], + gtk_signal_emit (GTK_OBJECT (text), e_text_signals[E_TEXT_KEYPRESS], e_tep_event.key.keyval, e_tep_event.key.state); @@ -2870,7 +2913,7 @@ e_text_event (GnomeCanvasItem *item, GdkEvent *event) /* We follow convention and emit popup events on right-clicks. */ if (event->type == GDK_BUTTON_PRESS && event->button.button == 3) { gtk_signal_emit (GTK_OBJECT (text), - signals[E_TEXT_POPUP], + e_text_signals[E_TEXT_POPUP], &(event->button), _get_position_from_xy (text, event->button.x, event->button.y)); @@ -3401,7 +3444,7 @@ e_text_command(ETextEventProcessor *tep, ETextEventProcessorCommand *command, gp e_text_get_selection (text, GDK_SELECTION_PRIMARY, command->time); break; case E_TEP_ACTIVATE: - gtk_signal_emit (GTK_OBJECT (text), signals[E_TEXT_ACTIVATE]); + gtk_signal_emit (GTK_OBJECT (text), e_text_signals[E_TEXT_ACTIVATE]); if (text->timer) { g_timer_reset(text->timer); } @@ -3721,6 +3764,7 @@ _selection_received (GtkInvisible *invisible, command.time = time; e_text_command(text->tep, &command, text); } + text->last_type_request = -1; d(g_print ("Setting last_type_request to %d at line %d\n", text->last_type_request, __LINE__)); if (text->queued_requests) { @@ -3734,8 +3778,6 @@ _selection_received (GtkInvisible *invisible, } } - - static void e_text_get_selection(EText *text, GdkAtom selection, guint32 time) { @@ -3934,7 +3976,7 @@ e_text_class_init (ETextClass *klass) parent_class = gtk_type_class (gnome_canvas_item_get_type ()); - signals[E_TEXT_CHANGED] = + e_text_signals[E_TEXT_CHANGED] = gtk_signal_new ("changed", GTK_RUN_LAST, E_OBJECT_CLASS_TYPE (object_class), @@ -3942,7 +3984,7 @@ e_text_class_init (ETextClass *klass) gtk_marshal_NONE__NONE, GTK_TYPE_NONE, 0); - signals[E_TEXT_ACTIVATE] = + e_text_signals[E_TEXT_ACTIVATE] = gtk_signal_new ("activate", GTK_RUN_LAST, E_OBJECT_CLASS_TYPE (object_class), @@ -3950,7 +3992,7 @@ e_text_class_init (ETextClass *klass) gtk_marshal_NONE__NONE, GTK_TYPE_NONE, 0); - signals[E_TEXT_KEYPRESS] = + e_text_signals[E_TEXT_KEYPRESS] = gtk_signal_new ("keypress", GTK_RUN_LAST, E_OBJECT_CLASS_TYPE (object_class), @@ -3958,23 +4000,15 @@ e_text_class_init (ETextClass *klass) gtk_marshal_NONE__INT_INT, GTK_TYPE_NONE, 2, GTK_TYPE_UINT, GTK_TYPE_UINT); - signals[E_TEXT_POPUP] = + e_text_signals[E_TEXT_POPUP] = gtk_signal_new ("popup", GTK_RUN_LAST, E_OBJECT_CLASS_TYPE (object_class), GTK_SIGNAL_OFFSET (ETextClass, popup), - gtk_marshal_NONE__POINTER_INT, + e_marshal_NONE__POINTER_INT, GTK_TYPE_NONE, 2, GTK_TYPE_POINTER, GTK_TYPE_INT); - signals[E_TEXT_STYLE_SET] = - gtk_signal_new ("style_set", - GTK_RUN_LAST, - E_OBJECT_CLASS_TYPE (object_class), - GTK_SIGNAL_OFFSET (ETextClass, style_set), - gtk_marshal_NONE__POINTER, - GTK_TYPE_NONE, 1, GTK_TYPE_STYLE); - - E_OBJECT_CLASS_ADD_SIGNALS (object_class, signals, E_TEXT_LAST_SIGNAL); + E_OBJECT_CLASS_ADD_SIGNALS (object_class, e_text_signals, E_TEXT_LAST_SIGNAL); gtk_object_add_arg_type ("EText::model", @@ -3988,7 +4022,7 @@ e_text_class_init (ETextClass *klass) gtk_object_add_arg_type ("EText::fontset", GTK_TYPE_STRING, GTK_ARG_WRITABLE, ARG_FONTSET); gtk_object_add_arg_type ("EText::font_gdk", - GTK_TYPE_GDK_FONT, GTK_ARG_WRITABLE, ARG_FONT_GDK); + GDK_TYPE_FONT, GTK_ARG_WRITABLE, ARG_FONT_GDK); gtk_object_add_arg_type ("EText::font_e", GTK_TYPE_POINTER, GTK_ARG_READWRITE, ARG_FONT_E); gtk_object_add_arg_type ("EText::bold", @@ -4014,11 +4048,11 @@ e_text_class_init (ETextClass *klass) gtk_object_add_arg_type ("EText::fill_color", GTK_TYPE_STRING, GTK_ARG_WRITABLE, ARG_FILL_COLOR); gtk_object_add_arg_type ("EText::fill_color_gdk", - GTK_TYPE_GDK_COLOR, GTK_ARG_READWRITE, ARG_FILL_COLOR_GDK); + GDK_TYPE_COLOR, GTK_ARG_READWRITE, ARG_FILL_COLOR_GDK); gtk_object_add_arg_type ("EText::fill_color_rgba", GTK_TYPE_UINT, GTK_ARG_READWRITE, ARG_FILL_COLOR_RGBA); gtk_object_add_arg_type ("EText::fill_stipple", - GTK_TYPE_GDK_WINDOW, GTK_ARG_READWRITE, ARG_FILL_STIPPLE); + GDK_TYPE_WINDOW, GTK_ARG_READWRITE, ARG_FILL_STIPPLE); gtk_object_add_arg_type ("EText::text_width", GTK_TYPE_DOUBLE, GTK_ARG_READABLE, ARG_TEXT_WIDTH); gtk_object_add_arg_type ("EText::text_height", @@ -4055,24 +4089,21 @@ e_text_class_init (ETextClass *klass) - klass->changed = NULL; - klass->activate = NULL; - klass->keypress = NULL; - klass->popup = NULL; - klass->style_set = e_text_style_set; + klass->changed = NULL; + klass->activate = NULL; object_class->destroy = e_text_destroy; object_class->set_arg = e_text_set_arg; object_class->get_arg = e_text_get_arg; - item_class->update = e_text_update; - item_class->realize = e_text_realize; + item_class->update = e_text_update; + item_class->realize = e_text_realize; item_class->unrealize = e_text_unrealize; - item_class->draw = e_text_draw; - item_class->point = e_text_point; - item_class->bounds = e_text_bounds; - item_class->render = e_text_render; - item_class->event = e_text_event; + item_class->draw = e_text_draw; + item_class->point = e_text_point; + item_class->bounds = e_text_bounds; + item_class->render = e_text_render; + item_class->event = e_text_event; } /* Object initialization function for the text item */ @@ -4142,15 +4173,12 @@ e_text_init (EText *text) text->pointer_in = FALSE; text->default_cursor_shown = TRUE; - text->line_wrap = FALSE; text->break_characters = NULL; text->max_lines = -1; - text->tooltip_timeout = 0; text->tooltip_count = 0; text->tooltip_owner = FALSE; - text->dbl_timeout = 0; text->tpl_timeout = 0; @@ -4203,31 +4231,3 @@ e_text_get_type (void) return text_type; } -void -e_text_cancel_editing (EText *text) -{ - if (text->revert) - e_text_model_set_text(text->model, text->revert); - e_text_stop_editing (text); -} - -void -e_text_stop_editing (EText *text) -{ - if (!text->editing) - return; - - g_free (text->revert); - text->revert = NULL; - - text->editing = FALSE; - if ( (!text->default_cursor_shown) && (!text->draw_borders) ) { - gdk_window_set_cursor (GTK_WIDGET (GNOME_CANVAS_ITEM (text)->canvas)->window, text->default_cursor); - text->default_cursor_shown = TRUE; - } - if (text->timer) { - g_timer_stop(text->timer); - g_timer_destroy(text->timer); - text->timer = NULL; - } -} diff --git a/widgets/text/e-text.h b/widgets/text/e-text.h index 49cc4b9e57..911edcd046 100644 --- a/widgets/text/e-text.h +++ b/widgets/text/e-text.h @@ -38,15 +38,13 @@ #define E_TEXT_H #include -#include #include #include #include #include -#include -BEGIN_GNOME_DECLS +G_BEGIN_DECLS /* Text item for the canvas. Text items are positioned by an anchor point and an anchor direction. @@ -249,7 +247,7 @@ struct _EText { gint last_type_request; /* Last selection type requested. */ guint32 last_time_request; /* The time of the last selection request. */ - guint32 last_selection_request; /* The time of the last selection request. */ + GdkAtom last_selection_request; /* The time of the last selection request. */ GList *queued_requests; /* Queued selection requests. */ }; @@ -269,6 +267,6 @@ GtkType e_text_get_type (void); void e_text_cancel_editing (EText *text); void e_text_stop_editing (EText *text); -END_GNOME_DECLS +G_END_DECLS #endif -- cgit v1.2.3