Draw numbers on numbered bookmarks
This commit is contained in:
parent
a564e9ec9f
commit
f52f035d7a
@ -46,7 +46,6 @@ moo_edit_bookmark_init (MooEditBookmark *bk)
|
||||
g_object_set (bk,
|
||||
"visible", TRUE,
|
||||
"background", "#E5E5FF",
|
||||
"stock-id", MOO_STOCK_EDIT_BOOKMARK,
|
||||
NULL);
|
||||
}
|
||||
|
||||
@ -279,6 +278,17 @@ moo_edit_add_bookmark (MooEdit *edit,
|
||||
|
||||
bk->no = no;
|
||||
|
||||
if (no)
|
||||
{
|
||||
char buf[32];
|
||||
g_snprintf (buf, sizeof buf, "<b>%d</b>", no);
|
||||
moo_line_mark_set_markup (MOO_LINE_MARK (bk), buf);
|
||||
}
|
||||
else
|
||||
{
|
||||
moo_line_mark_set_stock_id (MOO_LINE_MARK (bk), MOO_STOCK_EDIT_BOOKMARK);
|
||||
}
|
||||
|
||||
if (!edit->priv->update_bookmarks_idle)
|
||||
edit->priv->bookmarks =
|
||||
g_slist_insert_sorted (edit->priv->bookmarks, bk,
|
||||
|
@ -26,7 +26,7 @@ struct _MooLineMarkPrivate {
|
||||
|
||||
GtkWidget *widget;
|
||||
|
||||
char *name;
|
||||
char *markup;
|
||||
|
||||
MooTextBuffer *buffer;
|
||||
LineBuffer *line_buf;
|
||||
@ -76,7 +76,7 @@ enum {
|
||||
PROP_BACKGROUND_SET,
|
||||
PROP_PIXBUF,
|
||||
PROP_STOCK_ID,
|
||||
PROP_NAME,
|
||||
PROP_MARKUP,
|
||||
PROP_VISIBLE
|
||||
};
|
||||
|
||||
@ -121,10 +121,10 @@ moo_line_mark_class_init (MooLineMarkClass *klass)
|
||||
G_PARAM_READWRITE));
|
||||
|
||||
g_object_class_install_property (gobject_class,
|
||||
PROP_NAME,
|
||||
g_param_spec_string ("name",
|
||||
"name",
|
||||
"name",
|
||||
PROP_MARKUP,
|
||||
g_param_spec_string ("markup",
|
||||
"markup",
|
||||
"markup",
|
||||
NULL,
|
||||
G_PARAM_READWRITE));
|
||||
|
||||
@ -181,9 +181,9 @@ moo_line_mark_finalize (GObject *object)
|
||||
g_object_unref (mark->priv->pixbuf);
|
||||
if (mark->priv->background_gc)
|
||||
g_object_unref (mark->priv->background_gc);
|
||||
g_free (mark->priv->stock_id);
|
||||
|
||||
g_free (mark->priv->name);
|
||||
g_free (mark->priv->stock_id);
|
||||
g_free (mark->priv->markup);
|
||||
g_free (mark->priv);
|
||||
|
||||
G_OBJECT_CLASS (moo_line_mark_parent_class)->finalize (object);
|
||||
@ -214,8 +214,8 @@ moo_line_mark_set_property (GObject *object,
|
||||
moo_line_mark_changed (mark);
|
||||
break;
|
||||
|
||||
case PROP_NAME:
|
||||
moo_line_mark_set_name (mark, g_value_get_string (value));
|
||||
case PROP_MARKUP:
|
||||
moo_line_mark_set_markup (mark, g_value_get_string (value));
|
||||
break;
|
||||
|
||||
case PROP_VISIBLE:
|
||||
@ -256,8 +256,8 @@ moo_line_mark_get_property (GObject *object,
|
||||
g_value_set_boolean (value, mark->priv->background_set != 0);
|
||||
break;
|
||||
|
||||
case PROP_NAME:
|
||||
g_value_set_string (value, mark->priv->name);
|
||||
case PROP_MARKUP:
|
||||
g_value_set_string (value, mark->priv->markup);
|
||||
break;
|
||||
|
||||
case PROP_VISIBLE:
|
||||
@ -365,25 +365,27 @@ moo_line_mark_changed (MooLineMark *mark)
|
||||
|
||||
|
||||
void
|
||||
moo_line_mark_set_name (MooLineMark *mark,
|
||||
const char *name)
|
||||
moo_line_mark_set_markup (MooLineMark *mark,
|
||||
const char *markup)
|
||||
{
|
||||
char *tmp;
|
||||
|
||||
g_return_if_fail (MOO_IS_LINE_MARK (mark));
|
||||
|
||||
if (mark->priv->name != name)
|
||||
{
|
||||
g_free (mark->priv->name);
|
||||
mark->priv->name = g_strdup (name);
|
||||
g_object_notify (G_OBJECT (mark), "name");
|
||||
}
|
||||
if (!markup || !markup[0])
|
||||
markup = NULL;
|
||||
|
||||
tmp = mark->priv->markup;
|
||||
mark->priv->markup = g_strdup (markup);
|
||||
g_free (tmp);
|
||||
}
|
||||
|
||||
|
||||
const char *
|
||||
moo_line_mark_get_name (MooLineMark *mark)
|
||||
moo_line_mark_get_markup (MooLineMark *mark)
|
||||
{
|
||||
g_return_val_if_fail (MOO_IS_LINE_MARK (mark), NULL);
|
||||
return mark->priv->name;
|
||||
return mark->priv->markup;
|
||||
}
|
||||
|
||||
|
||||
|
@ -69,10 +69,6 @@ void moo_line_mark_set_background_gdk (MooLineMark *mark,
|
||||
void moo_line_mark_set_background (MooLineMark *mark,
|
||||
const char *color);
|
||||
|
||||
void moo_line_mark_set_name (MooLineMark *mark,
|
||||
const char *name);
|
||||
const char *moo_line_mark_get_name (MooLineMark *mark);
|
||||
|
||||
int moo_line_mark_get_line (MooLineMark *mark);
|
||||
MooTextBuffer *moo_line_mark_get_buffer (MooLineMark *mark);
|
||||
gboolean moo_line_mark_get_visible (MooLineMark *mark);
|
||||
@ -83,8 +79,11 @@ void moo_line_mark_set_stock_id (MooLineMark *mark,
|
||||
const char *stock_id);
|
||||
void moo_line_mark_set_pixbuf (MooLineMark *mark,
|
||||
GdkPixbuf *pixbuf);
|
||||
void moo_line_mark_set_markup (MooLineMark *mark,
|
||||
const char *markup);
|
||||
const char *moo_line_mark_get_stock_id (MooLineMark *mark);
|
||||
GdkPixbuf *moo_line_mark_get_pixbuf (MooLineMark *mark);
|
||||
const char *moo_line_mark_get_markup (MooLineMark *mark);
|
||||
GdkGC *moo_line_mark_get_background_gc (MooLineMark *mark);
|
||||
|
||||
|
||||
|
@ -2820,8 +2820,31 @@ get_n_digits (MooTextView *view)
|
||||
static void
|
||||
update_line_mark_icons (MooTextView *view)
|
||||
{
|
||||
/* XXX */
|
||||
view->priv->lm.icon_width = 16;
|
||||
int i;
|
||||
char str[32];
|
||||
GtkSettings *settings;
|
||||
PangoLayout *layout;
|
||||
|
||||
g_return_if_fail (GTK_WIDGET_REALIZED (view));
|
||||
|
||||
settings = gtk_widget_get_settings (GTK_WIDGET (view));
|
||||
|
||||
if (!gtk_icon_size_lookup_for_settings (settings, GTK_ICON_SIZE_MENU,
|
||||
&view->priv->lm.icon_width, NULL))
|
||||
view->priv->lm.icon_width = 16;
|
||||
|
||||
layout = gtk_widget_create_pango_layout (GTK_WIDGET (view), NULL);
|
||||
|
||||
for (i = 1; i < 10; ++i)
|
||||
{
|
||||
PangoRectangle rect;
|
||||
g_snprintf (str, sizeof str, "<b>%d</b>", i);
|
||||
pango_layout_set_markup (layout, str, -1);
|
||||
pango_layout_get_pixel_extents (layout, &rect, NULL);
|
||||
view->priv->lm.icon_width = MAX (view->priv->lm.icon_width, rect.width);
|
||||
}
|
||||
|
||||
g_object_unref (layout);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -2838,7 +2861,7 @@ update_digit_width (MooTextView *view)
|
||||
{
|
||||
int width;
|
||||
g_snprintf (str, sizeof str, "%d", i);
|
||||
pango_layout_set_markup (layout, str, -1);
|
||||
pango_layout_set_text (layout, str, -1);
|
||||
pango_layout_get_pixel_size (layout, &width, NULL);
|
||||
view->priv->lm.digit_width = MAX (view->priv->lm.digit_width, width);
|
||||
}
|
||||
@ -2937,6 +2960,7 @@ draw_marks (MooTextView *view,
|
||||
{
|
||||
MooLineMark *mark;
|
||||
GdkPixbuf *pixbuf;
|
||||
const char *markup;
|
||||
|
||||
mark = marks->data;
|
||||
marks = marks->next;
|
||||
@ -2960,6 +2984,27 @@ draw_marks (MooTextView *view,
|
||||
0, 0, x, y, -1, -1,
|
||||
GDK_RGB_DITHER_NORMAL, 0, 0);
|
||||
}
|
||||
|
||||
markup = moo_line_mark_get_markup (mark);
|
||||
|
||||
if (markup)
|
||||
{
|
||||
PangoLayout *layout;
|
||||
PangoRectangle rect;
|
||||
int x, y;
|
||||
|
||||
layout = gtk_widget_create_pango_layout (GTK_WIDGET (view), NULL);
|
||||
pango_layout_set_markup (layout, markup, -1);
|
||||
pango_layout_get_pixel_extents (layout, &rect, NULL);
|
||||
x = MARK_ICON_LPAD + (view->priv->lm.icon_width - rect.width) / 2;
|
||||
y = line_y - 1 + (line_height - rect.y - rect.height) / 2;
|
||||
|
||||
gdk_draw_layout (event->window,
|
||||
GTK_WIDGET(view)->style->fg_gc[GTK_WIDGET_STATE(view)],
|
||||
x, y, layout);
|
||||
|
||||
g_object_unref (layout);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1358,18 +1358,18 @@
|
||||
)
|
||||
)
|
||||
|
||||
(define-method set_name
|
||||
(define-method set_markup
|
||||
(of-object "MooLineMark")
|
||||
(c-name "moo_line_mark_set_name")
|
||||
(c-name "moo_line_mark_set_markup")
|
||||
(return-type "none")
|
||||
(parameters
|
||||
'("const-char*" "name")
|
||||
'("const-char*" "name" (null-ok))
|
||||
)
|
||||
)
|
||||
|
||||
(define-method get_name
|
||||
(define-method get_markup
|
||||
(of-object "MooLineMark")
|
||||
(c-name "moo_line_mark_get_name")
|
||||
(c-name "moo_line_mark_get_markup")
|
||||
(return-type "const-char*")
|
||||
)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user