aboutsummaryrefslogtreecommitdiffstats
path: root/widgets/text
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2011-06-05 04:53:10 +0800
committerMatthew Barnes <mbarnes@redhat.com>2011-06-09 01:14:48 +0800
commitf014ab82c81078d60cb1df8c986305c2cc9948c2 (patch)
treec3bde4e5da923c9ee082fcb994b10c2ce2f61dc2 /widgets/text
parent7428fc93d58921bab9968a999172b843af2a2244 (diff)
downloadgsoc2013-evolution-f014ab82c81078d60cb1df8c986305c2cc9948c2.tar
gsoc2013-evolution-f014ab82c81078d60cb1df8c986305c2cc9948c2.tar.gz
gsoc2013-evolution-f014ab82c81078d60cb1df8c986305c2cc9948c2.tar.bz2
gsoc2013-evolution-f014ab82c81078d60cb1df8c986305c2cc9948c2.tar.lz
gsoc2013-evolution-f014ab82c81078d60cb1df8c986305c2cc9948c2.tar.xz
gsoc2013-evolution-f014ab82c81078d60cb1df8c986305c2cc9948c2.tar.zst
gsoc2013-evolution-f014ab82c81078d60cb1df8c986305c2cc9948c2.zip
Coding style and whitespace cleanups.
Diffstat (limited to 'widgets/text')
-rw-r--r--widgets/text/e-text-model.c21
-rw-r--r--widgets/text/e-text.c99
2 files changed, 64 insertions, 56 deletions
diff --git a/widgets/text/e-text-model.c b/widgets/text/e-text-model.c
index 10f32b1592..f079346b72 100644
--- a/widgets/text/e-text-model.c
+++ b/widgets/text/e-text-model.c
@@ -155,7 +155,6 @@ e_text_model_dispose (GObject *object)
{
ETextModel *model;
- g_return_if_fail (object != NULL);
g_return_if_fail (E_IS_TEXT_MODEL (object));
model = E_TEXT_MODEL (object);
@@ -300,7 +299,6 @@ e_text_model_real_delete (ETextModel *model, gint position, gint length)
void
e_text_model_changed (ETextModel *model)
{
- g_return_if_fail (model != NULL);
g_return_if_fail (E_IS_TEXT_MODEL (model));
/*
@@ -326,7 +324,6 @@ e_text_model_cancel_completion (ETextModel *model)
void
e_text_model_reposition (ETextModel *model, ETextModelReposFn fn, gpointer repos_data)
{
- g_return_if_fail (model != NULL);
g_return_if_fail (E_IS_TEXT_MODEL (model));
g_return_if_fail (fn != NULL);
@@ -338,7 +335,6 @@ e_text_model_reposition (ETextModel *model, ETextModelReposFn fn, gpointer repos
gint
e_text_model_validate_position (ETextModel *model, gint pos)
{
- g_return_val_if_fail (model != NULL, 0);
g_return_val_if_fail (E_IS_TEXT_MODEL (model), 0);
if (E_TEXT_MODEL_GET_CLASS (model)->validate_pos)
@@ -350,7 +346,6 @@ e_text_model_validate_position (ETextModel *model, gint pos)
const gchar *
e_text_model_get_text (ETextModel *model)
{
- g_return_val_if_fail (model != NULL, NULL);
g_return_val_if_fail (E_IS_TEXT_MODEL (model), NULL);
if (E_TEXT_MODEL_GET_CLASS (model)->get_text)
@@ -362,7 +357,6 @@ e_text_model_get_text (ETextModel *model)
gint
e_text_model_get_text_length (ETextModel *model)
{
- g_return_val_if_fail (model != NULL, 0);
g_return_val_if_fail (E_IS_TEXT_MODEL (model), 0);
if (E_TEXT_MODEL_GET_CLASS (model)->get_text_len (model)) {
@@ -388,7 +382,6 @@ e_text_model_get_text_length (ETextModel *model)
void
e_text_model_set_text (ETextModel *model, const gchar *text)
{
- g_return_if_fail (model != NULL);
g_return_if_fail (E_IS_TEXT_MODEL (model));
if (E_TEXT_MODEL_GET_CLASS (model)->set_text)
@@ -398,7 +391,6 @@ e_text_model_set_text (ETextModel *model, const gchar *text)
void
e_text_model_insert (ETextModel *model, gint position, const gchar *text)
{
- g_return_if_fail (model != NULL);
g_return_if_fail (E_IS_TEXT_MODEL (model));
if (text == NULL)
@@ -414,7 +406,6 @@ e_text_model_insert_length (ETextModel *model,
const gchar *text,
gint length)
{
- g_return_if_fail (model != NULL);
g_return_if_fail (E_IS_TEXT_MODEL (model));
g_return_if_fail (length >= 0);
@@ -428,7 +419,6 @@ e_text_model_insert_length (ETextModel *model,
void
e_text_model_prepend (ETextModel *model, const gchar *text)
{
- g_return_if_fail (model != NULL);
g_return_if_fail (E_IS_TEXT_MODEL (model));
if (text == NULL)
@@ -440,7 +430,6 @@ e_text_model_prepend (ETextModel *model, const gchar *text)
void
e_text_model_append (ETextModel *model, const gchar *text)
{
- g_return_if_fail (model != NULL);
g_return_if_fail (E_IS_TEXT_MODEL (model));
if (text == NULL)
@@ -454,7 +443,6 @@ e_text_model_delete (ETextModel *model, gint position, gint length)
{
gint txt_len;
- g_return_if_fail (model != NULL);
g_return_if_fail (E_IS_TEXT_MODEL (model));
g_return_if_fail (length >= 0);
@@ -472,7 +460,6 @@ e_text_model_delete (ETextModel *model, gint position, gint length)
gint
e_text_model_object_count (ETextModel *model)
{
- g_return_val_if_fail (model != NULL, 0);
g_return_val_if_fail (E_IS_TEXT_MODEL (model), 0);
if (E_TEXT_MODEL_GET_CLASS (model)->obj_count)
@@ -484,7 +471,6 @@ e_text_model_object_count (ETextModel *model)
const gchar *
e_text_model_get_nth_object (ETextModel *model, gint n, gint *len)
{
- g_return_val_if_fail (model != NULL, NULL);
g_return_val_if_fail (E_IS_TEXT_MODEL (model), NULL);
if (n < 0 || n >= e_text_model_object_count (model))
@@ -502,7 +488,6 @@ e_text_model_strdup_nth_object (ETextModel *model, gint n)
const gchar *obj;
gint len = 0;
- g_return_val_if_fail (model != NULL, NULL);
g_return_val_if_fail (E_IS_TEXT_MODEL (model), NULL);
obj = e_text_model_get_nth_object (model, n, &len);
@@ -523,7 +508,6 @@ e_text_model_get_nth_object_bounds (ETextModel *model, gint n, gint *start, gint
const gchar *txt = NULL, *obj = NULL;
gint len = 0;
- g_return_if_fail (model != NULL);
g_return_if_fail (E_IS_TEXT_MODEL (model));
txt = e_text_model_get_text (model);
@@ -540,7 +524,6 @@ e_text_model_get_nth_object_bounds (ETextModel *model, gint n, gint *start, gint
gint
e_text_model_get_object_at_offset (ETextModel *model, gint offset)
{
- g_return_val_if_fail (model != NULL, -1);
g_return_val_if_fail (E_IS_TEXT_MODEL (model), -1);
if (offset < 0 || offset >= e_text_model_get_text_length (model))
@@ -572,11 +555,11 @@ e_text_model_get_object_at_offset (ETextModel *model, gint offset)
gint
e_text_model_get_object_at_pointer (ETextModel *model, const gchar *s)
{
- g_return_val_if_fail (model != NULL, -1);
g_return_val_if_fail (E_IS_TEXT_MODEL (model), -1);
g_return_val_if_fail (s != NULL, -1);
- return e_text_model_get_object_at_offset (model, s - e_text_model_get_text (model));
+ return e_text_model_get_object_at_offset (
+ model, s - e_text_model_get_text (model));
}
void
diff --git a/widgets/text/e-text.c b/widgets/text/e-text.c
index 175eea65d7..fefc0a3317 100644
--- a/widgets/text/e-text.c
+++ b/widgets/text/e-text.c
@@ -1483,16 +1483,21 @@ e_text_draw (GnomeCanvasItem *item, cairo_t *cr,
else
state = GTK_STATE_ACTIVE;
- indices[0] = MIN (text->selection_start, text->selection_end);
- indices[1] = MAX (text->selection_start, text->selection_end);
+ indices[0] = MIN (
+ text->selection_start,
+ text->selection_end);
+ indices[1] = MAX (
+ text->selection_start,
+ text->selection_end);
/* convert these into byte indices */
- indices[0] = g_utf8_offset_to_pointer (text->text, indices[0]) - text->text;
- indices[1] = g_utf8_offset_to_pointer (text->text, indices[1]) - text->text;
+ indices[0] = g_utf8_offset_to_pointer (
+ text->text, indices[0]) - text->text;
+ indices[1] = g_utf8_offset_to_pointer (
+ text->text, indices[1]) - text->text;
- clip_region = gdk_pango_layout_get_clip_region (text->layout,
- xpos, ypos,
- indices, 1);
+ clip_region = gdk_pango_layout_get_clip_region (
+ text->layout, xpos, ypos, indices, 1);
gdk_cairo_region (cr, clip_region);
cairo_clip (cr);
cairo_region_destroy (clip_region);
@@ -1506,7 +1511,10 @@ e_text_draw (GnomeCanvasItem *item, cairo_t *cr,
} else {
if (text->show_cursor) {
PangoRectangle strong_pos, weak_pos;
- gchar *offs = g_utf8_offset_to_pointer (text->text, text->selection_start);
+ gchar *offs;
+
+ offs = g_utf8_offset_to_pointer (
+ text->text, text->selection_start);
pango_layout_get_cursor_pos (
text->layout, offs - text->text +
@@ -1867,7 +1875,10 @@ e_text_event (GnomeCanvasItem *item, GdkEvent *event)
/* Simulate a GdkEventButton here, so that we can
* call e_text_do_popup directly */
- GdkEventButton *button = (GdkEventButton *) gdk_event_new (GDK_BUTTON_PRESS);
+ GdkEventButton *button;
+
+ button = (GdkEventButton *)
+ gdk_event_new (GDK_BUTTON_PRESS);
button->time = event->key.time;
button->button = 0;
e_text_do_popup (text, button, 0);
@@ -1883,7 +1894,9 @@ e_text_event (GnomeCanvasItem *item, GdkEvent *event)
gint ret;
if (text->im_context &&
- gtk_im_context_filter_keypress (text->im_context, (GdkEventKey*) event)) {
+ gtk_im_context_filter_keypress (
+ text->im_context,
+ (GdkEventKey*) event)) {
text->need_im_reset = TRUE;
return 1;
}
@@ -1935,10 +1948,12 @@ e_text_event (GnomeCanvasItem *item, GdkEvent *event)
e_tep_event.button.time = button.time;
e_tep_event.button.state = button.state;
e_tep_event.button.button = button.button;
- e_tep_event.button.position = get_position_from_xy (text, button.x, button.y);
+ e_tep_event.button.position =
+ get_position_from_xy (
+ text, button.x, button.y);
_get_tep (text);
- return_val = e_text_event_processor_handle_event (text->tep,
- &e_tep_event);
+ return_val = e_text_event_processor_handle_event (
+ text->tep, &e_tep_event);
e_tep_event.type = GDK_BUTTON_RELEASE;
}
#else
@@ -1954,8 +1969,11 @@ 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) {
if (text->handle_popup) {
- e_text_do_popup (text, &(event->button),
- get_position_from_xy (text, event->button.x, event->button.y));
+ e_text_do_popup (
+ text, &(event->button),
+ get_position_from_xy (
+ text, event->button.x,
+ event->button.y));
return 1;
}
else {
@@ -1968,13 +1986,13 @@ e_text_event (GnomeCanvasItem *item, GdkEvent *event)
if (event->type == GDK_BUTTON_PRESS) {
if (text->dbl_timeout == 0 &&
text->tpl_timeout == 0) {
- text->dbl_timeout = g_timeout_add (200,
- _click,
- &(text->dbl_timeout));
+ text->dbl_timeout = g_timeout_add (
+ 200, _click, &(text->dbl_timeout));
} else {
if (text->tpl_timeout == 0) {
e_tep_event.type = GDK_2BUTTON_PRESS;
- text->tpl_timeout = g_timeout_add (200, _click, &(text->tpl_timeout));
+ text->tpl_timeout = g_timeout_add (
+ 200, _click, &(text->tpl_timeout));
} else {
e_tep_event.type = GDK_3BUTTON_PRESS;
}
@@ -1986,10 +2004,12 @@ e_text_event (GnomeCanvasItem *item, GdkEvent *event)
e_tep_event.button.time = button.time;
e_tep_event.button.state = button.state;
e_tep_event.button.button = button.button;
- e_tep_event.button.position = get_position_from_xy (text, button.x, button.y);
+ e_tep_event.button.position =
+ get_position_from_xy (
+ text, button.x, button.y);
_get_tep (text);
- return_val = e_text_event_processor_handle_event (text->tep,
- &e_tep_event);
+ return_val = e_text_event_processor_handle_event (
+ text->tep, &e_tep_event);
if (event->button.button == 1) {
if (event->type == GDK_BUTTON_PRESS)
text->button_down = TRUE;
@@ -2006,10 +2026,12 @@ e_text_event (GnomeCanvasItem *item, GdkEvent *event)
GdkEventMotion motion = event->motion;
e_tep_event.motion.time = motion.time;
e_tep_event.motion.state = motion.state;
- e_tep_event.motion.position = get_position_from_xy (text, motion.x, motion.y);
+ e_tep_event.motion.position =
+ get_position_from_xy (
+ text, motion.x, motion.y);
_get_tep (text);
- return_val = e_text_event_processor_handle_event (text->tep,
- &e_tep_event);
+ return_val = e_text_event_processor_handle_event (
+ text->tep, &e_tep_event);
text->lastx = motion.x;
text->lasty = motion.y;
text->last_state = motion.state;
@@ -2028,7 +2050,8 @@ e_text_event (GnomeCanvasItem *item, GdkEvent *event)
text->pointer_in = FALSE;
if (text->editing || text->draw_borders) {
if (!text->default_cursor_shown) {
- gdk_window_set_cursor (window, text->default_cursor);
+ gdk_window_set_cursor (
+ window, text->default_cursor);
text->default_cursor_shown = TRUE;
}
}
@@ -2329,18 +2352,17 @@ e_text_do_popup (EText *text, GdkEventButton *button, gint position)
{
PopupClosure *closure = g_new (PopupClosure, 1);
- closure->text = text;
- g_object_ref (closure->text);
+ closure->text = g_object_ref (text);
closure->button = (GdkEventButton *) gdk_event_copy ((GdkEvent *) button);
closure->position = position;
gtk_clipboard_request_contents (
-
- gtk_widget_get_clipboard (GTK_WIDGET (GNOME_CANVAS_ITEM (text)->canvas),
- GDK_SELECTION_CLIPBOARD),
- gdk_atom_intern ("TARGETS", FALSE),
- popup_targets_received,
- closure);
+ gtk_widget_get_clipboard (
+ GTK_WIDGET (GNOME_CANVAS_ITEM (text)->canvas),
+ GDK_SELECTION_CLIPBOARD),
+ gdk_atom_intern ("TARGETS", FALSE),
+ popup_targets_received,
+ closure);
}
static void
@@ -2430,7 +2452,8 @@ _get_updated_position (EText *text, gboolean direction)
length = g_utf8_strlen (text->text, -1);
- /* length checks to make sure we are not wandering off into nonexistant memory... */
+ /* length checks to make sure we are not wandering
+ * off into nonexistant memory... */
if ((text->selection_end >= length) && (TRUE == direction)) /* forward */
return length;
/* checking for -ve value wont hurt! */
@@ -2452,7 +2475,8 @@ _get_updated_position (EText *text, gboolean direction)
new_pos = text->selection_end;
while (1)
{
- /* check before moving forward/backwards if we have more chars to move or not */
+ /* check before moving forward/backwards
+ * if we have more chars to move or not */
if (TRUE == direction)
p = g_utf8_next_char (p);
else
@@ -2677,7 +2701,8 @@ _get_position (EText *text, ETextEventProcessorCommand *command)
to activate that object.
(Normally, double click == select word, which is why this is here.) */
- obj_num = e_text_model_get_object_at_offset (text->model, text->selection_start);
+ obj_num = e_text_model_get_object_at_offset (
+ text->model, text->selection_start);
if (obj_num != -1) {
e_text_model_activate_nth_object (text->model, obj_num);
new_pos = text->selection_start;