[Tween-svn] [1639] Growl通知を個別発言にばらして通知

Zurück zum Archiv-Index

svnno****@sourc***** svnno****@sourc*****
2011年 10月 24日 (月) 16:54:26 JST


Revision: 1639
          http://sourceforge.jp/projects/tween/svn/view?view=rev&revision=1639
Author:   kiri_feather
Date:     2011-10-24 16:54:26 +0900 (Mon, 24 Oct 2011)

Log Message:
-----------
Growl通知を個別発言にばらして通知
Growlにユーザーのアイコンが表示されるように変更

Modified Paths:
--------------
    trunk/Tween/Growl.vb
    trunk/Tween/Tween.vb


-------------- next part --------------
Modified: trunk/Tween/Growl.vb
===================================================================
--- trunk/Tween/Growl.vb	2011-10-23 12:47:34 UTC (rev 1638)
+++ trunk/Tween/Growl.vb	2011-10-24 07:54:26 UTC (rev 1639)
@@ -196,7 +196,7 @@
         Return True
     End Function
 
-    Public Sub Notify(ByVal notificationType As NotifyType, ByVal id As String, ByVal title As String, ByVal text As String)
+    Public Sub Notify(ByVal notificationType As NotifyType, ByVal id As String, ByVal title As String, ByVal text As String, Optional ByVal icon As Image = Nothing)
         If Not _initialized Then Return
         Dim notificationName As String = ""
         Select Case notificationType
@@ -209,9 +209,18 @@
             Case NotifyType.UserStreamEvent
                 notificationName = "USERSTREAM_EVENT"
         End Select
