shutdowniconunx.cxx (d119d52d) shutdowniconunx.cxx (595ead2b)
1/**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance

--- 299 unchanged lines hidden (view full) ---

308 populate_menu( pMenu );
309
310 bool bModal = ShutdownIcon::bModalMode;
311 gtk_widget_set_sensitive( pExitMenuItem, !bModal);
312 gtk_widget_set_sensitive( pOpenMenuItem, !bModal);
313 gtk_widget_set_sensitive( pDisableMenuItem, !bModal);
314}
315
1/**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance

--- 299 unchanged lines hidden (view full) ---

308 populate_menu( pMenu );
309
310 bool bModal = ShutdownIcon::bModalMode;
311 gtk_widget_set_sensitive( pExitMenuItem, !bModal);
312 gtk_widget_set_sensitive( pOpenMenuItem, !bModal);
313 gtk_widget_set_sensitive( pDisableMenuItem, !bModal);
314}
315
316static void activate_cb( GtkStatusIcon *status_icon,
317 gpointer pMenu )
318{
319 refresh_menu( GTK_WIDGET( pMenu ) );
316
320
317static gboolean display_menu_cb( GtkWidget *,
318 GdkEventButton *event, GtkWidget *pMenu )
321 gtk_menu_popup( GTK_MENU( pMenu ), NULL, NULL,
322 gtk_status_icon_position_menu,
323 status_icon, 0, gtk_get_current_event_time() );
324}
325
326static void popup_menu_cb(GtkStatusIcon *status_icon,
327 guint button,
328 guint activate_time,
329 gpointer pMenu)
319{
330{
320 if (event->button == 2)
321 return sal_False;
331 if (button == 2)
332 return;
322
333
323 refresh_menu( pMenu );
334 refresh_menu( GTK_WIDGET( pMenu ) );
324
325 gtk_menu_popup( GTK_MENU( pMenu ), NULL, NULL,
326 gtk_status_icon_position_menu,
335
336 gtk_menu_popup( GTK_MENU( pMenu ), NULL, NULL,
337 gtk_status_icon_position_menu,
327 pTrayIcon, 0, event->time );
328
329 return sal_True;
338 status_icon, button, activate_time );
330}
331
332void SAL_DLLPUBLIC_EXPORT plugin_init_sys_tray()
333{
334 ::vos::OGuard aGuard( Application::GetSolarMutex() );
335
336 if( !g_type_from_name( "GdkDisplay" ) )
337 return;

--- 16 unchanged lines hidden (view full) ---

354
355 aLabel = rtl::OUStringToOString (
356 pShutdownIcon->GetResString( STR_QUICKSTART_TIP ),
357 RTL_TEXTENCODING_UTF8 );
358
359 GdkPixbuf *pPixbuf = ResIdToPixbuf( SV_ICON_LARGE_START + SV_ICON_ID_OFFICE );
360 g_object_set( G_OBJECT( pTrayIcon ),
361 "pixbuf", pPixbuf,
339}
340
341void SAL_DLLPUBLIC_EXPORT plugin_init_sys_tray()
342{
343 ::vos::OGuard aGuard( Application::GetSolarMutex() );
344
345 if( !g_type_from_name( "GdkDisplay" ) )
346 return;

--- 16 unchanged lines hidden (view full) ---

363
364 aLabel = rtl::OUStringToOString (
365 pShutdownIcon->GetResString( STR_QUICKSTART_TIP ),
366 RTL_TEXTENCODING_UTF8 );
367
368 GdkPixbuf *pPixbuf = ResIdToPixbuf( SV_ICON_LARGE_START + SV_ICON_ID_OFFICE );
369 g_object_set( G_OBJECT( pTrayIcon ),
370 "pixbuf", pPixbuf,
362 "title", aLabel.getStr(),
371 "title", aLabel.getStr(),/* Since 2.18 */
372 "tooltip-text", aLabel.getStr(), /* Since 2.16 */
363 NULL );
364 g_object_unref( pPixbuf );
365
373 NULL );
374 g_object_unref( pPixbuf );
375
366 gtk_status_icon_set_tooltip_text( pTrayIcon, aLabel.getStr() );
376 // gtk_status_icon_set_tooltip_text is available since 2.16
377 // so use instead deprecated gtk_status_icon_set_tooltip
378 gtk_status_icon_set_tooltip( pTrayIcon, aLabel.getStr() );
367
368 GtkWidget *pMenu = gtk_menu_new();
369
379
380 GtkWidget *pMenu = gtk_menu_new();
381
370 g_signal_connect( pTrayIcon, "button-press-event",
371 G_CALLBACK( display_menu_cb ), pMenu );
382 // Signal "button-press-event" is available since 2.14
383 // Use "activate" and "popup-menu" instead
384 g_signal_connect( pTrayIcon, "activate",
385 G_CALLBACK( activate_cb ), pMenu );
386 g_signal_connect( pTrayIcon, "popup-menu",
387 G_CALLBACK( popup_menu_cb ), pMenu );
372
373 g_signal_connect( pMenu, "deactivate",
374 G_CALLBACK (menu_deactivate_cb), NULL);
375}
376
377void SAL_DLLPUBLIC_EXPORT plugin_shutdown_sys_tray()
378{
379 ::vos::OGuard aGuard( Application::GetSolarMutex() );
380 if( !pTrayIcon )
381 return;
382 g_object_unref( pTrayIcon );
383 pTrayIcon = NULL;
384 pExitMenuItem = NULL;
385 pOpenMenuItem = NULL;
386 pDisableMenuItem = NULL;
387}
388
389#endif // ENABLE_QUICKSTART_APPLET
388
389 g_signal_connect( pMenu, "deactivate",
390 G_CALLBACK (menu_deactivate_cb), NULL);
391}
392
393void SAL_DLLPUBLIC_EXPORT plugin_shutdown_sys_tray()
394{
395 ::vos::OGuard aGuard( Application::GetSolarMutex() );
396 if( !pTrayIcon )
397 return;
398 g_object_unref( pTrayIcon );
399 pTrayIcon = NULL;
400 pExitMenuItem = NULL;
401 pOpenMenuItem = NULL;
402 pDisableMenuItem = NULL;
403}
404
405#endif // ENABLE_QUICKSTART_APPLET