Example #1
0
 /// Add New Pixbuf to Stock
 public static void AddToStock(string name, Gdk.Pixbuf pixbuf)
 {
     Gtk.IconFactory factory = new Gtk.IconFactory();
     factory.AddDefault();
     Gtk.IconSet iconset = new Gtk.IconSet(pixbuf);
     factory.Add(name, iconset);
 }
		public override object FindIcon(Uri path, string ext, string mimetype) {
			if(mimetype == null) {
				if(!path.IsFile) throw new ArgumentException();
				
				if(!fileMimeHash.ContainsKey(path.GetScrubbedLocalPath())) {
					ProcessStartInfo psi = new ProcessStartInfo("xdg-mime", string.Format("query filetype '{0}'", path.GetScrubbedLocalPath()));
					psi.RedirectStandardOutput = true;
					psi.UseShellExecute = false;
					Process p = Process.Start(psi);
					p.WaitForExit();
					StreamReader sr = p.StandardOutput;
					
					mimetype = sr.ReadLine();
					
					fileMimeHash[path.GetScrubbedLocalPath()] = mimetype;
				}
				else {
					mimetype = fileMimeHash[path.GetScrubbedLocalPath()];
				}
			}
			
			IconSet iconset = new IconSet();
			IconSource source = new IconSource();
			source.IconName = mimetype.Replace('/', '-'); //"inode-directory";
			//Console.WriteLine("{0}: {1}", psi.Arguments, text);
			iconset.AddSource(source);
			
			return iconset;
		}
        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);
        }
Example #4
0
 public Gdk.Pixbuf GetIcon(string name, Gtk.IconSize size)
 {
     Gtk.IconSet iconset = Gtk.IconFactory.LookupDefault(name);
     if (iconset != null)
     {
         return(iconset.RenderIcon(Gtk.Widget.DefaultStyle, Gtk.TextDirection.None, Gtk.StateType.Normal, size, null, null));
     }
     return(null);
 }
Example #5
0
        public static Pixbuf GetPixbuf(string resourceID)
        {
            Assembly callingAssembly = Assembly.GetCallingAssembly();
            IconSet  iconSet         = IconFactory.LookupDefault(resourceID);

            if (iconSet == null)
            {
                iconSet = new IconSet();
                ImageIcon.LoadIcon(iconSet, resourceID, callingAssembly);
                ImageIcon.iconFactory.Add(resourceID, iconSet);
            }
            return(iconSet.RenderIcon(Widget.DefaultStyle, TextDirection.Ltr, StateType.Normal, IconSize.Button, (Widget)null, (string)null, ImageIcon.ScaleFactor));
        }
Example #6
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);
        }
        static void AddToIconFactory(string stockId, Gdk.Pixbuf pixbuf, Gdk.Pixbuf pixbuf2x, Gtk.IconSize iconSize)
        {
            Gtk.IconSet iconSet = iconFactory.Lookup(stockId);
            if (iconSet == null)
            {
                iconSet = new Gtk.IconSet();
                iconFactory.Add(stockId, iconSet);
            }

            Gtk.IconSource source   = new Gtk.IconSource();
            Gtk.IconSource source2x = null;

            if (Platform.IsWindows)
            {
                var pixel_scale = GtkWorkarounds.GetPixelScale();
                source.Pixbuf = pixbuf.ScaleSimple((int)(pixbuf.Width * pixel_scale), (int)(pixbuf.Height * pixel_scale), Gdk.InterpType.Bilinear);
            }
            else
            {
                source.Pixbuf = pixbuf;
            }

            source.Size           = iconSize;
            source.SizeWildcarded = iconSize == Gtk.IconSize.Invalid;

            if (pixbuf2x != null)
            {
                if (GtkWorkarounds.SetSourceScale(source, 1))
                {
                    GtkWorkarounds.SetSourceScaleWildcarded(source, false);
                    source2x                = new Gtk.IconSource();
                    source2x.Pixbuf         = pixbuf2x;
                    source2x.Size           = iconSize;
                    source2x.SizeWildcarded = iconSize == Gtk.IconSize.Invalid;
                    GtkWorkarounds.SetSourceScale(source2x, 2);
                    GtkWorkarounds.SetSourceScaleWildcarded(source2x, false);
                }
            }
            else
            {
                GtkWorkarounds.SetSourceScaleWildcarded(source, true);
            }

            iconSet.AddSource(source);
            if (source2x != null)
            {
                iconSet.AddSource(source2x);
            }
        }
        static void AddIcon(string stockid, string resource)
        {
            Gtk.IconSet iconset = stock.Lookup (stockid);

            if (iconset == null) {
                iconset = new Gtk.IconSet ();
                Gdk.Pixbuf img = Gdk.Pixbuf.LoadFromResource (resource);
                IconSource source = new IconSource ();
                source.Size = Gtk.IconSize.Menu;
                source.SizeWildcarded = false;
                source.Pixbuf = img;
                iconset.AddSource (source);
                stock.Add (stockid, iconset);
            }
        }
