コード例 #1
0
        public Tag Execute(TagType type, Tag [] selection)
        {
            Category default_category = null;

            if (selection.Length > 0)
            {
                if (selection [0] is Category)
                {
                    default_category = (Category)selection [0];
                }
                else
                {
                    default_category = selection [0].Category;
                }
            }
            else
            {
                default_category = tag_store.RootCategory;
            }

            this.DefaultResponse = ResponseType.Ok;

            this.Title        = Catalog.GetString("Create New Tag");
            prompt_label.Text = Catalog.GetString("Name of New Tag:");
            this.auto_icon_checkbutton.Active = Preferences.Get <bool> (Preferences.TAG_ICON_AUTOMATIC);

            PopulateCategoryOptionMenu();
            this.Category = default_category;
            Update();
            tag_name_entry.GrabFocus();

            ResponseType response = (ResponseType)this.Run();


            Tag new_tag = null;

            if (response == ResponseType.Ok)
            {
                bool autoicon = this.auto_icon_checkbutton.Active;
                Preferences.Set(Preferences.TAG_ICON_AUTOMATIC, autoicon);
                try {
                    Category parent_category = Category;

                    if (type == TagType.Category)
                    {
                        new_tag = tag_store.CreateCategory(parent_category, tag_name_entry.Text, autoicon);
                    }
                    else
                    {
                        new_tag = tag_store.CreateTag(parent_category, tag_name_entry.Text, autoicon);
                    }
                } catch (Exception ex) {
                    // FIXME error dialog.
                    Log.Exception(ex);
                }
            }

            this.Destroy();
            return(new_tag);
        }
コード例 #2
0
        // Set the tags that will be added on import.
        public void AttachTags(IEnumerable <string> tags)
        {
            App.Instance.Database.BeginTransaction();
            var import_category = GetImportedTagsCategory();

            foreach (var tagname in tags)
            {
                var tag = tag_store.GetTagByName(tagname);
                if (tag == null)
                {
                    tag = tag_store.CreateCategory(import_category, tagname, false);
                    tag_store.Commit(tag);
                }
                attach_tags.Add(tag);
            }
            App.Instance.Database.CommitTransaction();
        }
コード例 #3
0
 private int CreateTagPriv(Category parent_tag, string name)
 {
     try {
         Tag created = tag_store.CreateCategory(parent_tag, name);
         return((int)created.Id);
     }
     catch {
         throw new DBusException("Failed to create tag.");
     }
 }
コード例 #4
0
        public Tag Execute(TagType type, Tag [] selection)
        {
            this.CreateDialog("create_tag_dialog");

            Category default_category = null;

            if (selection.Length > 0)
            {
                if (selection [0] is Category)
                {
                    default_category = (Category)selection [0];
                }
                else
                {
                    default_category = selection [0].Category;
                }
            }

            this.Dialog.DefaultResponse = ResponseType.Ok;

            this.Dialog.Title = Catalog.GetString("Create New Tag");
            prompt_label.Text = Catalog.GetString("Name of New Tag:");

            PopulateCategoryOptionMenu();
            this.Category = default_category;
            Update();
            tag_name_entry.GrabFocus();

            ResponseType response = (ResponseType)this.Dialog.Run();

            Tag new_tag = null;

            if (response == ResponseType.Ok)
            {
                try {
                    Category parent_category = Category;

                    if (type == TagType.Category)
                    {
                        new_tag = tag_store.CreateCategory(parent_category, tag_name_entry.Text) as Tag;
                    }
                    else
                    {
                        new_tag = tag_store.CreateTag(parent_category, tag_name_entry.Text);
                    }
                } catch (Exception ex) {
                    // FIXME error dialog.
                    Console.WriteLine("error {0}", ex);
                }
            }

            this.Dialog.Destroy();
            return(new_tag);
        }
コード例 #5
0
        private Tag EnsureTag(TagInfo info, Category parent)
        {
            Tag tag = tag_store.GetTagByName(info.TagName);

            if (tag != null)
            {
                return(tag);
            }

            tag = tag_store.CreateCategory(parent,
                                           info.TagName);

            if (info.HasIcon)
            {
                tag.StockIconName = info.IconName;
                tag_store.Commit(tag);
            }

            tags_created.Push(tag);
            return(tag);
        }