Use icons from the theme in the completion popup

Drop the XPM icons and load the PNG ones through the theme mechanisms,
like we do for the symbols tree.
This commit is contained in:
Colomban Wendling 2012-10-18 02:33:28 +02:00
parent dabae1f94f
commit 3783eed0ea
4 changed files with 42 additions and 62 deletions

View File

@ -17,7 +17,3 @@ dist_icons_actions_DATA = \
geany-build.png \ geany-build.png \
geany-close-all.png \ geany-close-all.png \
geany-save-all.png geany-save-all.png
dist_noinst_DATA = \
classviewer-var.xpm \
classviewer-method.xpm

View File

@ -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"
};

View File

@ -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"
};

View File

@ -4682,8 +4682,46 @@ static void setup_sci_keys(ScintillaObject *sci)
} }
#include "icons/16x16/classviewer-var.xpm" /* registers a Scintilla image from a named icon from the theme */
#include "icons/16x16/classviewer-method.xpm" 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). /* Create new editor widget (scintilla).
* @note The @c "sci-notify" signal is connected separately. */ * @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); SSM(sci, SCI_SETSCROLLWIDTHTRACKING, 1, 0);
/* tag autocompletion images */ /* tag autocompletion images */
SSM(sci, SCI_REGISTERIMAGE, 1, (sptr_t)classviewer_var); register_named_icon(sci, 1, "classviewer-var");
SSM(sci, SCI_REGISTERIMAGE, 2, (sptr_t)classviewer_method); register_named_icon(sci, 2, "classviewer-method");
/* necessary for column mode editing, implemented in Scintilla since 2.0 */ /* necessary for column mode editing, implemented in Scintilla since 2.0 */
SSM(sci, SCI_SETADDITIONALSELECTIONTYPING, 1, 0); SSM(sci, SCI_SETADDITIONALSELECTIONTYPING, 1, 0);