From 5880d1b990be6e1508b016ed65956dfbfb3a5973 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Sat, 15 Oct 2016 21:24:42 +0100 Subject: [PATCH] gtk: Cast static strings assigned to non-const variables GtkTargetEntry.target is particularly egregious, and it should really be constified. --- gtk/gtkaccelmap.c | 2 +- gtk/gtkbindings.c | 2 +- gtk/gtkclipboard.c | 2 +- gtk/gtkcolorbutton.c | 2 +- gtk/gtkcolorswatch.c | 2 +- gtk/gtkiconview.c | 2 +- gtk/gtklinkbutton.c | 4 ++-- gtk/gtknotebook.c | 6 +++--- gtk/gtkplacessidebar.c | 25 +++++++++++++++---------- gtk/gtksettings.c | 8 ++++---- gtk/gtktoolpalette.c | 4 ++-- gtk/gtktreeview.c | 2 +- gtk/gtkwindow.c | 2 +- 13 files changed, 34 insertions(+), 29 deletions(-) diff --git a/gtk/gtkaccelmap.c b/gtk/gtkaccelmap.c index d5e53d35f7..70e3c7dc29 100644 --- a/gtk/gtkaccelmap.c +++ b/gtk/gtkaccelmap.c @@ -609,7 +609,7 @@ gtk_accel_map_load_scanner (GScanner *scanner) skip_comment_single = scanner->config->skip_comment_single; scanner->config->skip_comment_single = TRUE; cpair_comment_single = scanner->config->cpair_comment_single; - scanner->config->cpair_comment_single = ";\n"; + scanner->config->cpair_comment_single = (char *) ";\n"; symbol_2_token = scanner->config->symbol_2_token; scanner->config->symbol_2_token = FALSE; saved_symbol = g_scanner_lookup_symbol (scanner, "gtk_accel_path"); diff --git a/gtk/gtkbindings.c b/gtk/gtkbindings.c index cd5757ef00..57cddec37f 100644 --- a/gtk/gtkbindings.c +++ b/gtk/gtkbindings.c @@ -1345,7 +1345,7 @@ create_signal_scanner (void) GScanner *scanner; scanner = g_scanner_new (NULL); - scanner->config->cset_identifier_nth = G_CSET_a_2_z G_CSET_A_2_Z G_CSET_DIGITS "-_"; + scanner->config->cset_identifier_nth = (char *) G_CSET_a_2_z G_CSET_A_2_Z G_CSET_DIGITS "-_"; g_scanner_scope_add_symbol (scanner, 0, "bind", GUINT_TO_POINTER (GTK_BINDING_TOKEN_BIND)); g_scanner_scope_add_symbol (scanner, 0, "unbind", GUINT_TO_POINTER (GTK_BINDING_TOKEN_UNBIND)); diff --git a/gtk/gtkclipboard.c b/gtk/gtkclipboard.c index e558a37a7f..d65e9c724d 100644 --- a/gtk/gtkclipboard.c +++ b/gtk/gtkclipboard.c @@ -2070,7 +2070,7 @@ gtk_clipboard_real_set_can_store (GtkClipboard *clipboard, GtkWidget *clipboard_widget; int i; static const GtkTargetEntry save_targets[] = { - { "SAVE_TARGETS", 0, TARGET_SAVE_TARGETS } + { (char *) "SAVE_TARGETS", 0, TARGET_SAVE_TARGETS } }; if (clipboard->selection != GDK_SELECTION_CLIPBOARD) diff --git a/gtk/gtkcolorbutton.c b/gtk/gtkcolorbutton.c index b77ea28496..5706b03257 100644 --- a/gtk/gtkcolorbutton.c +++ b/gtk/gtkcolorbutton.c @@ -130,7 +130,7 @@ static void gtk_color_button_drag_data_received (GtkWidget *widget, static guint color_button_signals[LAST_SIGNAL] = { 0 }; -static const GtkTargetEntry drop_types[] = { { "application/x-color", 0, 0 } }; +static const GtkTargetEntry drop_types[] = { { (char *) "application/x-color", 0, 0 } }; static void gtk_color_button_iface_init (GtkColorChooserInterface *iface); diff --git a/gtk/gtkcolorswatch.c b/gtk/gtkcolorswatch.c index 106a19bfad..ea6112facf 100644 --- a/gtk/gtkcolorswatch.c +++ b/gtk/gtkcolorswatch.c @@ -778,7 +778,7 @@ gtk_color_swatch_new (void) } static const GtkTargetEntry dnd_targets[] = { - { "application/x-color", 0 } + { (char *) "application/x-color", 0 } }; void diff --git a/gtk/gtkiconview.c b/gtk/gtkiconview.c index e6a8875d9a..444143b1d7 100644 --- a/gtk/gtkiconview.c +++ b/gtk/gtkiconview.c @@ -7125,7 +7125,7 @@ gtk_icon_view_get_reorderable (GtkIconView *icon_view) } static const GtkTargetEntry item_targets[] = { - { "GTK_TREE_MODEL_ROW", GTK_TARGET_SAME_WIDGET, 0 } + { (char *) "GTK_TREE_MODEL_ROW", GTK_TARGET_SAME_WIDGET, 0 } }; diff --git a/gtk/gtklinkbutton.c b/gtk/gtklinkbutton.c index 0ea9f6fa98..077c295e9c 100644 --- a/gtk/gtklinkbutton.c +++ b/gtk/gtklinkbutton.c @@ -128,8 +128,8 @@ static gboolean gtk_link_button_query_tooltip_cb (GtkWidget *widget, static gboolean gtk_link_button_activate_link (GtkLinkButton *link_button); static const GtkTargetEntry link_drop_types[] = { - { "text/uri-list", 0, 0 }, - { "_NETSCAPE_URL", 0, 0 } + { (char *) "text/uri-list", 0, 0 }, + { (char *) "_NETSCAPE_URL", 0, 0 } }; static guint link_signals[LAST_SIGNAL] = { 0, }; diff --git a/gtk/gtknotebook.c b/gtk/gtknotebook.c index 430ac06553..e48b0f19ee 100644 --- a/gtk/gtknotebook.c +++ b/gtk/gtknotebook.c @@ -313,12 +313,12 @@ struct _GtkNotebookPage }; static const GtkTargetEntry src_notebook_targets [] = { - { "GTK_NOTEBOOK_TAB", GTK_TARGET_SAME_APP, 0 }, - { "application/x-rootwindow-drop", 0, 0 }, + { (char *) "GTK_NOTEBOOK_TAB", GTK_TARGET_SAME_APP, 0 }, + { (char *) "application/x-rootwindow-drop", 0, 0 }, }; static const GtkTargetEntry dst_notebook_targets [] = { - { "GTK_NOTEBOOK_TAB", GTK_TARGET_SAME_APP, 0 }, + { (char *) "GTK_NOTEBOOK_TAB", GTK_TARGET_SAME_APP, 0 }, }; /*** GtkNotebook Methods ***/ diff --git a/gtk/gtkplacessidebar.c b/gtk/gtkplacessidebar.c index b75c30fa19..a66d4c6c42 100644 --- a/gtk/gtkplacessidebar.c +++ b/gtk/gtkplacessidebar.c @@ -302,12 +302,12 @@ enum { /* Target types for dragging from the shortcuts list */ static const GtkTargetEntry dnd_source_targets[] = { - { "DND_GTK_SIDEBAR_ROW", GTK_TARGET_SAME_WIDGET, DND_GTK_SIDEBAR_ROW } + { (char *) "DND_GTK_SIDEBAR_ROW", GTK_TARGET_SAME_WIDGET, DND_GTK_SIDEBAR_ROW } }; /* Target types for dropping into the shortcuts list */ static const GtkTargetEntry dnd_drop_targets [] = { - { "DND_GTK_SIDEBAR_ROW", GTK_TARGET_SAME_WIDGET, DND_GTK_SIDEBAR_ROW } + { (char *) "DND_GTK_SIDEBAR_ROW", GTK_TARGET_SAME_WIDGET, DND_GTK_SIDEBAR_ROW } }; G_DEFINE_TYPE (GtkPlacesSidebar, gtk_places_sidebar, GTK_TYPE_SCROLLED_WINDOW); @@ -909,7 +909,7 @@ update_places (GtkPlacesSidebar *sidebar) GVolume *volume; GSList *bookmarks, *sl; gint index; - gchar *original_uri, *mount_uri, *name, *identifier; + gchar *original_uri, *name, *identifier; GtkListBoxRow *selected; gchar *home_uri; GIcon *icon; @@ -943,11 +943,10 @@ update_places (GtkPlacesSidebar *sidebar) /* add built-in places */ if (should_show_recent (sidebar)) { - mount_uri = "recent:///"; icon = g_themed_icon_new_with_default_fallbacks ("document-open-recent-symbolic"); add_place (sidebar, PLACES_BUILT_IN, SECTION_COMPUTER, - _("Recent"), icon, mount_uri, + _("Recent"), icon, "recent:///", NULL, NULL, NULL, 0, _("Recent files")); g_object_unref (icon); @@ -967,7 +966,7 @@ update_places (GtkPlacesSidebar *sidebar) /* desktop */ if (sidebar->show_desktop) { - mount_uri = get_desktop_directory_uri (); + char *mount_uri = get_desktop_directory_uri (); if (mount_uri) { icon = g_themed_icon_new_with_default_fallbacks (ICON_NAME_DESKTOP); @@ -998,11 +997,10 @@ update_places (GtkPlacesSidebar *sidebar) /* Trash */ if (!sidebar->local_only && sidebar->show_trash) { - mount_uri = "trash:///"; /* No need to strdup */ icon = _gtk_trash_monitor_get_icon (sidebar->trash_monitor); sidebar->trash_row = add_place (sidebar, PLACES_BUILT_IN, SECTION_COMPUTER, - _("Trash"), icon, mount_uri, + _("Trash"), icon, "trash:///", NULL, NULL, NULL, 0, _("Open the trash")); g_object_add_weak_pointer (G_OBJECT (sidebar->trash_row), @@ -1045,6 +1043,8 @@ update_places (GtkPlacesSidebar *sidebar) mount = g_volume_get_mount (volume); if (mount != NULL) { + char *mount_uri; + /* Show mounted volume in the sidebar */ icon = g_mount_get_symbolic_icon (mount); root = g_mount_get_default_location (mount); @@ -1149,6 +1149,8 @@ update_places (GtkPlacesSidebar *sidebar) mount = g_volume_get_mount (volume); if (mount != NULL) { + char *mount_uri; + icon = g_mount_get_symbolic_icon (mount); root = g_mount_get_default_location (mount); mount_uri = g_file_get_uri (root); @@ -1184,11 +1186,10 @@ update_places (GtkPlacesSidebar *sidebar) /* file system root */ if (!sidebar->show_other_locations) { - mount_uri = "file:///"; /* No need to strdup */ icon = g_themed_icon_new_with_default_fallbacks (ICON_NAME_FILESYSTEM); add_place (sidebar, PLACES_BUILT_IN, SECTION_MOUNTS, - sidebar->hostname, icon, mount_uri, + sidebar->hostname, icon, "file:///", NULL, NULL, NULL, 0, _("Open the contents of the file system")); g_object_unref (icon); @@ -1199,6 +1200,8 @@ update_places (GtkPlacesSidebar *sidebar) for (l = mounts; l != NULL; l = l->next) { + char *mount_uri; + mount = l->data; if (g_mount_is_shadowed (mount)) { @@ -1325,6 +1328,8 @@ update_places (GtkPlacesSidebar *sidebar) network_mounts = g_list_reverse (network_mounts); for (l = network_mounts; l != NULL; l = l->next) { + char *mount_uri; + mount = l->data; root = g_mount_get_default_location (mount); icon = g_mount_get_symbolic_icon (mount); diff --git a/gtk/gtksettings.c b/gtk/gtksettings.c index 82333772e8..db367f6e2e 100644 --- a/gtk/gtksettings.c +++ b/gtk/gtksettings.c @@ -2513,21 +2513,21 @@ gtk_settings_set_double_property (GtkSettings *settings, static const GScannerConfig gtk_rc_scanner_config = { - ( + (char *) ( " \t\r\n" ) /* cset_skip_characters */, - ( + (char *) ( "_" G_CSET_a_2_z G_CSET_A_2_Z ) /* cset_identifier_first */, - ( + (char *) ( G_CSET_DIGITS "-_" G_CSET_a_2_z G_CSET_A_2_Z ) /* cset_identifier_nth */, - ( "#\n" ) /* cpair_comment_single */, + (char *) ( "#\n" ) /* cpair_comment_single */, TRUE /* case_sensitive */, diff --git a/gtk/gtktoolpalette.c b/gtk/gtktoolpalette.c index 93481bf0f5..8f1e7624f3 100644 --- a/gtk/gtktoolpalette.c +++ b/gtk/gtktoolpalette.c @@ -185,8 +185,8 @@ static GdkAtom dnd_target_atom_group = GDK_NONE; static const GtkTargetEntry dnd_targets[] = { - { "application/x-gtk-tool-palette-item", GTK_TARGET_SAME_APP, 0 }, - { "application/x-gtk-tool-palette-group", GTK_TARGET_SAME_APP, 0 }, + { (char *) "application/x-gtk-tool-palette-item", GTK_TARGET_SAME_APP, 0 }, + { (char *) "application/x-gtk-tool-palette-group", GTK_TARGET_SAME_APP, 0 }, }; static void gtk_tool_palette_set_hadjustment (GtkToolPalette *palette, diff --git a/gtk/gtktreeview.c b/gtk/gtktreeview.c index 70dda49a85..02eb655ba5 100644 --- a/gtk/gtktreeview.c +++ b/gtk/gtktreeview.c @@ -13205,7 +13205,7 @@ gtk_tree_view_set_reorderable (GtkTreeView *tree_view, if (reorderable) { const GtkTargetEntry row_targets[] = { - { "GTK_TREE_MODEL_ROW", GTK_TARGET_SAME_WIDGET, 0 } + { (char *) "GTK_TREE_MODEL_ROW", GTK_TARGET_SAME_WIDGET, 0 } }; gtk_tree_view_enable_model_drag_source (tree_view, diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c index 2f9356186c..86cc57f604 100644 --- a/gtk/gtkwindow.c +++ b/gtk/gtkwindow.c @@ -271,7 +271,7 @@ struct _GtkWindowPrivate }; static const GtkTargetEntry dnd_dest_targets [] = { - { "application/x-rootwindow-drop", 0, 0 }, + { (char *) "application/x-rootwindow-drop", 0, 0 }, }; enum {