From 3bd7d9a34411324ac05b29e5f3ce510852e454d6 Mon Sep 17 00:00:00 2001 From: Ariel Constenla-Haile Date: Tue, 18 Oct 2011 03:40:15 -0300 Subject: [PATCH 2/2] i118519 - gtk quickstarter: remove dependency on libegg, use GtkStatusIcon instead --- configure.in | 6 +- desktop/source/app/app.cxx | 14 ++++- desktop/source/app/cmdlineargs.cxx | 2 +- desktop/source/app/makefile.mk | 4 + scp2/source/ooo/common_brand.scp | 22 +++--- scp2/source/ooo/file_library_ooo.scp | 31 ++++----- sfx2/Library_sfx.mk | 8 ++ sfx2/source/appl/shutdownicon.cxx | 12 +++- sfx2/source/appl/shutdowniconunx.cxx | 121 +++++++++++----------------------- 9 files changed, 103 insertions(+), 117 deletions(-) diff --git a/configure.in b/configure.in index 7ff4551..1aa4217 100644 --- a/configure.in +++ b/configure.in @@ -5797,8 +5797,10 @@ if test "$test_gtk" = "yes"; then BUILD_TYPE="$BUILD_TYPE GTK" if test "x$enable_systray" = "xyes"; then - ENABLE_SYSTRAY_GTK="TRUE" - BUILD_TYPE="$BUILD_TYPE SYSTRAY_GTK" + PKG_CHECK_MODULES(GTK_2_16,gtk+-2.0 >= 2.16.0, + [ENABLE_SYSTRAY_GTK="TRUE" + BUILD_TYPE="$BUILD_TYPE SYSTRAY_GTK"], + [ENABLE_SYSTRAY_GTK=""]) fi AC_MSG_CHECKING([whether to enable DBUS support]) diff --git a/desktop/source/app/app.cxx b/desktop/source/app/app.cxx index 801bcd9..06ca695 100644 --- a/desktop/source/app/app.cxx +++ b/desktop/source/app/app.cxx @@ -132,6 +132,8 @@ #include #include #include +#include +#include #include #include #include @@ -145,6 +147,7 @@ #include #include #include +#include #include #include #include @@ -2118,12 +2121,21 @@ sal_Bool Desktop::InitializeQuickstartMode( Reference< XMultiServiceFactory >& r RTL_LOGFILE_CONTEXT( aLog, "desktop (cd100003) createInstance com.sun.star.office.Quickstart" ); sal_Bool bQuickstart = GetCommandLineArgs()->IsQuickstart(); + if ( !bQuickstart ) + { + SfxItemSet aOptSet( SFX_APP()->GetPool(), SID_ATTR_QUICKLAUNCHER, SID_ATTR_QUICKLAUNCHER ); + SFX_APP()->GetOptions(aOptSet); + const SfxPoolItem* pItem; + if ( SFX_ITEM_SET == aOptSet.GetItemState( SID_ATTR_QUICKLAUNCHER, sal_False, &pItem ) ) + bQuickstart = ((const SfxBoolItem*)pItem)->GetValue(); + } + Sequence< Any > aSeq( 1 ); aSeq[0] <<= bQuickstart; // Try to instanciate quickstart service. This service is not mandatory, so // do nothing if service is not available - + // #i105753# the following if was invented for performance // unfortunately this broke the QUARTZ behavior which is to always run // in quickstart mode since Mac applications do not usually quit diff --git a/desktop/source/app/cmdlineargs.cxx b/desktop/source/app/cmdlineargs.cxx index 3140c8a..3d436a5 100644 --- a/desktop/source/app/cmdlineargs.cxx +++ b/desktop/source/app/cmdlineargs.cxx @@ -422,7 +422,7 @@ sal_Bool CommandLineArgs::InterpretCommandLineParameter( const ::rtl::OUString& } else if ( aArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "-quickstart" )) == sal_True ) { -#if defined(WNT) || defined(OS2) || defined(QUARTZ) +#if defined(ENABLE_QUICKSTART_APPLET) SetBoolParam_Impl( CMD_BOOLPARAM_QUICKSTART, sal_True ); #endif SetBoolParam_Impl( CMD_BOOLPARAM_NOQUICKSTART, sal_False ); diff --git a/desktop/source/app/makefile.mk b/desktop/source/app/makefile.mk index 085d852..aac11f2 100644 --- a/desktop/source/app/makefile.mk +++ b/desktop/source/app/makefile.mk @@ -41,6 +41,10 @@ ENABLE_EXCEPTIONS=TRUE CFLAGS+=-DGNOME_VFS_ENABLED .ENDIF +.IF "$(GUI)"=="WNT" || "$(GUI)"=="OS2" || "$(GUIBASE)"=="aqua" || "$(ENABLE_SYSTRAY_GTK)"=="TRUE" +CFLAGS+=-DENABLE_QUICKSTART_APPLET +.ENDIF + # .IF "$(OS)" == "WNT" # .IF "$(COM)" == "GCC" # DEPLOYMENTMISCLIB = -ldeploymentmisc$(DLLPOSTFIX) diff --git a/scp2/source/ooo/common_brand.scp b/scp2/source/ooo/common_brand.scp index 88807d2..5af8680 100644 --- a/scp2/source/ooo/common_brand.scp +++ b/scp2/source/ooo/common_brand.scp @@ -98,7 +98,7 @@ Module gid_Module_Root_Brand gid_Brand_File_Share_Xdg_JavaFilter, gid_Brand_File_Share_Xdg_Math, gid_Brand_File_Share_Xdg_Printeradmin, -// gid_Brand_File_Share_Xdg_QStart, + gid_Brand_File_Share_Xdg_QStart, gid_Brand_File_Share_Xdg_StartCenter, gid_Brand_File_Share_Xdg_Writer, gid_Brand_File_Txt_Package); @@ -738,16 +738,16 @@ File gid_Brand_File_Share_Xdg_Printeradmin End #endif -//#if defined UNX && ! defined MACOSX -//#ifdef ENABLE_GTK -//File gid_Brand_File_Share_Xdg_QStart -// TXT_FILE_BODY; -// Dir = gid_Brand_Dir_Share_Xdg; -// Styles = (PACKED,SCPZIP_REPLACE); -// Name = "qstart.desktop"; -//End -//#endif -//#endif +#if defined UNX && ! defined MACOSX +#ifdef ENABLE_GTK +File gid_Brand_File_Share_Xdg_QStart + TXT_FILE_BODY; + Dir = gid_Brand_Dir_Share_Xdg; + Styles = (PACKED,SCPZIP_REPLACE); + Name = "qstart.desktop"; +End +#endif +#endif #if defined UNX && ! defined MACOSX File gid_Brand_File_Share_Xdg_Writer diff --git a/scp2/source/ooo/file_library_ooo.scp b/scp2/source/ooo/file_library_ooo.scp index 52a7d62..808fdf2 100755 --- a/scp2/source/ooo/file_library_ooo.scp +++ b/scp2/source/ooo/file_library_ooo.scp @@ -208,25 +208,18 @@ End #endif -//#ifdef UNX -//#ifdef ENABLE_GTK -//#ifdef ENABLE_SYSTRAY_GTK -//File gid_File_Lib_Egg_Tray -// TXT_FILE_BODY; -// Styles = (PACKED); -// Dir = SCP2_OOO_BIN_DIR; -// Name = STRING(CONCAT3(libeggtray,DLLPOSTFIX,UNXSUFFIX)); -//End -// -//File gid_File_Lib_QStart_Gtk -// Name = LIBNAME(qstart_gtk); -// TXT_FILE_BODY; -// Styles = (PACKED); -// Dir = SCP2_OOO_BIN_DIR; -//End -//#endif -//#endif -//#endif +#ifdef UNX +#ifdef ENABLE_GTK +#ifdef ENABLE_SYSTRAY_GTK +File gid_File_Lib_QStart_Gtk + Name = LIBNAME(qstart_gtk); + TXT_FILE_BODY; + Styles = (PACKED); + Dir = SCP2_OOO_BIN_DIR; +End +#endif +#endif +#endif STD_LIB_FILE( gid_File_Lib_Dba, dba) diff --git a/sfx2/Library_sfx.mk b/sfx2/Library_sfx.mk index 93c9fb9..634df79 100644 --- a/sfx2/Library_sfx.mk +++ b/sfx2/Library_sfx.mk @@ -273,6 +273,14 @@ $(eval $(call gb_Library_set_defs,sfx,\ )) endif +ifeq ($(ENABLE_SYSTRAY_GTK),TRUE) +$(eval $(call gb_Library_set_defs,sfx,\ + $$(DEFS) \ + -DENABLE_QUICKSTART_APPLET \ + -DENABLE_SYSTRAY_GTK \ +)) +endif + ifeq ($(OS),OS2) $(eval $(call gb_Library_add_exception_objects,sfx,\ sfx2/source/appl/shutdowniconOs2.ob \ diff --git a/sfx2/source/appl/shutdownicon.cxx b/sfx2/source/appl/shutdownicon.cxx index 92575a5..45e226e 100644 --- a/sfx2/source/appl/shutdownicon.cxx +++ b/sfx2/source/appl/shutdownicon.cxx @@ -62,6 +62,7 @@ #include #include #include +#include #include #ifdef UNX // need symlink #include @@ -826,8 +827,15 @@ rtl::OUString ShutdownIcon::getShortcutName() aShortcut += OUString( RTL_CONSTASCII_USTRINGPARAM( "\\" ) ); aShortcut += aShortcutName; #else // UNX - OUString aShortcut = getDotAutostart(); - aShortcut += OUString( RTL_CONSTASCII_USTRINGPARAM( "/qstart.desktop" ) ); + OUStringBuffer aStrBuff( getDotAutostart() ); + aStrBuff.appendAscii( RTL_CONSTASCII_STRINGPARAM( "/" ) ); + if ( sal_Int32 len = aShortcutName.getLength() ) + aStrBuff.append( aShortcutName.getStr(), len ); + else + aStrBuff.appendAscii( RTL_CONSTASCII_STRINGPARAM( "qstart" ) ); + aStrBuff.appendAscii( RTL_CONSTASCII_STRINGPARAM( ".desktop" ) ); + + OUString aShortcut( aStrBuff.makeStringAndClear() ); #endif // UNX return aShortcut; #endif // ENABLE_QUICKSTART_APPLET diff --git a/sfx2/source/appl/shutdowniconunx.cxx b/sfx2/source/appl/shutdowniconunx.cxx index 49ca9b9..405d840 100644 --- a/sfx2/source/appl/shutdowniconunx.cxx +++ b/sfx2/source/appl/shutdowniconunx.cxx @@ -2,12 +2,10 @@ #ifdef ENABLE_QUICKSTART_APPLET #include - #include #include #include -#include #include #include #include @@ -21,6 +19,7 @@ #endif // Cut/paste from vcl/inc/svids.hrc +#define SV_ICON_LARGE_START 24000 #define SV_ICON_SMALL_START 25000 #define SV_ICON_ID_OFFICE 1 @@ -36,9 +35,10 @@ using namespace ::rtl; using namespace ::osl; static ResMgr *pVCLResMgr; -static EggTrayIcon *pTrayIcon; +static GtkStatusIcon *pTrayIcon; static GtkWidget *pExitMenuItem = NULL; static GtkWidget *pOpenMenuItem = NULL; +static GtkWidget *pDisableMenuItem = NULL; static void open_url_cb( GtkWidget *, gpointer data ) { @@ -66,7 +66,6 @@ static void systray_disable_cb() static void exit_quickstarter_cb( GtkWidget * ) { - egg_tray_icon_cancel_message (pTrayIcon, 1 ); ShutdownIcon::getInstance()->terminateDesktop(); plugin_shutdown_sys_tray(); } @@ -78,7 +77,7 @@ static void menu_deactivate_cb( GtkWidget *pMenu ) static GdkPixbuf * ResIdToPixbuf( sal_uInt16 nResId ) { - ResId aResId( SV_ICON_SMALL_START + nResId, *pVCLResMgr ); + ResId aResId( nResId, *pVCLResMgr ); BitmapEx aIcon( aResId ); Bitmap pInSalBitmap = aIcon.GetBitmap(); AlphaMask pInSalAlpha = aIcon.GetAlpha(); @@ -152,9 +151,9 @@ static void add_item( GtkMenuShell *pMenuShell, const char *pAsciiURL, RTL_TEXTENCODING_UTF8); } - GdkPixbuf *pPixbuf= ResIdToPixbuf( nResId ); - GtkWidget *pImage = gtk_image_new_from_pixbuf( pPixbuf ); - g_object_unref( G_OBJECT( pPixbuf ) ); + GdkPixbuf *pPixbuf= ResIdToPixbuf( SV_ICON_SMALL_START + nResId ); + GtkWidget *pImage = gtk_image_new_from_pixbuf( pPixbuf ); + g_object_unref( G_OBJECT( pPixbuf ) ); GtkWidget *pMenuItem = gtk_image_menu_item_new_with_label( aLabel ); gtk_image_menu_item_set_image( GTK_IMAGE_MENU_ITEM( pMenuItem ), pImage ); @@ -262,10 +261,11 @@ static void populate_menu( GtkWidget *pMenu ) pShutdownIcon->GetResString( STR_QUICKSTART_FILEOPEN ), G_CALLBACK( open_file_cb )); + pMenuItem = gtk_separator_menu_item_new(); gtk_menu_shell_append( pMenuShell, pMenuItem ); - (void) add_image_menu_item + pDisableMenuItem = add_image_menu_item ( pMenuShell, GTK_STOCK_CLOSE, pShutdownIcon->GetResString( STR_QUICKSTART_PRELAUNCH_UNX ), G_CALLBACK( systray_disable_cb ) ); @@ -289,31 +289,9 @@ static void refresh_menu( GtkWidget *pMenu ) bool bModal = ShutdownIcon::bModalMode; gtk_widget_set_sensitive( pExitMenuItem, !bModal); gtk_widget_set_sensitive( pOpenMenuItem, !bModal); + gtk_widget_set_sensitive( pDisableMenuItem, !bModal); } -extern "C" { -static void -layout_menu( GtkMenu *menu, - gint *x, gint *y, gboolean *push_in, - gpointer ) -{ - GtkRequisition req; - GtkWidget *ebox = GTK_BIN( pTrayIcon )->child; - - gtk_widget_size_request( GTK_WIDGET( menu ), &req ); - gdk_window_get_origin( ebox->window, x, y ); - - (*x) += ebox->allocation.x; - (*y) += ebox->allocation.y; - - if (*y >= gdk_screen_get_height (gtk_widget_get_screen (ebox)) / 2) - (*y) -= req.height; - else - (*y) += ebox->allocation.height; - - *push_in = sal_True; -} -} static gboolean display_menu_cb( GtkWidget *, GdkEventButton *event, GtkWidget *pMenu ) @@ -321,36 +299,15 @@ static gboolean display_menu_cb( GtkWidget *, if (event->button == 2) return sal_False; -#ifdef TEMPLATE_DIALOG_MORE_POLISHED - if (event->button == 1 && - event->type == GDK_2BUTTON_PRESS) - { - open_template_cb( NULL ); - return sal_True; - } - if (event->button == 3) - { - ... as below ... -#endif - refresh_menu( pMenu ); gtk_menu_popup( GTK_MENU( pMenu ), NULL, NULL, - layout_menu, NULL, 0, event->time ); + gtk_status_icon_position_menu, + pTrayIcon, 0, event->time ); return sal_True; } -extern "C" { - static gboolean - show_at_idle( gpointer ) - { - ::vos::OGuard aGuard( Application::GetSolarMutex() ); - gtk_widget_show_all( GTK_WIDGET( pTrayIcon ) ); - return sal_False; - } -} - void SAL_DLLPUBLIC_EXPORT plugin_init_sys_tray() { ::vos::OGuard aGuard( Application::GetSolarMutex() ); @@ -358,41 +315,42 @@ void SAL_DLLPUBLIC_EXPORT plugin_init_sys_tray() if( !g_type_from_name( "GdkDisplay" ) ) return; + ShutdownIcon *pShutdownIcon = ShutdownIcon::getInstance(); + if ( !pShutdownIcon ) + return; + + pTrayIcon = gtk_status_icon_new(); + pVCLResMgr = CREATEVERSIONRESMGR( vcl ); + + if ( !pTrayIcon || !pVCLResMgr ) + return; + + // disable shutdown + pShutdownIcon->SetVeto( true ); + pShutdownIcon->addTerminateListener(); + OString aLabel; - ShutdownIcon *pShutdownIcon = ShutdownIcon::getInstance(); aLabel = rtl::OUStringToOString ( pShutdownIcon->GetResString( STR_QUICKSTART_TIP ), RTL_TEXTENCODING_UTF8 ); - pTrayIcon = egg_tray_icon_new( aLabel ); - - GtkWidget *pParent = gtk_event_box_new(); - GtkTooltips *pTooltips = gtk_tooltips_new(); - gtk_tooltips_set_tip( GTK_TOOLTIPS( pTooltips ), pParent, aLabel, NULL ); + GdkPixbuf *pPixbuf = ResIdToPixbuf( SV_ICON_LARGE_START + SV_ICON_ID_OFFICE ); + g_object_set( G_OBJECT( pTrayIcon ), + "pixbuf", pPixbuf, + "title", aLabel.getStr(), + NULL ); + g_object_unref( pPixbuf ); - GtkWidget *pIconImage = gtk_image_new(); - gtk_container_add( GTK_CONTAINER( pParent ), pIconImage ); + gtk_status_icon_set_tooltip_text( pTrayIcon, aLabel.getStr() ); - pVCLResMgr = CREATEVERSIONRESMGR( vcl ); + GtkWidget *pMenu = gtk_menu_new(); - GdkPixbuf *pPixbuf = ResIdToPixbuf( SV_ICON_ID_OFFICE ); - gtk_image_set_from_pixbuf( GTK_IMAGE( pIconImage ), pPixbuf ); - g_object_unref( pPixbuf ); + g_signal_connect( pTrayIcon, "button-press-event", + G_CALLBACK( display_menu_cb ), pMenu ); - GtkWidget *pMenu = gtk_menu_new(); - g_signal_connect (pMenu, "deactivate", - G_CALLBACK (menu_deactivate_cb), NULL); - g_signal_connect( pParent, "button_press_event", - G_CALLBACK( display_menu_cb ), pMenu ); - gtk_container_add( GTK_CONTAINER( pTrayIcon ), pParent ); - - // Show at idle to avoid artefacts at startup - g_idle_add (show_at_idle, (gpointer) pTrayIcon); - - // disable shutdown - pShutdownIcon->SetVeto( true ); - pShutdownIcon->addTerminateListener(); + g_signal_connect( pMenu, "deactivate", + G_CALLBACK (menu_deactivate_cb), NULL); } void SAL_DLLPUBLIC_EXPORT plugin_shutdown_sys_tray() @@ -400,10 +358,11 @@ void SAL_DLLPUBLIC_EXPORT plugin_shutdown_sys_tray() ::vos::OGuard aGuard( Application::GetSolarMutex() ); if( !pTrayIcon ) return; - gtk_widget_destroy( GTK_WIDGET( pTrayIcon ) ); + g_object_unref( pTrayIcon ); pTrayIcon = NULL; pExitMenuItem = NULL; pOpenMenuItem = NULL; + pDisableMenuItem = NULL; } #endif // ENABLE_QUICKSTART_APPLET -- 1.7.6.4