[Xfce4-commits] [panel-plugins/xfce4-whiskermenu-plugin] 470/473: Use a single instance of the garcon menu.

noreply at xfce.org noreply at xfce.org
Tue Feb 17 00:00:40 CET 2015


This is an automated email from the git hooks/post-receive script.

gottcode pushed a commit to branch master
in repository panel-plugins/xfce4-whiskermenu-plugin.

commit 68e78e753d39828be4c25d696531bc79e5a0672a
Author: Graeme Gott <graeme at gottcode.org>
Date:   Sat Feb 14 17:55:46 2015 -0500

    Use a single instance of the garcon menu.
---
 panel-plugin/applications-page.cpp |   49 ++++++++++++++++++------------------
 1 file changed, 25 insertions(+), 24 deletions(-)

diff --git a/panel-plugin/applications-page.cpp b/panel-plugin/applications-page.cpp
index 677a708..1dcedb9 100644
--- a/panel-plugin/applications-page.cpp
+++ b/panel-plugin/applications-page.cpp
@@ -63,6 +63,12 @@ ApplicationsPage::ApplicationsPage(Window* window) :
 ApplicationsPage::~ApplicationsPage()
 {
 	clear_applications();
+
+	// Free menu
+	if (G_LIKELY(m_garcon_menu))
+	{
+		g_object_unref(m_garcon_menu);
+	}
 }
 
 //-----------------------------------------------------------------------------
@@ -199,44 +205,39 @@ void ApplicationsPage::clear_applications()
 		delete i->second;
 	}
 	m_items.clear();
-
-	// Unreference menu
-	if (m_garcon_menu)
-	{
-		g_object_unref(m_garcon_menu);
-		m_garcon_menu = NULL;
-	}
 }
 
 //-----------------------------------------------------------------------------
 
 void ApplicationsPage::load_contents()
 {
-	// Load garcon menu
-	if (wm_settings->custom_menu_file.empty())
-	{
-		m_garcon_menu = garcon_menu_new_applications();
-	}
-	else
+	// Create menu
+	if (!m_garcon_menu)
 	{
-		m_garcon_menu = garcon_menu_new_for_path(wm_settings->custom_menu_file.c_str());
-	}
+		if (wm_settings->custom_menu_file.empty())
+		{
+			m_garcon_menu = garcon_menu_new_applications();
+		}
+		else
+		{
+			m_garcon_menu = garcon_menu_new_for_path(wm_settings->custom_menu_file.c_str());
+		}
 
-	if (m_garcon_menu && !garcon_menu_load(m_garcon_menu, NULL, NULL))
-	{
-		g_object_unref(m_garcon_menu);
-		m_garcon_menu = NULL;
+		if (!m_garcon_menu)
+		{
+			m_load_status = STATUS_INVALID;
+			return;
+		}
+
+		g_signal_connect_slot<GarconMenu*>(m_garcon_menu, "reload-required", &ApplicationsPage::invalidate_applications, this);
 	}
 
-	if (!m_garcon_menu)
+	// Load menu
+	if (!garcon_menu_load(m_garcon_menu, NULL, NULL))
 	{
 		m_load_status = STATUS_INVALID;
-
 		return;
 	}
-
-	// Populate map of menu data
-	g_signal_connect_slot<GarconMenu*>(m_garcon_menu, "reload-required", &ApplicationsPage::invalidate_applications, this);
 	load_menu(m_garcon_menu, NULL);
 
 	// Sort items and categories

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list