summaryrefslogtreecommitdiff
path: root/gtk
diff options
context:
space:
mode:
authorOwen Taylor <otaylor@redhat.com>2001-10-23 16:02:23 +0000
committerOwen Taylor <otaylor@src.gnome.org>2001-10-23 16:02:23 +0000
commit4e32ede28751a90f747ccd0a7144bd10aa613a36 (patch)
tree29f2e22d6a8c302ccc3f6a420316f49754f9394f /gtk
parent0d5635b36613c0e5eca772e223001d1858433c28 (diff)
downloadgdk-pixbuf-4e32ede28751a90f747ccd0a7144bd10aa613a36.tar.gz
Remove G_DISABLE_CONST_RETURNS.
Tue Oct 23 11:53:00 2001 Owen Taylor <otaylor@redhat.com> * gtk/Makefile.am (INCLUDES): Remove G_DISABLE_CONST_RETURNS. * gtk/gtkfontsel.[ch]: Make gtk_font_selection_get_font() G_CONST_RETURN. (Murray Cumming) * gtk/gtkfontsel.c (gtk_font_selection_dialog_get_preview_text): Make G_CONST_RETURN. * gtk/gtkfilesel.c (open_user_dir): Fix bug with freeing results of g_get_home_dir(). * gtk/gtkfilesel.c: Make filesel->fileop_file a duplicated copy. Storing the return from gtk_entry_get_text() is evil. * gtk/gtkcombo.c gtk/gtkcellrenderertext.c gtk/gtkbindings.c gtk/gtkfilesel.c gtk/gtkfontsel.c gtk/gtkimmodule.c gtk/gtkobject.c gtk/gtkoldeditable.c gtk/gtktreedatalist.c gtk/gtksignal.c: Add const. * gdk/x11/gdkkeys-x11.c (get_direction): Add missing const. * gtk/gtktreeview.c: Namespace object data keys to be safe, even if we are setting them on private widgets. * gtk/gtktreeview.c (gtk_tree_view_real_start_interactive_search): Duplicate entry->text before setting it as object data.
Diffstat (limited to 'gtk')
-rw-r--r--gtk/Makefile.am1
-rw-r--r--gtk/gtkbindings.c7
-rw-r--r--gtk/gtkcellrenderertext.c2
-rw-r--r--gtk/gtkcombo.c2
-rw-r--r--gtk/gtkfilesel.c46
-rw-r--r--gtk/gtkfontsel.c10
-rw-r--r--gtk/gtkfontsel.h14
-rw-r--r--gtk/gtkimmodule.c2
-rw-r--r--gtk/gtkmain.c9
-rw-r--r--gtk/gtkobject.c2
-rw-r--r--gtk/gtkoldeditable.c4
-rw-r--r--gtk/gtkrc.c2
-rw-r--r--gtk/gtkscale.c2
-rw-r--r--gtk/gtksignal.c6
-rw-r--r--gtk/gtktreedatalist.c2
-rw-r--r--gtk/gtktreeview.c15
16 files changed, 67 insertions, 59 deletions
diff --git a/gtk/Makefile.am b/gtk/Makefile.am
index 294ff9910..242fc689a 100644
--- a/gtk/Makefile.am
+++ b/gtk/Makefile.am
@@ -11,7 +11,6 @@ INCLUDES = @STRIP_BEGIN@ \
-DGTK_VERSION=\"@GTK_VERSION@\" \
-DGTK_BINARY_VERSION=\"@GTK_BINARY_VERSION@\" \
-DTESTGTK_RCFILE=\"`pwd`/$(srcdir)/testgtkrc\" \
- -DG_DISABLE_CONST_RETURNS \
-I$(top_builddir)/gtk \
-I$(top_srcdir) -I../gdk \
-I$(top_srcdir)/gdk \
diff --git a/gtk/gtkbindings.c b/gtk/gtkbindings.c
index 66ae70f65..902410e11 100644
--- a/gtk/gtkbindings.c
+++ b/gtk/gtkbindings.c
@@ -793,8 +793,8 @@ static inline gboolean
binding_match_activate (GSList *pspec_list,
GtkObject *object,
guint path_length,
- gchar *path,
- gchar *path_reversed)
+ const gchar *path,
+ const gchar *path_reversed)
{
GSList *slist;
@@ -938,7 +938,8 @@ gtk_bindings_activate (GtkObject *object,
while (class_type && !handled)
{
guint path_length;
- gchar *path, *path_reversed;
+ const gchar *path;
+ gchar *path_reversed;
path = gtk_type_name (class_type);
path_reversed = g_strdup (path);
diff --git a/gtk/gtkcellrenderertext.c b/gtk/gtkcellrenderertext.c
index 353e4e02e..2bf054b50 100644
--- a/gtk/gtkcellrenderertext.c
+++ b/gtk/gtkcellrenderertext.c
@@ -1317,7 +1317,7 @@ gtk_cell_renderer_text_editing_done (GtkCellEditable *entry,
gpointer data)
{
gchar *path;
- gchar *new_text;
+ const gchar *new_text;
path = g_object_get_data (G_OBJECT (entry), GTK_CELL_RENDERER_TEXT_PATH);
new_text = gtk_entry_get_text (GTK_ENTRY (entry));
diff --git a/gtk/gtkcombo.c b/gtk/gtkcombo.c
index 8a52efc43..edbed499c 100644
--- a/gtk/gtkcombo.c
+++ b/gtk/gtkcombo.c
@@ -304,7 +304,7 @@ gtk_combo_window_key_press (GtkWidget *window,
static GtkListItem *
gtk_combo_find (GtkCombo * combo)
{
- gchar *text;
+ const gchar *text;
gchar *ltext;
GList *clist;
int (*string_compare) (const char *, const char *);
diff --git a/gtk/gtkfilesel.c b/gtk/gtkfilesel.c
index 4326af41d..fa330d0cc 100644
--- a/gtk/gtkfilesel.c
+++ b/gtk/gtkfilesel.c
@@ -240,7 +240,7 @@ enum {
static CompletionState* cmpl_init_state (void);
static void cmpl_free_state (CompletionState *cmpl_state);
static gint cmpl_state_okay (CompletionState* cmpl_state);
-static gchar* cmpl_strerror (gint);
+static const gchar* cmpl_strerror (gint);
static PossibleCompletion* cmpl_completion_matches(gchar *text_to_complete,
gchar **remaining_text,
@@ -293,7 +293,7 @@ static gint cmpl_last_valid_char (CompletionState* cmpl_state)
/* When the user selects a non-directory, call cmpl_completion_fullname
* to get the full name of the selected file.
*/
-static gchar* cmpl_completion_fullname (gchar*, CompletionState* cmpl_state);
+static gchar* cmpl_completion_fullname (const gchar*, CompletionState* cmpl_state);
/* Directory operations. */
@@ -308,7 +308,7 @@ static gboolean check_dir (gchar *dir_name,
static CompletionDir* open_dir (gchar* dir_name,
CompletionState* cmpl_state);
#ifdef HAVE_PWD_H
-static CompletionDir* open_user_dir (gchar* text_to_complete,
+static CompletionDir* open_user_dir (const gchar* text_to_complete,
CompletionState *cmpl_state);
#endif
static CompletionDir* open_relative_dir (gchar* dir_name, CompletionDir* dir,
@@ -355,6 +355,7 @@ static void gtk_file_selection_get_property (GObject *object,
GValue *value,
GParamSpec *pspec);
static void gtk_file_selection_init (GtkFileSelection *filesel);
+static void gtk_file_selection_finalize (GObject *object);
static void gtk_file_selection_destroy (GtkObject *object);
static gint gtk_file_selection_key_press (GtkWidget *widget,
GdkEventKey *event,
@@ -495,6 +496,7 @@ gtk_file_selection_class_init (GtkFileSelectionClass *class)
parent_class = gtk_type_class (GTK_TYPE_DIALOG);
+ gobject_class->finalize = gtk_file_selection_finalize;
gobject_class->set_property = gtk_file_selection_set_property;
gobject_class->get_property = gtk_file_selection_get_property;
@@ -878,7 +880,7 @@ filenames_drag_get (GtkWidget *widget,
guint time,
GtkFileSelection *filesel)
{
- gchar *file;
+ const gchar *file;
gchar *uri_list;
char hostname[256];
int res;
@@ -1085,7 +1087,7 @@ gtk_file_selection_get_filename (GtkFileSelection *filesel)
static gchar nothing[2] = "";
static gchar something[MAXPATHLEN*2];
char *sys_filename;
- char *text;
+ const char *text;
g_return_val_if_fail (GTK_IS_FILE_SELECTION (filesel), nothing);
@@ -1158,6 +1160,14 @@ gtk_file_selection_destroy (GtkObject *object)
GTK_OBJECT_CLASS (parent_class)->destroy (object);
}
+static void
+gtk_file_selection_finalize (GObject *object)
+{
+ GtkFileSelection *filesel = GTK_FILE_SELECTION (object);
+
+ g_free (filesel->fileop_file);
+}
+
/* Begin file operations callbacks */
static void
@@ -1204,7 +1214,7 @@ gtk_file_selection_create_dir_confirmed (GtkWidget *widget,
gpointer data)
{
GtkFileSelection *fs = data;
- gchar *dirname;
+ const gchar *dirname;
gchar *path;
gchar *full_path;
gchar *sys_full_path;
@@ -1376,7 +1386,7 @@ gtk_file_selection_delete_file (GtkWidget *widget,
GtkWidget *vbox;
GtkWidget *button;
GtkWidget *dialog;
- gchar *filename;
+ const gchar *filename;
gchar *buf;
g_return_if_fail (GTK_IS_FILE_SELECTION (fs));
@@ -1392,7 +1402,8 @@ gtk_file_selection_delete_file (GtkWidget *widget,
if (strlen (filename) < 1)
return;
- fs->fileop_file = filename;
+ g_free (fs->fileop_file);
+ fs->fileop_file = g_strdup (filename);
/* main dialog */
fs->fileop_dialog = dialog = gtk_dialog_new ();
@@ -1450,7 +1461,7 @@ gtk_file_selection_rename_file_confirmed (GtkWidget *widget,
{
GtkFileSelection *fs = data;
gchar *buf;
- gchar *file;
+ const gchar *file;
gchar *path;
gchar *new_filename;
gchar *old_filename;
@@ -1532,7 +1543,8 @@ gtk_file_selection_rename_file (GtkWidget *widget,
if (fs->fileop_dialog)
return;
- fs->fileop_file = gtk_entry_get_text (GTK_ENTRY (fs->selection_entry));
+ g_free (fs->fileop_file);
+ fs->fileop_file = g_strdup (gtk_entry_get_text (GTK_ENTRY (fs->selection_entry)));
if (strlen (fs->fileop_file) < 1)
return;
@@ -1638,9 +1650,7 @@ gtk_file_selection_key_press (GtkWidget *widget,
#ifdef G_WITH_CYGWIN
translate_win32_path (fs);
#endif
- text = gtk_entry_get_text (GTK_ENTRY (fs->selection_entry));
-
- text = g_strdup (text);
+ text = g_strdup (gtk_entry_get_text (GTK_ENTRY (fs->selection_entry)));
gtk_file_selection_populate (fs, text, TRUE);
@@ -2078,7 +2088,7 @@ cmpl_last_valid_char (CompletionState *cmpl_state)
}
static gchar*
-cmpl_completion_fullname (gchar *text,
+cmpl_completion_fullname (const gchar *text,
CompletionState *cmpl_state)
{
static char nothing[2] = "";
@@ -2489,7 +2499,7 @@ open_ref_dir (gchar *text_to_complete,
/* open a directory by user name */
static CompletionDir*
-open_user_dir (gchar *text_to_complete,
+open_user_dir (const gchar *text_to_complete,
CompletionState *cmpl_state)
{
CompletionDir *result;
@@ -2508,11 +2518,9 @@ open_user_dir (gchar *text_to_complete,
if (!cmp_len)
{
/* ~/ */
- gchar *homedir = g_get_home_dir ();
+ const gchar *homedir = g_get_home_dir ();
gchar *utf8_homedir = g_filename_to_utf8 (homedir, -1, NULL, NULL, NULL);
- g_free (homedir);
-
if (utf8_homedir)
result = open_dir (utf8_homedir, cmpl_state);
else
@@ -3494,7 +3502,7 @@ cmpl_state_okay (CompletionState* cmpl_state)
return cmpl_state && cmpl_state->reference_dir;
}
-static gchar*
+static const gchar*
cmpl_strerror (gint err)
{
if (err == CMPL_ERRNO_TOO_LONG)
diff --git a/gtk/gtkfontsel.c b/gtk/gtkfontsel.c
index d7196fea4..95c43472f 100644
--- a/gtk/gtkfontsel.c
+++ b/gtk/gtkfontsel.c
@@ -504,7 +504,7 @@ gtk_font_selection_select_font (GtkWidget *w,
gpointer data)
{
GtkFontSelection *fontsel;
- gchar *family_name;
+ const gchar *family_name;
gint index;
fontsel = GTK_FONT_SELECTION (data);
@@ -762,7 +762,7 @@ gtk_font_selection_size_activate (GtkWidget *w,
{
GtkFontSelection *fontsel;
gint new_size;
- gchar *text;
+ const gchar *text;
fontsel = GTK_FONT_SELECTION (data);
@@ -836,7 +836,7 @@ gtk_font_selection_update_preview (GtkFontSelection *fontsel)
gint new_height;
GtkRequisition old_requisition;
GtkWidget *preview_entry = fontsel->preview_entry;
- gchar *text;
+ const gchar *text;
gtk_widget_get_child_requisition (preview_entry, &old_requisition);
@@ -957,7 +957,7 @@ gtk_font_selection_set_font_name (GtkFontSelection *fontsel,
/* This returns the text in the preview entry. You should copy the returned
text if you need it. */
-gchar*
+G_CONST_RETURN gchar*
gtk_font_selection_get_preview_text (GtkFontSelection *fontsel)
{
return gtk_entry_get_text (GTK_ENTRY (fontsel->preview_entry));
@@ -1093,7 +1093,7 @@ gtk_font_selection_dialog_set_font_name (GtkFontSelectionDialog *fsd,
return gtk_font_selection_set_font_name (GTK_FONT_SELECTION (fsd->fontsel), fontname);
}
-gchar*
+G_CONST_RETURN gchar*
gtk_font_selection_dialog_get_preview_text (GtkFontSelectionDialog *fsd)
{
return gtk_font_selection_get_preview_text (GTK_FONT_SELECTION (fsd->fontsel));
diff --git a/gtk/gtkfontsel.h b/gtk/gtkfontsel.h
index 5d8eb8214..e6a20cfe0 100644
--- a/gtk/gtkfontsel.h
+++ b/gtk/gtkfontsel.h
@@ -135,13 +135,11 @@ gchar* gtk_font_selection_get_font_name (GtkFontSelection *fontsel);
GdkFont* gtk_font_selection_get_font (GtkFontSelection *fontsel);
#endif /* GTK_DISABLE_DEPRECATED */
-gboolean gtk_font_selection_set_font_name (GtkFontSelection *fontsel,
- const gchar *fontname);
-gchar* gtk_font_selection_get_preview_text (GtkFontSelection *fontsel);
-void gtk_font_selection_set_preview_text (GtkFontSelection *fontsel,
- const gchar *text);
-
-
+gboolean gtk_font_selection_set_font_name (GtkFontSelection *fontsel,
+ const gchar *fontname);
+G_CONST_RETURN gchar* gtk_font_selection_get_preview_text (GtkFontSelection *fontsel);
+void gtk_font_selection_set_preview_text (GtkFontSelection *fontsel,
+ const gchar *text);
/*****************************************************************************
* GtkFontSelectionDialog functions.
@@ -175,7 +173,7 @@ gboolean gtk_font_selection_dialog_set_font_name (GtkFontSelectionDialog *fsd
/* This returns the text in the preview entry. You should copy the returned
text if you need it. */
-gchar* gtk_font_selection_dialog_get_preview_text (GtkFontSelectionDialog *fsd);
+G_CONST_RETURN gchar* gtk_font_selection_dialog_get_preview_text (GtkFontSelectionDialog *fsd);
/* This sets the text in the preview entry. It will be copied by the entry,
so there's no need to g_strdup() it first. */
diff --git a/gtk/gtkimmodule.c b/gtk/gtkimmodule.c
index 1086d9fc6..ea40819e3 100644
--- a/gtk/gtkimmodule.c
+++ b/gtk/gtkimmodule.c
@@ -482,7 +482,7 @@ _gtk_im_module_get_default_context_id (const gchar *locale)
gint best_goodness = 0;
gint i;
gchar *tmp_locale, *tmp;
- gchar *envvar;
+ const gchar *envvar;
if (!contexts_hash)
gtk_im_module_init ();
diff --git a/gtk/gtkmain.c b/gtk/gtkmain.c
index 378b28705..450f3741a 100644
--- a/gtk/gtkmain.c
+++ b/gtk/gtkmain.c
@@ -227,9 +227,10 @@ check_setugid (void)
static gchar **
get_module_path (void)
{
- gchar *module_path = g_getenv ("GTK_MODULE_PATH");
- gchar *exe_prefix = g_getenv("GTK_EXE_PREFIX");
+ const gchar *module_path_env = g_getenv ("GTK_MODULE_PATH");
+ const gchar *exe_prefix = g_getenv("GTK_EXE_PREFIX");
gchar **result;
+ gchar *module_path;
gchar *default_dir;
if (exe_prefix)
@@ -242,8 +243,8 @@ get_module_path (void)
default_dir = g_build_filename (get_gtk_win32_directory (""), "modules", NULL);
#endif
}
- module_path = g_strconcat (module_path ? module_path : "",
- module_path ? G_SEARCHPATH_SEPARATOR_S : "",
+ module_path = g_strconcat (module_path_env ? module_path_env : "",
+ module_path_env ? G_SEARCHPATH_SEPARATOR_S : "",
default_dir, NULL);
result = pango_split_file_list (module_path);
diff --git a/gtk/gtkobject.c b/gtk/gtkobject.c
index 6dc3fff79..1f45383be 100644
--- a/gtk/gtkobject.c
+++ b/gtk/gtkobject.c
@@ -134,7 +134,7 @@ gtk_arg_set_from_value (GtkArg *arg,
case G_TYPE_STRING: if (copy_string)
GTK_VALUE_STRING (*arg) = g_value_dup_string (value);
else
- GTK_VALUE_STRING (*arg) = g_value_get_string (value);
+ GTK_VALUE_STRING (*arg) = (char *) g_value_get_string (value);
break;
default:
return FALSE;
diff --git a/gtk/gtkoldeditable.c b/gtk/gtkoldeditable.c
index 5182c1e1f..f67952807 100644
--- a/gtk/gtkoldeditable.c
+++ b/gtk/gtkoldeditable.c
@@ -476,7 +476,7 @@ gtk_old_editable_get_public_chars (GtkOldEditable *old_editable,
gint end)
{
gchar *str = NULL;
- gchar *charset;
+ const gchar *charset;
gboolean need_conversion = !g_get_charset (&charset);
if (old_editable->visible)
@@ -595,7 +595,7 @@ gtk_old_editable_paste_received (GtkOldEditable *old_editable,
gboolean is_clipboard)
{
const gchar *str = NULL;
- gchar *charset;
+ const gchar *charset;
gboolean need_conversion = FALSE;
if (text)
diff --git a/gtk/gtkrc.c b/gtk/gtkrc.c
index 2975c3855..b8d27f29f 100644
--- a/gtk/gtkrc.c
+++ b/gtk/gtkrc.c
@@ -659,7 +659,7 @@ gtk_rc_parse_named (GtkRcContext *context,
const gchar *type)
{
gchar *path = NULL;
- gchar *home_dir;
+ const gchar *home_dir;
gchar *subpath;
if (type)
diff --git a/gtk/gtkscale.c b/gtk/gtkscale.c
index 10cf85ea6..4920c4ea9 100644
--- a/gtk/gtkscale.c
+++ b/gtk/gtkscale.c
@@ -94,7 +94,7 @@ single_string_accumulator (GSignalInvocationHint *ihint,
gpointer dummy)
{
gboolean continue_emission;
- gchar *str;
+ const gchar *str;
str = g_value_get_string (handler_return);
g_value_set_string (return_accu, str);
diff --git a/gtk/gtksignal.c b/gtk/gtksignal.c
index 1d98d9223..b24741dd8 100644
--- a/gtk/gtksignal.c
+++ b/gtk/gtksignal.c
@@ -106,7 +106,7 @@ gtk_signal_connect_object_while_alive (GtkObject *object,
g_signal_connect_closure_by_id (object,
g_signal_lookup (signal, G_OBJECT_TYPE (object)), 0,
- g_cclosure_new_object_swap (func, alive_object),
+ g_cclosure_new_object_swap (func, G_OBJECT (alive_object)),
FALSE);
}
@@ -254,7 +254,7 @@ gtk_arg_set_from_value (GtkArg *arg,
case G_TYPE_STRING: if (copy_string)
GTK_VALUE_STRING (*arg) = g_value_dup_string (value);
else
- GTK_VALUE_STRING (*arg) = g_value_get_string (value);
+ GTK_VALUE_STRING (*arg) = (char *) g_value_get_string (value);
break;
default:
return FALSE;
@@ -286,7 +286,7 @@ gtk_argloc_set_from_value (GtkArg *arg,
case G_TYPE_STRING: if (copy_string)
*GTK_RETLOC_STRING (*arg) = g_value_dup_string (value);
else
- *GTK_RETLOC_STRING (*arg) = g_value_get_string (value);
+ *GTK_RETLOC_STRING (*arg) = (char *) g_value_get_string (value);
break;
default:
return FALSE;
diff --git a/gtk/gtktreedatalist.c b/gtk/gtktreedatalist.c
index 81d6332e6..82cbdf480 100644
--- a/gtk/gtktreedatalist.c
+++ b/gtk/gtktreedatalist.c
@@ -265,7 +265,7 @@ gtk_tree_data_list_compare_func (GtkTreeModel *model,
GValue a_value = {0, };
GValue b_value = {0, };
gint retval;
- gchar *stra, *strb;
+ const gchar *stra, *strb;
gtk_tree_model_get_value (model, a, column, &a_value);
gtk_tree_model_get_value (model, b, column, &b_value);
diff --git a/gtk/gtktreeview.c b/gtk/gtktreeview.c
index c56262511..f4d5be21c 100644
--- a/gtk/gtktreeview.c
+++ b/gtk/gtktreeview.c
@@ -6184,8 +6184,9 @@ gtk_tree_view_real_start_interactive_search (GtkTreeView *tree_view)
/* position window */
- gtk_object_set_data (GTK_OBJECT (window), "text",
- gtk_entry_get_text (GTK_ENTRY (entry)));
+ gtk_object_set_data_full (GTK_OBJECT (window), "gtk-tree-view-text",
+ g_strdup (gtk_entry_get_text (GTK_ENTRY (entry))),
+ (GDestroyNotify) g_free);
gtk_object_set_data (GTK_OBJECT (tree_view),
GTK_TREE_VIEW_SEARCH_DIALOG_KEY, window);
@@ -8979,8 +8980,8 @@ gtk_tree_view_search_move (GtkWidget *window,
GtkTreeModel *model;
GtkTreeSelection *selection;
- text = gtk_object_get_data (GTK_OBJECT (window), "text");
- selected_iter = gtk_object_get_data (GTK_OBJECT (window), "selected-iter");
+ text = gtk_object_get_data (GTK_OBJECT (window), "gtk-tree-view-text");
+ selected_iter = gtk_object_get_data (GTK_OBJECT (window), "gtk-tree-view-selected-iter");
g_return_if_fail (text != NULL);
@@ -9191,10 +9192,10 @@ gtk_tree_view_search_init (GtkWidget *entry,
/* search */
gtk_tree_selection_unselect_all (selection);
- selected_iter = gtk_object_get_data (GTK_OBJECT (window), "selected-iter");
+ selected_iter = gtk_object_get_data (GTK_OBJECT (window), "gtk-tree-view-selected-iter");
if (selected_iter)
g_free (selected_iter);
- gtk_object_remove_data (GTK_OBJECT (window), "selected-iter");
+ gtk_object_remove_data (GTK_OBJECT (window), "gtk-tree-view-selected-iter");
if (len < 1)
return;
@@ -9209,7 +9210,7 @@ gtk_tree_view_search_init (GtkWidget *entry,
{
selected_iter = g_malloc (sizeof (int));
*selected_iter = 1;
- gtk_object_set_data (GTK_OBJECT (window), "selected-iter",
+ gtk_object_set_data (GTK_OBJECT (window), "gtk-tree-view-selected-iter",
selected_iter);
}
}