Example #9
0
        static void AddIcon(string stockid, string resource)
        {
            Gtk.IconSet iconset = stock.Lookup(stockid);

            if (iconset == null)
            {
                iconset = new Gtk.IconSet();
                Gdk.Pixbuf img    = Gdk.Pixbuf.LoadFromResource(resource);
                IconSource source = new IconSource();
                source.Size           = Gtk.IconSize.Menu;
                source.SizeWildcarded = false;
                source.Pixbuf         = img;
                iconset.AddSource(source);
                stock.Add(stockid, iconset);
            }
        }
Example #10
0
        static void AddIcon(IconFactory stock, string stockid, string resource)
        {
            Gtk.IconSet iconset = stock.Lookup(stockid);

            if (iconset != null)
            {
                return;
            }

            iconset = new Gtk.IconSet();
            Gdk.Pixbuf img    = Gdk.Pixbuf.LoadFromResource(resource);
            IconSource source = new IconSource();

            source.Pixbuf = img;
            iconset.AddSource(source);
            stock.Add(stockid, iconset);
        }
Example #11
0
        static Gdk.Pixbuf GetPixbuf(string name, Gtk.IconSize size, bool generateDefaultIcon = true)
        {
            if (string.IsNullOrEmpty(name))
            {
                LoggingService.LogWarning("Empty icon requested. Stack Trace: " + Environment.NewLine + Environment.StackTrace);
                return(CreateColorBlock("#FF0000", size));
            }

            // If this name refers to an icon defined in an extension point, the images for the icon will now be laoded
            EnsureStockIconIsLoaded(name);

            //if an icon name begins with '#', we assume it's a hex colour
            if (name[0] == '#')
            {
                return(CreateColorBlock(name, size));
            }

            // Converts an image spec into a real stock icon id
            string stockid = GetStockIdForImageSpec(name, size);

            if (string.IsNullOrEmpty(stockid))
            {
                LoggingService.LogWarning("Can't get stock id for " + name + " : " + Environment.NewLine + Environment.StackTrace);
                return(CreateColorBlock("#FF0000", size));
            }

            Gtk.IconSet iconset = Gtk.IconFactory.LookupDefault(stockid);
            if (iconset != null)
            {
                return(iconset.RenderIcon(Gtk.Widget.DefaultStyle, Gtk.TextDirection.Ltr, Gtk.StateType.Normal, size, null, null));
            }

            if (Gtk.IconTheme.Default.HasIcon(stockid))
            {
                int        h      = iconSizes[(int)size].Height;
                Gdk.Pixbuf result = Gtk.IconTheme.Default.LoadIcon(stockid, h, (Gtk.IconLookupFlags) 0);
                return(result);
            }
            if (generateDefaultIcon)
            {
                LoggingService.LogWarning("Can't lookup icon: " + name);
                return(CreateColorBlock("#FF0000FF", size));
            }
            return(null);
        }
