diff --git a/icons/16x16/Makefile.am b/icons/16x16/Makefile.am index 1c6e6e75..0ec722ec 100644 --- a/icons/16x16/Makefile.am +++ b/icons/16x16/Makefile.am @@ -17,7 +17,3 @@ dist_icons_actions_DATA = \ geany-build.png \ geany-close-all.png \ geany-save-all.png - -dist_noinst_DATA = \ - classviewer-var.xpm \ - classviewer-method.xpm diff --git a/icons/16x16/classviewer-method.xpm b/icons/16x16/classviewer-method.xpm deleted file mode 100644 index e36b1b5f..00000000 --- a/icons/16x16/classviewer-method.xpm +++ /dev/null @@ -1,27 +0,0 @@ -/* XPM */ -static char *classviewer_method[] = { -/* columns rows colors chars-per-pixel */ -"16 16 5 1", -" c black", -". c #E0BC38", -"X c #F0DC5C", -"o c #FCFC80", -"O c None", -/* pixels */ -"OOOOOOOOOOOOOOOO", -"OOOOOOOOOOOOOOOO", -"OOOOOOOOOOOOOOOO", -"OOOOOOOOOO OOOO", -"OOOOOOOOO oo OO", -"OOOOOOOO ooooo O", -"OOOOOOO ooooo. O", -"OOOO O XXoo.. O", -"OOO oo XXX... O", -"OO ooooo XX.. OO", -"O ooooo. X. OOO", -"O XXoo.. O OOOO", -"O XXX... OOOOOOO", -"O XXX.. OOOOOOOO", -"OO X. OOOOOOOOO", -"OOOO OOOOOOOOOO" -}; diff --git a/icons/16x16/classviewer-var.xpm b/icons/16x16/classviewer-var.xpm deleted file mode 100644 index e087626f..00000000 --- a/icons/16x16/classviewer-var.xpm +++ /dev/null @@ -1,27 +0,0 @@ -/* XPM */ -static char *classviewer_var[] = { -/* columns rows colors chars-per-pixel */ -"16 16 5 1", -" c black", -". c #8C748C", -"X c #9C94A4", -"o c #ACB4C0", -"O c None", -/* pixels */ -"OOOOOOOOOOOOOOOO", -"OOOOOOOOOOOOOOOO", -"OOOOOOOOOOOOOOOO", -"OOOOOOOOOOOOOOOO", -"OOOOOOOOOOOOOOOO", -"OOOOOOOOOOOOOOOO", -"OOOOOOOOO OOOOO", -"OOOOOOOO oo OOO", -"OOOOOOO ooooo OO", -"OOOOOO ooooo. OO", -"OOOOOO XXoo.. OO", -"OOOOOO XXX... OO", -"OOOOOO XXX.. OOO", -"OOOOOOO X. OOOO", -"OOOOOOOOO OOOOO", -"OOOOOOOOOOOOOOOO" -}; diff --git a/src/editor.c b/src/editor.c index 4c82d721..46507d3a 100644 --- a/src/editor.c +++ b/src/editor.c @@ -4682,8 +4682,46 @@ static void setup_sci_keys(ScintillaObject *sci) } -#include "icons/16x16/classviewer-var.xpm" -#include "icons/16x16/classviewer-method.xpm" +/* registers a Scintilla image from a named icon from the theme */ +static gboolean register_named_icon(ScintillaObject *sci, guint id, const gchar *name) +{ + GError *error = NULL; + GdkPixbuf *pixbuf; + gint n_channels, rowstride, width, height; + gint size; + + gtk_icon_size_lookup(GTK_ICON_SIZE_MENU, &size, NULL); + pixbuf = gtk_icon_theme_load_icon(gtk_icon_theme_get_default(), name, size, 0, &error); + if (! pixbuf) + { + g_warning("failed to load icon '%s': %s", name, error->message); + g_error_free(error); + return FALSE; + } + + n_channels = gdk_pixbuf_get_n_channels(pixbuf); + rowstride = gdk_pixbuf_get_rowstride(pixbuf); + width = gdk_pixbuf_get_width(pixbuf); + height = gdk_pixbuf_get_height(pixbuf); + + if (gdk_pixbuf_get_bits_per_sample(pixbuf) != 8 || + ! gdk_pixbuf_get_has_alpha(pixbuf) || + n_channels != 4 || + rowstride != width * n_channels) + { + g_warning("incompatible image data for icon '%s'", name); + g_object_unref(pixbuf); + return FALSE; + } + + SSM(sci, SCI_RGBAIMAGESETWIDTH, width, 0); + SSM(sci, SCI_RGBAIMAGESETHEIGHT, height, 0); + SSM(sci, SCI_REGISTERRGBAIMAGE, id, (sptr_t)gdk_pixbuf_get_pixels(pixbuf)); + + g_object_unref(pixbuf); + return TRUE; +} + /* Create new editor widget (scintilla). * @note The @c "sci-notify" signal is connected separately. */ @@ -4715,8 +4753,8 @@ static ScintillaObject *create_new_sci(GeanyEditor *editor) SSM(sci, SCI_SETSCROLLWIDTHTRACKING, 1, 0); /* tag autocompletion images */ - SSM(sci, SCI_REGISTERIMAGE, 1, (sptr_t)classviewer_var); - SSM(sci, SCI_REGISTERIMAGE, 2, (sptr_t)classviewer_method); + register_named_icon(sci, 1, "classviewer-var"); + register_named_icon(sci, 2, "classviewer-method"); /* necessary for column mode editing, implemented in Scintilla since 2.0 */ SSM(sci, SCI_SETADDITIONALSELECTIONTYPING, 1, 0);