Exemple #1
0
        protected override void OnShown()
        {
            Trace.Call();

            if (!IsPopulated)
            {
                IsPopulated = true;
                foreach (var chatView in ChatViewManager.Chats)
                {
                    if (!(chatView is XmppGroupChatView))
                    {
                        // only invite to group chats
                        continue;
                    }
                    if (chatView == ChatViewManager.ActiveChat)
                    {
                        // don't need to add current chat to invite list
                        continue;
                    }
                    if (chatView.ProtocolManager != ProtocolManager)
                    {
                        // only add chats from current server
                        continue;
                    }
                    var groupChatView = (XmppGroupChatView)chatView;
                    if (groupChatView.IsContactList)
                    {
                        // ignore our abused groupchatview
                        continue;
                    }

                    var item = new Gtk.ImageMenuItem(chatView.Name);
                    item.Image = new Gtk.Image(GroupChatView.IconPixbuf);
                    var chatid = chatView.ID;
                    item.Activated += delegate {
                        var inviteFromChatModel = ChatViewManager.ActiveChat.ChatModel;
                        ThreadPool.QueueUserWorkItem(delegate {
                            try {
                                for (int i = 0; i < Invitees.Count; i++)
                                {
                                    ProtocolManager.CommandInvite(
                                        new CommandModel(
                                            Frontend.FrontendManager,
                                            inviteFromChatModel,
                                            chatid + " " + Invitees[i].ID
                                            )
                                        );
                                }
                            } catch (Exception ex) {
                                Frontend.ShowException(ex);
                            }
                        });
                    };
                    item.Show();
                    Append(item);
                }
            }

            base.OnShown();
        }
        public override void Initialize()
        {
            // Don't add item to tools menu if Sticky Notes XML file does not
            // exist. Only check for the file once, since Initialize is called
            // for each note when Tomboy starts up.
            if (sticky_file_might_exist)
            {
                if (sticky_file_existence_confirmed || File.Exists(sticky_xml_path))
                {
                    item = new Gtk.ImageMenuItem(
                        Catalog.GetString("Import from Sticky Notes"));
                    item.Image      = new Gtk.Image(Gtk.Stock.Convert, Gtk.IconSize.Menu);
                    item.Activated += ImportButtonClicked;
                    item.Show();
                    AddPluginMenuItem(item);

                    sticky_file_existence_confirmed = true;
                    CheckForFirstRun();
                }
                else
                {
                    sticky_file_might_exist = false;
                    Logger.Debug(debug_no_sticky_file);
                }
            }
        }
 public override void OnNoteOpened()
 {
     item =
         new Gtk.ImageMenuItem(Catalog.GetString("Export to HTML"));
     item.Image      = new Gtk.Image(Gtk.Stock.Save, Gtk.IconSize.Menu);
     item.Activated += ExportButtonClicked;
     item.Show();
     AddPluginMenuItem(item);
 }
		public override void OnNoteOpened ()
		{
			item =
			        new Gtk.ImageMenuItem (Catalog.GetString ("Export to HTML"));
			item.Image = new Gtk.Image (Gtk.Stock.Save, Gtk.IconSize.Menu);
			item.Activated += ExportButtonClicked;
			item.Show ();
			AddPluginMenuItem (item);
		}
 public override void OnNoteOpened()
 {
     item            = new Gtk.ImageMenuItem(Catalog.GetString("Print"));
     item.Image      = new Gtk.Image(Gtk.Stock.Print, Gtk.IconSize.Menu);
     item.Activated += PrintButtonClicked;
     item.AddAccelerator("activate", Window.AccelGroup,
                         (uint)Gdk.Key.p, Gdk.ModifierType.ControlMask,
                         Gtk.AccelFlags.Visible);
     item.Show();
     AddPluginMenuItem(item);
 }
		public override void OnNoteOpened ()
		{
			item = new Gtk.ImageMenuItem (Catalog.GetString ("Print"));
			item.Image = new Gtk.Image (Gtk.Stock.Print, Gtk.IconSize.Menu);
			item.Activated += PrintButtonClicked;
			item.AddAccelerator ("activate", Window.AccelGroup,
				(uint) Gdk.Key.p, Gdk.ModifierType.ControlMask,
				Gtk.AccelFlags.Visible);
			item.Show ();
			AddPluginMenuItem (item);
		}
		public static Gtk.MenuItem MakeMenuItem (Gtk.Menu menu, string label, string image_name, EventHandler e, bool enabled)
		{
			Gtk.ImageMenuItem i = new Gtk.ImageMenuItem (label);
			i.Activated += e;
	                i.Sensitive = enabled;
			i.Image = Gtk.Image.NewFromIconName (image_name, Gtk.IconSize.Menu);
			
			menu.Append (i);
			i.Show ();
	
		        return i;
		}
