[gtksourceview] Fix GCC picky warnings, based on a patch by Philip Withnall.
- From: Paolo Borelli <pborelli src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gtksourceview] Fix GCC picky warnings, based on a patch by Philip Withnall.
- Date: Wed, 19 Aug 2009 10:30:03 +0000 (UTC)
commit b3bf2c7d38849b3f8d7b8bb38c68292744259c45
Author: Paolo Borelli <pborelli gnome org>
Date: Wed Aug 19 12:28:30 2009 +0200
Fix GCC picky warnings, based on a patch by Philip Withnall.
gtksourceview/gtksourcebuffer.c | 70 ++++++++++++++--------------
gtksourceview/gtksourcelanguage-parser-2.c | 10 ++--
gtksourceview/gtksourcelanguage.c | 3 +
gtksourceview/gtksourceprintcompositor.c | 13 +++--
gtksourceview/gtksourceundomanager.c | 10 ++--
gtksourceview/gtksourceview.c | 46 ++++++++++---------
tests/test-widget.c | 58 +++++++++++++----------
7 files changed, 110 insertions(+), 100 deletions(-)
---
diff --git a/gtksourceview/gtksourcebuffer.c b/gtksourceview/gtksourcebuffer.c
index f18871a..dfe2923 100644
--- a/gtksourceview/gtksourcebuffer.c
+++ b/gtksourceview/gtksourcebuffer.c
@@ -1387,7 +1387,7 @@ gtk_source_buffer_get_style_scheme (GtkSourceBuffer *buffer)
static gboolean
source_mark_remove (GtkSourceBuffer *buffer, GtkSourceMark *mark)
{
- gint i;
+ guint i;
for (i = 0; i < buffer->priv->source_marks->len; ++i)
{
@@ -1459,27 +1459,27 @@ static void
source_mark_insert (GtkSourceBuffer *buffer, GtkSourceMark *mark)
{
GtkTextIter iter;
- gint index, cmp;
+ gint idx, cmp;
gtk_text_buffer_get_iter_at_mark (GTK_TEXT_BUFFER (buffer),
&iter,
GTK_TEXT_MARK (mark));
- index = source_mark_bsearch (buffer, &iter, &cmp);
- if (index >= 0)
+ idx = source_mark_bsearch (buffer, &iter, &cmp);
+ if (idx >= 0)
{
/* if the mark we found is at same iter or before
* put our mark after that */
if (cmp >= 0)
- index++;
+ idx++;
}
else
{
- index = 0;
+ idx = 0;
}
g_object_ref (mark);
- g_array_insert_val (buffer->priv->source_marks, index, mark);
+ g_array_insert_val (buffer->priv->source_marks, idx, mark);
}
static void
@@ -1575,7 +1575,7 @@ _gtk_source_buffer_source_mark_next (GtkSourceBuffer *buffer,
const gchar *category)
{
GtkTextIter iter;
- gint index, cmp;
+ gint idx, cmp;
g_return_val_if_fail (GTK_IS_SOURCE_BUFFER (buffer), NULL);
@@ -1586,23 +1586,23 @@ _gtk_source_buffer_source_mark_next (GtkSourceBuffer *buffer,
&iter,
GTK_TEXT_MARK (mark));
- index = source_mark_bsearch (buffer, &iter, &cmp);
+ idx = source_mark_bsearch (buffer, &iter, &cmp);
/* the array should already contain @mark */
- g_return_val_if_fail (index >= 0, NULL);
+ g_return_val_if_fail (idx >= 0, NULL);
g_return_val_if_fail (cmp == 0, NULL);
/* move up to our mark among the ones at this position */
- while (mark != g_array_index (buffer->priv->source_marks, GtkSourceMark *, index))
+ while (mark != g_array_index (buffer->priv->source_marks, GtkSourceMark *, idx))
{
- ++index;
+ ++idx;
}
- while (++index < buffer->priv->source_marks->len)
+ while ((guint) ++idx < buffer->priv->source_marks->len)
{
GtkSourceMark *ret;
- ret = g_array_index (buffer->priv->source_marks, GtkSourceMark *, index);
+ ret = g_array_index (buffer->priv->source_marks, GtkSourceMark *, idx);
if (category == NULL ||
0 == strcmp (category, gtk_source_mark_get_category (ret)))
{
@@ -1619,7 +1619,7 @@ _gtk_source_buffer_source_mark_prev (GtkSourceBuffer *buffer,
const gchar *category)
{
GtkTextIter iter;
- gint index, cmp;
+ gint idx, cmp;
g_return_val_if_fail (GTK_IS_SOURCE_BUFFER (buffer), NULL);
@@ -1630,23 +1630,23 @@ _gtk_source_buffer_source_mark_prev (GtkSourceBuffer *buffer,
&iter,
GTK_TEXT_MARK (mark));
- index = source_mark_bsearch (buffer, &iter, &cmp);
+ idx = source_mark_bsearch (buffer, &iter, &cmp);
/* the array should already contain @mark */
- g_return_val_if_fail (index >= 0, NULL);
+ g_return_val_if_fail (idx >= 0, NULL);
g_return_val_if_fail (cmp == 0, NULL);
/* move up to our mark among the ones at this position */
- while (mark != g_array_index (buffer->priv->source_marks, GtkSourceMark *, index))
+ while (mark != g_array_index (buffer->priv->source_marks, GtkSourceMark *, idx))
{
- ++index;
+ ++idx;
}
- while (--index >= 0)
+ while (--idx >= 0)
{
GtkSourceMark *ret;
- ret = g_array_index (buffer->priv->source_marks, GtkSourceMark *, index);
+ ret = g_array_index (buffer->priv->source_marks, GtkSourceMark *, idx);
if (category == NULL ||
0 == strcmp (category, gtk_source_mark_get_category (ret)))
{
@@ -1677,25 +1677,25 @@ gtk_source_buffer_forward_iter_to_source_mark (GtkSourceBuffer *buffer,
const gchar *category)
{
GtkTextIter i;
- gint index, cmp;
+ gint idx, cmp;
g_return_val_if_fail (GTK_IS_SOURCE_BUFFER (buffer), FALSE);
g_return_val_if_fail (iter != NULL, FALSE);
i = *iter;
- index = source_mark_bsearch (buffer, &i, &cmp);
- if (index < 0)
+ idx = source_mark_bsearch (buffer, &i, &cmp);
+ if (idx < 0)
return FALSE;
if (cmp >= 0)
- ++index;
+ ++idx;
- while (index < buffer->priv->source_marks->len)
+ while ((guint) idx < buffer->priv->source_marks->len)
{
GtkSourceMark *mark;
- mark = g_array_index (buffer->priv->source_marks, GtkSourceMark *, index);
+ mark = g_array_index (buffer->priv->source_marks, GtkSourceMark *, idx);
if (category == NULL ||
0 == strcmp (category, gtk_source_mark_get_category (mark)))
{
@@ -1710,7 +1710,7 @@ gtk_source_buffer_forward_iter_to_source_mark (GtkSourceBuffer *buffer,
}
}
- ++index;
+ ++idx;
}
return FALSE;
@@ -1736,25 +1736,25 @@ gtk_source_buffer_backward_iter_to_source_mark (GtkSourceBuffer *buffer,
const gchar *category)
{
GtkTextIter i;
- gint index, cmp;
+ gint idx, cmp;
g_return_val_if_fail (GTK_IS_SOURCE_BUFFER (buffer), FALSE);
g_return_val_if_fail (iter != NULL, FALSE);
i = *iter;
- index = source_mark_bsearch (buffer, &i, &cmp);
- if (index < 0)
+ idx = source_mark_bsearch (buffer, &i, &cmp);
+ if (idx < 0)
return FALSE;
if (cmp <= 0)
- --index;
+ --idx;
- while (index >= 0)
+ while (idx >= 0)
{
GtkSourceMark *mark;
- mark = g_array_index (buffer->priv->source_marks, GtkSourceMark *, index);
+ mark = g_array_index (buffer->priv->source_marks, GtkSourceMark *, idx);
if (category == NULL ||
0 == strcmp (category, gtk_source_mark_get_category (mark)))
{
@@ -1768,7 +1768,7 @@ gtk_source_buffer_backward_iter_to_source_mark (GtkSourceBuffer *buffer,
}
}
- --index;
+ --idx;
}
return FALSE;
diff --git a/gtksourceview/gtksourcelanguage-parser-2.c b/gtksourceview/gtksourcelanguage-parser-2.c
index abb6305..0cdfd05 100644
--- a/gtksourceview/gtksourcelanguage-parser-2.c
+++ b/gtksourceview/gtksourcelanguage-parser-2.c
@@ -251,14 +251,14 @@ static GRegexCompileFlags
get_regex_flags (xmlNode *node,
GRegexCompileFlags flags)
{
- xmlAttr *attribute;
+ xmlAttr *attr;
- for (attribute = node->properties; attribute != NULL; attribute = attribute->next)
+ for (attr = node->properties; attr != NULL; attr = attr->next)
{
- g_return_val_if_fail (attribute->children != NULL, flags);
+ g_return_val_if_fail (attr->children != NULL, flags);
- flags = update_regex_flags (flags, attribute->name,
- attribute->children->content);
+ flags = update_regex_flags (flags, attr->name,
+ attr->children->content);
}
return flags;
diff --git a/gtksourceview/gtksourcelanguage.c b/gtksourceview/gtksourcelanguage.c
index 2f340a8..09f123a 100644
--- a/gtksourceview/gtksourcelanguage.c
+++ b/gtksourceview/gtksourcelanguage.c
@@ -708,6 +708,9 @@ gtk_source_language_parse_file (GtkSourceLanguage *language)
case GTK_SOURCE_LANGUAGE_VERSION_2_0:
success = _gtk_source_language_file_parse_version2 (language, ctx_data);
break;
+
+ default:
+ g_assert_not_reached ();
}
if (!success)
diff --git a/gtksourceview/gtksourceprintcompositor.c b/gtksourceview/gtksourceprintcompositor.c
index baa851d..eb55101 100644
--- a/gtksourceview/gtksourceprintcompositor.c
+++ b/gtksourceview/gtksourceprintcompositor.c
@@ -2648,7 +2648,7 @@ gtk_source_print_compositor_paginate (GtkSourcePrintCompositor *compositor,
PangoRectangle logical_rect;
gboolean is_first_line = TRUE;
double part_height = 0;
- gint index;
+ gint idx;
layout_iter = pango_layout_get_iter (compositor->priv->layout);
@@ -2680,9 +2680,9 @@ gtk_source_print_compositor_paginate (GtkSourcePrintCompositor *compositor,
* may start in the middle of a line, so we have
* to add.
*/
- index = gtk_text_iter_get_line_index (&start);
- index += pango_layout_iter_get_index (layout_iter);
- gtk_text_iter_set_line_index (&start, index);
+ idx = gtk_text_iter_get_line_index (&start);
+ idx += pango_layout_iter_get_index (layout_iter);
+ gtk_text_iter_set_line_index (&start, idx);
pango_layout_iter_free (layout_iter);
@@ -3090,6 +3090,7 @@ gtk_source_print_compositor_draw_page (GtkSourcePrintCompositor *compositor,
g_return_if_fail (GTK_IS_SOURCE_PRINT_COMPOSITOR (compositor));
g_return_if_fail (GTK_IS_PRINT_CONTEXT (context));
+ g_return_if_fail (page_nr >= 0);
compositor->priv->current_page = page_nr;
@@ -3162,13 +3163,13 @@ gtk_source_print_compositor_draw_page (GtkSourcePrintCompositor *compositor,
g_return_if_fail (compositor->priv->buffer != NULL);
g_return_if_fail (compositor->priv->pages != NULL);
- g_return_if_fail (page_nr < compositor->priv->pages->len);
+ g_return_if_fail ((guint) page_nr < compositor->priv->pages->len);
offset = g_array_index (compositor->priv->pages, int, page_nr);
gtk_text_buffer_get_iter_at_offset (GTK_TEXT_BUFFER (compositor->priv->buffer),
&start, offset);
- if (page_nr + 1 < compositor->priv->pages->len)
+ if ((guint) page_nr + 1 < compositor->priv->pages->len)
{
offset = g_array_index (compositor->priv->pages, int, page_nr + 1);
gtk_text_buffer_get_iter_at_offset (GTK_TEXT_BUFFER (compositor->priv->buffer),
diff --git a/gtksourceview/gtksourceundomanager.c b/gtksourceview/gtksourceundomanager.c
index 9d919e5..b1abd3b 100644
--- a/gtksourceview/gtksourceundomanager.c
+++ b/gtksourceview/gtksourceundomanager.c
@@ -141,8 +141,6 @@ enum {
G_DEFINE_TYPE (GtkSourceUndoManager, gtk_source_undo_manager, G_TYPE_OBJECT)
-static void gtk_source_undo_manager_class_init (GtkSourceUndoManagerClass *klass);
-static void gtk_source_undo_manager_init (GtkSourceUndoManager *um);
static void gtk_source_undo_manager_finalize (GObject *object);
static void gtk_source_undo_manager_insert_text_handler (GtkTextBuffer *buffer,
@@ -1071,7 +1069,7 @@ gtk_source_undo_manager_modified_changed_handler (GtkTextBuffer *buffer,
GtkSourceUndoManager *um)
{
GtkSourceUndoAction *action;
- gint index;
+ gint idx;
g_return_if_fail (GTK_SOURCE_IS_UNDO_MANAGER (um));
g_return_if_fail (um->priv != NULL);
@@ -1079,8 +1077,8 @@ gtk_source_undo_manager_modified_changed_handler (GtkTextBuffer *buffer,
if (um->priv->actions->len == 0)
return;
- index = um->priv->next_redo + 1;
- action = action_list_nth_data (um->priv->actions, index);
+ idx = um->priv->next_redo + 1;
+ action = action_list_nth_data (um->priv->actions, idx);
if (gtk_text_buffer_get_modified (buffer) == FALSE)
{
@@ -1119,7 +1117,7 @@ gtk_source_undo_manager_modified_changed_handler (GtkTextBuffer *buffer,
while (action->order_in_group > 1)
{
- action = action_list_nth_data (um->priv->actions, ++index);
+ action = action_list_nth_data (um->priv->actions, ++idx);
g_return_if_fail (action != NULL);
}
diff --git a/gtksourceview/gtksourceview.c b/gtksourceview/gtksourceview.c
index 3da074f..a2d7c82 100644
--- a/gtksourceview/gtksourceview.c
+++ b/gtksourceview/gtksourceview.c
@@ -222,7 +222,7 @@ static void view_dnd_drop (GtkTextView *view,
gint y,
GtkSelectionData *selection_data,
guint info,
- guint time,
+ guint timestamp,
gpointer data);
static gint calculate_real_tab_width (GtkSourceView *view,
@@ -869,7 +869,7 @@ get_mark_category_pixbuf (GtkSourceView *view,
switch (cat->icon_type)
{
case ICON_TYPE_NONE:
- break;
+ break;
case ICON_TYPE_PIXBUF:
if (cat->icon_pixbuf == NULL)
{
@@ -888,19 +888,21 @@ get_mark_category_pixbuf (GtkSourceView *view,
size,
GDK_INTERP_BILINEAR);
}
- break;
+ break;
case ICON_TYPE_STOCK:
cat->cached_icon = get_icon_from_stock (view,
cat->icon_stock,
size);
- break;
+ break;
case ICON_TYPE_NAME:
cat->cached_icon = get_icon_from_name (view,
cat->icon_name,
size);
- break;
+ break;
+ default:
+ g_return_val_if_reached (NULL);
}
-
+
return cat->cached_icon;
}
@@ -1035,8 +1037,9 @@ line_renderer_data_func (GtkSourceGutter *gutter,
gboolean current_line,
GtkSourceView *view)
{
- gchar *text;
int weight;
+ gchar *text;
+ GtkStyle *style;
if (current_line && gtk_text_view_get_cursor_visible (GTK_TEXT_VIEW (view)))
{
@@ -1058,9 +1061,8 @@ line_renderer_data_func (GtkSourceGutter *gutter,
"mode", GTK_CELL_RENDERER_MODE_ACTIVATABLE,
NULL);
- GtkStyle *style = gtk_widget_get_style (GTK_WIDGET (view));
-
- if (style)
+ style = gtk_widget_get_style (GTK_WIDGET (view));
+ if (style != NULL)
{
g_object_set (G_OBJECT (renderer),
"foreground-gdk", &style->fg[GTK_STATE_NORMAL],
@@ -1886,10 +1888,10 @@ static void
menu_item_activate_cb (GtkWidget *menu_item,
GtkTextView *text_view)
{
- const gchar *signal;
+ const gchar *gtksignal;
- signal = g_object_get_data (G_OBJECT (menu_item), "gtk-signal");
- g_signal_emit_by_name (G_OBJECT (text_view), signal);
+ gtksignal = g_object_get_data (G_OBJECT (menu_item), "gtk-signal");
+ g_signal_emit_by_name (G_OBJECT (text_view), gtksignal);
}
/* This function is taken from gtk+/tests/testtext.c */
@@ -3392,16 +3394,16 @@ compute_indentation (GtkSourceView *view,
return gtk_text_iter_get_slice (&start, &end);
}
-static gint
+static guint
get_real_indent_width (GtkSourceView *view)
{
return view->priv->indent_width < 0 ?
view->priv->tab_width :
- view->priv->indent_width;
+ (guint) view->priv->indent_width;
}
static gchar *
-get_indent_string (gint tabs, gint spaces)
+get_indent_string (guint tabs, guint spaces)
{
gchar *str;
@@ -3421,8 +3423,8 @@ indent_lines (GtkSourceView *view, GtkTextIter *start, GtkTextIter *end)
GtkTextBuffer *buf;
gint start_line, end_line;
gchar *tab_buffer = NULL;
- gint tabs = 0;
- gint spaces = 0;
+ guint tabs = 0;
+ guint spaces = 0;
gint i;
buf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
@@ -3444,7 +3446,7 @@ indent_lines (GtkSourceView *view, GtkTextIter *start, GtkTextIter *end)
}
else if (view->priv->indent_width > 0)
{
- gint indent_width;
+ guint indent_width;
indent_width = get_real_indent_width (view);
spaces = indent_width % view->priv->tab_width;
@@ -3464,7 +3466,7 @@ indent_lines (GtkSourceView *view, GtkTextIter *start, GtkTextIter *end)
{
GtkTextIter iter;
GtkTextIter iter2;
- gint replaced_spaces = 0;
+ guint replaced_spaces = 0;
gtk_text_buffer_get_iter_at_line (buf, &iter, i);
@@ -3494,7 +3496,7 @@ indent_lines (GtkSourceView *view, GtkTextIter *start, GtkTextIter *end)
if (replaced_spaces > 0)
{
gchar *indent_buf;
- gint t, s;
+ guint t, s;
t = tabs + (spaces + replaced_spaces) / view->priv->tab_width;
s = (spaces + replaced_spaces) % view->priv->tab_width;
@@ -4028,7 +4030,7 @@ view_dnd_drop (GtkTextView *view,
gint y,
GtkSelectionData *selection_data,
guint info,
- guint time,
+ guint timestamp,
gpointer data)
{
diff --git a/tests/test-widget.c b/tests/test-widget.c
index 66e9c50..5e7d527 100644
--- a/tests/test-widget.c
+++ b/tests/test-widget.c
@@ -106,15 +106,15 @@ static GtkActionEntry buffer_action_entries[] = {
};
static GtkActionEntry view_action_entries[] = {
- { "FileMenu", NULL, "_File" },
+ { "FileMenu", NULL, "_File", NULL, NULL, NULL },
{ "Print", GTK_STOCK_PRINT, "_Print", "<control>P",
"Print the current file", G_CALLBACK (print_file_cb) },
- { "ViewMenu", NULL, "_View" },
+ { "ViewMenu", NULL, "_View", NULL, NULL, NULL },
{ "NewView", GTK_STOCK_NEW, "_New View", NULL,
"Create a new view of the file", G_CALLBACK (new_view_cb) },
- { "TabWidth", NULL, "_Tab Width" },
- { "IndentWidth", NULL, "I_ndent Width" },
- { "SmartHomeEnd", NULL, "_Smart Home/End" },
+ { "TabWidth", NULL, "_Tab Width", NULL, NULL, NULL },
+ { "IndentWidth", NULL, "I_ndent Width", NULL, NULL, NULL },
+ { "SmartHomeEnd", NULL, "_Smart Home/End", NULL, NULL, NULL },
{ "Find", GTK_STOCK_FIND, "_Find", "<control>F",
"Find", G_CALLBACK (find_cb) },
{ "Replace", GTK_STOCK_FIND_AND_REPLACE, "Search and _Replace", "<control>R",
@@ -1175,6 +1175,32 @@ mark_tooltip_func (GtkSourceMark *mark,
return g_strdup_printf ("<b>Line</b>: %d\n<i>Column</i>: %d", line, column);
}
+static void
+add_source_mark_pixbufs (GtkSourceView *view)
+{
+ GdkColor color;
+
+ gdk_color_parse ("lightgreen", &color);
+ gtk_source_view_set_mark_category_background (view, MARK_TYPE_1, &color);
+ gtk_source_view_set_mark_category_icon_from_stock (view, MARK_TYPE_1, GTK_STOCK_YES);
+ gtk_source_view_set_mark_category_priority (view, MARK_TYPE_1, 1);
+ gtk_source_view_set_mark_category_tooltip_func (view,
+ MARK_TYPE_1,
+ mark_tooltip_func,
+ NULL,
+ NULL);
+
+ gdk_color_parse ("pink", &color);
+ gtk_source_view_set_mark_category_background (view, MARK_TYPE_2, &color);
+ gtk_source_view_set_mark_category_icon_from_stock (view, MARK_TYPE_2, GTK_STOCK_NO);
+ gtk_source_view_set_mark_category_priority (view, MARK_TYPE_2, 2);
+ gtk_source_view_set_mark_category_tooltip_markup_func (view,
+ MARK_TYPE_2,
+ mark_tooltip_func,
+ NULL,
+ NULL);
+}
+
static GtkWidget *
create_view_window (GtkSourceBuffer *buffer, GtkSourceView *from)
{
@@ -1314,27 +1340,7 @@ create_view_window (GtkSourceBuffer *buffer, GtkSourceView *from)
g_free (tmp);
}
- /* add source mark pixbufs */
- GdkColor color;
- gdk_color_parse ("lightgreen", &color);
- gtk_source_view_set_mark_category_background (GTK_SOURCE_VIEW (view), MARK_TYPE_1, &color);
- gtk_source_view_set_mark_category_icon_from_stock (GTK_SOURCE_VIEW (view), MARK_TYPE_1, GTK_STOCK_YES);
- gtk_source_view_set_mark_category_priority (GTK_SOURCE_VIEW (view), MARK_TYPE_1, 1);
- gtk_source_view_set_mark_category_tooltip_func (GTK_SOURCE_VIEW (view),
- MARK_TYPE_1,
- mark_tooltip_func,
- NULL,
- NULL);
-
- gdk_color_parse ("pink", &color);
- gtk_source_view_set_mark_category_background (GTK_SOURCE_VIEW (view), MARK_TYPE_2, &color);
- gtk_source_view_set_mark_category_icon_from_stock (GTK_SOURCE_VIEW (view), MARK_TYPE_2, GTK_STOCK_NO);
- gtk_source_view_set_mark_category_priority (GTK_SOURCE_VIEW (view), MARK_TYPE_2, 2);
- gtk_source_view_set_mark_category_tooltip_markup_func (GTK_SOURCE_VIEW (view),
- MARK_TYPE_2,
- mark_tooltip_func,
- NULL,
- NULL);
+ add_source_mark_pixbufs (GTK_SOURCE_VIEW (view));
gtk_widget_show_all (vbox);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]