From 569e5de21acc66597e902975cbc357a2fc9ba37c Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Thu, 25 Nov 2010 13:38:40 +0000 Subject: Resolves: rhbz#610103 exit quickstarter if physically deleted (cherry picked from commit 6cce245a2c4993828be54f3b415efb8bc8748f2c) --- sfx2/source/appl/shutdowniconunx.cxx | 48 ++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) (limited to 'sfx2/source/appl/shutdowniconunx.cxx') diff --git a/sfx2/source/appl/shutdowniconunx.cxx b/sfx2/source/appl/shutdowniconunx.cxx index b988ad614d13..7791ad721ff7 100644 --- a/sfx2/source/appl/shutdowniconunx.cxx +++ b/sfx2/source/appl/shutdowniconunx.cxx @@ -19,6 +19,10 @@ #include "shutdownicon.hxx" #endif +#ifdef ENABLE_GIO +#include +#endif + // Cut/paste from vcl/inc/svids.hrc #define SV_ICON_SMALL_START 25000 @@ -39,6 +43,9 @@ static EggTrayIcon *pTrayIcon; static GtkWidget *pExitMenuItem = NULL; static GtkWidget *pOpenMenuItem = NULL; static GtkWidget *pDisableMenuItem = NULL; +#ifdef ENABLE_GIO +GFileMonitor* pMonitor = NULL; +#endif static void open_url_cb( GtkWidget *, gpointer data ) { @@ -357,6 +364,22 @@ extern "C" { } } +#ifdef ENABLE_GIO +/* + * See rhbz#610103. If the quickstarter is running, then LibreOffice is + * upgraded, then the old quickstarter is still running, but is now unreliable + * as the old install has been deleted. A fairly intractable problem but we + * can avoid much of the pain if we turn off the quickstarter if we detect + * that it has been physically deleted. +*/ +static void notify_file_changed(GFileMonitor * /*gfilemonitor*/, GFile * /*arg1*/, + GFile * /*arg2*/, GFileMonitorEvent event_type, gpointer /*user_data*/) +{ + if (event_type == G_FILE_MONITOR_EVENT_DELETED) + exit_quickstarter_cb(GTK_WIDGET(pTrayIcon)); +} +#endif + void SAL_DLLPUBLIC_EXPORT plugin_init_sys_tray() { ::SolarMutexGuard aGuard; @@ -402,6 +425,20 @@ void SAL_DLLPUBLIC_EXPORT plugin_init_sys_tray() g_signal_connect(GTK_WIDGET(pTrayIcon), "destroy", G_CALLBACK(exit_quickstarter_cb), NULL); + +#ifdef ENABLE_GIO + GFile* pFile = NULL; + rtl::OUString sLibraryFileUrl; + if (osl::Module::getUrlFromAddress(plugin_init_sys_tray, sLibraryFileUrl)) + pFile = g_file_new_for_uri(rtl::OUStringToOString(sLibraryFileUrl, RTL_TEXTENCODING_UTF8).getStr()); + + if (pFile) + { + if ((pMonitor = g_file_monitor_file(pFile, G_FILE_MONITOR_NONE, NULL, NULL))) + g_signal_connect(pMonitor, "changed", (GCallback)notify_file_changed, NULL); + g_object_unref(pFile); + } +#endif } void SAL_DLLPUBLIC_EXPORT plugin_shutdown_sys_tray() @@ -410,6 +447,17 @@ void SAL_DLLPUBLIC_EXPORT plugin_shutdown_sys_tray() if( !pTrayIcon ) return; +#ifdef ENABLE_GIO + if (pMonitor) + { + g_signal_handlers_disconnect_by_func(pMonitor, + (void*)notify_file_changed, pMonitor); + g_file_monitor_cancel(pMonitor); + g_object_unref(pMonitor); + pMonitor = NULL; + } +#endif + /* we have to set pTrayIcon to NULL now, because gtk_widget_destroy * causes calling exit_quickstarter_cb (which then calls this func.) * again -> crash. -- cgit