Take bookmarks line background color from style scheme
This commit is contained in:
parent
a0b4e13b5b
commit
ec1db186a9
@ -41,6 +41,9 @@
|
||||
<!-- Search Matching -->
|
||||
<style name="search-match" background="yellow"/>
|
||||
|
||||
<!-- Bookmarks -->
|
||||
<style name="bookmark" background="#E5E5FF"/>
|
||||
|
||||
<!-- legacy styles for old lang files -->
|
||||
<style name="Others" foreground="dark-red"/>
|
||||
<style name="Others 2" bold="true"/>
|
||||
|
@ -21,7 +21,8 @@
|
||||
G_DEFINE_TYPE (MooEditBookmark, moo_edit_bookmark, MOO_TYPE_LINE_MARK)
|
||||
|
||||
|
||||
static void disconnect_bookmark (MooEditBookmark *bk);
|
||||
static void disconnect_bookmark (MooEditBookmark *bk);
|
||||
static const char *get_bookmark_color (MooEdit *doc);
|
||||
|
||||
|
||||
static void
|
||||
@ -42,10 +43,7 @@ moo_edit_bookmark_class_init (MooEditBookmarkClass *klass)
|
||||
static void
|
||||
moo_edit_bookmark_init (MooEditBookmark *bk)
|
||||
{
|
||||
g_object_set (bk,
|
||||
"visible", TRUE,
|
||||
"background", "#E5E5FF",
|
||||
NULL);
|
||||
g_object_set (bk, "visible", TRUE, NULL);
|
||||
}
|
||||
|
||||
|
||||
@ -268,7 +266,7 @@ moo_edit_add_bookmark (MooEdit *edit,
|
||||
|
||||
g_object_set (edit, "show-line-marks", TRUE, NULL);
|
||||
|
||||
bk = g_object_new (MOO_TYPE_EDIT_BOOKMARK, NULL);
|
||||
bk = g_object_new (MOO_TYPE_EDIT_BOOKMARK, "background", get_bookmark_color (edit), NULL);
|
||||
moo_text_buffer_add_line_mark (get_moo_buffer (edit), MOO_LINE_MARK (bk), line);
|
||||
g_object_set_data (G_OBJECT (bk), "moo-edit-bookmark", GINT_TO_POINTER (TRUE));
|
||||
|
||||
@ -479,3 +477,34 @@ _moo_edit_bookmark_get_text (MooEditBookmark *bk)
|
||||
|
||||
return line;
|
||||
}
|
||||
|
||||
|
||||
static const char *
|
||||
get_bookmark_color (MooEdit *doc)
|
||||
{
|
||||
MooTextStyle *style;
|
||||
MooTextStyleScheme *scheme;
|
||||
|
||||
scheme = moo_text_view_get_style_scheme (MOO_TEXT_VIEW (doc));
|
||||
if (!scheme)
|
||||
return NULL;
|
||||
|
||||
style = _moo_text_style_scheme_lookup_style (scheme, "bookmark");
|
||||
return style ? _moo_text_style_get_bg_color (style) : NULL;
|
||||
}
|
||||
|
||||
void
|
||||
_moo_edit_update_bookmarks_style (MooEdit *edit)
|
||||
{
|
||||
const GSList *bookmarks;
|
||||
const char *color;
|
||||
|
||||
color = get_bookmark_color (edit);
|
||||
|
||||
bookmarks = moo_edit_list_bookmarks (edit);
|
||||
while (bookmarks)
|
||||
{
|
||||
moo_line_mark_set_background (bookmarks->data, color);
|
||||
bookmarks = bookmarks->next;
|
||||
}
|
||||
}
|
||||
|
@ -51,6 +51,7 @@ void _moo_edit_line_mark_deleted (MooEdit *edit,
|
||||
MooLineMark *mark);
|
||||
gboolean _moo_edit_line_mark_clicked (MooTextView *view,
|
||||
int line);
|
||||
void _moo_edit_update_bookmarks_style(MooEdit *edit);
|
||||
|
||||
|
||||
/***********************************************************************/
|
||||
|
@ -80,6 +80,9 @@ static GtkTextBuffer *get_buffer (MooEdit *edit);
|
||||
static void modified_changed_cb (GtkTextBuffer *buffer,
|
||||
MooEdit *edit);
|
||||
|
||||
static void moo_edit_apply_style_scheme (MooTextView *view,
|
||||
MooTextStyleScheme *scheme);
|
||||
|
||||
|
||||
enum {
|
||||
DOC_STATUS_CHANGED,
|
||||
@ -126,6 +129,7 @@ moo_edit_class_init (MooEditClass *klass)
|
||||
widget_class->focus_out_event = moo_edit_focus_out;
|
||||
|
||||
textview_class->line_mark_clicked = _moo_edit_line_mark_clicked;
|
||||
textview_class->apply_style_scheme = moo_edit_apply_style_scheme;
|
||||
|
||||
klass->filename_changed = moo_edit_filename_changed;
|
||||
klass->config_notify = moo_edit_config_notify;
|
||||
@ -572,6 +576,15 @@ moo_edit_get_property (GObject *object,
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
moo_edit_apply_style_scheme (MooTextView *view,
|
||||
MooTextStyleScheme *scheme)
|
||||
{
|
||||
MOO_TEXT_VIEW_CLASS (moo_edit_parent_class)->apply_style_scheme (view, scheme);
|
||||
_moo_edit_update_bookmarks_style (MOO_EDIT (view));
|
||||
}
|
||||
|
||||
|
||||
static gboolean
|
||||
moo_edit_focus_in (GtkWidget *widget,
|
||||
GdkEventFocus *event)
|
||||
|
@ -107,6 +107,17 @@ get_color (GtkSourceStyleScheme *scheme,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const char *
|
||||
_moo_text_style_get_bg_color (const MooTextStyle *style)
|
||||
{
|
||||
g_return_val_if_fail (style != NULL, NULL);
|
||||
|
||||
if (((GtkSourceStyle*)style)->mask & GTK_SOURCE_STYLE_USE_BACKGROUND)
|
||||
return ((GtkSourceStyle*)style)->background;
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void
|
||||
_moo_text_style_scheme_apply (MooTextStyleScheme *scheme,
|
||||
GtkWidget *widget)
|
||||
|
@ -48,6 +48,8 @@ MooTextStyle *_moo_text_style_scheme_lookup_style (MooTextStyleScheme *sch
|
||||
void _moo_text_style_apply_to_tag (const MooTextStyle *style,
|
||||
GtkTextTag *tag);
|
||||
|
||||
const char *_moo_text_style_get_bg_color (const MooTextStyle *style);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
@ -92,6 +92,9 @@ static void moo_text_view_paste_clipboard (GtkTextView *text_view);
|
||||
static void moo_text_view_populate_popup(GtkTextView *text_view,
|
||||
GtkMenu *menu);
|
||||
|
||||
static void moo_text_view_apply_style_scheme (MooTextView *view,
|
||||
MooTextStyleScheme *scheme);
|
||||
|
||||
static void invalidate_gcs (MooTextView *view);
|
||||
static void update_gcs (MooTextView *view);
|
||||
static void update_tab_width (MooTextView *view);
|
||||
@ -302,6 +305,7 @@ static void moo_text_view_class_init (MooTextViewClass *klass)
|
||||
klass->undo = moo_text_view_undo;
|
||||
klass->redo = moo_text_view_redo;
|
||||
klass->char_inserted = moo_text_view_char_inserted;
|
||||
klass->apply_style_scheme = moo_text_view_apply_style_scheme;
|
||||
|
||||
g_type_class_add_private (klass, sizeof (MooTextViewPrivate));
|
||||
|
||||
@ -2590,6 +2594,14 @@ moo_text_view_get_lang (MooTextView *view)
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
moo_text_view_apply_style_scheme (MooTextView *view,
|
||||
MooTextStyleScheme *scheme)
|
||||
{
|
||||
_moo_text_style_scheme_apply (scheme, GTK_WIDGET (view));
|
||||
_moo_text_buffer_set_style_scheme (get_moo_buffer (view), scheme);
|
||||
}
|
||||
|
||||
void
|
||||
moo_text_view_set_style_scheme (MooTextView *view,
|
||||
MooTextStyleScheme *scheme)
|
||||
@ -2604,8 +2616,15 @@ moo_text_view_set_style_scheme (MooTextView *view,
|
||||
g_object_unref (view->priv->style_scheme);
|
||||
|
||||
view->priv->style_scheme = g_object_ref (scheme);
|
||||
_moo_text_style_scheme_apply (scheme, GTK_WIDGET (view));
|
||||
_moo_text_buffer_set_style_scheme (get_moo_buffer (view), scheme);
|
||||
|
||||
MOO_TEXT_VIEW_GET_CLASS (view)->apply_style_scheme (view, scheme);
|
||||
}
|
||||
|
||||
MooTextStyleScheme *
|
||||
moo_text_view_get_style_scheme (MooTextView *view)
|
||||
{
|
||||
g_return_val_if_fail (MOO_IS_TEXT_VIEW (view), NULL);
|
||||
return view->priv->style_scheme;
|
||||
}
|
||||
|
||||
|
||||
|
@ -86,6 +86,9 @@ struct _MooTextViewClass
|
||||
MooTextSelectionType type,
|
||||
GtkTextIter *start,
|
||||
GtkTextIter *end);
|
||||
|
||||
void (*apply_style_scheme) (MooTextView *view,
|
||||
MooTextStyleScheme *scheme);
|
||||
};
|
||||
|
||||
|
||||
@ -134,6 +137,7 @@ void moo_text_view_set_right_margin_color (MooTextView *view,
|
||||
const char *color);
|
||||
void moo_text_view_set_right_margin_offset (MooTextView *view,
|
||||
guint offset);
|
||||
MooTextStyleScheme *moo_text_view_get_style_scheme (MooTextView *view);
|
||||
void moo_text_view_set_style_scheme (MooTextView *view,
|
||||
MooTextStyleScheme *scheme);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user