Module notify (linux only!)

Share your advanced PureBasic knowledge/code with the community.
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Module notify (linux only!)

Post by ts-soft »

Code: Select all

;======================================================================
; Module:           notify
;
; Author:           Thomas (ts-soft) Schulz
; CoAuthor:         Idle
; Date:             Jul 23, 2013
; Version:          0.9.0
; Target Compiler:  PureBasic 5.20+
; Target OS:        Linux
; Depedencies:      libnotify-dev
; Online reference: https://developer-next.gnome.org/libnotify/
; License:          Free, unrestricted, no warranty whatsoever
;                   Use at your own risk
;======================================================================

; History:
; Version 0.9.0
; + Clear_Actions

; Version 0.8.0  Idle   
; + Changed to use Interface   
; + Add_Action
; + Action Callback

; Version 0.7
; + Get_ServerInfo
; + Get_ServerCaps

; Version 0.6
; + Update
; + Get_AppName
; + Set_AppName
; + Close
; ~ result of show is *notification
; ~ better error-handling
; ~ example

DeclareModule notify
  #NOTIFY_EXPIRES_DEFAULT = -1
  #NOTIFY_EXPIRES_NEVER   =  0
  
  Enumeration ; NotifyUrgency
    #NOTIFY_URGENCY_LOW       ; Low urgency. Used for unimportant notifications.
    #NOTIFY_URGENCY_NORMAL    ; Normal urgency. Used for most standard notifications.
    #NOTIFY_URGENCY_CRITICAL  ; Critical urgency. Used for very important notifications.
  EndEnumeration
  
  Enumeration 1 ; ServerInfoType
    #NOTIFY_SERVER_NAME
    #NOTIFY_SERVER_VENDOR
    #NOTIFY_SERVER_VERSION
    #NOTYFY_SERVER_SPEC_VERSION
  EndEnumeration
  
  
  Declare.i New(Title.s,
                Message.s,
                Img.s = "",     ; The optional icon theme icon name or filename.
                ImageID.i = 0,  ; The optional ImageID from a by PB loaded Image.
                AppName.s = "", ; Optional to reset appname
                urgency.l = #NOTIFY_URGENCY_NORMAL,
                timeout.l = #NOTIFY_EXPIRES_DEFAULT)  ; Initialized libnotify.
  
  
  Interface INotify
    Free()              ; free instances and eventually uninitialized libnotify.
    Show()
    Update(Title.s, Message.s, Img.s = "", ImageID.i = 0)
    Close()
    Get_AppName.s()
    Set_AppName(AppName.s)
    Get_ServerInfo.s(ServerInfoType.l)
    Get_ServerCaps(List ServerCaps.s())
    Add_Action(Action.s, Label.s, *Callback = 0, *User_data = 0)
    Clear_Actions()
  EndInterface 

EndDeclareModule

Module notify
  EnableExplicit
  
  Global gInit 
  Global gInstances
  
  Prototype ON_Action(*this.INotify,action.s,*userdata) ; user call back prototype used as ActionCallback(*notify.ModNotify::INotify, Action.s, *userdata)
  
  Structure actions
    *this                 ; store instance pointer
    *callback             ; user callback function
    *userdata             ; the user data for a action   
  EndStructure   
  
  Structure sNotify
    *vt
    *notification
    *action.ON_Action      ; callback prototye set from internal callback 
    *userdata              ; user data set from internal callback
    NOTIFY_SERVER_NAME.s
    NOTIFY_SERVER_VENDOR.s
    NOTIFY_SERVER_VERSION.s
    NOTYFY_SERVER_SPEC_VERSION.s
    List Servercaps.s()
    List lpointerActions.i() ; store the pointers to heap allocated action callbacks   
  EndStructure   
  
  
  ImportC "-lnotify"
    notify_init.i(app_name.p-utf8)
    ; Initialized libnotify. This must be called before any other functions.
    ; Returns : #TRUE if successful, or #FALSE on error.
    
    notify_uninit()
    ; Uninitialized libnotify.
    
    notify_is_initted.i()
    ; Gets whether or not libnotify is initialized.
    ; Returns : #TRUE if libnotify is initialized, or #FALSE otherwise.
    
    notify_get_app_name.i()
    ; Gets the application name registered.
    ; Returns : The registered application name, passed to notify_init().
    
    notify_set_app_name(app_name.p-utf8)
    ; Sets the application name.
    
    notify_notification_new.i(summary.p-utf8,     ; The required summary text.
                              body.p-utf8 = 0,    ; The optional body text.
                              icon.p-utf8 = 0)    ; The optional icon theme icon name or filename.
    ; Returns : The new NotifyNotification.
    
    notify_notification_update.i(*notification,   ; The notification to update.
                                 summary.p-utf8,  ; The new required summary text.
                                 body.p-utf8,     ; The optional body text.
                                 icon.p-utf8)     ; The optional icon theme icon name or filename.
    ; Updates the notification text and icon. This won't send the update out and display it on the screen.
    ; For that, you will need to call notify_notification_show().
    ; Returns : #TRUE, unless an invalid parameter was passed.
    
    notify_notification_show(*notification, ; The notification.
                             *error)        ; The returned error information.
    ; Tells the notification server to display the notification on the screen.
    ; Returns : #TRUE if successful. On error, this will return #FALSE and set error.
    
    notify_notification_set_timeout(*notification, ; The notification.
                                    timeout.l)     ; The timeout in milliseconds.
    ; Sets the timeout of the notification. To set the default time, pass #NOTIFY_EXPIRES_DEFAULT as timeout.
    ; To set the notification To never expire, pass #NOTIFY_EXPIRES_NEVER.
    
    notify_notification_set_urgency(*notification, ; The notification.
                                    urgency)       ; The urgency level. 
    ; Sets the urgency level of this notification.
    
    notify_notification_set_image_from_pixbuf(*notification, ; The notification.
                                              *pixbuf)       ; The image.
    ; Sets the image in the notification from a GdkPixbuf.
    
    notify_notification_close(*notification, ; The notification.
                              *error)        ; The returned error information.
    ; Synchronously tells the notification server to hide the notification on the screen.
    ; Returns : #TRUE on success, or #FALSE on error with error filled in.
    
    notify_get_server_info(*ret_name = 0, ; a location to store the server name, or NULL.
                           *ret_vendor = 0, ; a location to store the server vendor, or NULL.
                           *ret_version = 0, ; a location to store the server version, or NULL.
                           *ret_spec_version = 0) ; a location to store the version the service is compliant with, or NULL.
    ; Synchronously queries the server for its information, specifically, the name, vendor, server version,
    ; and the version of the notifications specification that it is compliant with.
    ; Returns : #TRUE if successful, and the variables passed will be set, #FALSE on error. The returned strings must be freed with g_free
    
    notify_get_server_caps.i()
    ; Synchronously queries the server for its capabilities and returns them in a GList.
    ; Returns : a GList of server capability strings. Free the List elements with g_free() and the List itself with g_list_free().
    
    notify_notification_add_action(*notification, action.p-utf8, label.p-utf8, *callback, *user_data = 0, *free_func = 0)
    ; Adds an action To a notification. When the action is invoked, the specified callback function will be called, along With the value passed To user_data.
    ; action : The action ID. label : The human-readable action label. callback : The action's callback function. [scope async] user_data : Optional custom Data To pass To callback. [allow-none]
    ; free_func : An optional function To free user_data when the notification is destroyed. [scope async][allow-none]
    
    notify_notification_clear_actions(*notification)
    ; Clears all actions from the notification
  EndImport
  
  ;-Private initialisation
  Procedure Init()
    Protected appname.s
    AppName = GetFilePart(ProgramFilename(), #PB_FileSystem_NoExtension)
    If Not notify_is_initted()
      gInit =  notify_init(AppName)
      If Not gInit 
        MessageRequester("ModNotify","Failed to initialise libnotify")
      EndIf   
    EndIf
  EndProcedure   
  
  Procedure I_New(AppName.s = "")
    Protected *this.sNotify, *strmem
    If gInit
      *this = AllocateMemory(SizeOf(sNotify))
      
      If *this
        
        InitializeStructure(*this,sNotify)
        
        *this\vt = ?vt_Notify
        
        If AppName <> ""
          notify_set_app_name(AppName)
        EndIf
        gInstances + 1
        
        If notify_get_server_info(@*strmem)
          If *strmem
            *this\NOTIFY_SERVER_NAME = PeekS(*strmem, -1, #PB_UTF8) : g_free_(*strmem)
          EndIf
        EndIf
        If notify_get_server_info(0, @*strmem)
          If *strmem
            *this\NOTIFY_SERVER_VENDOR = PeekS(*strmem, -1, #PB_UTF8) : g_free_(*strmem)
          EndIf
        EndIf
        If notify_get_server_info(0, 0, @*strmem)
          If *strmem
            *this\NOTIFY_SERVER_VERSION = PeekS(*strmem, -1, #PB_UTF8) : g_free_(*strmem)
          EndIf
        EndIf
        If notify_get_server_info(0, 0, 0, @*strmem)
          If *strmem
            *this\NOTYFY_SERVER_SPEC_VERSION = PeekS(*strmem, -1, #PB_UTF8) : g_free_(*strmem)
          EndIf
        EndIf   
        
        ProcedureReturn *this
      EndIf
    EndIf
  EndProcedure
  
  Procedure New(Title.s, Message.s, Img.s = "", ImageID.i = 0, AppName.s="",urgency.l = #NOTIFY_URGENCY_NORMAL, timeout.l = #NOTIFY_EXPIRES_DEFAULT)
    Protected *this.sNotify,error.GError, result.i, nullImg.s
    
    *this = I_new(AppName)  ;creates new notification class
    If *this 
      If Img = ""
        *this\notification = notify_notification_new(Title, Message, nullImg)
      Else
        *this\notification = notify_notification_new(Title, Message, Img)
      EndIf
      If *this\notification
        If ImageID
          notify_notification_set_image_from_pixbuf(*this\notification, ImageID)
        EndIf
        notify_notification_set_urgency(*this\notification, urgency)
        notify_notification_set_timeout(*this\notification, timeout)
        
        ProcedureReturn  *this
      EndIf
    EndIf 
    ProcedureReturn #False
  EndProcedure
  
  Procedure Free(*this.sNotify)
    If *this
      ForEach *this\lpointerActions()
        FreeMemory(*this\lpointerActions())
      Next
      ClearStructure(*this, sNotify)
      FreeMemory(*this)
      gInstances - 1
      If gInstances = 0   
        notify_uninit()
        ginit=0
      EndIf
    EndIf   
  EndProcedure
  
  Procedure Show(*this.sNotify)
    Protected error.GError, result.i
    If *this
      result = notify_notification_show(*this\notification, @error)
      If Not result
        Debug "Error in notify::Show():"
        Debug "message: " + PeekS(error\message, -1, #PB_UTF8)
      EndIf
    EndIf
  EndProcedure   
  
  Procedure Update(*this.sNotify, Title.s, Message.s, Img.s = "", ImageID.i = 0)
    Protected error.GError, result.i, nullImg.s
    
    If Img = ""
      result = notify_notification_update(*this\notification, Title, Message, nullImg)
    Else
      result = notify_notification_update(*this\notification, Title, Message, Img)
    EndIf
    If result
      If ImageID
        notify_notification_set_image_from_pixbuf(*this\notification, ImageID)
      EndIf
      result = notify_notification_show(*this\notification, @error)
      If Not result
        Debug "Error in notify::Show():"
        Debug "message: " + PeekS(error\message, -1, #PB_UTF8)
      EndIf
      ProcedureReturn *this 
    EndIf
    
    ProcedureReturn #False
  EndProcedure
  
  Procedure.s Get_AppName(*this.sNotify)
    ProcedureReturn PeekS(notify_get_app_name(), -1, #PB_UTF8)
  EndProcedure
  
  Procedure Set_AppName(*this.sNotify,AppName.s)
    notify_set_app_name(AppName)
  EndProcedure
  
  Procedure Close(*this.sNotify)
    Protected error.GError
    
    If Not notify_notification_close(*this\notification, @error)
      Debug "Error in notify::Show():"
      Debug "message: " + PeekS(error\message, -1, #PB_UTF8)
      ProcedureReturn #False
    EndIf
    
    ProcedureReturn #True
  EndProcedure
  
  Procedure.s Get_ServerInfo(*this.sNotify,ServerInfoType.l)
    Protected Result.s, *strmem
    If *this     
      Select ServerInfoType
        Case #NOTIFY_SERVER_NAME
          result  = *this\NOTIFY_SERVER_NAME   
        Case #NOTIFY_SERVER_VENDOR
          result = *this\NOTIFY_SERVER_VENDOR
        Case #NOTIFY_SERVER_VERSION
          result = *this\NOTIFY_SERVER_VERSION
        Case #NOTYFY_SERVER_SPEC_VERSION
          result = *this\NOTYFY_SERVER_SPEC_VERSION
      EndSelect
      ProcedureReturn Result
    EndIf 
  EndProcedure
  
  Procedure Get_ServerCaps(*this.sNotify,List ServerCaps.s())
    Protected *GList.GList, i, j, *mem
    
    If *this
      
      *GList = notify_get_server_caps()
      If *GList
        j = g_list_length_(*GList) - 1
        If j > -1
          For i = 0 To j
            AddElement(ServerCaps())
            *mem = g_list_nth_data_(*GList, i)
            If *mem
              ServerCaps() = PeekS(*mem, -1, #PB_UTF8)
              g_free_(*mem)
            EndIf
          Next
        EndIf
        g_list_free_(*GList)
        
        ProcedureReturn #True
      EndIf
    EndIf
    
  EndProcedure
  
  ;Internal helper to wrap Action Callback and recast from C 
  ProcedureC I_Action_CallBack(*notifcation, *action, *data.actions)
    Protected *this.sNotify
    Protected action.s
    If *data
      *this = *data\this
      *this\action = *data\callback
      *this\userdata = *data\userdata
      action = PeekS(*action, -1, #PB_UTF8)
      If *this\action 
        *this\action(*this, action, *this\userdata)
      EndIf
    EndIf   
  EndProcedure   
  
  Procedure Add_Action(*this.sNotify, action.s, label.s, *callback = 0, *user_data = 0);
    ;heap allocates a struct including the *this pointer *callback *userdata and stores it in a List lpointerActions()
    Protected *action.actions
    
    If *this
      If *this\notification
        *action = AllocateMemory(SizeOf(actions))
        AddElement(*this\lpointerActions())
        *this\lpointerActions() = *action
        *action\callback = *callback
        *action\this = *this
        *action\userdata = *user_data
        notify_notification_add_action(*this\notification, action, label, @I_Action_Callback(), *action, 0);
      EndIf
    EndIf
  EndProcedure   

  Procedure Clear_Actions(*this.sNotify)
    If *this
      notify_notification_clear_actions(*this\notification)
    EndIf
  EndProcedure
    
  ;-Initilise lib notify
  init()
  
  DataSection : vt_Notify :
    Data.i @Free()
    Data.i @Show()
    Data.i @Update()
    Data.i @Close()
    Data.i @Get_AppName()
    Data.i @Set_AppName()
    Data.i @Get_ServerInfo()
    Data.i @Get_ServerCaps()
    Data.i @Add_Action()
    Data.i @Clear_Actions()
  EndDataSection

EndModule

CompilerIf #PB_Compiler_IsMainFile
  EnableExplicit
  
  Procedure ActionCallback(*notify.notify::INotify, Action.s, *userdata)
    
    MessageRequester("Notify CallBack", Action + " " + "UserData " + Str(*userdata))
    If Action = "ByeBye"
      *notify\Close()
      If IsWindow(0) : PostEvent(#PB_Event_CloseWindow) : EndIf
    EndIf   
    
  EndProcedure 
  
  
  NewList ServerCaps.s()
  Define  i, info.s, actions_allowed = #False
  
  UsePNGImageDecoder()
  
  Define  notify.notify::INotify 
  
  notify = notify::New("PureBasic Example", "Feel the <b>..Pure.. Power</b>", "", CatchImage(0, ?logo_png_start))
  
  If notify
    For i = 1 To 4
      info + notify\Get_ServerInfo(i) + "; "
    Next
    Debug "ServerInfo:"
    Debug info
    If notify\Get_ServerCaps(ServerCaps.s())
      Debug ""
      Debug "ServerCaps:"
      ForEach ServerCaps()
        Debug ServerCaps()
        If ServerCaps() = "actions" : actions_allowed = #True : EndIf
      Next
    EndIf
    
    If actions_allowed
      notify\Add_Action("ByeBye","Bye", @ActionCallback(), 456)
    EndIf
    
    notify\Show()
    
    Delay(1000)
    notify\Update("Homepage:", "http://www.purebasic.com")
    
    ;need a window open to activate callbacks
    OpenWindow(0, 0, 0, 100, 100, "test")
    Repeat
    Until WaitWindowEvent() = #PB_Event_CloseWindow
    
    notify\Free()
    
  EndIf
  DataSection
    logo_png_start:
    ; size : 3325 bytes
    Data.q $0A1A0A0D474E5089,$524448490D000000,$3000000030000000,$F902570000000608,$5948700900000087
    Data.q $1C0000201C000073,$00009E9B0FCD0120,$D607454D49740700,$C953B60D17151C0C,$4144499C0C000004
    Data.q $5D8C7999D5DE6854,$EF7B9CE73FC75DD7,$78E2CF17D9BDE65B,$907126A2B60927A9,$546D02D2602C8A93
    Data.q $5555116D24489694,$A152044A2540A505,$A6A102108AA90682,$A0510A2ACB454034,$B66CE3524E2C84B4
    Data.q $8F167B19C664F6C7,$E1CF77DFBEDF5F67,$B1ED89363C667B8F,$27DD5EE8E91C48C7,$FEFDF6DF9EFBFBBD
    Data.q $9E2A3C4B568B62AE,$D6DFF68796A1F479,$815294B6322A5311,$BB0B61B900A00ED6,$FB22D8969AFEE4B9
    Data.q $D751B97E0F23F4C5,$18151C295CF1D8FF,$82D1904672062B29,$11D749B5D4C9A04C,$15D2A39A9954BAE9
    Data.q $7A4DA72A4445D2A9,$7E93373E1D4A5F36,$07E5256670B67273,$637AF6076D6068DA,$A6559BD1E2799C00
    Data.q $1807E306DD745030,$0251C06106308EBF,$1C5CF2839E3839E5,$2E50F8190295C5C7,$94117AE01082AD41
    Data.q $D058AE74B55282E7,$F9DC8FF555266AF9,$058C81E6069ED7C3,$6F87F8D7AE72D172,$CFA7B7FCE9A2A1DE
    Data.q $6036831B4068374F,$021A040DAAF63708,$6A69C51B9408D06D,$0AA21E7A426C69C2,$411D7A0C8D4C57C2
    Data.q $D7E1FC57575F75AD,$DC281D7817B801DE,$2E2F81FF767F0010,$00AB746CC0789D9C,$80C26E785EF74263
    Data.q $2BAA15FB418D2017,$45086C614B2BCA15,$B4DFF625F989D4C1,$62C9E9E391C2FCDD,$63C67EF6B1B59B69
    Data.q $BA3DAFD0D79AEA93,$83EFAA8DF0B33733,$31A2366B9A131831,$5BB4A40290081E1B,$541477C025061480
    Data.q $1A9D2F8FBDB03C0A,$C0538097654B1FC9,$68EF6E00E5B8B000,$6CD9B2B7D4E5D191,$DE306F59DACC1823
    Data.q $C2D6208F58BF0D98,$62924344EF0880CB,$E717F1B7BB7B856E,$BC0F37353CFF4AE7,$FE2F1407BC0CBC03
    Data.q $F03FCFDCF0002DE7,$426369CFE2C2D4B9,$C6F75DCD63180D43,$B64DD003EF34EFC5,$4E56D6F6E45A9CB0
    Data.q $02599D0DAFB5AB94,$A83F640F592F004E,$AFC0D7A6F46B6102,$B17CFF333EA7AA7E,$EE242FE375E98952
    Data.q $B02C203D611AF27A,$D3662CCD9244818B,$27C18D8D621CF0EC,$FC083D69AE5D1F0F,$B397EA7436DFF027
    Data.q $0D951E2DBC49D365,$EB5B64CF9F3FA9CB,$E4C22108148786DA,$83BD088D653D6215,$13C5E030BC9D1730
    Data.q $4F7F4FB49A552AA4,$7A855337D5FFB9AF,$D3A5B11C0438147D,$BBBDF0069B3D92BF,$98DC9B642A51DB6F
    Data.q $5568139B4428D4BB,$7A9A041001247C01,$4F422392C2234750,$084559422F52F45C,$791E4ED7647C3352
    Data.q $FC0934A15CF664EB,$4E90DCF2B6F3EED8,$E214B8F8187C00DC,$93751FD6D788CECE,$BAC5EA37BC5EA33B
    Data.q $4286D6F681C8D163,$04067AC1AD7557D5,$33277340DA30F5CA,$46A79DBEDC1CA3D3,$AF024E4D8ECF0B27
    Data.q $D2507DCFF8DBCF00,$643E06E80F00056E,$75F74D0237764DAF,$5D3F7D5DF5FCDCB4,$10890840A5A97DF1
    Data.q $2EE972B289A26882,$C1DED7D864CE1967,$CE0D8F37F94AC56B,$5D4813780E7990D8,$1CC0F991A2B7692E
    Data.q $FB1028A02C4402B0,$CF53787F9DBEAEE8,$06D180349CB9D2F7,$20922546345E3421,$FCC7B43EBB34EE7D
    Data.q $B72E7C787E54E8D5,$DA2F02EF00AEA958,$C00AD7F18CDE9F7A,$B7E002CFADBE1058,$B3F76F62FB1BDCEE
    Data.q $0C615AD2EDB3B353,$3D9F4C3DAD502908,$70C0C4F376BBDDC9,$0C043014EAD2D0EE,$566A0FA580A7005B
    Data.q $AFB17FE7C4E00A5B,$FF317CB9EEE5BDAB,$A1D1F6FD9F4EC797,$C9FE767B1BFEA055,$D68B9E794FDCECFC
    Data.q $2EF7788636831810,$7E3EBEBECBBECE46,$D34B0BCBFCF1BDF7,$96CB526D97FE44B6,$039537D252D7F8E7
    Data.q $9FE79B777C7C8F23,$C6E28B17A35AE590,$5D3169AF9C8CA663,$07AFC0A5F01D4E5C,$368950607A80FD54
    Data.q $B9E51E29A3DEC706,$8CD726C7EFF15CD5,$CDD4F65369DB37FF,$7767C0F6ABD436B5,$424BAFFF75CD39F7
    Data.q $181142F226B6CA37,$D3D726634F4D0221,$4F9AD5046046D5D8,$946C6C718C83E2B9,$FE5475B52C73B393
    Data.q $EC3B693819726C69,$6AF264BD7EBE3580,$C2EBF7D8EFA78801,$13AD53173D440FD1,$B3A7008C1CA90651
    Data.q $10E9180C0844E505,$15E9AB22B9D318C8,$BE5FD11E1DC51C5A,$41E1DC8D1BB77F7F,$3FC9DC9943926D09
    Data.q $362BF35D32767538,$1A10F2D98B44D67C,$54734B36F747D4FD,$CA149D2111B89CC4,$841CA90A54854841
    Data.q $3ECB9407EABF630A,$4D6BA946898F9AE5,$4F2174454A54F810,$5C7312E239A052BC,$FC79191B8F2448DC
    Data.q $683B393FBED7D0E8,$87D4F03D4B755B2B,$273151DFD19AF66F,$476BCEA35EE237AE,$1529020408C60DA6
    Data.q $DC5CA78D7DD432AE,$8A2F189D8DAD0368,$D8F0625A9D246869,$7571FF25364DEC6B,$E1AC7BD9C9FDFA31
    Data.q $62570BDAAF81DB45,$51549F7B3B0BE2A3,$4D5F17170282E079,$245E581D08D78FC8,$90852908A4484225
    Data.q $63F18562883A570A,$42D907E71223B06F,$8D62D007BD4FF7E9,$B703B1F13A32DADE,$0B285472AAF9A447
    Data.q $8825271A1908C485,$235E7B02E48348D0,$30E11090F9691276,$7A75FC79380F5EA2,$F0C0CAFB50C46684
    Data.q $CA03181B78067032,$72A9E9D2CB81CD9B,$E94BA353E5C99835,$4AE52BB64FD57AF6,$4A15082D71D211C7
    Data.q $B135088DA28690AB,$F308A448460D68D6,$3E5880787A70E904,$F1C8E47F58D8D04D,$C09647E0419B5F45
    Data.q $91802CB82F4B5FCD,$B87F55CD5A1D497C,$A66AC2FCF77FCE94,$9E10ECEDEC1EF35C,$4DACFA05CDF4E17B
    Data.q $4350FB0A1D03EA28,$7D4B389B1872A44A,$8713E08ECE8E8669,$FBCB69C1EA14AD8F,$566E7D96AEA6055F
    Data.q $DBD4BFB3589B68D0,$25EB3F7B5DC6FD59,$F8C9060450286EE3,$996ADC3189A52ACC,$505B5DE309A01EA0
    Data.q $8D4CC9E616662A42,$90323A1FADDBDFD2,$12F3FE5ACF54A85A,$542A99B3CAD9B130,$4BED4775BD5F5207
    Data.q $A621B1A443FFB7BB,$9302A973B3D759B5,$1E4FE9B575F4A313,$496BEE5495E9913E,$6D6DBD894DADFDAA
    Data.q $30B15A2B12689571,$EFD3E63D7D1DCC31,$D4F613CB17CE660C,$5F13A7AE57C6B15F,$CCFC4C471DC40FB1
    Data.q $A56B8F6DED2267FE,$A39A2A641088E1C2,$4FC79935B4F4C343,$A7024E2B97BD4D9D,$FBAEA941B9AA00ED
    Data.q $13DB4434B7DD631A,$64F95CA91FFA345E,$1800FC06BC033726,$980155FC63D7F204,$DFEB6B44B1FFB83E
    Data.q $EA549060168445E2,$5F31D46E08F0C6F0,$ACE7B2A40CCD9F1F,$B2E8126C75643C14,$031AEFB4E807A17A
    Data.q $9BCEA59BB3E35B0E,$8913FEDC0F33A10E,$794508AE785BF264,$7A7D7926C6066558,$6E74C9CAB6D6F986
    Data.q $5355B8F9E36A3809,$8F056CD004846ACA,$1B75FC9ECE769DB4,$C5F67BD7FE24D97F,$3B132648FE3535F7
    Data.q $E7016B1673CFAC40,$35B4F702F92A454B,$DE1F24F7B3F7BFB9,$F92E99D7D63EA7DD,$53B9B550AE78F4C1
    Data.q $05ACC00B02AE86B1,$250862B9B0DEB950,$AF59EBBC1E4C475C,$12E30BCA5A0BE9B9,$08912A2A5F1F5611
    Data.q $5AD12AEAF4915C99,$7ECDAD1D0364AE95,$87ABD28573E398C5,$43D3B1CAFC5F96E6,$1996E0D186D298DA
    Data.q $AFE4FE0F0B00597E,$FAEEB8C6FE9B9B24,$2A904A5CF9ACDB7C,$8E2A6BAD5142626C,$94E2CF98A254BE4B
    Data.q $2838892D2E7AB48B,$5B267EBF2E5ABD35,$B5BF1F89E1A9F978,$08556FA81EB55B9A,$B6DFF707E3002FFD
    Data.q $2113468886F931AD,$810B2A90980411CD,$AF0C8C2840852111,$5CF7C03D5A84F6DA,$149908B94A8D7E8A
    Data.q $48B1123CF269D44D,$1CAA573DBDAD5B39,$991A3FC5E56E7E7A,$3BD5AFA3BCD6031A,$CFD17D81E6F80117
    Data.q $C87D8689931D37B5,$42002C175F84BF90,$0433DAC81D7B6B00,$651891EA1B40EEDA,$1225E904F396A861
    Data.q $663C5B438ECD3CA5,$0757FD552F8F5AAA,$8DFC68677F97C573,$C66C13BD6B3942B1,$EEEEF2FBC07A973B
    Data.q $474F793E34B57783,$2A569886896D81CB,$2900237A0006F7F4,$875AC5A48AFC2231,$25231213C92C6816
    Data.q $0CA5CA5CF351EB81,$AEED0ACCB132ECF5,$AD5B9394A1EBB343,$77F2BEAE5F38DFD5,$DE7D3E333D2FF353
    Data.q $1569733C95FA8032,$D5F9B9FA0BA56F92,$B4A943B367C737EC,$94C5E22FAF020D1F,$C51FF6109509C272
    Data.q $2FC6C41BC37FC4DA,$1888214485EE1701,$FA22764D104DC249,$2B247459278E90F6,$163BB3D8222474D9
    Data.q $31697F6E54B47079,$B000B3797E856735,$E54291F9C0D964BC,$72677F4CADCCBFDC,$B4452AD0285D396E
    Data.q $D40CE13A462373D3,$08DD9D6C64CAF588,$E16E1B08427058CE,$5E0D05AB854A4B90,$F99157A42CA26512
    Data.q $3A7F0B1333EDF9A2,$34D5F4F9BB68BD3A,$466D9A9F333EF53B,$B9F40E5E3946768B,$985A9DDF738533B7
    Data.q $D565AA67296E6179,$CE919471C278AAE7,$A1E6BD42617DA745,$5AAC00DEED2D9FB5,$D5743A11EEF9302C
    Data.q $95B9F7FB9536393C,$E952796A3A2B3B05,$ED8E239157101E4A,$A5FA04EC1A962DAA,$E9FADF35750FFD10
    Data.q $39B57776F75DAE9E,$D1223D678E34A4B1,$1D43BB2A409CF5A8,$CCE66054B943942D,$3C7A713CC751ED00
    Data.q $2F2E4765372A56F3,$17375FABD36CC700,$06DBB876BA7E44BA,$A73D5B9B81BB01F4,$EDEA1E5BF69EB1FF
    Data.q $248F593DBDB7BEDE,$D5D930FA4F59D2D1,$D30C4C2C73152EFA,$43D34707E7F5731C,$0D89C1F56C3C1121
    Data.q $4C1615DC321BA2F3,$1FA026E04EB692C4,$7A67CB7E31ADBFE8,$92DDD3DBD83CF63B,$A529284491EAF168
    Data.q $F4EAC33E42929183,$91C9CCF82458B128,$7C857EC26562B9D4,$D8B1B466CCBC92C1,$BB01B6C431B84682
    Data.q $9ABA27FF44257E80,$B647D763BBB87D6F,$4B96CC8B7889B4F5,$9E8F06E220A61764,$36ACC6D4A8595918
    Data.q $C550CD374ACED178,$CF36B10C0F92D216,$D17DD6FDB7AC7FE9,$933E3D3C318AEF58,$33B25FE335F5FACD
    Data.q $D4B31B82A8626BD2,$ACC363D803B62125,$6D476936E3A936CB,$59006E85C25B37CD,$77ACDB05D5988074
    Data.q $E528CB5FCFC8562A,$30D8E621A5C012FF,$FF5ABFFF62923733,$195FD8DAF3401403,$4E454900000000B7
    Data.b $44,$AE,$42,$60,$82
    logo_png_end:
  EndDataSection
  
CompilerEndIf
Screenshot:
Image

Please test it.

Tested on: Linux Mint 15 Cinnamon (x64), Ubuntu 13.04 Gnome-Edition (x86) and Mageia 3 KDE (x86)

Have fun
Thomas
Last edited by ts-soft on Tue Jul 23, 2013 7:05 pm, edited 6 times in total.
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Re: Module notify (linux only!)

Post by ts-soft »

Update:
History wrote:; Version 0.6
; + Update
; + Get_AppName
; + Set_AppName
; + Close
; ~ result of show is *notification
; ~ better error-handling
; ~ example
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
User avatar
idle
Always Here
Always Here
Posts: 5870
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: Module notify (linux only!)

Post by idle »

Thanks Thomas, this will be very useful.
Windows 11, Manjaro, Raspberry Pi OS
Image
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Re: Module notify (linux only!)

Post by ts-soft »

Update:
History wrote:; Version 0.7
; + Get_ServerInfo
; + Get_ServerCaps
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
Poshu
Enthusiast
Enthusiast
Posts: 459
Joined: Tue Jan 25, 2005 7:01 pm
Location: Canada

Re: Module notify (linux only!)

Post by Poshu »

Already loving it.
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Re: Module notify (linux only!)

Post by ts-soft »

You're welcome :D

In the moment, i have problems to understand the actions. Every help is welcome.

Greetings - Thomas
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
User avatar
idle
Always Here
Always Here
Posts: 5870
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: Module notify (linux only!)

Post by idle »

ts-soft wrote:You're welcome :D

In the moment, i have problems to understand the actions. Every help is welcome.

Greetings - Thomas
I'll have a look at the actions today if you like.

Do you think it'd be nicer to wrap it in an interface?
My eyes aren't used to modules yet and the code swims in my vision! :?
Windows 11, Manjaro, Raspberry Pi OS
Image
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Re: Module notify (linux only!)

Post by ts-soft »

idle wrote:I'll have a look at the actions today if you like.
I like :D
idle wrote:Do you think it'd be nicer to wrap it in an interface?
My eyes aren't used to modules yet and the code swims in my vision! :?
A interface in module is a good idea, so the object can hold *notification.

With my tests with actions, there is no popup anymore :mrgreen:
and i can't see the problem. I have no full example in c found and not
so many time to test.

Greetings - Thomas
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
User avatar
idle
Always Here
Always Here
Posts: 5870
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: Module notify (linux only!)

Post by idle »

I'll add an interface and have a bash at the actions, I'll pm you the result later
Windows 11, Manjaro, Raspberry Pi OS
Image
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Re: Module notify (linux only!)

Post by ts-soft »

Thx, but for me it's time to go sleeping, have a hard day tomorrow.
(learning for some ms-server certification in my old days :mrgreen: )

I have a look on it tomorrow.

Thomas
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
User avatar
idle
Always Here
Always Here
Posts: 5870
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: Module notify (linux only!)

Post by idle »

Catch you later, good luck for tomorrow!
Windows 11, Manjaro, Raspberry Pi OS
Image
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Re: Module notify (linux only!)

Post by ts-soft »

Update:
History wrote:; Version 0.9.0
; + Clear_Actions

; Version 0.8.0 Idle
; + Changed to use Interface
; + Add_Action
; + Action Callback
Snapshot:
Image
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
uwekel
Enthusiast
Enthusiast
Posts: 740
Joined: Sat Dec 03, 2011 5:54 pm
Location: Oldenburg (Germany)

Re: Module notify (linux only!)

Post by uwekel »

On Fedora 19 you have to install the paket libnotify-devel to get it working.
PB 5.70 LTS (x64) - Debian Testing, Gnome 3.30.2
Post Reply