[gtksourceview] Style scheme: small clean-up
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtksourceview] Style scheme: small clean-up
- Date: Tue, 20 Aug 2013 22:45:17 +0000 (UTC)
commit ff6b2a6ac28c70480cd592755d9d45bb5bc94ace
Author: Sébastien Wilmet <swilmet gnome org>
Date: Tue Aug 20 22:47:35 2013 +0200
Style scheme: small clean-up
gtksourceview/gtksourcestyle-private.h | 11 ++-
gtksourceview/gtksourcestyle.c | 54 ++++++++++++++++-
gtksourceview/gtksourcestylescheme.c | 5 +-
gtksourceview/gtksourcestylescheme.h | 87 ++++++++++++++++-----------
gtksourceview/gtksourcestyleschememanager.c | 3 +
gtksourceview/gtksourcestyleschememanager.h | 8 +--
6 files changed, 119 insertions(+), 49 deletions(-)
---
diff --git a/gtksourceview/gtksourcestyle-private.h b/gtksourceview/gtksourcestyle-private.h
index 70da550..59c9501 100644
--- a/gtksourceview/gtksourcestyle-private.h
+++ b/gtksourceview/gtksourcestyle-private.h
@@ -27,7 +27,8 @@
G_BEGIN_DECLS
-enum {
+enum
+{
GTK_SOURCE_STYLE_USE_LINE_BACKGROUND = 1 << 0, /*< nick=use_line_background >*/
GTK_SOURCE_STYLE_USE_BACKGROUND = 1 << 1, /*< nick=use_background >*/
GTK_SOURCE_STYLE_USE_FOREGROUND = 1 << 2, /*< nick=use_foreground >*/
@@ -40,12 +41,14 @@ enum {
struct _GtkSourceStyle
{
GObject base_instance;
- /* foreground and background are strings interned with
- * with g_intern_string(), so we don't need to copy/free
- * them. */
+
+ /* These fields are strings interned with g_intern_string(), so we don't
+ * need to copy/free them.
+ */
const gchar *foreground;
const gchar *background;
const gchar *line_background;
+
guint italic : 1;
guint bold : 1;
guint underline : 1;
diff --git a/gtksourceview/gtksourcestyle.c b/gtksourceview/gtksourcestyle.c
index b391fe2..cc753d2 100644
--- a/gtksourceview/gtksourcestyle.c
+++ b/gtksourceview/gtksourcestyle.c
@@ -37,6 +37,7 @@ static void gtk_source_style_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec);
+
static void gtk_source_style_get_property (GObject *object,
guint prop_id,
GValue *value,
@@ -44,7 +45,8 @@ static void gtk_source_style_get_property (GObject *object,
G_DEFINE_TYPE (GtkSourceStyle, gtk_source_style, G_TYPE_OBJECT)
-enum {
+enum
+{
PROP_0,
PROP_LINE_BACKGROUND,
PROP_LINE_BACKGROUND_SET,
@@ -266,14 +268,17 @@ gtk_source_style_set_property (GObject *object,
style->bold = g_value_get_boolean (value) != 0;
SET_MASK (style, BOLD);
break;
+
case PROP_ITALIC:
style->italic = g_value_get_boolean (value) != 0;
SET_MASK (style, ITALIC);
break;
+
case PROP_UNDERLINE:
style->underline = g_value_get_boolean (value) != 0;
SET_MASK (style, UNDERLINE);
break;
+
case PROP_STRIKETHROUGH:
style->strikethrough = g_value_get_boolean (value) != 0;
SET_MASK (style, STRIKETHROUGH);
@@ -282,21 +287,27 @@ gtk_source_style_set_property (GObject *object,
case PROP_FOREGROUND_SET:
MODIFY_MASK (style, value, FOREGROUND);
break;
+
case PROP_BACKGROUND_SET:
MODIFY_MASK (style, value, BACKGROUND);
break;
+
case PROP_LINE_BACKGROUND_SET:
MODIFY_MASK (style, value, LINE_BACKGROUND);
break;
+
case PROP_BOLD_SET:
MODIFY_MASK (style, value, BOLD);
break;
+
case PROP_ITALIC_SET:
MODIFY_MASK (style, value, ITALIC);
break;
+
case PROP_UNDERLINE_SET:
MODIFY_MASK (style, value, UNDERLINE);
break;
+
case PROP_STRIKETHROUGH_SET:
MODIFY_MASK (style, value, STRIKETHROUGH);
break;
@@ -320,21 +331,27 @@ gtk_source_style_get_property (GObject *object,
case PROP_FOREGROUND:
g_value_set_string (value, style->foreground);
break;
+
case PROP_BACKGROUND:
g_value_set_string (value, style->background);
break;
+
case PROP_LINE_BACKGROUND:
g_value_set_string (value, style->line_background);
break;
+
case PROP_BOLD:
g_value_set_boolean (value, style->bold);
break;
+
case PROP_ITALIC:
g_value_set_boolean (value, style->italic);
break;
+
case PROP_UNDERLINE:
g_value_set_boolean (value, style->underline);
break;
+
case PROP_STRIKETHROUGH:
g_value_set_boolean (value, style->strikethrough);
break;
@@ -342,21 +359,27 @@ gtk_source_style_get_property (GObject *object,
case PROP_FOREGROUND_SET:
GET_MASK (style, value, FOREGROUND);
break;
+
case PROP_BACKGROUND_SET:
GET_MASK (style, value, BACKGROUND);
break;
+
case PROP_LINE_BACKGROUND_SET:
GET_MASK (style, value, LINE_BACKGROUND);
break;
+
case PROP_BOLD_SET:
GET_MASK (style, value, BOLD);
break;
+
case PROP_ITALIC_SET:
GET_MASK (style, value, ITALIC);
break;
+
case PROP_UNDERLINE_SET:
GET_MASK (style, value, UNDERLINE);
break;
+
case PROP_STRIKETHROUGH_SET:
GET_MASK (style, value, STRIKETHROUGH);
break;
@@ -367,7 +390,6 @@ gtk_source_style_get_property (GObject *object,
}
}
-
/**
* gtk_source_style_copy:
* @style: a #GtkSourceStyle structure to copy.
@@ -424,39 +446,67 @@ _gtk_source_style_apply (const GtkSourceStyle *style,
g_object_freeze_notify (G_OBJECT (tag));
if (style->mask & GTK_SOURCE_STYLE_USE_BACKGROUND)
+ {
g_object_set (tag, "background", style->background, NULL);
+ }
else
+ {
g_object_set (tag, "background-set", FALSE, NULL);
+ }
if (style->mask & GTK_SOURCE_STYLE_USE_FOREGROUND)
+ {
g_object_set (tag, "foreground", style->foreground, NULL);
+ }
else
+ {
g_object_set (tag, "foreground-set", FALSE, NULL);
+ }
if (style->mask & GTK_SOURCE_STYLE_USE_LINE_BACKGROUND)
+ {
g_object_set (tag, "paragraph-background", style->line_background, NULL);
+ }
else
+ {
g_object_set (tag, "paragraph-background-set", FALSE, NULL);
+ }
if (style->mask & GTK_SOURCE_STYLE_USE_ITALIC)
+ {
g_object_set (tag, "style", style->italic ? PANGO_STYLE_ITALIC : PANGO_STYLE_NORMAL,
NULL);
+ }
else
+ {
g_object_set (tag, "style-set", FALSE, NULL);
+ }
if (style->mask & GTK_SOURCE_STYLE_USE_BOLD)
+ {
g_object_set (tag, "weight", style->bold ? PANGO_WEIGHT_BOLD : PANGO_WEIGHT_NORMAL,
NULL);
+ }
else
+ {
g_object_set (tag, "weight-set", FALSE, NULL);
+ }
if (style->mask & GTK_SOURCE_STYLE_USE_UNDERLINE)
+ {
g_object_set (tag, "underline", style->underline ? PANGO_UNDERLINE_SINGLE :
PANGO_UNDERLINE_NONE, NULL);
+ }
else
+ {
g_object_set (tag, "underline-set", FALSE, NULL);
+ }
if (style->mask & GTK_SOURCE_STYLE_USE_STRIKETHROUGH)
+ {
g_object_set (tag, "strikethrough", style->strikethrough != 0, NULL);
+ }
else
+ {
g_object_set (tag, "strikethrough-set", FALSE, NULL);
+ }
g_object_thaw_notify (G_OBJECT (tag));
}
diff --git a/gtksourceview/gtksourcestylescheme.c b/gtksourceview/gtksourcestylescheme.c
index a3789ae..4c55550 100644
--- a/gtksourceview/gtksourcestylescheme.c
+++ b/gtksourceview/gtksourcestylescheme.c
@@ -19,11 +19,12 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include "gtksourceview-i18n.h"
+#include "gtksourcestylescheme.h"
#include "gtksourcestyleschememanager.h"
+#include "gtksourcestyle-private.h"
#include "gtksourceview.h"
#include "gtksourcelanguage-private.h"
-#include "gtksourcestyle-private.h"
+#include "gtksourceview-i18n.h"
#include <libxml/parser.h>
#include <string.h>
diff --git a/gtksourceview/gtksourcestylescheme.h b/gtksourceview/gtksourcestylescheme.h
index fd66129..f7bbca0 100644
--- a/gtksourceview/gtksourcestylescheme.h
+++ b/gtksourceview/gtksourcestylescheme.h
@@ -52,41 +52,58 @@ struct _GtkSourceStyleSchemeClass
void (*_gtk_source_reserved2) (void);
};
-GType gtk_source_style_scheme_get_type (void) G_GNUC_CONST;
-
-GtkSourceStyleScheme *_gtk_source_style_scheme_new (const gchar *id,
- const gchar *name);
-
-const gchar *gtk_source_style_scheme_get_id (GtkSourceStyleScheme *scheme);
-const gchar *gtk_source_style_scheme_get_name (GtkSourceStyleScheme *scheme);
-const gchar *gtk_source_style_scheme_get_description(GtkSourceStyleScheme *scheme);
-
-const gchar * const * gtk_source_style_scheme_get_authors (GtkSourceStyleScheme *scheme);
-
-const gchar *gtk_source_style_scheme_get_filename (GtkSourceStyleScheme *scheme);
-
-GtkSourceStyle *gtk_source_style_scheme_get_style (GtkSourceStyleScheme *scheme,
- const gchar *style_id);
-GtkSourceStyleScheme *_gtk_source_style_scheme_new_from_file (const gchar *filename);
-GtkSourceStyleScheme *_gtk_source_style_scheme_get_default (void);
-const gchar *_gtk_source_style_scheme_get_parent_id (GtkSourceStyleScheme *scheme);
-void _gtk_source_style_scheme_set_parent (GtkSourceStyleScheme *scheme,
- GtkSourceStyleScheme *parent_scheme);
-
-/* private */
-void _gtk_source_style_scheme_apply (GtkSourceStyleScheme *scheme,
- GtkWidget *widget);
-void _gtk_source_style_scheme_unapply (GtkSourceStyleScheme *scheme,
- GtkWidget *widget);
-GtkSourceStyle *_gtk_source_style_scheme_get_matching_brackets_style
- (GtkSourceStyleScheme *scheme);
-GtkSourceStyle *_gtk_source_style_scheme_get_right_margin_style
- (GtkSourceStyleScheme *scheme);
-GtkSourceStyle *_gtk_source_style_scheme_get_draw_spaces_style
- (GtkSourceStyleScheme *scheme);
-gboolean _gtk_source_style_scheme_get_current_line_color
- (GtkSourceStyleScheme *scheme,
- GdkRGBA *color);
+GType gtk_source_style_scheme_get_type (void) G_GNUC_CONST;
+
+G_GNUC_INTERNAL
+GtkSourceStyleScheme *_gtk_source_style_scheme_new (const gchar *id,
+ const gchar *name);
+
+const gchar *gtk_source_style_scheme_get_id (GtkSourceStyleScheme
*scheme);
+
+const gchar *gtk_source_style_scheme_get_name (GtkSourceStyleScheme
*scheme);
+
+const gchar *gtk_source_style_scheme_get_description (GtkSourceStyleScheme
*scheme);
+
+const gchar * const * gtk_source_style_scheme_get_authors (GtkSourceStyleScheme
*scheme);
+
+const gchar *gtk_source_style_scheme_get_filename (GtkSourceStyleScheme
*scheme);
+
+GtkSourceStyle *gtk_source_style_scheme_get_style (GtkSourceStyleScheme *scheme,
+ const gchar
*style_id);
+
+G_GNUC_INTERNAL
+GtkSourceStyleScheme *_gtk_source_style_scheme_new_from_file (const gchar
*filename);
+
+G_GNUC_INTERNAL
+GtkSourceStyleScheme *_gtk_source_style_scheme_get_default (void);
+
+G_GNUC_INTERNAL
+const gchar *_gtk_source_style_scheme_get_parent_id (GtkSourceStyleScheme
*scheme);
+
+G_GNUC_INTERNAL
+void _gtk_source_style_scheme_set_parent (GtkSourceStyleScheme *scheme,
+ GtkSourceStyleScheme
*parent_scheme);
+
+G_GNUC_INTERNAL
+void _gtk_source_style_scheme_apply (GtkSourceStyleScheme *scheme,
+ GtkWidget
*widget);
+
+G_GNUC_INTERNAL
+void _gtk_source_style_scheme_unapply (GtkSourceStyleScheme *scheme,
+ GtkWidget
*widget);
+
+G_GNUC_INTERNAL
+GtkSourceStyle *_gtk_source_style_scheme_get_matching_brackets_style (GtkSourceStyleScheme
*scheme);
+
+G_GNUC_INTERNAL
+GtkSourceStyle *_gtk_source_style_scheme_get_right_margin_style (GtkSourceStyleScheme
*scheme);
+
+G_GNUC_INTERNAL
+GtkSourceStyle *_gtk_source_style_scheme_get_draw_spaces_style (GtkSourceStyleScheme
*scheme);
+
+G_GNUC_INTERNAL
+gboolean _gtk_source_style_scheme_get_current_line_color (GtkSourceStyleScheme *scheme,
+ GdkRGBA *color);
G_END_DECLS
#endif /* __GTK_SOURCE_STYLE_SCHEME_H__ */
diff --git a/gtksourceview/gtksourcestyleschememanager.c b/gtksourceview/gtksourcestyleschememanager.c
index 2d16483..f7678ad 100644
--- a/gtksourceview/gtksourcestyleschememanager.c
+++ b/gtksourceview/gtksourcestyleschememanager.c
@@ -20,6 +20,7 @@
*/
#include "gtksourcestyleschememanager.h"
+#include "gtksourcestylescheme.h"
#include "gtksourceview-marshal.h"
#include "gtksourceview-i18n.h"
#include "gtksourceview-utils.h"
@@ -30,6 +31,8 @@
* @Short_description: Object which provides access to #GtkSourceStyleScheme<!-- -->s
* @Title: GtkSourceStyleSchemeManager
* @See_also: #GtkSourceStyleScheme
+ *
+ * Object which provides access to #GtkSourceStyleScheme<!-- -->s.
*/
#define SCHEME_FILE_SUFFIX ".xml"
diff --git a/gtksourceview/gtksourcestyleschememanager.h b/gtksourceview/gtksourcestyleschememanager.h
index 7e0bfd4..75c5816 100644
--- a/gtksourceview/gtksourcestyleschememanager.h
+++ b/gtksourceview/gtksourcestyleschememanager.h
@@ -24,7 +24,6 @@
#include <glib-object.h>
#include <gtksourceview/gtksourcetypes.h>
-#include <gtksourceview/gtksourcestylescheme.h>
G_BEGIN_DECLS
@@ -35,7 +34,6 @@ G_BEGIN_DECLS
#define GTK_SOURCE_IS_STYLE_SCHEME_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass),
GTK_SOURCE_TYPE_STYLE_SCHEME_MANAGER))
#define GTK_SOURCE_STYLE_SCHEME_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj),
GTK_SOURCE_TYPE_STYLE_SCHEME_MANAGER, GtkSourceStyleSchemeManagerClass))
-
typedef struct _GtkSourceStyleSchemeManagerClass GtkSourceStyleSchemeManagerClass;
typedef struct _GtkSourceStyleSchemeManagerPrivate GtkSourceStyleSchemeManagerPrivate;
@@ -57,7 +55,6 @@ struct _GtkSourceStyleSchemeManagerClass
void (*_gtk_source_reserved4) (void);
};
-
GType gtk_source_style_scheme_manager_get_type (void) G_GNUC_CONST;
GtkSourceStyleSchemeManager *
@@ -69,10 +66,10 @@ GtkSourceStyleSchemeManager *
void gtk_source_style_scheme_manager_set_search_path (GtkSourceStyleSchemeManager
*manager,
gchar
**path);
-void gtk_source_style_scheme_manager_append_search_path (GtkSourceStyleSchemeManager
*manager,
+void gtk_source_style_scheme_manager_append_search_path (GtkSourceStyleSchemeManager
*manager,
const gchar
*path);
-void gtk_source_style_scheme_manager_prepend_search_path (GtkSourceStyleSchemeManager
*manager,
+void gtk_source_style_scheme_manager_prepend_search_path (GtkSourceStyleSchemeManager
*manager,
const gchar
*path);
const gchar * const * gtk_source_style_scheme_manager_get_search_path (GtkSourceStyleSchemeManager
*manager);
@@ -87,4 +84,3 @@ GtkSourceStyleScheme *gtk_source_style_scheme_manager_get_scheme (GtkSourceStyl
G_END_DECLS
#endif /* __GTK_SOURCE_STYLE_SCHEME_MANAGER_H__ */
-
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]