Exemplo n.º 1
0
            public ApplicationMenuItem(OpenWithMenu menu, MimeApplication ma) : base(ma.Name)
            {
                this.application = ma;

                if (!menu.ShowIcons)
                {
                    return;
                }

                if (ma.Icon == null)
                {
                    return;
                }

                Gdk.Pixbuf pixbuf = null;

                try {
                    if (ma.Icon.StartsWith("/"))
                    {
                        pixbuf = new Gdk.Pixbuf(ma.Icon, 16, 16);
                    }
                    else
                    {
                        pixbuf = IconTheme.Default.LoadIcon(ma.Icon, 16,
                                                            (IconLookupFlags)0);
                    }
                } catch {
                    pixbuf = null;
                }

                if (pixbuf != null)
                {
                    Image = new Gtk.Image(pixbuf);
                }
            }
Exemplo n.º 2
0
        public AppMenuItem(OpenWithMenu menu, MimeApplication mime_application) : base(mime_application.Name)
        {
            App = mime_application;

            if (menu.ShowIcons)
            {
                if (mime_application.Icon != null)
                {
                    Gdk.Pixbuf pixbuf = null;

                    try {
                        if (mime_application.Icon.StartsWith("/"))
                        {
                            pixbuf = new Gdk.Pixbuf(mime_application.Icon, 16, 16);
                        }
                        else
                        {
                            pixbuf = IconTheme.Default.LoadIcon(mime_application.Icon,
                                                                16, (IconLookupFlags)0);
                        }
                    } catch (System.Exception) {
                        pixbuf = null;
                    }

                    if (pixbuf != null)
                    {
                        Image = new Gtk.Image(pixbuf);
                    }
                }
            }
        }
Exemplo n.º 3
0
			public ApplicationMenuItem (OpenWithMenu menu, MimeApplication ma) : base (ma.Name)
			{
				this.application = ma;
				
				if (!menu.ShowIcons)
					return;
					
				if (ma.Icon == null)
					return;

				Gdk.Pixbuf pixbuf = null; 
				
				try {
					if (ma.Icon.StartsWith ("/"))
						pixbuf = new Gdk.Pixbuf (ma.Icon, 16, 16);
					else 
						pixbuf = IconTheme.Default.LoadIcon (ma.Icon, 16, 
										     (IconLookupFlags)0);
				} catch {
					pixbuf = null;
				}
				
				if (pixbuf != null)
						Image = new Gtk.Image (pixbuf);
			}
		public AppMenuItem (OpenWithMenu menu, MimeApplication mime_application) : base (mime_application.Name)
		{
			App = mime_application;
			
			if (menu.ShowIcons) {
				if (mime_application.Icon != null) {
					Gdk.Pixbuf pixbuf = null; 

					try {
						if (mime_application.Icon.StartsWith ("/"))
							pixbuf = new Gdk.Pixbuf (mime_application.Icon, 16, 16);
						else 
							pixbuf = IconTheme.Default.LoadIcon (mime_application.Icon,
											     16, (IconLookupFlags)0);
					} catch (System.Exception) {
						pixbuf = null;
					}

					if (pixbuf != null)
						Image = new Gtk.Image (pixbuf);
				}
			}
		}
Exemplo n.º 5
0
    private static void ApplicationsFor(OpenWithMenu menu, string [] mime_types, out ArrayList union, out ArrayList intersection)
    {
        //Console.WriteLine ("Getting applications");
        union        = new ArrayList();
        intersection = new ArrayList();

        if (mime_types == null || mime_types.Length < 1)
        {
            return;
        }

        bool first = true;

        foreach (string mime_type in mime_types)
        {
            if (mime_type == null)
            {
                continue;
            }

            MimeApplication [] apps = Gnome.Vfs.Mime.GetAllApplications(mime_type);
            for (int i = 0; i < apps.Length; i++)
            {
                apps [i] = apps [i].Copy();
            }

            foreach (MimeApplication app in apps)
            {
                // Skip apps that don't take URIs
                if (!app.SupportsUris())
                {
                    continue;
                }

                // Skip apps that we were told to ignore
                if (menu.IgnoreApp != null)
                {
                    if (app.BinaryName.IndexOf(menu.IgnoreApp) != -1)
                    {
                        continue;
                    }
                }

                if (!union.Contains(app))
                {
                    union.Add(app);
                }

                if (first)
                {
                    intersection.Add(app);
                }
            }

            if (!first)
            {
                for (int i = 0; i < intersection.Count; i++)
                {
                    MimeApplication app = intersection [i] as MimeApplication;
                    if (System.Array.IndexOf(apps, app) == -1)
                    {
                        intersection.Remove(app);
                        i--;
                    }
                }
            }

            first = false;
        }
    }