[Libreoffice-commits] .: Branch 'libreoffice-3-3' - 3 commits - desktop/inc desktop/source sfx2/source

Caolán McNamara caolan at kemper.freedesktop.org
Sat Nov 27 08:47:14 PST 2010


 desktop/inc/app.hxx                  |    1 
 desktop/source/app/app.cxx           |   25 +++++++++++++++--
 desktop/source/app/appfirststart.cxx |    6 ++--
 sfx2/source/appl/makefile.mk         |    4 ++
 sfx2/source/appl/shutdowniconunx.cxx |   50 ++++++++++++++++++++++++++++++++++-
 5 files changed, 79 insertions(+), 7 deletions(-)

New commits:
commit 34766f8183bd35849fcbeb752dc4baec87aa7b71
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Thu Nov 25 13:38:40 2010 +0000

    Resolves: rhbz#610103 exit quickstarter if physically deleted
    (cherry picked from commit 6cce245a2c4993828be54f3b415efb8bc8748f2c)

diff --git a/sfx2/source/appl/makefile.mk b/sfx2/source/appl/makefile.mk
index 72ac94a..a583102 100644
--- a/sfx2/source/appl/makefile.mk
+++ b/sfx2/source/appl/makefile.mk
@@ -53,6 +53,10 @@ CFLAGS+=-DENABLE_QUICKSTART_APPLET
         CDEFS+=-DDLL_NAME=libsfx$(DLLPOSTFIX)$(DLLPOST)
 .IF "$(ENABLE_SYSTRAY_GTK)"=="TRUE"
         PKGCONFIG_MODULES=gtk+-2.0
+.IF "$(ENABLE_GIO)"!=""
+        PKGCONFIG_MODULES+=gio-2.0
+        CDEFS+=-DENABLE_GIO
+.ENDIF
         .INCLUDE: pkg_config.mk
         CFLAGS+=$(PKGCONFIG_CFLAGS)
         CFLAGS+=-DENABLE_QUICKSTART_APPLET
diff --git a/sfx2/source/appl/shutdowniconunx.cxx b/sfx2/source/appl/shutdowniconunx.cxx
index c28e73a..7791ad7 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 <gio/gio.h>
+#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.
@@ -418,7 +466,7 @@ void SAL_DLLPUBLIC_EXPORT plugin_shutdown_sys_tray()
      */
     GtkWidget* const pIcon = GTK_WIDGET( pTrayIcon );
     pTrayIcon = NULL;
-	gtk_widget_destroy( pIcon );
+    gtk_widget_destroy( pIcon );
 
     pExitMenuItem = NULL;
     pOpenMenuItem = NULL;
commit 5ce0c6a44121e037cd0505e5b2e00c051a43d600
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Thu Nov 25 09:40:08 2010 +0000

    start quickstarter on every launch if configured to use it
    (cherry picked from commit f3c0854fc93928772e7a3fba92402441ec51e312)

diff --git a/desktop/inc/app.hxx b/desktop/inc/app.hxx
index b657374..977080c 100644
--- a/desktop/inc/app.hxx
+++ b/desktop/inc/app.hxx
@@ -155,6 +155,7 @@ class Desktop : public Application
         sal_Bool				InitializeInstallation( const rtl::OUString& rAppFilename );
         sal_Bool				InitializeConfiguration();
         void                    FlushConfiguration();
+        static sal_Bool         shouldLaunchQuickstart();
         sal_Bool				InitializeQuickstartMode( com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >& rSMgr );
 
         void					HandleBootstrapPathErrors( ::utl::Bootstrap::Status, const ::rtl::OUString& aMsg );
diff --git a/desktop/source/app/app.cxx b/desktop/source/app/app.cxx
index b8d9aa7..05858e1 100644
--- a/desktop/source/app/app.cxx
+++ b/desktop/source/app/app.cxx
@@ -140,6 +140,9 @@
 #include <vcl/stdtext.hxx>
 #include <vcl/msgbox.hxx>
 #include <sfx2/sfx.hrc>
+#include <sfx2/app.hxx>
+#include <svl/itemset.hxx>
+#include <svl/eitem.hxx>
 #include <ucbhelper/contentbroker.hxx>
 #include <unotools/bootstrap.hxx>
 #include <cppuhelper/bootstrap.hxx>
@@ -2071,6 +2074,22 @@ void Desktop::FlushConfiguration()
     }
 }
 
