Lines 2-13
Link Here
|
2 |
#ifdef ENABLE_QUICKSTART_APPLET |
2 |
#ifdef ENABLE_QUICKSTART_APPLET |
3 |
|
3 |
|
4 |
#include <unotools/moduleoptions.hxx> |
4 |
#include <unotools/moduleoptions.hxx> |
5 |
|
|
|
6 |
#include <unotools/dynamicmenuoptions.hxx> |
5 |
#include <unotools/dynamicmenuoptions.hxx> |
7 |
|
6 |
|
8 |
#include <gtk/gtk.h> |
7 |
#include <gtk/gtk.h> |
9 |
#include <glib.h> |
8 |
#include <glib.h> |
10 |
#include <eggtray/eggtrayicon.h> |
|
|
11 |
#include <vos/mutex.hxx> |
9 |
#include <vos/mutex.hxx> |
12 |
#include <vcl/bitmapex.hxx> |
10 |
#include <vcl/bitmapex.hxx> |
13 |
#include <vcl/bmpacc.hxx> |
11 |
#include <vcl/bmpacc.hxx> |
Lines 21-26
Link Here
|
21 |
#endif |
19 |
#endif |
22 |
|
20 |
|
23 |
// Cut/paste from vcl/inc/svids.hrc |
21 |
// Cut/paste from vcl/inc/svids.hrc |
|
|
22 |
#define SV_ICON_LARGE_START 24000 |
24 |
#define SV_ICON_SMALL_START 25000 |
23 |
#define SV_ICON_SMALL_START 25000 |
25 |
|
24 |
|
26 |
#define SV_ICON_ID_OFFICE 1 |
25 |
#define SV_ICON_ID_OFFICE 1 |
Lines 36-44
using namespace ::rtl;
Link Here
|
36 |
using namespace ::osl; |
35 |
using namespace ::osl; |
37 |
|
36 |
|
38 |
static ResMgr *pVCLResMgr; |
37 |
static ResMgr *pVCLResMgr; |
39 |
static EggTrayIcon *pTrayIcon; |
38 |
static GtkStatusIcon *pTrayIcon; |
40 |
static GtkWidget *pExitMenuItem = NULL; |
39 |
static GtkWidget *pExitMenuItem = NULL; |
41 |
static GtkWidget *pOpenMenuItem = NULL; |
40 |
static GtkWidget *pOpenMenuItem = NULL; |
|
|
41 |
static GtkWidget *pDisableMenuItem = NULL; |
42 |
|
42 |
|
43 |
static void open_url_cb( GtkWidget *, gpointer data ) |
43 |
static void open_url_cb( GtkWidget *, gpointer data ) |
44 |
{ |
44 |
{ |
Lines 66-72
static void systray_disable_cb()
Link Here
|
66 |
|
66 |
|
67 |
static void exit_quickstarter_cb( GtkWidget * ) |
67 |
static void exit_quickstarter_cb( GtkWidget * ) |
68 |
{ |
68 |
{ |
69 |
egg_tray_icon_cancel_message (pTrayIcon, 1 ); |
|
|
70 |
ShutdownIcon::getInstance()->terminateDesktop(); |
69 |
ShutdownIcon::getInstance()->terminateDesktop(); |
71 |
plugin_shutdown_sys_tray(); |
70 |
plugin_shutdown_sys_tray(); |
72 |
} |
71 |
} |
Lines 78-84
static void menu_deactivate_cb( GtkWidget *pMenu )
Link Here
|
78 |
|
77 |
|
79 |
static GdkPixbuf * ResIdToPixbuf( sal_uInt16 nResId ) |
78 |
static GdkPixbuf * ResIdToPixbuf( sal_uInt16 nResId ) |
80 |
{ |
79 |
{ |
81 |
ResId aResId( SV_ICON_SMALL_START + nResId, *pVCLResMgr ); |
80 |
ResId aResId( nResId, *pVCLResMgr ); |
82 |
BitmapEx aIcon( aResId ); |
81 |
BitmapEx aIcon( aResId ); |
83 |
Bitmap pInSalBitmap = aIcon.GetBitmap(); |
82 |
Bitmap pInSalBitmap = aIcon.GetBitmap(); |
84 |
AlphaMask pInSalAlpha = aIcon.GetAlpha(); |
83 |
AlphaMask pInSalAlpha = aIcon.GetAlpha(); |
Lines 152-160
static void add_item( GtkMenuShell *pMenuShell, const char *pAsciiURL,
Link Here
|
152 |
RTL_TEXTENCODING_UTF8); |
151 |
RTL_TEXTENCODING_UTF8); |
153 |
} |
152 |
} |
154 |
|
153 |
|
155 |
GdkPixbuf *pPixbuf= ResIdToPixbuf( nResId ); |
154 |
GdkPixbuf *pPixbuf= ResIdToPixbuf( SV_ICON_SMALL_START + nResId ); |
156 |
GtkWidget *pImage = gtk_image_new_from_pixbuf( pPixbuf ); |
155 |
GtkWidget *pImage = gtk_image_new_from_pixbuf( pPixbuf ); |
157 |
g_object_unref( G_OBJECT( pPixbuf ) ); |
156 |
g_object_unref( G_OBJECT( pPixbuf ) ); |
158 |
|
157 |
|
159 |
GtkWidget *pMenuItem = gtk_image_menu_item_new_with_label( aLabel ); |
158 |
GtkWidget *pMenuItem = gtk_image_menu_item_new_with_label( aLabel ); |
160 |
gtk_image_menu_item_set_image( GTK_IMAGE_MENU_ITEM( pMenuItem ), pImage ); |
159 |
gtk_image_menu_item_set_image( GTK_IMAGE_MENU_ITEM( pMenuItem ), pImage ); |
Lines 262-271
static void populate_menu( GtkWidget *pMenu )
Link Here
|
262 |
pShutdownIcon->GetResString( STR_QUICKSTART_FILEOPEN ), |
261 |
pShutdownIcon->GetResString( STR_QUICKSTART_FILEOPEN ), |
263 |
G_CALLBACK( open_file_cb )); |
262 |
G_CALLBACK( open_file_cb )); |
264 |
|
263 |
|
|
|
264 |
|
265 |
pMenuItem = gtk_separator_menu_item_new(); |
265 |
pMenuItem = gtk_separator_menu_item_new(); |
266 |
gtk_menu_shell_append( pMenuShell, pMenuItem ); |
266 |
gtk_menu_shell_append( pMenuShell, pMenuItem ); |
267 |
|
267 |
|
268 |
(void) add_image_menu_item |
268 |
pDisableMenuItem = add_image_menu_item |
269 |
( pMenuShell, GTK_STOCK_CLOSE, |
269 |
( pMenuShell, GTK_STOCK_CLOSE, |
270 |
pShutdownIcon->GetResString( STR_QUICKSTART_PRELAUNCH_UNX ), |
270 |
pShutdownIcon->GetResString( STR_QUICKSTART_PRELAUNCH_UNX ), |
271 |
G_CALLBACK( systray_disable_cb ) ); |
271 |
G_CALLBACK( systray_disable_cb ) ); |
Lines 289-319
static void refresh_menu( GtkWidget *pMenu )
Link Here
|
289 |
bool bModal = ShutdownIcon::bModalMode; |
289 |
bool bModal = ShutdownIcon::bModalMode; |
290 |
gtk_widget_set_sensitive( pExitMenuItem, !bModal); |
290 |
gtk_widget_set_sensitive( pExitMenuItem, !bModal); |
291 |
gtk_widget_set_sensitive( pOpenMenuItem, !bModal); |
291 |
gtk_widget_set_sensitive( pOpenMenuItem, !bModal); |
|
|
292 |
gtk_widget_set_sensitive( pDisableMenuItem, !bModal); |
292 |
} |
293 |
} |
293 |
|
294 |
|
294 |
extern "C" { |
|
|
295 |
static void |
296 |
layout_menu( GtkMenu *menu, |
297 |
gint *x, gint *y, gboolean *push_in, |
298 |
gpointer ) |
299 |
{ |
300 |
GtkRequisition req; |
301 |
GtkWidget *ebox = GTK_BIN( pTrayIcon )->child; |
302 |
|
303 |
gtk_widget_size_request( GTK_WIDGET( menu ), &req ); |
304 |
gdk_window_get_origin( ebox->window, x, y ); |
305 |
|
306 |
(*x) += ebox->allocation.x; |
307 |
(*y) += ebox->allocation.y; |
308 |
|
309 |
if (*y >= gdk_screen_get_height (gtk_widget_get_screen (ebox)) / 2) |
310 |
(*y) -= req.height; |
311 |
else |
312 |
(*y) += ebox->allocation.height; |
313 |
|
314 |
*push_in = sal_True; |
315 |
} |
316 |
} |
317 |
|
295 |
|
318 |
static gboolean display_menu_cb( GtkWidget *, |
296 |
static gboolean display_menu_cb( GtkWidget *, |
319 |
GdkEventButton *event, GtkWidget *pMenu ) |
297 |
GdkEventButton *event, GtkWidget *pMenu ) |
Lines 321-356
static gboolean display_menu_cb( GtkWidget *,
Link Here
|
321 |
if (event->button == 2) |
299 |
if (event->button == 2) |
322 |
return sal_False; |
300 |
return sal_False; |
323 |
|
301 |
|
324 |
#ifdef TEMPLATE_DIALOG_MORE_POLISHED |
|
|
325 |
if (event->button == 1 && |
326 |
event->type == GDK_2BUTTON_PRESS) |
327 |
{ |
328 |
open_template_cb( NULL ); |
329 |
return sal_True; |
330 |
} |
331 |
if (event->button == 3) |
332 |
{ |
333 |
... as below ... |
334 |
#endif |
335 |
|
336 |
refresh_menu( pMenu ); |
302 |
refresh_menu( pMenu ); |
337 |
|
303 |
|
338 |
gtk_menu_popup( GTK_MENU( pMenu ), NULL, NULL, |
304 |
gtk_menu_popup( GTK_MENU( pMenu ), NULL, NULL, |
339 |
layout_menu, NULL, 0, event->time ); |
305 |
gtk_status_icon_position_menu, |
|
|
306 |
pTrayIcon, 0, event->time ); |
340 |
|
307 |
|
341 |
return sal_True; |
308 |
return sal_True; |
342 |
} |
309 |
} |
343 |
|
310 |
|
344 |
extern "C" { |
|
|
345 |
static gboolean |
346 |
show_at_idle( gpointer ) |
347 |
{ |
348 |
::vos::OGuard aGuard( Application::GetSolarMutex() ); |
349 |
gtk_widget_show_all( GTK_WIDGET( pTrayIcon ) ); |
350 |
return sal_False; |
351 |
} |
352 |
} |
353 |
|
354 |
void SAL_DLLPUBLIC_EXPORT plugin_init_sys_tray() |
311 |
void SAL_DLLPUBLIC_EXPORT plugin_init_sys_tray() |
355 |
{ |
312 |
{ |
356 |
::vos::OGuard aGuard( Application::GetSolarMutex() ); |
313 |
::vos::OGuard aGuard( Application::GetSolarMutex() ); |
Lines 358-398
void SAL_DLLPUBLIC_EXPORT plugin_init_sys_tray()
Link Here
|
358 |
if( !g_type_from_name( "GdkDisplay" ) ) |
315 |
if( !g_type_from_name( "GdkDisplay" ) ) |
359 |
return; |
316 |
return; |
360 |
|
317 |
|
|
|
318 |
ShutdownIcon *pShutdownIcon = ShutdownIcon::getInstance(); |
319 |
if ( !pShutdownIcon ) |
320 |
return; |
321 |
|
322 |
pTrayIcon = gtk_status_icon_new(); |
323 |
pVCLResMgr = CREATEVERSIONRESMGR( vcl ); |
324 |
|
325 |
if ( !pTrayIcon || !pVCLResMgr ) |
326 |
return; |
327 |
|
328 |
// disable shutdown |
329 |
pShutdownIcon->SetVeto( true ); |
330 |
pShutdownIcon->addTerminateListener(); |
331 |
|
361 |
OString aLabel; |
332 |
OString aLabel; |
362 |
ShutdownIcon *pShutdownIcon = ShutdownIcon::getInstance(); |
|
|
363 |
|
333 |
|
364 |
aLabel = rtl::OUStringToOString ( |
334 |
aLabel = rtl::OUStringToOString ( |
365 |
pShutdownIcon->GetResString( STR_QUICKSTART_TIP ), |
335 |
pShutdownIcon->GetResString( STR_QUICKSTART_TIP ), |
366 |
RTL_TEXTENCODING_UTF8 ); |
336 |
RTL_TEXTENCODING_UTF8 ); |
367 |
|
337 |
|
368 |
pTrayIcon = egg_tray_icon_new( aLabel ); |
338 |
GdkPixbuf *pPixbuf = ResIdToPixbuf( SV_ICON_LARGE_START + SV_ICON_ID_OFFICE ); |
369 |
|
339 |
g_object_set( G_OBJECT( pTrayIcon ), |
370 |
GtkWidget *pParent = gtk_event_box_new(); |
340 |
"pixbuf", pPixbuf, |
371 |
GtkTooltips *pTooltips = gtk_tooltips_new(); |
341 |
"title", aLabel.getStr(), |
372 |
gtk_tooltips_set_tip( GTK_TOOLTIPS( pTooltips ), pParent, aLabel, NULL ); |
342 |
NULL ); |
|
|
343 |
g_object_unref( pPixbuf ); |
373 |
|
344 |
|
374 |
GtkWidget *pIconImage = gtk_image_new(); |
345 |
gtk_status_icon_set_tooltip_text( pTrayIcon, aLabel.getStr() ); |
375 |
gtk_container_add( GTK_CONTAINER( pParent ), pIconImage ); |
|
|
376 |
|
346 |
|
377 |
pVCLResMgr = CREATEVERSIONRESMGR( vcl ); |
347 |
GtkWidget *pMenu = gtk_menu_new(); |
378 |
|
348 |
|
379 |
GdkPixbuf *pPixbuf = ResIdToPixbuf( SV_ICON_ID_OFFICE ); |
349 |
g_signal_connect( pTrayIcon, "button-press-event", |
380 |
gtk_image_set_from_pixbuf( GTK_IMAGE( pIconImage ), pPixbuf ); |
350 |
G_CALLBACK( display_menu_cb ), pMenu ); |
381 |
g_object_unref( pPixbuf ); |
|
|
382 |
|
351 |
|
383 |
GtkWidget *pMenu = gtk_menu_new(); |
352 |
g_signal_connect( pMenu, "deactivate", |
384 |
g_signal_connect (pMenu, "deactivate", |
353 |
G_CALLBACK (menu_deactivate_cb), NULL); |
385 |
G_CALLBACK (menu_deactivate_cb), NULL); |
|
|
386 |
g_signal_connect( pParent, "button_press_event", |
387 |
G_CALLBACK( display_menu_cb ), pMenu ); |
388 |
gtk_container_add( GTK_CONTAINER( pTrayIcon ), pParent ); |
389 |
|
390 |
// Show at idle to avoid artefacts at startup |
391 |
g_idle_add (show_at_idle, (gpointer) pTrayIcon); |
392 |
|
393 |
// disable shutdown |
394 |
pShutdownIcon->SetVeto( true ); |
395 |
pShutdownIcon->addTerminateListener(); |
396 |
} |
354 |
} |
397 |
|
355 |
|
398 |
void SAL_DLLPUBLIC_EXPORT plugin_shutdown_sys_tray() |
356 |
void SAL_DLLPUBLIC_EXPORT plugin_shutdown_sys_tray() |
Lines 400-409
void SAL_DLLPUBLIC_EXPORT plugin_shutdown_sys_tray()
Link Here
|
400 |
::vos::OGuard aGuard( Application::GetSolarMutex() ); |
358 |
::vos::OGuard aGuard( Application::GetSolarMutex() ); |
401 |
if( !pTrayIcon ) |
359 |
if( !pTrayIcon ) |
402 |
return; |
360 |
return; |
403 |
gtk_widget_destroy( GTK_WIDGET( pTrayIcon ) ); |
361 |
g_object_unref( pTrayIcon ); |
404 |
pTrayIcon = NULL; |
362 |
pTrayIcon = NULL; |
405 |
pExitMenuItem = NULL; |
363 |
pExitMenuItem = NULL; |
406 |
pOpenMenuItem = NULL; |
364 |
pOpenMenuItem = NULL; |
|
|
365 |
pDisableMenuItem = NULL; |
407 |
} |
366 |
} |
408 |
|
367 |
|
409 |
#endif // ENABLE_QUICKSTART_APPLET |
368 |
#endif // ENABLE_QUICKSTART_APPLET |
410 |
- |
|
|