Exemple #8
0
        public static Gtk.MenuItem MakeMenuItem(Gtk.Menu menu, string label, string image_name, EventHandler e, bool enabled)
        {
            Gtk.ImageMenuItem i = new Gtk.ImageMenuItem(label);
            i.Activated += e;
            i.Sensitive  = enabled;
            i.Image      = Gtk.Image.NewFromIconName(image_name, Gtk.IconSize.Menu);

            menu.Append(i);
            i.Show();

            return(i);
        }
		public override void OnNoteOpened ()
		{
			menu = new Gtk.Menu ();
			menu.Hidden += OnMenuHidden;
			menu.ShowAll ();
			menu_item = new Gtk.ImageMenuItem (
			        Catalog.GetString ("What links here?"));
			menu_item.Image = new Gtk.Image (Gtk.Stock.JumpTo, Gtk.IconSize.Menu);
			menu_item.Submenu = menu;
			menu_item.Activated += OnMenuItemActivated;
			menu_item.Show ();
			AddPluginMenuItem (menu_item);
		}
Exemple #10
0
 public override void OnNoteOpened()
 {
     menu         = new Gtk.Menu();
     menu.Hidden += OnMenuHidden;
     menu.ShowAll();
     menu_item = new Gtk.ImageMenuItem(
         Catalog.GetString("What links here?"));
     menu_item.Image      = new Gtk.Image(Gtk.Stock.JumpTo, Gtk.IconSize.Menu);
     menu_item.Submenu    = menu;
     menu_item.Activated += OnMenuItemActivated;
     menu_item.Show();
     AddPluginMenuItem(menu_item);
 }
		public override void Initialize ()
		{
            // Translators: a 'sketch' is a quick drawing
			menu_item = new Gtk.ImageMenuItem (
					Catalog.GetString ("Add a sketch"));
			// FIXME: Use a real Sketching icon instead of the Edit icon
			menu_item.Image = new Gtk.Image (Gtk.Stock.Edit, Gtk.IconSize.Menu);
			menu_item.Activated += OnMenuItemActivated;
			menu_item.Show ();
			AddPluginMenuItem (menu_item);

			if (!Note.TagTable.IsDynamicTagRegistered ("sketch"))
				Note.TagTable.RegisterDynamicTag ("sketch", typeof (SketchingTextTag));
		}
        public override void OnNoteOpened()
        {
            // Add the menu item when the window is created.
            menu_item = new Gtk.ImageMenuItem (
                Catalog.GetString ("Word count"));
            menu_item.Image = new Gtk.Image (Gtk.Stock.Index,
                Gtk.IconSize.Menu);
            menu_item.Activated += OnMenuItemActivated;
            menu_item.AddAccelerator ("activate", Window.AccelGroup,
                (uint) Gdk.Key.o, Gdk.ModifierType.ControlMask,
                Gtk.AccelFlags.Visible);

            menu_item.Show ();
            AddPluginMenuItem (menu_item);
        }
        public override void Initialize()
        {
            // Translators: a 'sketch' is a quick drawing
            menu_item = new Gtk.ImageMenuItem(
                Catalog.GetString("Add a sketch"));
            // FIXME: Use a real Sketching icon instead of the Edit icon
            menu_item.Image      = new Gtk.Image(Gtk.Stock.Edit, Gtk.IconSize.Menu);
            menu_item.Activated += OnMenuItemActivated;
            menu_item.Show();
            AddPluginMenuItem(menu_item);

            if (!Note.TagTable.IsDynamicTagRegistered("sketch"))
            {
                Note.TagTable.RegisterDynamicTag("sketch", typeof(SketchingTextTag));
            }
        }
