[gtksourceview] Fix coding style.
- From: Ignacio Casal Quinteiro <icq src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtksourceview] Fix coding style.
- Date: Mon, 29 Nov 2010 11:02:39 +0000 (UTC)
commit 94bffaf708059f0d4474cd48774285ac7cb757d7
Author: Ignacio Casal Quinteiro <icq gnome org>
Date: Mon Nov 29 12:02:26 2010 +0100
Fix coding style.
gtksourceview/gtksourcecompletioninfo.c | 237 +++++++++++++++----------------
1 files changed, 114 insertions(+), 123 deletions(-)
---
diff --git a/gtksourceview/gtksourcecompletioninfo.c b/gtksourceview/gtksourcecompletioninfo.c
index c35ef98..6c127c6 100644
--- a/gtksourceview/gtksourcecompletioninfo.c
+++ b/gtksourceview/gtksourcecompletioninfo.c
@@ -28,32 +28,24 @@
* This object can be used to show a calltip or help for the
.* current completion proposal.
*/
-
+
#include <gtksourceview/gtksourcecompletioninfo.h>
#include "gtksourcecompletionutils.h"
#include "gtksourceview-i18n.h"
-#ifndef MIN
-#define MIN (a, b) ((a) < (b) ? (a) : (b))
-#endif
-
-#ifndef MAX
-#define MAX (a, b) ((a) > (b) ? (a) : (b))
-#endif
-
struct _GtkSourceCompletionInfoPrivate
{
GtkWidget *scroll;
GtkWidget *widget;
-
+
gint max_height;
gint max_width;
-
- gboolean shrink_height;
- gboolean shrink_width;
-
+
guint idle_resize;
guint request_id;
+
+ guint shrink_height : 1;
+ guint shrink_width : 1;
};
/* Signals */
@@ -96,7 +88,7 @@ get_scrolled_window_sizing (GtkSourceCompletionInfo *info,
GtkAllocation allocation;
*border = gtk_container_get_border_width (GTK_CONTAINER (info));
-
+
scrollbar = gtk_scrolled_window_get_hscrollbar (GTK_SCROLLED_WINDOW (info->priv->scroll));
if (gtk_widget_get_visible (scrollbar))
@@ -128,7 +120,7 @@ window_resize (GtkSourceCompletionInfo *info)
GtkStyle *style = gtk_widget_get_style (GTK_WIDGET (info));
gtk_window_get_default_size (GTK_WINDOW (info), &width, &height);
-
+
if (info->priv->widget != NULL)
{
/* Try to resize to fit widget, if necessary */
@@ -148,10 +140,10 @@ window_resize (GtkSourceCompletionInfo *info)
{
height = MIN (req.height + style->ythickness * 2, info->priv->max_height);
}
-
+
height += off + hscroll;
}
-
+
if (info->priv->shrink_width)
{
if (info->priv->max_width == -1)
@@ -162,11 +154,11 @@ window_resize (GtkSourceCompletionInfo *info)
{
width = MIN (req.width + style->xthickness * 2, info->priv->max_width);
}
-
+
width += off + vscroll;
}
}
-
+
gtk_window_resize (GTK_WINDOW (info), width, height);
}
@@ -174,14 +166,14 @@ static void
gtk_source_completion_info_init (GtkSourceCompletionInfo *info)
{
info->priv = GTK_SOURCE_COMPLETION_INFO_GET_PRIVATE (info);
-
+
/* Tooltip style */
gtk_window_set_title (GTK_WINDOW (info), _("Completion Info"));
gtk_widget_set_name (GTK_WIDGET (info), "gtk-tooltip");
gtk_widget_ensure_style (GTK_WIDGET (info));
-
+
gtk_window_set_type_hint (GTK_WINDOW (info),
- GDK_WINDOW_TYPE_HINT_NORMAL);
+ GDK_WINDOW_TYPE_HINT_NORMAL);
gtk_window_set_default_size (GTK_WINDOW (info), 300, 200);
gtk_container_set_border_width (GTK_CONTAINER (info), 1);
@@ -191,7 +183,7 @@ static gboolean
idle_resize (GtkSourceCompletionInfo *info)
{
info->priv->idle_resize = 0;
-
+
window_resize (info);
return FALSE;
}
@@ -206,13 +198,13 @@ queue_resize (GtkSourceCompletionInfo *info)
}
static void
-gtk_source_completion_info_get_property (GObject *object,
- guint prop_id,
- GValue *value,
+gtk_source_completion_info_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
GParamSpec *pspec)
{
GtkSourceCompletionInfo *info = GTK_SOURCE_COMPLETION_INFO (object);
-
+
switch (prop_id)
{
case PROP_MAX_WIDTH:
@@ -234,13 +226,13 @@ gtk_source_completion_info_get_property (GObject *object,
}
static void
-gtk_source_completion_info_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
+gtk_source_completion_info_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
GParamSpec *pspec)
{
GtkSourceCompletionInfo *info = GTK_SOURCE_COMPLETION_INFO (object);
-
+
switch (prop_id)
{
case PROP_MAX_WIDTH:
@@ -269,12 +261,12 @@ static void
gtk_source_completion_info_finalize (GObject *object)
{
GtkSourceCompletionInfo *info = GTK_SOURCE_COMPLETION_INFO (object);
-
+
if (info->priv->idle_resize != 0)
{
g_source_remove (info->priv->idle_resize);
}
-
+
G_OBJECT_CLASS (gtk_source_completion_info_parent_class)->finalize (object);
}
@@ -283,8 +275,8 @@ gtk_source_completion_info_show (GtkWidget *widget)
{
/* First emit BEFORE_SHOW and then chain up */
g_signal_emit (widget, signals[BEFORE_SHOW], 0);
-
- GTK_WIDGET_CLASS (gtk_source_completion_info_parent_class)->show (widget);
+
+ GTK_WIDGET_CLASS (gtk_source_completion_info_parent_class)->show (widget);
}
static gboolean
@@ -294,14 +286,14 @@ gtk_source_completion_info_draw (GtkWidget *widget,
GTK_WIDGET_CLASS (gtk_source_completion_info_parent_class)->draw (widget, cr);
gtk_paint_shadow (gtk_widget_get_style (widget),
- cr,
- GTK_STATE_NORMAL,
- GTK_SHADOW_OUT,
- widget,
- NULL,
- 0, 0,
- gtk_widget_get_allocated_width (widget),
- gtk_widget_get_allocated_height (widget));
+ cr,
+ GTK_STATE_NORMAL,
+ GTK_SHADOW_OUT,
+ widget,
+ NULL,
+ 0, 0,
+ gtk_widget_get_allocated_width (widget),
+ gtk_widget_get_allocated_height (widget));
return FALSE;
}
@@ -311,14 +303,14 @@ gtk_source_completion_info_class_init (GtkSourceCompletionInfoClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
-
+
object_class->get_property = gtk_source_completion_info_get_property;
object_class->set_property = gtk_source_completion_info_set_property;
object_class->finalize = gtk_source_completion_info_finalize;
-
+
widget_class->show = gtk_source_completion_info_show;
widget_class->draw = gtk_source_completion_info_draw;
-
+
/**
* GtkSourceCompletionInfo::show-info:
* @info: The #GscInf who emits the signal
@@ -329,53 +321,52 @@ gtk_source_completion_info_class_init (GtkSourceCompletionInfoClass *klass)
**/
signals[BEFORE_SHOW] =
g_signal_new ("before-show",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
- 0,
- NULL,
- NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE,
- 0);
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
+ 0,
+ NULL,
+ NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE,
+ 0);
/* Properties */
g_object_class_install_property (object_class,
- PROP_MAX_WIDTH,
- g_param_spec_int ("max-width",
- _("Maximum width"),
- _("The maximum allowed width"),
- -1,
- G_MAXINT,
- -1,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+ PROP_MAX_WIDTH,
+ g_param_spec_int ("max-width",
+ _("Maximum width"),
+ _("The maximum allowed width"),
+ -1,
+ G_MAXINT,
+ -1,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
g_object_class_install_property (object_class,
- PROP_MAX_HEIGHT,
- g_param_spec_int ("max-height",
- _("Maximum height"),
- _("The maximum allowed height"),
- -1,
- G_MAXINT,
- -1,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
-
+ PROP_MAX_HEIGHT,
+ g_param_spec_int ("max-height",
+ _("Maximum height"),
+ _("The maximum allowed height"),
+ -1,
+ G_MAXINT,
+ -1,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
g_object_class_install_property (object_class,
- PROP_SHRINK_WIDTH,
- g_param_spec_boolean ("shrink-width",
- _("Shrink width"),
- _("Whether the window should shrink width to fit the contents"),
- TRUE,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+ PROP_SHRINK_WIDTH,
+ g_param_spec_boolean ("shrink-width",
+ _("Shrink width"),
+ _("Whether the window should shrink width to fit the contents"),
+ TRUE,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
g_object_class_install_property (object_class,
- PROP_SHRINK_HEIGHT,
- g_param_spec_boolean ("shrink-height",
- _("Shrink height"),
- _("Whether the window should shrink height to fit the contents"),
- TRUE,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
-
+ PROP_SHRINK_HEIGHT,
+ g_param_spec_boolean ("shrink-height",
+ _("Shrink height"),
+ _("Whether the window should shrink height to fit the contents"),
+ TRUE,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+
g_type_class_add_private (object_class, sizeof (GtkSourceCompletionInfoPrivate));
}
@@ -387,8 +378,8 @@ gtk_source_completion_info_class_init (GtkSourceCompletionInfoClass *klass)
GtkSourceCompletionInfo *
gtk_source_completion_info_new (void)
{
- return g_object_new (GTK_TYPE_SOURCE_COMPLETION_INFO,
- "type", GTK_WINDOW_POPUP,
+ return g_object_new (GTK_TYPE_SOURCE_COMPLETION_INFO,
+ "type", GTK_WINDOW_POPUP,
NULL);
}
@@ -398,23 +389,23 @@ gtk_source_completion_info_new (void)
* @view: a #GtkTextView on which the info window should be positioned.
* @iter: (allow-none): a #GtkTextIter.
*
- * Moves the #GtkSourceCompletionInfo to @iter. If @iter is %NULL @info is
+ * Moves the #GtkSourceCompletionInfo to @iter. If @iter is %NULL @info is
* moved to the cursor position. Moving will respect the #GdkGravity setting
* of the info window and will ensure the line at @iter is not occluded by
* the window.
*/
void
gtk_source_completion_info_move_to_iter (GtkSourceCompletionInfo *info,
- GtkTextView *view,
- GtkTextIter *iter)
+ GtkTextView *view,
+ GtkTextIter *iter)
{
GtkTextBuffer *buffer;
GtkTextMark *insert_mark;
GtkTextIter start;
-
+
g_return_if_fail (GTK_IS_SOURCE_COMPLETION_INFO (info));
g_return_if_fail (GTK_IS_SOURCE_VIEW (view));
-
+
if (iter == NULL)
{
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
@@ -425,10 +416,10 @@ gtk_source_completion_info_move_to_iter (GtkSourceCompletionInfo *info,
{
start = *iter;
}
-
+
gtk_source_completion_utils_move_to_iter (GTK_WINDOW (info),
- GTK_SOURCE_VIEW (view),
- &start);
+ GTK_SOURCE_VIEW (view),
+ &start);
}
/**
@@ -448,10 +439,10 @@ gtk_source_completion_info_move_to_iter (GtkSourceCompletionInfo *info,
*/
void
gtk_source_completion_info_set_sizing (GtkSourceCompletionInfo *info,
- gint width,
- gint height,
- gboolean shrink_width,
- gboolean shrink_height)
+ gint width,
+ gint height,
+ gboolean shrink_width,
+ gboolean shrink_height)
{
g_return_if_fail (GTK_IS_SOURCE_COMPLETION_INFO (info));
@@ -467,7 +458,7 @@ gtk_source_completion_info_set_sizing (GtkSourceCompletionInfo *info,
info->priv->max_height = height;
info->priv->shrink_width = shrink_width;
info->priv->shrink_height = shrink_height;
-
+
queue_resize (info);
}
@@ -475,9 +466,9 @@ static gboolean
needs_viewport (GtkWidget *widget)
{
guint id;
-
+
id = g_signal_lookup ("set-scroll-adjustments", G_TYPE_FROM_INSTANCE (widget));
-
+
return id == 0;
}
@@ -496,7 +487,7 @@ use_scrolled_window (GtkSourceCompletionInfo *info,
GtkRequisition req;
gint mw;
gint mh;
-
+
mw = info->priv->max_width;
mh = info->priv->max_height;
gtk_widget_get_preferred_size (widget, &req, NULL);
@@ -510,10 +501,9 @@ create_scrolled_window (GtkSourceCompletionInfo *info)
/* Create scrolled window main widget */
info->priv->scroll = gtk_scrolled_window_new (NULL, NULL);
-
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (info->priv->scroll),
- GTK_POLICY_AUTOMATIC,
- GTK_POLICY_AUTOMATIC);
+ GTK_POLICY_AUTOMATIC,
+ GTK_POLICY_AUTOMATIC);
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (info->priv->scroll),
GTK_SHADOW_NONE);
@@ -532,7 +522,7 @@ create_scrolled_window (GtkSourceCompletionInfo *info)
*/
void
gtk_source_completion_info_set_widget (GtkSourceCompletionInfo *info,
- GtkWidget *widget)
+ GtkWidget *widget)
{
GtkWidget *child;
@@ -543,11 +533,11 @@ gtk_source_completion_info_set_widget (GtkSourceCompletionInfo *info,
{
return;
}
-
+
if (info->priv->widget != NULL)
{
g_signal_handler_disconnect (info->priv->widget, info->priv->request_id);
-
+
gtk_container_remove (GTK_CONTAINER (gtk_widget_get_parent (info->priv->widget)),
info->priv->widget);
@@ -557,9 +547,9 @@ gtk_source_completion_info_set_widget (GtkSourceCompletionInfo *info,
info->priv->scroll = NULL;
}
}
-
+
info->priv->widget = widget;
-
+
if (widget != NULL)
{
/* Keep it alive */
@@ -567,18 +557,19 @@ gtk_source_completion_info_set_widget (GtkSourceCompletionInfo *info,
{
g_object_ref (widget);
}
-
- info->priv->request_id = g_signal_connect_after (widget,
- "size-request",
- G_CALLBACK (widget_size_request_cb),
- info);
-
+
+ info->priv->request_id =
+ g_signal_connect_after (widget,
+ "size-request",
+ G_CALLBACK (widget_size_request_cb),
+ info);
+
/* See if it needs a viewport */
if (use_scrolled_window (info, widget))
{
create_scrolled_window (info);
child = widget;
-
+
if (needs_viewport (widget))
{
child = gtk_viewport_new (NULL, NULL);
@@ -587,14 +578,14 @@ gtk_source_completion_info_set_widget (GtkSourceCompletionInfo *info,
gtk_container_add (GTK_CONTAINER (child), widget);
}
-
+
gtk_container_add (GTK_CONTAINER (info->priv->scroll), child);
}
else
{
gtk_container_add (GTK_CONTAINER (info), widget);
}
-
+
gtk_widget_show (widget);
}
@@ -621,9 +612,9 @@ void
gtk_source_completion_info_process_resize (GtkSourceCompletionInfo *info)
{
g_return_if_fail (GTK_IS_SOURCE_COMPLETION_INFO (info));
-
+
if (info->priv->idle_resize != 0)
+ {
window_resize (info);
+ }
}
-
-
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]