コード例 #1
0
        public void Add(string name)
        {
            IconSet    icon_set = new IconSet();
            IconSource source   = new IconSource();

            source.IconName = name;
            icon_set.AddSource(source);

            Add(name, icon_set);
        }
コード例 #2
0
        void AddStockIcon(IconFactory factory, string stockId, string filename)
        {
            var pixbuf = new Pixbuf(Assembly.GetCallingAssembly(), filename);

            var source = new IconSource()
            {
                Pixbuf         = pixbuf,
                SizeWildcarded = true,
                Size           = IconSize.SmallToolbar
            };

            var set = new IconSet();

            set.AddSource(source);

            factory.Add(stockId, set);
        }
コード例 #3
0
ファイル: StockIcons.cs プロジェクト: NattyNarwhal/muine
        // Methods
        // Methods :: Public
        // Methods :: Public :: Initalize
        public static void Initialize()
        {
            IconFactory factory = new IconFactory();

            factory.AddDefault();

            // Stock Icons
            foreach (string name in stock_icons)
            {
                Pixbuf  pixbuf  = new Pixbuf(null, name + ".png");
                IconSet iconset = new IconSet(pixbuf);

                // Add menu variant if we have it
                Assembly a = Assembly.GetCallingAssembly();

                Stream menu_stream =
                    a.GetManifestResourceStream(name + "-16.png");

                if (menu_stream != null)
                {
                    IconSource source = new IconSource();
                    source.Pixbuf         = new Pixbuf(menu_stream);
                    source.Size           = IconSize.Menu;
                    source.SizeWildcarded = false;

                    iconset.AddSource(source);
                }

                factory.Add(name, iconset);
            }

            // Themed Icons
            foreach (string name in icon_theme_icons)
            {
                IconSet    iconset    = new IconSet();
                IconSource iconsource = new IconSource();

                iconsource.IconName = name;
                iconset.AddSource(iconsource);
                factory.Add(name, iconset);
            }

            // register cover image icon size
            cover_size = Icon.SizeRegister("muine-album-cover-size",
                                           CoverDatabase.CoverSize, CoverDatabase.CoverSize);
        }
コード例 #4
0
        public static void Initialize()
        {
            IconFactory icon_factory = new IconFactory();

            icon_factory.AddDefault();

            foreach (string item_id in stock_icon_names)
            {
                StockItem item = new StockItem(item_id, null, 0, Gdk.ModifierType.ShiftMask, null);

                IconSet icon_set = null;

                string file = System.IO.Path.Combine(MainClass.Paths.ResDir, item_id);

                icon_set = new IconSet();

                if (System.IO.File.Exists(file))
                {
                    try{
                        IconSource source = new IconSource();
                        source.Pixbuf = new Pixbuf(file);
                        source.Size   = IconSize.LargeToolbar;
                        icon_set.AddSource(source);
                    }catch (Exception ex) {
                        Tool.Logger.Error(ex.Message);
                        //continue;
                    }
                }

                if (icon_set == null)
                {
                    continue;
                }

                icon_factory.Add(item.StockId, icon_set);
                StockManager.Add(item);
            }
        }
コード例 #5
0
        public static void Load(string themePath)
        {
            if (themePath == null)
            {
                throw new ArgumentNullException("themePath");
            }

            if (themePath.Length == 0)
            {
                throw new ArgumentException("Argument is empty", "themePath");
            }

            // gtk requires an absolute path
            if (!Path.IsPathRooted(themePath))
            {
                throw new ArgumentException("Path must be absolute", "themePath");
            }

            if (!Directory.Exists(themePath))
            {
                throw new DirectoryNotFoundException(string.Format("Path to theme \"{0}\" not found", themePath));
            }

            //IconSize[]				  iconSizes   = (IconSize[])Enum.GetValues(typeof(IconSize));

            // all icon sizes the app uses
            IconSize[] iconSizes = { IconSize.Menu,                                     /* 16px */
                                     IconSize.LargeToolbar,                             /* 24px */
                                     IconSize.Button,                                   /* 24px */
                                     IconSize.Dialog                                    /* 48px */
            };

            Dictionary <string, string> iconNames = GetAllIconNames();
            IconFactory fac = new IconFactory();

            foreach (KeyValuePair <string, string> namePair in iconNames)
            {
                string  name = namePair.Key;
                string  nameInCustomTheme = namePair.Value;
                IconSet iconSet           = new IconSet();
                bool    setHasSources     = false;

                foreach (Gtk.IconSize size in iconSizes)
                {
                    int    sz       = IconUtils.GetIconSizeVal(size);
                    string fullPath = Path.Combine(Path.Combine(themePath, sz.ToString()), nameInCustomTheme);

                    if (!File.Exists(fullPath))
                    {
                        if (Global.EnableDebugging)
                        {
                            Debug.WriteLine(string.Format("IconTheme: could not find custom icon for \"{0}\" (size = {1}), using system default", name, sz));
                        }
                        continue;
                    }

                    IconSource source = new IconSource();

#if LOAD_PIXBUFS
                    source.Pixbuf = new Gdk.Pixbuf(fullPath);
#else
                    source.Filename = fullPath;
#endif

                    source.Size = size;
                    //source.IconName = name;
                    source.SizeWildcarded = false;

                    iconSet.AddSource(source);
                    setHasSources = true;
                }
                if (setHasSources)
                {
                    fac.Add(name, iconSet);
                }
            }

            fac.AddDefault();             // add icon factory to the apps default factories
        }