Make StashWidgetID map to gconstpointer rather than gpointer

This allows to use constant strings (e.g. string literals) as the
widget ID without triggering tons of compiler warnings.  In cases
widgets or non-constant strings are used, this just don't change
anything, since anyway we don't really need the widget pointer not
to be constant.

git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@5857 ea778897-0a13-0410-b9d1-a72fbfd435f5
This commit is contained in:
Colomban Wendling 2011-06-17 22:53:01 +00:00
parent 9fa8cd8bf9
commit 83527f798c
3 changed files with 8 additions and 6 deletions

View File

@ -4,6 +4,9 @@
Remove support of size being -1 in document_open_file_list().
* src/utils.c src/utils.h:
Remove support of size being -1 in utils_get_line_endings().
* src/stash.c, src/stash.h:
Make StashWidgetID map to gconstpointer, allowing use of const
strings as the widget key.
2011-06-16 Colomban Wendling <colomban(at)geany(dot)org>

View File

@ -566,14 +566,13 @@ lookup_widget(GtkWidget *widget, const gchar *widget_name)
static GtkWidget *
get_widget(GtkWidget *owner, StashWidgetID widget_id)
{
GtkWidget *widget = widget_id;
GtkWidget *widget;
if (owner)
{
const gchar *widget_name = widget_id;
widget = lookup_widget(owner, (const gchar *)widget_id);
else
widget = (GtkWidget *)widget_id;
widget = lookup_widget(owner, widget_name);
}
if (!GTK_IS_WIDGET(widget))
{
g_warning("Unknown widget in %s()!", G_STRFUNC);

View File

@ -30,7 +30,7 @@ typedef struct StashGroup StashGroup;
/** Can be @c GtkWidget* or @c gchar* depending on whether the @a owner argument is used for
* stash_group_display() and stash_group_update(). */
typedef gpointer StashWidgetID;
typedef gconstpointer StashWidgetID;
StashGroup *stash_group_new(const gchar *name);