Example #12
0
        public static void Initialize()
        {
            Gtk.IconFactory factory = new Gtk.IconFactory();
            factory.AddDefault();

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

                factory.Add(name, iconset);
            }

            // Stock Images
            foreach (string name in stock_images_names)
            {
                stock_images.Add(name, new Gdk.Pixbuf(null, name + ".png"));
            }
        }
        public static Xwt.Drawing.Image GetIcon(string name, bool generateDefaultIcon)
        {
            name = name ?? "";

            Xwt.Drawing.Image img;
            if (icons.TryGetValue(name, out img))
            {
                return(img);
            }

            if (string.IsNullOrEmpty(name))
            {
                LoggingService.LogWarning("Empty icon requested. Stack Trace: " + Environment.NewLine + Environment.StackTrace);
                icons [name] = img = CreateColorIcon("#FF0000");
                return(img);
            }

            //if an icon name begins with '#', we assume it's a hex colour
            if (name[0] == '#')
            {
                icons [name] = img = CreateColorBlock(name, Gtk.IconSize.Dialog).ToXwtImage();
                return(img);
            }

            EnsureStockIconIsLoaded(name);

            // Try again since it may have already been registered
            if (icons.TryGetValue(name, out img))
            {
                return(img);
            }

            Gtk.IconSet iconset = Gtk.IconFactory.LookupDefault(name);
            if (iconset == null && !Gtk.IconTheme.Default.HasIcon(name) && generateDefaultIcon)
            {
                LoggingService.LogWarning("Unknown icon: " + name);
                return(CreateColorIcon("#FF0000FF"));
            }

            return(icons [name] = img = Xwt.Toolkit.CurrentEngine.WrapImage(name));
        }
Example #14
0
        private static void LoadIcon(IconSet iconSet, string resourceID, Assembly callingAssembly)
        {
            Pixbuf     pixbuf1     = ImageIcon.LoadResource(resourceID, callingAssembly);
            Pixbuf     pixbuf2     = ImageIcon.LoadResource2x(resourceID, callingAssembly);
            IconSource iconSource1 = new IconSource();

            ImageIcon.ConfigIconSource(pixbuf1, iconSource1);
            if (pixbuf2 != null)
            {
                GtkWorkarounds.SetSourceScale(iconSource1, 1.0);
                GtkWorkarounds.SetSourceScaleWildcarded(iconSource1, false);
                IconSource iconSource2 = new IconSource();
                ImageIcon.ConfigIconSource(pixbuf2, iconSource2);
                GtkWorkarounds.SetSourceScale(iconSource2, ImageIcon.ScaleFactor);
                GtkWorkarounds.SetSourceScaleWildcarded(iconSource2, false);
                iconSet.AddSource(iconSource2);
            }
            else
            {
                iconSet.AddSource(iconSource1);
            }
        }