-
-        Dim n As Object =
-                _connector.GetType("Growl.Connector.Notification").InvokeMember(
+        Dim n As Object = Nothing
+        If icon IsNot Nothing Then
+            Dim gCore As Type = _core.GetType("Growl.CoreLibrary.Resource")
+            Dim res As Object = gCore.InvokeMember("op_Implicit",
+                                                   BindingFlags.Public Or BindingFlags.Static Or BindingFlags.InvokeMethod,
+                                                   Nothing,
+                                                   Nothing,
+                                                   New Object() {icon})
+            Dim priority As Object =
+                    _connector.GetType("Growl.Connector.Priority").InvokeMember(
+                        "Normal", BindingFlags.GetField, Nothing, Nothing, Nothing)
+            n = _connector.GetType("Growl.Connector.Notification").InvokeMember(
                     "Notification",
                     BindingFlags.CreateInstance,
                     Nothing,
@@ -220,7 +229,23 @@
                                   notificationName,
                                   id,
                                   title,
-                                  text})
+                                  text,
+                                  res,
+                                  False,
+                                  priority,
+                                  "aaa"})
+        Else
+            n = _connector.GetType("Growl.Connector.Notification").InvokeMember(
+                    "Notification",
+                    BindingFlags.CreateInstance,
+                    Nothing,
+                    _connector,
+                    New Object() {_appName,
+                                    notificationName,
+                                    id,
+                                    title,
+                                    text})
+        End If
         '_targetConnector.GetType.InvokeMember("Notify", BindingFlags.InvokeMethod, Nothing, _targetConnector, New Object() {n})
         Dim cc As Object = _connector.GetType("Growl.Connector.CallbackContext").InvokeMember(
             Nothing, BindingFlags.CreateInstance, Nothing, _connector,

Modified: trunk/Tween/Tween.vb
===================================================================
--- trunk/Tween/Tween.vb	2011-10-23 12:47:34 UTC (rev 1638)
+++ trunk/Tween/Tween.vb	2011-10-24 07:54:26 UTC (rev 1639)
@@ -1545,69 +1545,131 @@
         '新着通知
         If BalloonRequired() Then
             If notifyPosts IsNot Nothing AndAlso notifyPosts.Length > 0 Then
-                Dim sb As New StringBuilder
-                Dim reply As Boolean = False
-                Dim dm As Boolean = False
-                For Each post As PostClass In notifyPosts
-                    If post.IsReply AndAlso Not post.IsExcludeReply Then reply = True
-                    If post.IsDm Then dm = True
-                    If sb.Length > 0 Then sb.Append(System.Environment.NewLine)
-                    Select Case SettingDialog.NameBalloon
-                        Case NameBalloonEnum.UserID
-                            sb.Append(post.ScreenName).Append(" : ")
-                        Case NameBalloonEnum.NickName
-                            sb.Append(post.Nickname).Append(" : ")
-                    End Select
-                    sb.Append(post.TextFromApi)
-                Next
-                'If SettingDialog.DispUsername Then NotifyIcon1.BalloonTipTitle = tw.Username + " - " Else NotifyIcon1.BalloonTipTitle = ""
-                Dim title As New StringBuilder
-                Dim ntIcon As ToolTipIcon
-                Dim nt As GrowlHelper.NotifyType
-                If SettingDialog.DispUsername Then
-                    title.Append(tw.Username)
-                    title.Append(" - ")
-                Else
-                    'title.Clear()
-                End If
-                If dm Then
-                    'NotifyIcon1.BalloonTipIcon = ToolTipIcon.Warning
-                    'NotifyIcon1.BalloonTipTitle += "Tween [DM] " + My.Resources.RefreshDirectMessageText1 + " " + addCount.ToString() + My.Resources.RefreshDirectMessageText2
-                    ntIcon = ToolTipIcon.Warning
-                    title.Append("Tween [DM] ")
-                    title.Append(My.Resources.RefreshDirectMessageText1)
-                    title.Append(" ")
-                    title.Append(addCount)
-                    title.Append(My.Resources.RefreshDirectMessageText2)
-                    nt = GrowlHelper.NotifyType.DirectMessage
-                ElseIf reply Then
-                    'NotifyIcon1.BalloonTipIcon = ToolTipIcon.Warning
-                    'NotifyIcon1.BalloonTipTitle += "Tween [Reply!] " + My.Resources.RefreshTimelineText1 + " " + addCount.ToString() + My.Resources.RefreshTimelineText2
-                    ntIcon = ToolTipIcon.Warning
-                    title.Append("Tween [Reply!] ")
-                    title.Append(My.Resources.RefreshTimelineText1)
-                    title.Append(" ")
-                    title.Append(addCount)
-                    title.Append(My.Resources.RefreshTimelineText2)
-                    nt = GrowlHelper.NotifyType.Reply
-                Else
-                    'NotifyIcon1.BalloonTipIcon = ToolTipIcon.Info
-                    'NotifyIcon1.BalloonTipTitle += "Tween " + My.Resources.RefreshTimelineText1 + " " + addCount.ToString() + My.Resources.RefreshTimelineText2
-                    ntIcon = ToolTipIcon.Info
-                    title.Append("Tween ")
-                    title.Append(My.Resources.RefreshTimelineText1)
-                    title.Append(" ")
-                    title.Append(addCount)
-                    title.Append(My.Resources.RefreshTimelineText2)
-                    nt = GrowlHelper.NotifyType.Notify
-                End If
-                Dim bText As String = sb.ToString
-                If String.IsNullOrEmpty(bText) Then Exit Sub
-                'NotifyIcon1.BalloonTipText = sb.ToString()
-                'NotifyIcon1.ShowBalloonTip(500)
+                'Growlは一個ずつばらして通知
                 If SettingDialog.IsNotifyUseGrowl Then
-                    gh.Notify(nt, DateTime.Now.Ticks.ToString(), title.ToString(), bText)
+                    For Each post In notifyPosts
+                        Dim sb As New StringBuilder
+                        Dim reply As Boolean = False
+                        Dim dm As Boolean = False
+
+                        If post.IsReply AndAlso Not post.IsExcludeReply Then reply = True
+                        If post.IsDm Then dm = True
+                        If sb.Length > 0 Then sb.Append(System.Environment.NewLine)
+                        Select Case SettingDialog.NameBalloon
+                            Case NameBalloonEnum.UserID
+                                sb.Append(post.ScreenName).Append(" : ")
+                            Case NameBalloonEnum.NickName
+                                sb.Append(post.Nickname).Append(" : ")
+                        End Select
+                        sb.Append(post.TextFromApi)
+
+                        Dim title As New StringBuilder
+                        Dim ntIcon As ToolTipIcon
+                        Dim nt As GrowlHelper.NotifyType
+                        If SettingDialog.DispUsername Then
+                            title.Append(tw.Username)
+                            title.Append(" - ")
+                        Else
+                            'title.Clear()
+                        End If
+                        If dm Then
+                            'NotifyIcon1.BalloonTipIcon = ToolTipIcon.Warning
+                            'NotifyIcon1.BalloonTipTitle += "Tween [DM] " + My.Resources.RefreshDirectMessageText1 + " " + addCount.ToString() + My.Resources.RefreshDirectMessageText2
+                            ntIcon = ToolTipIcon.Warning
+                            title.Append("Tween [DM] ")
+                            title.Append(My.Resources.RefreshDirectMessageText1)
+                            title.Append(" ")
+                            title.Append(addCount)
+                            title.Append(My.Resources.RefreshDirectMessageText2)
+                            nt = GrowlHelper.NotifyType.DirectMessage
+                        ElseIf reply Then
+                            'NotifyIcon1.BalloonTipIcon = ToolTipIcon.Warning
+                            'NotifyIcon1.BalloonTipTitle += "Tween [Reply!] " + My.Resources.RefreshTimelineText1 + " " + addCount.ToString() + My.Resources.RefreshTimelineText2
+                            ntIcon = ToolTipIcon.Warning
+                            title.Append("Tween [Reply!] ")
+                            title.Append(My.Resources.RefreshTimelineText1)
+                            title.Append(" ")
+                            title.Append(addCount)
+                            title.Append(My.Resources.RefreshTimelineText2)
+                            nt = GrowlHelper.NotifyType.Reply
+                        Else
+                            'NotifyIcon1.BalloonTipIcon = ToolTipIcon.Info
+                            'NotifyIcon1.BalloonTipTitle += "Tween " + My.Resources.RefreshTimelineText1 + " " + addCount.ToString() + My.Resources.RefreshTimelineText2
+                            ntIcon = ToolTipIcon.Info
+                            title.Append("Tween ")
+                            title.Append(My.Resources.RefreshTimelineText1)
+                            title.Append(" ")
+                            title.Append(addCount)
+                            title.Append(My.Resources.RefreshTimelineText2)
+                            nt = GrowlHelper.NotifyType.Notify
+                        End If
+                        Dim bText As String = sb.ToString
+                        If String.IsNullOrEmpty(bText) Then Exit Sub
+
+                        gh.Notify(nt, DateTime.Now.Ticks.ToString(), title.ToString(), bText, Me.TIconDic(post.ImageUrl))
+                    Next
                 Else
+                    Dim sb As New StringBuilder
+                    Dim reply As Boolean = False
+                    Dim dm As Boolean = False
+                    For Each post As PostClass In notifyPosts
+                        If post.IsReply AndAlso Not post.IsExcludeReply Then reply = True
+                        If post.IsDm Then dm = True
+                        If sb.Length > 0 Then sb.Append(System.Environment.NewLine)
+                        Select Case SettingDialog.NameBalloon
+                            Case NameBalloonEnum.UserID
+                                sb.Append(post.ScreenName).Append(" : ")
+                            Case NameBalloonEnum.NickName
+                                sb.Append(post.Nickname).Append(" : ")
+                        End Select
+                        sb.Append(post.TextFromApi)
+
+                    Next
+                    'If SettingDialog.DispUsername Then NotifyIcon1.BalloonTipTitle = tw.Username + " - " Else NotifyIcon1.BalloonTipTitle = ""
+                    Dim title As New StringBuilder
+                    Dim ntIcon As ToolTipIcon
+                    Dim nt As GrowlHelper.NotifyType
+                    If SettingDialog.DispUsername Then
+                        title.Append(tw.Username)
+                        title.Append(" - ")
+                    Else
+                        'title.Clear()
+                    End If
+                    If dm Then
+                        'NotifyIcon1.BalloonTipIcon = ToolTipIcon.Warning
+                        'NotifyIcon1.BalloonTipTitle += "Tween [DM] " + My.Resources.RefreshDirectMessageText1 + " " + addCount.ToString() + My.Resources.RefreshDirectMessageText2
+                        ntIcon = ToolTipIcon.Warning
+                        title.Append("Tween [DM] ")
+                        title.Append(My.Resources.RefreshDirectMessageText1)
+                        title.Append(" ")
+                        title.Append(addCount)
+                        title.Append(My.Resources.RefreshDirectMessageText2)
+                        nt = GrowlHelper.NotifyType.DirectMessage
+                    ElseIf reply Then
+                        'NotifyIcon1.BalloonTipIcon = ToolTipIcon.Warning
+                        'NotifyIcon1.BalloonTipTitle += "Tween [Reply!] " + My.Resources.RefreshTimelineText1 + " " + addCount.ToString() + My.Resources.RefreshTimelineText2
+                        ntIcon = ToolTipIcon.Warning
+                        title.Append("Tween [Reply!] ")
+                        title.Append(My.Resources.RefreshTimelineText1)
+                        title.Append(" ")
+                        title.Append(addCount)
+                        title.Append(My.Resources.RefreshTimelineText2)
+                        nt = GrowlHelper.NotifyType.Reply
+                    Else
+                        'NotifyIcon1.BalloonTipIcon = ToolTipIcon.Info
+                        'NotifyIcon1.BalloonTipTitle += "Tween " + My.Resources.RefreshTimelineText1 + " " + addCount.ToString() + My.Resources.RefreshTimelineText2
+                        ntIcon = ToolTipIcon.Info
+                        title.Append("Tween ")
+                        title.Append(My.Resources.RefreshTimelineText1)
+                        title.Append(" ")
+                        title.Append(addCount)
+                        title.Append(My.Resources.RefreshTimelineText2)
+                        nt = GrowlHelper.NotifyType.Notify
+                    End If
+                    Dim bText As String = sb.ToString
+                    If String.IsNullOrEmpty(bText) Then Exit Sub
+                    'NotifyIcon1.BalloonTipText = sb.ToString()
+                    'NotifyIcon1.ShowBalloonTip(500)
                     NotifyIcon1.BalloonTipTitle = title.ToString()
                     NotifyIcon1.BalloonTipText = bText
                     NotifyIcon1.BalloonTipIcon = ntIcon



Tween-svn メーリングリストの案内
Zurück zum Archiv-Index