+sal_Bool Desktop::shouldLaunchQuickstart()
+{
+    sal_Bool bQuickstart = GetCommandLineArgs()->IsQuickstart();
+    if (!bQuickstart)
+    {
+        const SfxPoolItem* pItem=0;
+        SfxItemSet aQLSet(SFX_APP()->GetPool(), SID_ATTR_QUICKLAUNCHER, SID_ATTR_QUICKLAUNCHER);
+        SFX_APP()->GetOptions(aQLSet);
+        SfxItemState eState = aQLSet.GetItemState(SID_ATTR_QUICKLAUNCHER, FALSE, &pItem);
+        if (SFX_ITEM_SET == eState)
+            bQuickstart = ((SfxBoolItem*)pItem)->GetValue();
+    }
+    return bQuickstart;
+}
+
+
 sal_Bool Desktop::InitializeQuickstartMode( Reference< XMultiServiceFactory >& rSMgr )
 {
     try
@@ -2080,9 +2099,7 @@ sal_Bool Desktop::InitializeQuickstartMode( Reference< XMultiServiceFactory >& r
         // this will only be activated if -quickstart was specified on cmdline
         RTL_LOGFILE_CONTEXT( aLog, "desktop (cd100003) createInstance com.sun.star.office.Quickstart" );
 
-        sal_Bool bQuickstart = GetCommandLineArgs()->IsQuickstart();
-        Sequence< Any > aSeq( 1 );
-        aSeq[0] <<= bQuickstart;
+        sal_Bool bQuickstart = shouldLaunchQuickstart();
 
         // Try to instanciate quickstart service. This service is not mandatory, so
         // do nothing if service is not available
@@ -2095,6 +2112,8 @@ sal_Bool Desktop::InitializeQuickstartMode( Reference< XMultiServiceFactory >& r
         if ( bQuickstart )
         #endif
         {
+            Sequence< Any > aSeq( 1 );
+            aSeq[0] <<= bQuickstart;
             Reference < XComponent > xQuickstart( rSMgr->createInstanceWithArguments(
                                                 DEFINE_CONST_UNICODE( "com.sun.star.office.Quickstart" ), aSeq ),
                                                 UNO_QUERY );
diff --git a/desktop/source/app/appfirststart.cxx b/desktop/source/app/appfirststart.cxx
index 6acc9e7..6e6b4c3 100644
--- a/desktop/source/app/appfirststart.cxx
+++ b/desktop/source/app/appfirststart.cxx
@@ -286,7 +286,8 @@ void Desktop::DoRestartActionsIfNecessary( sal_Bool bQuickStart )
                 Reference< util::XChangesBatch >( xPSet, UNO_QUERY_THROW )->commitChanges();
 
                 Sequence< Any > aSeq( 1 );
-                aSeq[0] <<= sal_True;
+                sal_Bool bQuickstart = shouldLaunchQuickstart();
+                aSeq[0] <<= bQuickstart;
 
                 Reference < XInitialization > xQuickstart( ::comphelper::getProcessServiceFactory()->createInstance(
                     OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.office.Quickstart" ) ) ),UNO_QUERY_THROW );
commit 2c74c04a7167ef1dee0be558c4929776348d7887
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Thu Nov 25 09:38:16 2010 +0000

    Only start the quick-starter on restart, don't install it forever
    (cherry picked from commit eab21a84137e010ae46b0b77c44c80d377964071)

diff --git a/desktop/source/app/appfirststart.cxx b/desktop/source/app/appfirststart.cxx
index 79c3c57..6acc9e7 100644
--- a/desktop/source/app/appfirststart.cxx
+++ b/desktop/source/app/appfirststart.cxx
@@ -285,9 +285,8 @@ void Desktop::DoRestartActionsIfNecessary( sal_Bool bQuickStart )
                 xPSet->setPropertyValue( sPropName, makeAny( sal_False ) );
                 Reference< util::XChangesBatch >( xPSet, UNO_QUERY_THROW )->commitChanges();
 
-                Sequence< Any > aSeq( 2 );
+                Sequence< Any > aSeq( 1 );
                 aSeq[0] <<= sal_True;
-                aSeq[1] <<= sal_True;
 
                 Reference < XInitialization > xQuickstart( ::comphelper::getProcessServiceFactory()->createInstance(
                     OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.office.Quickstart" ) ) ),UNO_QUERY_THROW );


More information about the Libreoffice-commits mailing list