Example #15
0
    static void AddIcon(string stockid, Gtk.IconSize iconSize, string resource)
    {
        Gtk.IconSet iconset = stock.Lookup(stockid);

        if (iconset == null)
        {
            iconset = new Gtk.IconSet();
            Gdk.Pixbuf img = Gdk.Pixbuf.LoadFromResource(resource);
            //no scaling in the given size, ...
            IconSource source = new IconSource();
            source.Size           = iconSize;
            source.SizeWildcarded = false;
            source.Pixbuf         = img;
            iconset.AddSource(source);
            //... but allow to use the image for all other sizes, too.
            source = new IconSource();
            source.SizeWildcarded = true;
            source.Pixbuf         = img;
            iconset.AddSource(source);

            stock.Add(stockid, iconset);
        }
    }
	public static void Initialize ()
	{
		Gtk.StockItem [] stock_items = {	
			FromDef ("f-spot-adjust-colors", Catalog.GetString ("Adjust Colors"), 0, Gdk.ModifierType.ShiftMask, null),
			FromDef ("f-spot-autocolor", Catalog.GetString ("Auto Color"), 0, Gdk.ModifierType.ShiftMask, null),
			FromDef ("f-spot-browse", Catalog.GetString ("Browse"), 0, Gdk.ModifierType.ShiftMask, null),
			FromDef ("f-spot-camera", Catalog.GetString ("Camera"), 0, Gdk.ModifierType.ShiftMask, null),
			FromDef ("f-spot-crop", Catalog.GetString ("Crop"), 0, Gdk.ModifierType.ShiftMask, null),
			FromDef ("f-spot-desaturate", Catalog.GetString ("Desaturate"), 0, Gdk.ModifierType.ShiftMask, null),
			FromDef ("f-spot-edit-image", Catalog.GetString ("Edit Photo"), 0, Gdk.ModifierType.ShiftMask, null),
			FromDef ("f-spot-fullscreen", Catalog.GetString ("Fullscreen"), 0, Gdk.ModifierType.ShiftMask, null),
			FromDef ("f-spot-horizon", Catalog.GetString ("Straighten"), 0, Gdk.ModifierType.ShiftMask, null),
			FromDef ("f-spot-loading", Catalog.GetString ("Loading"), 0, Gdk.ModifierType.ShiftMask, null),
			FromDef ("f-spot-new-tag", Catalog.GetString ("Create New Tag"), 0, Gdk.ModifierType.ShiftMask, null),
			FromDef ("f-spot-question-mark", Catalog.GetString ("Question"), 0, Gdk.ModifierType.ShiftMask, null),
			FromDef ("f-spot-red-eye", Catalog.GetString ("Reduce Red-Eye"), 0, Gdk.ModifierType.ShiftMask, null),
			FromDef ("f-spot-rotate-270", Catalog.GetString ("Rotate _Left"), 0, Gdk.ModifierType.ShiftMask, null),
			FromDef ("f-spot-rotate-90", Catalog.GetString ("Rotate _Right"), 0, Gdk.ModifierType.ShiftMask, null),
			FromDef ("f-spot-sepia", Catalog.GetString ("Sepia Tone"), 0, Gdk.ModifierType.ShiftMask, null),
			FromDef ("f-spot-slideshow", Catalog.GetString ("Slideshow"), 0, Gdk.ModifierType.ShiftMask, null),
			FromDef ("f-spot-soft-focus", Catalog.GetString ("Soft Focus"), 0, Gdk.ModifierType.ShiftMask, null),
			FromDef ("f-spot-stock_near", Catalog.GetString ("Near"), 0, Gdk.ModifierType.ShiftMask, null),
			FromDef ("f-spot-stock_far", Catalog.GetString ("Far"), 0, Gdk.ModifierType.ShiftMask, null),
			FromDef ("f-spot-view-restore", Catalog.GetString ("Restore View"), 0, Gdk.ModifierType.ShiftMask, null),
		};

		IconFactory icon_factory = new IconFactory ();
		icon_factory.AddDefault ();

		foreach (Gtk.StockItem item in stock_items) {
			Pixbuf pixbuf = PixbufUtils.LoadFromAssembly (item.StockId + ".png");
			IconSet icon_set = new IconSet (pixbuf);
			icon_factory.Add (item.StockId, icon_set);
			
			Gtk.StockManager.Add (item);
		}
	}
Example #17
0
        static void AddIcon(IconFactory stock, string stockid, string resource)
        {
            Gtk.IconSet iconset = stock.Lookup (stockid);

            if (iconset != null)
                return;

            iconset = new Gtk.IconSet ();
            Gdk.Pixbuf img = Gdk.Pixbuf.LoadFromResource (resource);
            IconSource source = new IconSource ();
            source.Pixbuf = img;
            iconset.AddSource (source);
            stock.Add (stockid, iconset);
        }
Example #18
0
    static void AddIcon(string stockid, Gtk.IconSize iconSize, string resource)
    {
        Gtk.IconSet iconset = stock.Lookup (stockid);

        if (iconset == null) {
            iconset = new Gtk.IconSet ();
            Gdk.Pixbuf img = Gdk.Pixbuf.LoadFromResource (resource);
            //no scaling in the given size, ...
            IconSource source = new IconSource ();
            source.Size = iconSize;
            source.SizeWildcarded = false;
            source.Pixbuf = img;
            iconset.AddSource (source);
            //... but allow to use the image for all other sizes, too.
            source = new IconSource ();
            source.SizeWildcarded = true;
            source.Pixbuf = img;
            iconset.AddSource (source);

            stock.Add (stockid, iconset);
        }
    }
