[gnome-menus] libmenu: Simplify some code
- From: Vincent Untz <vuntz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-menus] libmenu: Simplify some code
- Date: Mon, 1 Aug 2011 17:44:47 +0000 (UTC)
commit 6ba57847943cd74839a306ed6c8926401e370b85
Author: Vincent Untz <vuntz gnome org>
Date: Sun Jun 12 12:50:05 2011 +0200
libmenu: Simplify some code
libmenu/desktop-entries.c | 27 ++++++++++++++-------------
1 files changed, 14 insertions(+), 13 deletions(-)
---
diff --git a/libmenu/desktop-entries.c b/libmenu/desktop-entries.c
index 4d30c7d..fc918bf 100644
--- a/libmenu/desktop-entries.c
+++ b/libmenu/desktop-entries.c
@@ -346,7 +346,6 @@ DesktopEntry *
desktop_entry_copy (DesktopEntry *entry)
{
DesktopEntry *retval;
- int i;
menu_verbose ("Copying desktop entry \"%s\"\n",
entry->basename);
@@ -367,23 +366,23 @@ desktop_entry_copy (DesktopEntry *entry)
{
DesktopEntryDesktop *desktop_entry = (DesktopEntryDesktop*) entry;
DesktopEntryDesktop *retval_desktop_entry = (DesktopEntryDesktop*) retval;
+ int i;
retval_desktop_entry->appinfo = g_object_ref (desktop_entry->appinfo);
- i = 0;
if (desktop_entry->categories != NULL)
{
+ i = 0;
for (; desktop_entry->categories[i]; i++);
- }
- retval_desktop_entry->categories = g_new0 (GQuark, i + 1);
+ retval_desktop_entry->categories = g_new0 (GQuark, i + 1);
- i = 0;
- if (desktop_entry->categories != NULL)
- {
+ i = 0;
for (; desktop_entry->categories[i]; i++)
retval_desktop_entry->categories[i] = desktop_entry->categories[i];
}
+ else
+ retval_desktop_entry->categories = NULL;
}
else if (entry->type == DESKTOP_ENTRY_DIRECTORY)
{
@@ -565,20 +564,22 @@ desktop_entry_add_legacy_category (DesktopEntry *entry)
menu_verbose ("Adding Legacy category to \"%s\"\n",
entry->basename);
- i = 0;
if (desktop_entry->categories != NULL)
{
+ i = 0;
for (; desktop_entry->categories[i]; i++);
- }
- categories = g_new0 (GQuark, i + 2);
+ categories = g_new0 (GQuark, i + 2);
- i = 0;
- if (desktop_entry->categories != NULL)
- {
+ i = 0;
for (; desktop_entry->categories[i]; i++)
categories[i] = desktop_entry->categories[i];
}
+ else
+ {
+ categories = g_new0 (GQuark, 2);
+ i = 0;
+ }
categories[i] = g_quark_from_string ("Legacy");
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]