[Xfce4-commits] [panel-plugins/xfce4-whiskermenu-plugin] 459/473: Fix hang at launch by removing load thread. Closes #105

noreply at xfce.org noreply at xfce.org
Tue Feb 17 00:00:29 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 fb43dafe8596bda694db7de83f23cfaf2de4943a
Author: Graeme Gott <graeme at gottcode.org>
Date:   Sat Feb 14 05:28:48 2015 -0500

    Fix hang at launch by removing load thread. Closes #105
---
 panel-plugin/applications-page.cpp |   47 ++++++------------------------------
 panel-plugin/applications-page.h   |   15 +-----------
 panel-plugin/window.cpp            |   39 ++++--------------------------
 panel-plugin/window.h              |    3 ---
 4 files changed, 13 insertions(+), 91 deletions(-)

diff --git a/panel-plugin/applications-page.cpp b/panel-plugin/applications-page.cpp
index e33058e..ff56bb6 100644
--- a/panel-plugin/applications-page.cpp
+++ b/panel-plugin/applications-page.cpp
@@ -43,7 +43,6 @@ enum
 ApplicationsPage::ApplicationsPage(Window* window) :
 	Page(window),
 	m_garcon_menu(NULL),
-	m_load_thread(NULL),
 	m_load_status(STATUS_INVALID)
 {
 	// Set desktop environment for applications
@@ -63,12 +62,6 @@ ApplicationsPage::ApplicationsPage(Window* window) :
 
 ApplicationsPage::~ApplicationsPage()
 {
-	if (m_load_thread)
-	{
-		g_thread_join(m_load_thread);
-		m_load_thread = NULL;
-	}
-
 	clear_applications();
 }
 
@@ -160,35 +153,20 @@ void ApplicationsPage::invalidate_applications()
 
 //-----------------------------------------------------------------------------
 
-bool ApplicationsPage::load_applications()
+void ApplicationsPage::load_applications()
 {
 	// Check if already loaded
 	if (m_load_status == STATUS_LOADED)
 	{
-		return false;
-	}
-	// Check if currently loading
-	else if (m_load_status == STATUS_LOADING)
-	{
-		return true;
-	}
-	// Check if loading garcon
-	else if (m_load_thread)
-	{
-		return true;
+		return;
 	}
 	m_load_status = STATUS_LOADING;
 
+	// Load menu
 	clear_applications();
+	load_contents();
 
-	// Load garcon menu in thread if possible
-	m_load_thread = g_thread_try_new(NULL, (GThreadFunc)&ApplicationsPage::load_garcon_menu_slot, this, NULL);
-	if (!m_load_thread)
-	{
-		load_garcon_menu();
-	}
-
-	return true;
+	return;
 }
 
 //-----------------------------------------------------------------------------
@@ -232,8 +210,9 @@ void ApplicationsPage::clear_applications()
 
 //-----------------------------------------------------------------------------
 
-void ApplicationsPage::load_garcon_menu()
+void ApplicationsPage::load_contents()
 {
+	// Load garcon menu
 	if (wm_settings->custom_menu_file.empty())
 	{
 		m_garcon_menu = garcon_menu_new_applications();
@@ -249,19 +228,9 @@ void ApplicationsPage::load_garcon_menu()
 		m_garcon_menu = NULL;
 	}
 
-	g_idle_add((GSourceFunc)&ApplicationsPage::load_contents_slot, this);
-}
-
-//-----------------------------------------------------------------------------
-
-void ApplicationsPage::load_contents()
-{
 	if (!m_garcon_menu)
 	{
-		get_window()->set_loaded();
-
 		m_load_status = STATUS_INVALID;
-		m_load_thread = NULL;
 
 		return;
 	}
@@ -307,10 +276,8 @@ void ApplicationsPage::load_contents()
 
 	// Update menu items of other panels
 	get_window()->set_items();
-	get_window()->set_loaded();
 
 	m_load_status = STATUS_LOADED;
-	m_load_thread = NULL;
 }
 
 //-----------------------------------------------------------------------------
diff --git a/panel-plugin/applications-page.h b/panel-plugin/applications-page.h
index 0a08706..dcedadf 100644
--- a/panel-plugin/applications-page.h
+++ b/panel-plugin/applications-page.h
@@ -43,7 +43,7 @@ public:
 	Launcher* get_application(const std::string& desktop_id) const;
 
 	void invalidate_applications();
-	bool load_applications();
+	void load_applications();
 	void reload_category_icon_size();
 
 private:
@@ -54,23 +54,10 @@ private:
 	void load_menu(GarconMenu* menu, Category* parent_category);
 	void load_menu_item(GarconMenuItem* menu_item, Category* category);
 
-	static gpointer load_garcon_menu_slot(ApplicationsPage *obj)
-	{
-		obj->load_garcon_menu();
-		return NULL;
-	}
-
-	static gboolean load_contents_slot(ApplicationsPage* obj)
-	{
-		obj->load_contents();
-		return false;
-	}
-
 private:
 	GarconMenu* m_garcon_menu;
 	std::vector<Category*> m_categories;
 	std::map<std::string, Launcher*> m_items;
-	GThread* m_load_thread;
 	int m_load_status;
 };
 
