Branch: refs/heads/master Author: Colomban Wendling ban@herbesfolles.org Committer: Colomban Wendling ban@herbesfolles.org Date: Tue, 01 Jan 2013 18:10:48 UTC Commit: 3783eed0ea0a032fae43f031305c1605aa245c8f https://github.com/geany/geany/commit/3783eed0ea0a032fae43f031305c1605aa245c...
Log Message: ----------- 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.
Modified Paths: -------------- icons/16x16/Makefile.am icons/16x16/classviewer-method.xpm icons/16x16/classviewer-var.xpm src/editor.c
Modified: icons/16x16/Makefile.am 4 files changed, 0 insertions(+), 4 deletions(-) =================================================================== @@ -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
Modified: icons/16x16/classviewer-method.xpm 27 files changed, 0 insertions(+), 27 deletions(-) =================================================================== @@ -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" -};
Modified: icons/16x16/classviewer-var.xpm 27 files changed, 0 insertions(+), 27 deletions(-) =================================================================== @@ -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" -};
Modified: src/editor.c 46 files changed, 42 insertions(+), 4 deletions(-) =================================================================== @@ -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);
-------------- This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).