; Module/File: SysTray_SetNameGtk3.pb ; Function: Set SysTray name for icon sorting in the tray - Linux Gtk3 ; Author: Omi ; Date: Dec. 27, 2016 ; Version: 0.1 ; Target Compiler: PureBasic 5.22/5.3/5.4/5.5 ; Target OS: Linux: (X/K/L)ubuntu, Mint, 32/64, Ascii/Uni ;-------------------------------------------------------------- EnableExplicit ImportC "" gtk_status_icon_set_name(*status_icon, name.p-utf8) g_type_check_instance_is_a(*instance.GTypeInstance, *type.GTypeClass) EndImport Macro G_TYPE_MAKE_FUNDAMENTAL(x) ((x) << 2) EndMacro ;GType ... #G_TYPE_OBJECT = G_TYPE_MAKE_FUNDAMENTAL(20) ; Object constants #Win_Main = 0 #SysTrayEntry1= 0 Global.i gEvent, gQuit Global *gScreen.GdkScreen, gArea.GdkRectangle, *gOrientation Global *gSysTrayEntry Global.s gSysTrayIcon1= #PB_Compiler_Home + "examples/sources/Data/Drive.bmp" ProcedureC SysTray_Popup(*status_icon, button, activate_time, user_data) Debug user_data EndProcedure Procedure SysTray_IdIsValid(*object) ProcedureReturn g_type_check_instance_is_a(*object, #G_TYPE_OBJECT) EndProcedure Procedure Create_WinMain() If OpenWindow(#Win_Main, 300, 200, 500, 100, "SysTray icon set name", #PB_Window_SystemMenu | #PB_Window_ScreenCentered) TextGadget(#PB_Any, 5, 5, 490, 40, "Click on new SysTray icon w. Tooltip 'PureBasic icon' to set title.") *gSysTrayEntry= AddSysTrayIcon(#SysTrayEntry1, WindowID(#Win_Main), LoadImage(0, gSysTrayIcon1)); Return is GtkStatusIcon -> NOT DOCUMENTED SysTrayIconToolTip(#SysTrayEntry1, "PureBasic icon") EndIf EndProcedure Create_WinMain() Repeat gEvent= WaitWindowEvent() Select gEvent Case #PB_Event_CloseWindow gQuit= #True Case #PB_Event_SysTray If EventGadget() = #SysTrayEntry1 If SysTray_IdIsValid(*gSysTrayEntry) gtk_status_icon_set_name(*gSysTrayEntry, "PB SysTrayName") EndIf EndIf EndSelect Until gQuit ; IDE Options = PureBasic 5.45 LTS (Linux - x86) ; CursorPosition = 8 ; Folding = - ; EnableUnicode ; EnableXP