diff --git a/panel-plugin/window.cpp b/panel-plugin/window.cpp
index da53e09..bfdf717 100644
--- a/panel-plugin/window.cpp
+++ b/panel-plugin/window.cpp
@@ -75,18 +75,6 @@ WhiskerMenu::Window::Window() :
 	m_window_box = GTK_BOX(gtk_vbox_new(false, 0));
 	gtk_container_add(GTK_CONTAINER(m_window), GTK_WIDGET(m_window_box));
 
-	// Create loading message
-	m_window_load_contents = gtk_frame_new(NULL);
-	gtk_frame_set_shadow_type(GTK_FRAME(m_window_load_contents), GTK_SHADOW_OUT);
-	gtk_box_pack_start(m_window_box, m_window_load_contents, true, true, 0);
-
-	m_window_load_spinner = GTK_SPINNER(gtk_spinner_new());
-
-	GtkAlignment* alignment = GTK_ALIGNMENT(gtk_alignment_new(0.5, 0.5, 0.1, 0.1));
-	gtk_container_add(GTK_CONTAINER(alignment), GTK_WIDGET(m_window_load_spinner));
-
-	gtk_container_add(GTK_CONTAINER(m_window_load_contents), GTK_WIDGET(alignment));
-
 	// Create the border of the window
 	m_window_contents = gtk_frame_new(NULL);
 	gtk_frame_set_shadow_type(GTK_FRAME(m_window_contents), GTK_SHADOW_OUT);
@@ -223,8 +211,7 @@ WhiskerMenu::Window::Window() :
 	gtk_widget_hide(m_applications->get_widget());
 	gtk_widget_hide(m_search_results->get_widget());
 	m_default_button->set_active(true);
-	gtk_widget_hide(m_window_contents);
-	gtk_widget_show(m_window_load_contents);
+	gtk_widget_show(m_window_contents);
 
 	// Resize to last known size
 	gtk_window_set_default_size(m_window, m_geometry.width, m_geometry.height);
@@ -238,10 +225,6 @@ WhiskerMenu::Window::Window() :
 	on_screen_changed_event(GTK_WIDGET(m_window), NULL);
 
 	g_object_ref_sink(m_window);
-
-	// Start loading applications immediately
-	m_applications->load_applications();
-	gtk_spinner_start(m_window_load_spinner);
 }
 
 //-----------------------------------------------------------------------------
@@ -308,12 +291,10 @@ void WhiskerMenu::Window::show(GtkWidget* parent, bool horizontal)
 	m_recent->enforce_item_count();
 
 	// Make sure applications list is current; does nothing unless list has changed
-	if (m_applications->load_applications() && gtk_widget_get_visible(m_window_contents))
-	{
-		gtk_widget_hide(m_window_contents);
-		gtk_widget_show(m_window_load_contents);
-		gtk_spinner_start(m_window_load_spinner);
-	}
+	m_applications->load_applications();
+
+	// Focus search entry
+	gtk_widget_grab_focus(GTK_WIDGET(m_search_entry));
 
 	// Reset mouse cursor by forcing default page to hide
 	gtk_widget_show(m_default_page->get_widget());
@@ -642,16 +623,6 @@ void WhiskerMenu::Window::set_items()
 
 //-----------------------------------------------------------------------------
 
-void WhiskerMenu::Window::set_loaded()
-{
-	gtk_spinner_stop(m_window_load_spinner);
-	gtk_widget_hide(m_window_load_contents);
-	gtk_widget_show(m_window_contents);
-	gtk_widget_grab_focus(GTK_WIDGET(m_search_entry));
-}
-
-//-----------------------------------------------------------------------------
-
 void WhiskerMenu::Window::unset_items()
 {
 	m_search_results->unset_menu_items();
diff --git a/panel-plugin/window.h b/panel-plugin/window.h
index bfaec1f..99f225f 100644
--- a/panel-plugin/window.h
+++ b/panel-plugin/window.h
@@ -71,7 +71,6 @@ public:
 	void on_context_menu_destroyed();
 	void set_categories(const std::vector<SectionButton*>& categories);
 	void set_items();
-	void set_loaded();
 	void unset_items();
 
 private:
@@ -96,8 +95,6 @@ private:
 
 	GtkBox* m_window_box;
 	GtkWidget* m_window_contents;
-	GtkSpinner* m_window_load_spinner;
-	GtkWidget* m_window_load_contents;
 
 	GtkBox* m_vbox;
 	GtkBox* m_title_box;

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


More information about the Xfce4-commits mailing list