void OnCategoryActivated(object sender, EventArgs args) { CategoryMenuItem item = sender as CategoryMenuItem; if (item == null) { return; } string categoryName = item.CategoryName; Tasque.RemoteControl tasque = GetTasqueRemoteControl(); if (tasque == null) { return; } string taskName = GetTaskName(); if (taskName == null) { return; } CreateTask(categoryName, taskName); }
private void CreateTask(string categoryName, string taskName) { Tasque.RemoteControl tasque = GetTasqueRemoteControl(); if (tasque == null) { return; } // Trim and truncate to 100 chars max (this is a // "number out of a hat")...a4gpa protection taskName = taskName.Trim(); if (taskName.Length > 100) { taskName = taskName.Substring(0, 100); } if (taskName == string.Empty) { return; } try { tasque.CreateTask(categoryName, taskName, false); } catch (Exception e) { Logger.Debug("Exception calling Tasque.CreateTask ()", e.Message); } }
void UpdateMenu() { // // Clear out the old list // foreach (Gtk.MenuItem old_item in menu.Children) { menu.Remove(old_item); } Tasque.RemoteControl tasque = GetTasqueRemoteControl(); string [] taskCategories = null; if (tasque != null) { try { taskCategories = tasque.GetCategoryNames(); } catch (Exception e) { Logger.Debug("Exception calling Tasque.GetCategoryNames (): {0}", e.Message); } } if (taskCategories != null) { // // Build a new list // foreach (string category in taskCategories) { CategoryMenuItem item = new CategoryMenuItem(category); item.Activated += OnCategoryActivated; item.ShowAll(); menu.Append(item); } } // If nothing was found, add in a "dummy" item if (menu.Children.Length == 0) { Gtk.MenuItem blankItem = new Gtk.MenuItem(Catalog.GetString("--- Tasque is not running ---")); blankItem.Sensitive = false; blankItem.ShowAll(); menu.Append(blankItem); } submenuBuilt = true; }
Tasque.RemoteControl GetTasqueRemoteControl() { Tasque.RemoteControl remoteControl = null; try { if (Bus.Session.NameHasOwner(TasqueNamespace) == false) { return(null); } remoteControl = Bus.Session.GetObject <Tasque.RemoteControl> ( TasqueNamespace, TasquePath); } catch (Exception e) { Logger.Error("Exception when getting Tasque.RemoteControl: {0}", e.Message); } return(remoteControl); }