Skip to content

Commit

Permalink
Merge pull request geany#3916 from techee/symtree_icons
Browse files Browse the repository at this point in the history
Export some types/functions so plugins have access to Geany symbol icons
  • Loading branch information
techee authored Jun 29, 2024
2 parents 20908b8 + 39ce0c0 commit 9bf5769
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 16 deletions.
21 changes: 19 additions & 2 deletions src/symbols.c
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,23 @@ const gchar *symbols_get_context_separator(gint ft_id)
}


/** Gets the icon data corresponding to the provided TMIcon.
* @param icon TMIcon.
*
* Returns the GdkPixbuf corresponding to the provided TMIcon.
*
* @since 2.1
*/
GEANY_API_SYMBOL
GdkPixbuf *symbols_get_icon_pixbuf(TMIcon icon)
{
if (icon < TM_N_ICONS)
return symbols_icons[icon].pixbuf;

return NULL;
}


/* sort by name, then line */
static gint compare_symbol(const TMTag *tag_a, const TMTag *tag_b)
{
Expand Down Expand Up @@ -437,7 +454,7 @@ static void tag_list_add_groups(GtkTreeStore *tree_store, TMParserType lang)
GdkPixbuf *icon = NULL;

if (icon_id < TM_N_ICONS)
icon = symbols_icons[icon_id].pixbuf;
icon = symbols_get_icon_pixbuf(icon_id);

g_assert(title != NULL);
g_ptr_array_add(top_level_iter_names, (gchar *)title);
Expand Down Expand Up @@ -1476,7 +1493,7 @@ static void show_goto_popup(GeanyDocument *doc, GPtrArray *tags, gboolean have_b

tooltip = g_markup_printf_escaped("%s:%lu\n<small><tt>%s</tt></small>", fname, tmtag->line, sym);

image = gtk_image_new_from_pixbuf(symbols_icons[get_tag_class(tmtag)].pixbuf);
image = gtk_image_new_from_pixbuf(symbols_get_icon_pixbuf(get_tag_class(tmtag)));
box = g_object_new(GTK_TYPE_BOX, "orientation", GTK_ORIENTATION_HORIZONTAL, "spacing", 12, NULL);
label = g_object_new(GTK_TYPE_LABEL, "label", text, "use-markup", TRUE, "xalign", 0.0, NULL);
gtk_size_group_add_widget(group, label);
Expand Down
1 change: 1 addition & 0 deletions src/symbols.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ G_BEGIN_DECLS

const gchar *symbols_get_context_separator(gint ft_id);

GdkPixbuf *symbols_get_icon_pixbuf(TMIcon icon);

#ifdef GEANY_PRIVATE

Expand Down
34 changes: 20 additions & 14 deletions src/tagmanager/tm_parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,26 @@ typedef enum
typedef gint TMParserType;


/* keep in sync with icon names in symbols.c */
/**
* Identifiers of icons used by Geany in the symbol tree, in the autocompletion popup,
* and in the goto popup.
*/
typedef enum
{
TM_ICON_CLASS,
TM_ICON_MACRO,
TM_ICON_MEMBER,
TM_ICON_METHOD,
TM_ICON_NAMESPACE,
TM_ICON_OTHER,
TM_ICON_STRUCT,
TM_ICON_VAR,
TM_ICON_NONE,
TM_N_ICONS = TM_ICON_NONE
} TMIcon;


#ifdef GEANY_PRIVATE

/* keep in sync with tm_parsers.h and parser_map in tm_parser.c */
Expand Down Expand Up @@ -125,20 +145,6 @@ enum
TM_PARSER_COUNT
};

/* keep in sync with icon names in symbols.c */
enum
{
TM_ICON_CLASS,
TM_ICON_MACRO,
TM_ICON_MEMBER,
TM_ICON_METHOD,
TM_ICON_NAMESPACE,
TM_ICON_OTHER,
TM_ICON_STRUCT,
TM_ICON_VAR,
TM_ICON_NONE,
TM_N_ICONS = TM_ICON_NONE
};

void tm_parser_verify_type_mappings(void);

Expand Down

0 comments on commit 9bf5769

Please sign in to comment.