Exemple #14
0
        void UpdateMenu()
        {
            //
            // Clear out the old list
            //
            foreach (Gtk.MenuItem oldItem in menu.Children)
            {
                menu.Remove(oldItem);
            }

            //
            // Build a new menu
            //

            // Add the "New Notebook..."
            Gtk.ImageMenuItem newNotebookMenuItem =
                new Gtk.ImageMenuItem(Catalog.GetString("_New notebook..."));
            newNotebookMenuItem.Image      = new Gtk.Image(NewNotebookIcon);
            newNotebookMenuItem.Activated += OnNewNotebookMenuItem;
            newNotebookMenuItem.Show();
            menu.Append(newNotebookMenuItem);

            // Add the "(no notebook)" item at the top of the list
            NotebookMenuItem noNotebookMenuItem = new NotebookMenuItem(Note, null);

            noNotebookMenuItem.ShowAll();
            menu.Append(noNotebookMenuItem);

            // Add in all the real notebooks
            List <NotebookMenuItem> notebookMenuItems = GetNotebookMenuItems();

            if (notebookMenuItems.Count > 0)
            {
                Gtk.SeparatorMenuItem separator = new Gtk.SeparatorMenuItem();
                separator.ShowAll();
                menu.Append(separator);

                foreach (NotebookMenuItem item in GetNotebookMenuItems())
                {
                    item.ShowAll();
                    menu.Append(item);
                }
            }
        }
		public override void Initialize ()
		{
			// Don't add item to tools menu if Sticky Notes XML file does not
			// exist. Only check for the file once, since Initialize is called
			// for each note when Tomboy starts up.
			if (sticky_file_might_exist) {
				if (sticky_file_existence_confirmed || File.Exists (sticky_xml_path)) {
					item = new Gtk.ImageMenuItem (
					        Catalog.GetString ("Import from Sticky Notes"));
					item.Image = new Gtk.Image (Gtk.Stock.Convert, Gtk.IconSize.Menu);
					item.Activated += ImportButtonClicked;
					item.Show ();
					AddPluginMenuItem (item);

					sticky_file_existence_confirmed = true;
					CheckForFirstRun ();
				} else {
					sticky_file_might_exist = false;
					Logger.Debug (debug_no_sticky_file);
				}
			}
		}
        protected virtual void Populate(Gtk.Menu menu)
        {
            foreach (var w in menu.Children.ToArray())
            {
                menu.Remove(w);
            }

            foreach (var child in Children)
            {
                var wGtk  = child.ToGtk() as Gtk.Widget;
                var image = wGtk;
                var ti    = wGtk as Gtk.ToolItem;
                if (ti != null && ti.Child is Gtk.EventBox)
                {
                    ((Gtk.EventBox)ti.Child).VisibleWindow = false;
                }
                var but = wGtk as Gtk.ToolButton;
                if (but != null)
                {
                    image = but.IconWidget;
                }

                var item = new Gtk.ImageMenuItem("")
                {
                    Image       = image,
                    TooltipText = wGtk.TooltipText
                };
                item.Show();

                menu.Add(item);
                var b = child as IGtkToolbarItemBackend;
                if (b != null)
                {
                    item.ButtonPressEvent += (s, e) => b.Click(s, e);
                }

                item.ModifyBg(Gtk.StateType.Prelight, Notifycolor);
            }
        }
Exemple #17
0
        protected override void OnShown()
        {
            Trace.Call();

            if (!IsPopulated)
            {
                IsPopulated = true;
                foreach (var chatView in ChatViewManager.Chats)
                {
                    if (!(chatView is GroupChatView))
                    {
                        continue;
                    }

                    var item = new Gtk.ImageMenuItem(chatView.Name);
                    item.Image = new Gtk.Image(GroupChatView.IconPixbuf);
                    // HACK: anonymous methods inside foreach loops needs this
                    var chat = chatView;
                    item.Activated += delegate {
                        foreach (var invitee in Invitees)
                        {
                            ProtocolManager.CommandInvite(
                                new CommandModel(
                                    Frontend.FrontendManager,
                                    ChatViewManager.ActiveChat.ChatModel,
                                    String.Format("{0} {1}",
                                                  invitee.ID,
                                                  chat.ID)
                                    )
                                );
                        }
                    };
                    item.Show();
                    Append(item);
                }
            }

            base.OnShown();
        }
Exemple #18
0
        protected override void OnShown()
        {
            Trace.Call();

            if (!IsPopulated)
            {
                IsPopulated = true;
                foreach (var chatView in ChatViewManager.Chats)
                {
                    if (!(chatView is GroupChatView))
                    {
                        // only invite to group chats
                        continue;
                    }
                    if (chatView == ChatViewManager.ActiveChat)
                    {
                        // don't need to add current chat to invite list
                        continue;
                    }
                    if (chatView.ProtocolManager != ProtocolManager)
                    {
                        // only add chats from current server
                        continue;
                    }

                    var item = new Gtk.ImageMenuItem(chatView.Name);
                    item.Image = new Gtk.Image(GroupChatView.IconPixbuf);
                    // HACK: anonymous methods inside foreach loops needs this
                    var chat = chatView;
                    item.Activated += delegate {
                        OnItemActivated(chat);
                    };
                    item.Show();
                    Append(item);
                }
            }

            base.OnShown();
        }