Example #19
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);
            }
        }
		static void AddToIconFactory (string stockId, Gdk.Pixbuf pixbuf, Gdk.Pixbuf pixbuf2x, Gtk.IconSize iconSize)
		{
			Gtk.IconSet iconSet = iconFactory.Lookup (stockId);
			if (iconSet == null) {
				iconSet = new Gtk.IconSet ();
				iconFactory.Add (stockId, iconSet);
			}

			Gtk.IconSource source = new Gtk.IconSource ();
			Gtk.IconSource source2x = null;

			if (Platform.IsWindows) {
				var pixel_scale = GtkWorkarounds.GetPixelScale ();
				source.Pixbuf = pixbuf.ScaleSimple ((int)(pixbuf.Width * pixel_scale), (int)(pixbuf.Height * pixel_scale), Gdk.InterpType.Bilinear);
			} else {
				source.Pixbuf = pixbuf;
			}

			source.Size = iconSize;
			source.SizeWildcarded = iconSize == Gtk.IconSize.Invalid;

			if (pixbuf2x != null) {
				if (GtkWorkarounds.SetSourceScale (source, 1)) {
					GtkWorkarounds.SetSourceScaleWildcarded (source, false);
					source2x = new Gtk.IconSource ();
					source2x.Pixbuf = pixbuf2x;
					source2x.Size = iconSize;
					source2x.SizeWildcarded = iconSize == Gtk.IconSize.Invalid;
					GtkWorkarounds.SetSourceScale (source2x, 2);
					GtkWorkarounds.SetSourceScaleWildcarded (source2x, false);
				}
			} else {
				GtkWorkarounds.SetSourceScaleWildcarded (source, true);
			}

			iconSet.AddSource (source);
			if (source2x != null)
				iconSet.AddSource (source2x);
		}
Example #21
0
 private void AddToToolbar(BaseTemplate i)
 {
     var w1 = new IconFactory();
     var w2 = new IconSet(new Pixbuf(
         Assembly.GetExecutingAssembly(),
         i.GetIcon()));
     w1.Add(i.Type + "_icon", w2);
     w1.AddDefault();
     var act = new Gtk.Action("c_Create" + i.Type + "Action", null, "Create " + i.Type + " Project", null);
     act.Activated +=
         (object sender, System.EventArgs e) =>
             { this.PromptCreateProject(i.Type); };
     var t = act.CreateToolItem();
     (t as ToolButton).StockId = i.Type + "_icon";
     this.c_Toolbar.Add(t);
 }
Example #22
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
        }
Example #23
0
        public BookmarkAction(Browser browser)
            : base("Bookmark", "_Bookmark")
        {
            this.browser = browser;

            IconSet bookmark_iconset = new IconSet();
            IconSource bookmark_iconsource = new IconSource();
            bookmark_iconsource.IconName = "bookmark-new";
            bookmark_iconset.AddSource(bookmark_iconsource);
            browser.factory.Add("summa-bookmark-new", bookmark_iconset);

            Tooltip = "Bookmark this item";
            StockId = "summa-bookmark-new";
            Activated += Bookmark;

            switch(Config.Bookmarker) {
                case "Native":
                    bookmarker = new NativeBookmarker();
                    break;
                case "Dieu":
                    bookmarker = new DieuBookmarker();
                    break;
            }
        }
        // ============================================
        // PUBLIC Methods
        // ============================================
        /// Initialize NyFolder Stock Icons (Only Main() Call This)
        public static void Initialize()
        {
            Gtk.IconFactory factory = new Gtk.IconFactory();
            factory.AddDefault();

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

                factory.Add(name, iconset);
            }

            // Stock Images
            stock_images = Hashtable.Synchronized(new Hashtable());
            foreach (string name in stock_images_names) {
                stock_images.Add(name, new Gdk.Pixbuf(null, name + ".png"));
            }
        }
 /// Add New Pixbuf to Stock
 public static void AddToStock(string name, Gdk.Pixbuf pixbuf)
 {
     Gtk.IconFactory factory = new Gtk.IconFactory();
     factory.AddDefault();
     Gtk.IconSet iconset = new Gtk.IconSet(pixbuf);
     factory.Add(name, iconset);
 }