Esempio n. 1
0
        public void AddTemplate(string name, string category, string singularText, string pluralText, Dictionary <string, object> options, params NotificationAction[] actions)
        {
            bool   desktopNotify    = (options.ContainsKey("DesktopNotify") && ((bool)options["DesktopNotify"]) == true);
            bool   showInMainWindow = (options.ContainsKey("ShowInMainWindow") && ((bool)options["ShowInMainWindow"]) == true);
            string iconUrl          = (options.ContainsKey("IconUrl") ? (string)options["IconUrl"] : null);

            var template = new ActivityFeedItemTemplate(name, category, singularText, pluralText, desktopNotify, showInMainWindow, iconUrl, actions);

            lock (m_Templates)
                m_Templates.Add(name, template);

            if (!String.IsNullOrEmpty(category) && !m_Categories.Contains(category))
            {
                m_Categories.Add(category);
                if (CategoryAdded != null)
                {
                    CategoryAdded(category);
                }
            }

            if (TemplateAdded != null)
            {
                TemplateAdded(template);
            }
        }
Esempio n. 2
0
        public void AddTemplate(string name, string category, string singularText, string pluralText, Dictionary<string, object> options, params NotificationAction[] actions)
        {
            bool desktopNotify    = (options.ContainsKey("DesktopNotify") && ((bool)options["DesktopNotify"]) == true);
            bool showInMainWindow = (options.ContainsKey("ShowInMainWindow") && ((bool)options["ShowInMainWindow"]) == true);
            string iconUrl        = (options.ContainsKey("IconUrl") ? (string)options["IconUrl"] : null);

            var template = new ActivityFeedItemTemplate(name, category, singularText, pluralText, desktopNotify, showInMainWindow, iconUrl, actions);

            m_Templates.Add(name, template);

            if (!String.IsNullOrEmpty(category) && !m_Categories.Contains(category)) {
                m_Categories.Add(category);
                if (CategoryAdded != null)
                    CategoryAdded(category);
            }

            if (TemplateAdded != null)
                TemplateAdded(template);
        }
Esempio n. 3
0
 public override void DesktopNotify(ActivityFeedItemTemplate template, IActivityFeedItem item, string text)
 {
     // FIXME: This will need to be different on windows/osx...
     QApplication.Invoke(delegate {
         Notification notif = new Notification(text, item.Content);
         foreach (var action in template.Actions) {
             notif.AddAction(action.Name, action.Label, delegate {
                 item.TriggerAction(action.Name);
             });
         }
         notif.Show ();
     });
 }
Esempio n. 4
0
 void HandleTemplateAdded(ActivityFeedItemTemplate template)
 {
     QApplication.Invoke(delegate {
         string category = (template.Category == null) ? null : template.Category.ToLower().Replace(" ", "-");
         string js = Util.CreateJavascriptCall("ActivityFeed.addTemplate", template.Name, category,
                               template.SingularText, template.PluralText, template.IconUrl,
                               template.Actions);
         var ret = m_ActivityWebView.Page().MainFrame().EvaluateJavaScript(js);
         if (ret.IsNull() || !ret.ToBool()) {
             throw new Exception("Failed to add template!\n" + js);
         }
     });
 }
Esempio n. 5
0
 public abstract void DesktopNotify(ActivityFeedItemTemplate template, IActivityFeedItem item, string text);