Exemple #19
0
        protected override void OnShown()
        {
            Trace.Call();

            if (!IsPopulated) {
                IsPopulated = true;
                foreach (var chatView in ChatViewManager.Chats) {
                    if (!(chatView is GroupChatView)) {
                        // only invite to group chats
                        continue;
                    }
                    if (chatView == ChatViewManager.ActiveChat) {
                        // don't need to add current chat to invite list
                        continue;
                    }
                    if (chatView.ProtocolManager != ProtocolManager) {
                        // only add chats from current server
                        continue;
                    }

                    var item = new Gtk.ImageMenuItem(chatView.Name);
                    item.Image = new Gtk.Image(GroupChatView.IconPixbuf);
                    // HACK: anonymous methods inside foreach loops needs this
                    var chat = chatView;
                    item.Activated += delegate {
                        OnItemActivated(chat);
                    };
                    item.Show();
                    Append(item);
                }
            }

            base.OnShown();
        }
		void UpdateMenu ()
		{
			//
			// Clear out the old list
			//
			foreach (Gtk.MenuItem oldItem in menu.Children) {
				menu.Remove (oldItem);
			}

			//
			// Build a new menu
			//
			
			// Add the "New Notebook..."
			Gtk.ImageMenuItem newNotebookMenuItem =
				new Gtk.ImageMenuItem (Catalog.GetString ("_New notebook..."));
			newNotebookMenuItem.Image = new Gtk.Image (NewNotebookIcon);
			newNotebookMenuItem.Activated += OnNewNotebookMenuItem;
			newNotebookMenuItem.Show ();
			menu.Append (newNotebookMenuItem);
			
			// Add the "(no notebook)" item at the top of the list
			NotebookMenuItem noNotebookMenuItem = new NotebookMenuItem (Note, null);
			noNotebookMenuItem.ShowAll ();
			menu.Append (noNotebookMenuItem);
			
			// Add in all the real notebooks
			List<NotebookMenuItem> notebookMenuItems = GetNotebookMenuItems ();
			if (notebookMenuItems.Count > 0) {
				Gtk.SeparatorMenuItem separator = new Gtk.SeparatorMenuItem ();
				separator.ShowAll ();
				menu.Append (separator);
				
				foreach (NotebookMenuItem item in GetNotebookMenuItems ()) {
					item.ShowAll ();
					menu.Append (item);
				}
			}
		}
Exemple #21
0
        private void ConvertAndAddMenuItem(System.Windows.Forms.ToolStripItem item,
                                           Gtk.MenuShell gtkMenuShell)
        {
            if (item is System.Windows.Forms.ToolStripMenuItem)
            {
                var winformMenuItem = item as System.Windows.Forms.ToolStripMenuItem;

                // windows forms use '&' for mneumonic, gtk uses '_'
                var gtkMenuItem = new Gtk.ImageMenuItem(winformMenuItem.Text.Replace("&", "_"));

                if (winformMenuItem.Image != null)
                {
                    MemoryStream memStream;
                    var          image = winformMenuItem.Image;
                    if (image.Width != 16 || image.Height != 16)
                    {
                        var newImage = ResizeImage(image, 16, 16);
                        memStream = new MemoryStream(newImage);
                    }
                    else
                    {
                        memStream = new MemoryStream();
                        image.Save(memStream, ImageFormat.Png);
                        memStream.Position = 0;
                    }
                    gtkMenuItem.Image = new Gtk.Image(memStream);
                }

                gtkMenuItem.TooltipText = winformMenuItem.ToolTipText;
                gtkMenuItem.Visible     = winformMenuItem.Visible;
                gtkMenuItem.Sensitive   = winformMenuItem.Enabled;

                gtkMenuItem.Activated += (sender, e) =>
                                         DBusBackgroundWorker.InvokeWinformsThread((Action)winformMenuItem.PerformClick);

                winformMenuItem.TextChanged +=
                    (sender, e) => DBusBackgroundWorker.InvokeGtkThread(() =>
                {
                    var label = gtkMenuItem.Child as Gtk.Label;
                    if (label != null)
                    {
                        label.Text = winformMenuItem.Text;
                    }
                }
                                                                        );
                winformMenuItem.EnabledChanged += (sender, e) =>
                                                  DBusBackgroundWorker.InvokeGtkThread
                                                      (() => gtkMenuItem.Sensitive = winformMenuItem.Enabled);
                winformMenuItem.VisibleChanged += (sender, e) =>
                                                  DBusBackgroundWorker.InvokeGtkThread
                                                      (() => gtkMenuItem.Visible = winformMenuItem.Visible);

                gtkMenuItem.Show();
                gtkMenuShell.Insert(gtkMenuItem,
                                    winformMenuItem.Owner.Items.IndexOf(winformMenuItem));

                if (winformMenuItem.HasDropDownItems)
                {
                    var subMenu = new Gtk.Menu();
                    foreach (System.Windows.Forms.ToolStripItem dropDownItem in
                             winformMenuItem.DropDownItems)
                    {
                        ConvertAndAddMenuItem(dropDownItem, subMenu);
                    }
                    gtkMenuItem.Submenu = subMenu;

                    winformMenuItem.DropDown.ItemAdded += (sender, e) =>
                                                          DBusBackgroundWorker.InvokeGtkThread
                                                              (() => ConvertAndAddMenuItem(e.Item, subMenu));
                }
            }
            else if (item is System.Windows.Forms.ToolStripSeparator)
            {
                var gtkSeparator = new Gtk.SeparatorMenuItem();
                gtkSeparator.Show();
                gtkMenuShell.Insert(gtkSeparator, item.Owner.Items.IndexOf(item));
            }
            else
            {
                Debug.Fail("Unexpected menu item");
            }
        }
