[gedit] Clean up gedit_recent_add_document()
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gedit] Clean up gedit_recent_add_document()
- Date: Fri, 26 Jun 2015 12:22:41 +0000 (UTC)
commit cd9ed7b05eb0397ac3345d7e5177d2a112e7874b
Author: Sébastien Wilmet <swilmet gnome org>
Date: Fri Jun 26 14:17:49 2015 +0200
Clean up gedit_recent_add_document()
- Don't allocate the GtkRecentData on the heap, having it on the stack is
simpler.
- Avoid an indentation level.
gedit/gedit-recent.c | 49 ++++++++++++++++++++++---------------------------
1 files changed, 22 insertions(+), 27 deletions(-)
---
diff --git a/gedit/gedit-recent.c b/gedit/gedit-recent.c
index bcae0ac..28ee5db 100644
--- a/gedit/gedit-recent.c
+++ b/gedit/gedit-recent.c
@@ -31,48 +31,43 @@
void
gedit_recent_add_document (GeditDocument *document)
{
- GtkRecentManager *recent_manager;
- GtkRecentData *recent_data;
GtkSourceFile *file;
GFile *location;
+ GtkRecentManager *recent_manager;
+ GtkRecentData recent_data;
gchar *uri;
+ static gchar *groups[2] = { "gedit", NULL };
g_return_if_fail (GEDIT_IS_DOCUMENT (document));
- static gchar *groups[2] = {
- "gedit",
- NULL
- };
-
file = gedit_document_get_file (document);
location = gtk_source_file_get_location (file);
- if (location != NULL)
+ if (location == NULL)
{
- recent_manager = gtk_recent_manager_get_default ();
-
- recent_data = g_slice_new (GtkRecentData);
+ return;
+ }
- recent_data->display_name = NULL;
- recent_data->description = NULL;
- recent_data->mime_type = gedit_document_get_mime_type (document);
- recent_data->app_name = (gchar *) g_get_application_name ();
- recent_data->app_exec = g_strjoin (" ", g_get_prgname (), "%u", NULL);
- recent_data->groups = groups;
- recent_data->is_private = FALSE;
+ recent_manager = gtk_recent_manager_get_default ();
- uri = g_file_get_uri (location);
+ recent_data.display_name = NULL;
+ recent_data.description = NULL;
+ recent_data.mime_type = gedit_document_get_mime_type (document);
+ recent_data.app_name = (gchar *) g_get_application_name ();
+ recent_data.app_exec = g_strjoin (" ", g_get_prgname (), "%u", NULL);
+ recent_data.groups = groups;
+ recent_data.is_private = FALSE;
- if (!gtk_recent_manager_add_full (recent_manager, uri, recent_data))
- {
- g_warning ("Failed to add uri '%s' to the recent manager.", uri);
- }
+ uri = g_file_get_uri (location);
- g_free (uri);
- g_free (recent_data->app_exec);
- g_free (recent_data->mime_type);
- g_slice_free (GtkRecentData, recent_data);
+ if (!gtk_recent_manager_add_full (recent_manager, uri, &recent_data))
+ {
+ g_warning ("Failed to add uri '%s' to the recent manager.", uri);
}
+
+ g_free (uri);
+ g_free (recent_data.app_exec);
+ g_free (recent_data.mime_type);
}
void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]