[gedit/wip/view-cleanup] view: various small code improvements
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gedit/wip/view-cleanup] view: various small code improvements
- Date: Wed, 24 Jun 2015 13:13:27 +0000 (UTC)
commit 739575fc029d1fc6ddaff142b79d1c560ff0568c
Author: Sébastien Wilmet <swilmet gnome org>
Date: Wed Jun 24 15:08:46 2015 +0200
view: various small code improvements
gedit/gedit-view.c | 56 +++++++++++++++++++++++----------------------------
gedit/gedit-view.h | 21 ++----------------
2 files changed, 28 insertions(+), 49 deletions(-)
---
diff --git a/gedit/gedit-view.c b/gedit/gedit-view.c
index d2eccb6..ca668e9 100644
--- a/gedit/gedit-view.c
+++ b/gedit/gedit-view.c
@@ -60,14 +60,13 @@ struct _GeditViewPrivate
G_DEFINE_TYPE_WITH_PRIVATE (GeditView, gedit_view, GTK_SOURCE_TYPE_VIEW)
-/* Signals */
enum
{
DROP_URIS,
LAST_SIGNAL
};
-static guint view_signals [LAST_SIGNAL] = { 0 };
+static guint view_signals[LAST_SIGNAL] = { 0 };
static void
file_read_only_notify_handler (GtkSourceFile *file,
@@ -100,7 +99,7 @@ current_buffer_removed (GeditView *view)
static void
on_notify_buffer_cb (GeditView *view,
- GParamSpec *arg1,
+ GParamSpec *pspec,
gpointer userdata)
{
GtkTextBuffer *buffer;
@@ -110,7 +109,9 @@ on_notify_buffer_cb (GeditView *view,
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
if (buffer == NULL || !GEDIT_IS_DOCUMENT (buffer))
+ {
return;
+ }
file = gedit_document_get_file (GEDIT_DOCUMENT (buffer));
@@ -128,7 +129,7 @@ on_notify_buffer_cb (GeditView *view,
static void
gedit_view_init (GeditView *view)
{
- GtkTargetList *tl;
+ GtkTargetList *target_list;
gedit_debug (DEBUG_VIEW);
@@ -138,16 +139,16 @@ gedit_view_init (GeditView *view)
/* Drag and drop support */
view->priv->direct_save_uri = NULL;
- tl = gtk_drag_dest_get_target_list (GTK_WIDGET (view));
+ target_list = gtk_drag_dest_get_target_list (GTK_WIDGET (view));
- if (tl != NULL)
+ if (target_list != NULL)
{
- gtk_target_list_add (tl,
+ gtk_target_list_add (target_list,
gdk_atom_intern ("XdndDirectSave0", FALSE),
0,
TARGET_XDNDDIRECTSAVE);
- gtk_target_list_add_uri_targets (tl, TARGET_URI_LIST);
- gtk_target_list_add (tl,
+ gtk_target_list_add_uri_targets (target_list, TARGET_URI_LIST);
+ gtk_target_list_add (target_list,
gdk_atom_intern_static_string ("GTK_NOTEBOOK_TAB"),
GTK_TARGET_SAME_APP,
TARGET_TAB);
@@ -197,15 +198,14 @@ gedit_view_constructed (GObject *object)
view = GEDIT_VIEW (object);
priv = view->priv;
- /* Get setting values */
use_default_font = g_settings_get_boolean (view->priv->editor_settings,
GEDIT_SETTINGS_USE_DEFAULT_FONT);
- /*
- * Set tab, fonts, wrap mode, colors, etc. according
- * to preferences
- */
- if (!use_default_font)
+ if (use_default_font)
+ {
+ gedit_view_set_font (view, TRUE, NULL);
+ }
+ else
{
gchar *editor_font;
@@ -216,10 +216,6 @@ gedit_view_constructed (GObject *object)
g_free (editor_font);
}
- else
- {
- gedit_view_set_font (view, TRUE, NULL);
- }
g_settings_bind (priv->editor_settings,
GEDIT_SETTINGS_DISPLAY_LINE_NUMBERS,
@@ -281,21 +277,20 @@ gedit_view_constructed (GObject *object)
"smart-home-end",
G_SETTINGS_BIND_GET);
- g_object_set (G_OBJECT (view),
- "indent_on_tab", TRUE,
- NULL);
+ gtk_source_view_set_indent_on_tab (GTK_SOURCE_VIEW (view), TRUE);
G_OBJECT_CLASS (gedit_view_parent_class)->constructed (object);
}
-static gint
-gedit_view_focus_out (GtkWidget *widget, GdkEventFocus *event)
+static gboolean
+gedit_view_focus_out (GtkWidget *widget,
+ GdkEventFocus *event)
{
gtk_widget_queue_draw (widget);
GTK_WIDGET_CLASS (gedit_view_parent_class)->focus_out_event (widget, event);
- return FALSE;
+ return GDK_EVENT_PROPAGATE;
}
static GdkAtom
@@ -303,13 +298,13 @@ drag_get_uri_target (GtkWidget *widget,
GdkDragContext *context)
{
GdkAtom target;
- GtkTargetList *tl;
+ GtkTargetList *target_list;
- tl = gtk_target_list_new (NULL, 0);
- gtk_target_list_add_uri_targets (tl, 0);
+ target_list = gtk_target_list_new (NULL, 0);
+ gtk_target_list_add_uri_targets (target_list, 0);
- target = gtk_drag_dest_find_target (widget, context, tl);
- gtk_target_list_unref (tl);
+ target = gtk_drag_dest_find_target (widget, context, target_list);
+ gtk_target_list_unref (target_list);
return target;
}
@@ -771,7 +766,6 @@ gedit_view_class_init (GeditViewClass *klass)
*
* If the drag context has any other mime type, then pass the
* information onto the GtkTextView's standard handlers.
- * (widget_class->function_name).
*
* See bug #89881 for details
*/
diff --git a/gedit/gedit-view.h b/gedit/gedit-view.h
index ebf956e..2854122 100644
--- a/gedit/gedit-view.h
+++ b/gedit/gedit-view.h
@@ -30,9 +30,6 @@
G_BEGIN_DECLS
-/*
- * Type checking and casting macros
- */
#define GEDIT_TYPE_VIEW (gedit_view_get_type ())
#define GEDIT_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GEDIT_TYPE_VIEW, GeditView))
#define GEDIT_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GEDIT_TYPE_VIEW, GeditViewClass))
@@ -40,27 +37,18 @@ G_BEGIN_DECLS
#define GEDIT_IS_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GEDIT_TYPE_VIEW))
#define GEDIT_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GEDIT_TYPE_VIEW, GeditViewClass))
-/* Private structure type */
-typedef struct _GeditViewPrivate GeditViewPrivate;
-
-/*
- * Main object structure
- */
typedef struct _GeditView GeditView;
+typedef struct _GeditViewClass GeditViewClass;
+typedef struct _GeditViewPrivate GeditViewPrivate;
struct _GeditView
{
GtkSourceView view;
- /*< private > */
+ /*< private >*/
GeditViewPrivate *priv;
};
-/*
- * Class definition
- */
-typedef struct _GeditViewClass GeditViewClass;
-
struct _GeditViewClass
{
GtkSourceViewClass parent_class;
@@ -71,9 +59,6 @@ struct _GeditViewClass
gpointer padding;
};
-/*
- * Public methods
- */
GType gedit_view_get_type (void) G_GNUC_CONST;
GtkWidget *gedit_view_new (GeditDocument *doc);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]