[gtk+/filesystemmodel] fix lots of gcc warnings
- From: Benjamin Otte <otte src gnome org>
- To: svn-commits-list gnome org
- Subject: [gtk+/filesystemmodel] fix lots of gcc warnings
- Date: Thu, 25 Jun 2009 13:52:08 +0000 (UTC)
commit 716c16f02d238167c23ae953684f873ecf139e45
Author: Benjamin Otte <otte gnome org>
Date: Thu Jun 25 13:54:59 2009 +0200
fix lots of gcc warnings
It fixes a lot of, but not all of the errors produced by
-Wall -Wextra -Wno-missing-field-initializers -Wno-unused-parameter
-Wold-style-definition -Wdeclaration-after-statement
-Wmissing-declarations -Wmissing-prototypes -Wredundant-decls
-Wmissing-noreturn -Wshadow -Wpointer-arith -Wcast-align -Wwrite-strings
-Winline -Wformat-nonliteral -Wformat-security -Wswitch-enum
-Wswitch-default -Winit-self -Wmissing-include-dirs -Wundef
-Waggregate-return -Wmissing-format-attribute -Wnested-externs
-Wunsafe-loop-optimizations -Wpacked -Winvalid-pch -Wlogical-op
gtk/gtkfilechooserbutton.c | 2 -
gtk/gtkfilechooserdefault.c | 139 ++++++++++++-----------------------------
gtk/gtkfilechooserdialog.c | 8 +-
gtk/gtkfilechooserprivate.h | 2 +
gtk/gtkfilechoosersettings.c | 12 ++--
gtk/gtkfilesystemmodel.h | 3 +
6 files changed, 56 insertions(+), 110 deletions(-)
---
diff --git a/gtk/gtkfilechooserbutton.c b/gtk/gtkfilechooserbutton.c
index 3b95ade..1be16e7 100644
--- a/gtk/gtkfilechooserbutton.c
+++ b/gtk/gtkfilechooserbutton.c
@@ -1807,8 +1807,6 @@ model_add_volumes (GtkFileChooserButton *button,
}
}
-extern gchar * _gtk_file_chooser_label_for_file (GFile *file);
-
static void
model_add_bookmarks (GtkFileChooserButton *button,
GSList *bookmarks)
diff --git a/gtk/gtkfilechooserdefault.c b/gtk/gtkfilechooserdefault.c
index 5c10df1..63bf313 100644
--- a/gtk/gtkfilechooserdefault.c
+++ b/gtk/gtkfilechooserdefault.c
@@ -394,8 +394,6 @@ static void location_switch_to_path_bar (GtkFileChooserDefault *impl);
static void search_stop_searching (GtkFileChooserDefault *impl,
gboolean remove_query);
-static void search_clear_model_row (GtkTreeModel *model,
- GtkTreeIter *iter);
static void search_clear_model (GtkFileChooserDefault *impl,
gboolean remove_from_treeview);
static gboolean search_should_respond (GtkFileChooserDefault *impl);
@@ -404,9 +402,6 @@ static GSList *search_get_selected_files (GtkFileChooserDefault *impl);
static void search_entry_activate_cb (GtkEntry *entry,
gpointer data);
static void settings_load (GtkFileChooserDefault *impl);
-static void search_get_valid_child_iter (GtkFileChooserDefault *impl,
- GtkTreeIter *child_iter,
- GtkTreeIter *iter);
static void recent_stop_loading (GtkFileChooserDefault *impl);
static void recent_clear_model (GtkFileChooserDefault *impl,
@@ -438,6 +433,9 @@ typedef struct {
static void shortcuts_pane_model_filter_drag_source_iface_init (GtkTreeDragSourceIface *iface);
+/* make gcc not complain about missing declaration */
+GType _shortcuts_pane_model_filter_get_type (void);
+
G_DEFINE_TYPE_WITH_CODE (ShortcutsPaneModelFilter,
_shortcuts_pane_model_filter,
GTK_TYPE_TREE_MODEL_FILTER,
@@ -941,15 +939,7 @@ error_dialog (GtkFileChooserDefault *impl,
{
if (error)
{
- char *uri = NULL;
- char *text;
-
- if (file)
- uri = g_file_get_uri (file);
- text = g_strdup_printf (msg, uri);
- error_message (impl, text, error->message);
- g_free (text);
- g_free (uri);
+ error_message (impl, msg, error->message);
g_error_free (error);
}
}
@@ -1403,6 +1393,11 @@ shortcuts_update_count (GtkFileChooserDefault *impl,
impl->shortcuts_current_folder_active = TRUE;
break;
+ case SHORTCUTS_SEARCH:
+ case SHORTCUTS_RECENT:
+ case SHORTCUTS_RECENT_SEPARATOR:
+ case SHORTCUTS_BOOKMARKS_SEPARATOR:
+ case SHORTCUTS_CURRENT_FOLDER_SEPARATOR:
default:
/* nothing */
break;
@@ -2337,8 +2332,6 @@ edited_idle_cb (GtkFileChooserDefault *impl)
&error);
if (file)
{
- GError *error = NULL;
-
if (g_file_make_directory (file, NULL, &error))
change_folder_and_display_error (impl, file, FALSE);
else
@@ -3702,7 +3695,7 @@ shortcuts_list_create (GtkFileChooserDefault *impl)
/* Target types for dragging a row to/from the shortcuts list */
const GtkTargetEntry tree_model_row_targets[] = {
- { "GTK_TREE_MODEL_ROW", GTK_TARGET_SAME_WIDGET, GTK_TREE_MODEL_ROW }
+ { (char *) "GTK_TREE_MODEL_ROW", GTK_TARGET_SAME_WIDGET, GTK_TREE_MODEL_ROW }
};
/* Scrolled window */
@@ -4026,12 +4019,12 @@ file_list_drag_data_received_get_info_cb (GCancellable *cancellable,
change_folder_and_display_error (data->impl, data->file, FALSE);
else
{
- GError *error = NULL;
+ GError *err = NULL;
gtk_file_chooser_default_unselect_all (chooser);
- gtk_file_chooser_default_select_file (chooser, data->file, &error);
- if (error)
- error_selecting_dragged_file_dialog (data->impl, data->file, error);
+ gtk_file_chooser_default_select_file (chooser, data->file, &err);
+ if (err)
+ error_selecting_dragged_file_dialog (data->impl, data->file, err);
else
browse_files_center_selected_row (data->impl);
}
@@ -4078,15 +4071,15 @@ file_list_drag_data_received_cb (GtkWidget *widget,
uris = gtk_selection_data_get_uris (selection_data);
if (uris && uris[0])
{
- struct FileListDragData *data;
+ struct FileListDragData *drag;
uri = uris[0];
file = g_file_new_for_uri (uri);
- data = g_new0 (struct FileListDragData, 1);
- data->impl = g_object_ref (impl);
- data->uris = uris;
- data->file = file;
+ drag = g_new0 (struct FileListDragData, 1);
+ drag->impl = g_object_ref (impl);
+ drag->uris = uris;
+ drag->file = file;
if (impl->file_list_drag_data_received_cancellable)
g_cancellable_cancel (impl->file_list_drag_data_received_cancellable);
@@ -4095,7 +4088,7 @@ file_list_drag_data_received_cb (GtkWidget *widget,
_gtk_file_system_get_info (impl->file_system, file,
"standard::type",
file_list_drag_data_received_get_info_cb,
- data);
+ drag);
}
g_signal_stop_emission_by_name (widget, "drag-data-received");
@@ -4288,12 +4281,6 @@ list_button_press_event_cb (GtkWidget *widget,
return TRUE;
}
-typedef struct {
- OperationMode operation_mode;
- gint general_column;
- gint model_column;
-} ColumnMap;
-
/* Sets the sort column IDs for the file list based on the operation mode */
static void
file_list_set_sort_column_ids (GtkFileChooserDefault *impl)
@@ -6495,6 +6482,12 @@ stop_loading_and_clear_list_model (GtkFileChooserDefault *impl)
gtk_tree_view_set_model (GTK_TREE_VIEW (impl->browse_files_tree_view), NULL);
}
+/* workaround because we don't pass a static string to strftime() (as we should)
+ * and this aborts with -Werror otherwise */
+#if __GNUC__ >= 4
+#pragma GCC diagnostic warning "-Wformat-nonliteral"
+#endif
+
static char *
my_g_format_time_for_display (glong secs)
{
@@ -7203,6 +7196,7 @@ gtk_file_chooser_default_update_current_folder (GtkFileChooser *chooser,
recent_switch_to_browse_mode (impl);
break;
case OPERATION_MODE_BROWSE:
+ default:
break;
}
@@ -8353,16 +8347,16 @@ save_entry_get_info_cb (GCancellable *cancellable,
}
else /* GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER */
{
- GError *error = NULL;
+ GError *err = NULL;
set_busy_cursor (data->impl, TRUE);
- g_file_make_directory (data->file, NULL, &error);
+ g_file_make_directory (data->file, NULL, &err);
set_busy_cursor (data->impl, FALSE);
- if (!error)
+ if (!err)
g_signal_emit_by_name (data->impl, "response-requested");
else
- error_creating_folder_dialog (data->impl, data->file, error);
+ error_creating_folder_dialog (data->impl, data->file, err);
}
}
else
@@ -8520,7 +8514,7 @@ gtk_file_chooser_default_should_respond (GtkFileChooserEmbed *chooser_embed)
file_list:
- g_assert (impl->action >= GTK_FILE_CHOOSER_ACTION_OPEN && impl->action <= GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER);
+ g_assert (impl->action <= GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER);
if (impl->operation_mode == OPERATION_MODE_SEARCH)
return search_should_respond (impl);
@@ -8569,6 +8563,7 @@ gtk_file_chooser_default_should_respond (GtkFileChooserEmbed *chooser_embed)
case SAVE_ENTRY:
goto save_entry;
+ case NOT_REACHED:
default:
g_assert_not_reached ();
}
@@ -8764,10 +8759,6 @@ search_add_hit (GtkFileChooserDefault *impl,
gchar *uri)
{
GFile *file;
- GtkTreeIter iter;
- GtkTreePath *p;
- GCancellable *cancellable;
- struct SearchHitInsertRequest *request;
file = g_file_new_for_uri (uri);
if (!file)
@@ -8782,6 +8773,7 @@ search_add_hit (GtkFileChooserDefault *impl,
_gtk_file_system_model_add_and_query_file (impl->search_model,
file,
MODEL_ATTRIBUTES);
+ g_object_unref (file);
}
/* Callback used from GtkSearchEngine when we get new hits */
@@ -8853,9 +8845,6 @@ static void
search_clear_model (GtkFileChooserDefault *impl,
gboolean remove_from_treeview)
{
- GtkTreeModel *model;
- GtkTreeIter iter;
-
if (!impl->search_model)
return;
@@ -8916,54 +8905,6 @@ search_switch_to_browse_mode (GtkFileChooserDefault *impl)
file_list_set_sort_column_ids (impl);
}
-static gboolean
-search_get_is_filtered (GtkFileChooserDefault *impl,
- GFile *file,
- const gchar *display_name,
- const gchar *mime_type)
-{
- GtkFileFilterInfo filter_info;
- GtkFileFilterFlags needed;
- gboolean result;
-
- if (!impl->current_filter)
- return FALSE;
-
- filter_info.contains = GTK_FILE_FILTER_DISPLAY_NAME | GTK_FILE_FILTER_MIME_TYPE;
- needed = gtk_file_filter_get_needed (impl->current_filter);
-
- filter_info.display_name = display_name;
- filter_info.mime_type = mime_type;
-
- if (needed & GTK_FILE_FILTER_FILENAME)
- {
- filter_info.filename = g_file_get_path (file);
- if (filter_info.filename)
- filter_info.contains |= GTK_FILE_FILTER_FILENAME;
- }
- else
- filter_info.filename = NULL;
-
- if (needed & GTK_FILE_FILTER_URI)
- {
- filter_info.uri = g_file_get_uri (file);
- if (filter_info.uri)
- filter_info.contains |= GTK_FILE_FILTER_URI;
- }
- else
- filter_info.uri = NULL;
-
- result = gtk_file_filter_filter (impl->current_filter, &filter_info);
-
- if (filter_info.filename)
- g_free ((gchar *) filter_info.filename);
- if (filter_info.uri)
- g_free ((gchar *) filter_info.uri);
-
- return !result;
-
-}
-
/* Creates the search_model and puts it in the tree view */
static void
search_setup_model (GtkFileChooserDefault *impl)
@@ -9167,6 +9108,9 @@ stop_operation (GtkFileChooserDefault *impl, OperationMode mode)
gtk_widget_destroy (impl->recent_hbox);
impl->recent_hbox = NULL;
break;
+ default:
+ g_assert_not_reached ();
+ break;
}
}
@@ -9207,7 +9151,6 @@ recent_clear_model (GtkFileChooserDefault *impl,
gboolean remove_from_treeview)
{
GtkTreeModel *model;
- GtkTreeIter iter;
if (!impl->recent_model)
return;
@@ -9366,11 +9309,7 @@ recent_idle_load (gpointer data)
{
RecentLoadData *load_data = data;
GtkFileChooserDefault *impl = load_data->impl;
- GtkTreeIter iter;
- GtkTreePath *p;
GtkRecentInfo *info;
- const gchar *uri, *display_name, *mtime_text, *collated_name;
- glong mtime;
GFile *file;
GList *walk;
@@ -9745,6 +9684,9 @@ shortcuts_activate_volume (GtkFileChooserDefault *impl,
case OPERATION_MODE_RECENT:
recent_switch_to_browse_mode (impl);
break;
+ default:
+ g_assert_not_reached ();
+ break;
}
/* We ref the file chooser since volume_mount() may run a main loop, and the
@@ -10177,6 +10119,7 @@ location_popup_handler (GtkFileChooserDefault *impl,
recent_switch_to_browse_mode (impl);
break;
case OPERATION_MODE_BROWSE:
+ default:
g_assert_not_reached ();
break;
}
diff --git a/gtk/gtkfilechooserdialog.c b/gtk/gtkfilechooserdialog.c
index 0868691..cb09636 100644
--- a/gtk/gtkfilechooserdialog.c
+++ b/gtk/gtkfilechooserdialog.c
@@ -232,15 +232,15 @@ file_chooser_widget_response_requested (GtkWidget *widget,
for (l = children; l; l = l->next)
{
- GtkWidget *widget;
+ GtkWidget *child;
int response_id;
- widget = GTK_WIDGET (l->data);
- response_id = gtk_dialog_get_response_for_widget (GTK_DIALOG (dialog), widget);
+ child = GTK_WIDGET (l->data);
+ response_id = gtk_dialog_get_response_for_widget (GTK_DIALOG (dialog), child);
if (is_stock_accept_response_id (response_id))
{
dialog->priv->response_requested = TRUE;
- gtk_widget_activate (widget); /* Should we gtk_dialog_response (dialog, response_id) instead? */
+ gtk_widget_activate (child); /* Should we gtk_dialog_response (dialog, response_id) instead? */
break;
}
}
diff --git a/gtk/gtkfilechooserprivate.h b/gtk/gtkfilechooserprivate.h
index b42f811..cfb0c70 100644
--- a/gtk/gtkfilechooserprivate.h
+++ b/gtk/gtkfilechooserprivate.h
@@ -308,6 +308,8 @@ struct _GtkFileChooserDefault
#endif
};
+gchar * _gtk_file_chooser_label_for_file (GFile *file);
+
G_END_DECLS
diff --git a/gtk/gtkfilechoosersettings.c b/gtk/gtkfilechoosersettings.c
index 1fc9623..fe171d5 100644
--- a/gtk/gtkfilechoosersettings.c
+++ b/gtk/gtkfilechoosersettings.c
@@ -381,8 +381,8 @@ _gtk_file_chooser_settings_save (GtkFileChooserSettings *settings,
gchar *filename;
gchar *dirname;
gchar *contents;
- gchar *sort_column;
- gchar *sort_order;
+ const gchar *sort_column;
+ const gchar *sort_order;
gsize len;
gboolean retval;
GKeyFile *key_file;
@@ -472,20 +472,20 @@ _gtk_file_chooser_settings_save (GtkFileChooserSettings *settings,
if (!g_file_set_contents (filename, contents, len, NULL))
{
- char *dirname;
+ char *dir;
int saved_errno;
/* Directory is not there? */
- dirname = get_config_dirname ();
- if (g_mkdir_with_parents (dirname, 0700) != 0) /* 0700 per the XDG basedir spec */
+ dir = get_config_dirname ();
+ if (g_mkdir_with_parents (dir, 0700) != 0) /* 0700 per the XDG basedir spec */
{
saved_errno = errno;
g_set_error (error,
G_FILE_ERROR,
g_file_error_from_errno (saved_errno),
_("Error creating folder '%s': %s"),
- dirname, g_strerror (saved_errno));
+ dir, g_strerror (saved_errno));
goto out;
}
diff --git a/gtk/gtkfilesystemmodel.h b/gtk/gtkfilesystemmodel.h
index d27a647..11e1d7c 100644
--- a/gtk/gtkfilesystemmodel.h
+++ b/gtk/gtkfilesystemmodel.h
@@ -67,6 +67,9 @@ const GValue * _gtk_file_system_model_get_value (GtkFileSystemModel
void _gtk_file_system_model_add_file (GtkFileSystemModel *model,
GFile *file,
GFileInfo *info);
+void _gtk_file_system_model_add_and_query_file(GtkFileSystemModel *model,
+ GFile * file,
+ const char * attributes);
void _gtk_file_system_model_remove_file (GtkFileSystemModel *model,
GFile *file);
void _gtk_file_system_model_update_file (GtkFileSystemModel *model,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]