Exemple #22
0
        protected override void OnShown()
        {
            Trace.Call();

            if (!IsPopulated) {
                IsPopulated = true;
                foreach (var chatView in ChatViewManager.Chats) {
                    if (!(chatView is XmppGroupChatView)) {
                        // only invite to group chats
                        continue;
                    }
                    if (chatView == ChatViewManager.ActiveChat) {
                        // don't need to add current chat to invite list
                        continue;
                    }
                    if (chatView.ProtocolManager != ProtocolManager) {
                        // only add chats from current server
                        continue;
                    }
                    var groupChatView = (XmppGroupChatView) chatView;
                    if (groupChatView.IsContactList) {
                        // ignore our abused groupchatview
                        continue;
                    }

                    var item = new Gtk.ImageMenuItem(chatView.Name);
                    item.Image = new Gtk.Image(GroupChatView.IconPixbuf);
                    var chatid = chatView.ID;
                    item.Activated += delegate {
                        ThreadPool.QueueUserWorkItem(delegate {
                            try {
                                for (int i = 0; i < Invitees.Count; i++) {
                                    ProtocolManager.CommandInvite(
                                        new CommandModel(
                                            Frontend.FrontendManager,
                                            ChatViewManager.ActiveChat.ChatModel,
                                            chatid + " " + Invitees[i].ID
                                        )
                                     );
                                }
                            } catch (Exception ex) {
                                Frontend.ShowException(ex);
                            }
                        });
                    };
                    item.Show();
                    Append(item);
                }
            }

            base.OnShown();
        }
Exemple #23
0
        protected override void OnShown()
        {
            Trace.Call();

            if (!IsPopulated) {
                IsPopulated = true;
                foreach (var chatView in ChatViewManager.Chats) {
                    if (!(chatView is GroupChatView)) {
                        // only invite to group chats
                        continue;
                    }
                    if (chatView == ChatViewManager.ActiveChat) {
                        // don't need to add current chat to invite list
                        continue;
                    }
                    if (chatView.ProtocolManager != ProtocolManager) {
                        // only add chats from current server
                        continue;
                    }

                    var item = new Gtk.ImageMenuItem(chatView.Name);
                    item.Image = new Gtk.Image(GroupChatView.IconPixbuf);
                    // HACK: anonymous methods inside foreach loops needs this
                    var chat = chatView;
                    item.Activated += delegate {
                        foreach (var invitee in Invitees) {
                            ProtocolManager.CommandInvite(
                                new CommandModel(
                                    Frontend.FrontendManager,
                                    ChatViewManager.ActiveChat.ChatModel,
                                    String.Format("{0} {1}",
                                                  invitee.ID,
                                                  chat.ID)
                                )
                            );
                        }
                    };
                    item.Show();
                    Append(item);
                }
            }

            base.OnShown();
        }