public FolderChooserDialog(HComboFolder father) : base(Gtk.WindowType.Popup) { Gtk.IconTheme theme = Gtk.IconTheme.Default; folder_icon = new Gdk.Pixbuf(this.GetType().Assembly, "folder.png"); drive_icon = new Gdk.Pixbuf(this.GetType().Assembly, "drive.png"); if (theme.HasIcon("folder")) { folder_icon = theme.LoadIcon("folder", 24, Gtk.IconLookupFlags.ForceSvg); } if (theme.HasIcon("harddrive")) { drive_icon = theme.LoadIcon("harddrive", 24, Gtk.IconLookupFlags.ForceSvg); } this.father = father; this.Build(); //incarca baza DriveInfo[] difs = DriveInfo.GetDrives(); foreach (DriveInfo di in difs) { // adauga doar discurile fixe if (di.DriveType == DriveType.Fixed) { FolderTree.Nodes.Add(new HTreeNode(di.Name, drive_icon)); } } //add dummy childs foreach (HTreeNode node in FolderTree.Nodes) { node.Nodes.Add(new HTreeNode("dummy")); } }
public static Gtk.IconTheme GetForScreen(Gdk.Screen screen) { IntPtr raw_ret = gtk_icon_theme_get_for_screen(screen == null ? IntPtr.Zero : screen.Handle); Gtk.IconTheme ret = GLib.Object.GetObject(raw_ret) as Gtk.IconTheme; return(ret); }
public IconInfo(Gtk.IconTheme icon_theme, Gdk.Pixbuf pixbuf) : base(IntPtr.Zero) { if (GetType() != typeof(IconInfo)) { var vals = new List <GLib.Value> (); var names = new List <string> (); CreateNativeObject(names.ToArray(), vals.ToArray()); return; } Raw = gtk_icon_info_new_for_pixbuf(icon_theme == null ? IntPtr.Zero : icon_theme.Handle, pixbuf == null ? IntPtr.Zero : pixbuf.Handle); }
public static Gdk.Pixbuf TryLoadIcon(Gtk.IconTheme theme, string icon_name, int size, Gtk.IconLookupFlags flags) { try { return(theme.LoadIcon(icon_name, size, flags)); } catch { try { return(theme.LoadIcon("gtk-missing-image", size, flags)); } catch { return(null); } } }
public static Gtk.IconInfo IconThemeLookUpByGIcon(Gtk.IconTheme theme, GLib.Icon icon, int size, int flags) { return(NativeHelper <Gtk.IconInfo> (() => { IntPtr raw_ret = gtk_icon_theme_lookup_by_gicon(theme.Handle, icon == null ? IntPtr.Zero : ((icon is GLib.Object) ? (icon as GLib.Object).Handle : (icon as GLib.IconAdapter).Handle), size, (int)flags); Gtk.IconInfo ret = raw_ret == IntPtr.Zero ? null : (Gtk.IconInfo)GLib.Opaque.GetOpaque(raw_ret, typeof(Gtk.IconInfo), true); return ret; }, null, GTK_NOT_FOUND, "Failed to lookup by GIcon: {0}")); }
public static Gdk.Pixbuf TryLoadIcon(Gtk.IconTheme theme, string[] names, int size, Gtk.IconLookupFlags flags) { try { var info = theme.ChooseIcon(names, size, flags); return(info.LoadIcon()); } catch { try { return(theme.LoadIcon("gtk-missing-image", size, flags)); } catch { return(null); } } }
public static string LookupSync(Gtk.IconTheme icon_theme, Gnome.ThumbnailFactory thumbnail_factory, string file_uri, string custom_icon, Gnome.IconLookupFlags flags, out Gnome.IconLookupResultFlags result) { IntPtr native_file_uri = GLib.Marshaller.StringToPtrGStrdup(file_uri); IntPtr native_custom_icon = GLib.Marshaller.StringToPtrGStrdup(custom_icon); int native_result; IntPtr raw_ret = gnome_icon_lookup_sync(icon_theme == null ? IntPtr.Zero : icon_theme.Handle, thumbnail_factory == null ? IntPtr.Zero : thumbnail_factory.Handle, native_file_uri, native_custom_icon, (int)flags, out native_result); string ret = GLib.Marshaller.PtrToStringGFree(raw_ret); GLib.Marshaller.Free(native_file_uri); GLib.Marshaller.Free(native_custom_icon); result = (Gnome.IconLookupResultFlags)native_result; return(ret); }
public static Gdk.Pixbuf LoadMimeIcon (string mimetype, int size) { Gtk.IconTheme icon_theme = Gtk.IconTheme.Default; Gnome.IconLookupResultFlags result; // FIXME when ximian bug #76540 is fixed // change "new Gnome.Vfs.FileInfo (IntPtr.Zero)" to "null" string icon_name = Gnome.Icon.Lookup (icon_theme, null, null, null, new Gnome.Vfs.FileInfo (IntPtr.Zero), mimetype, (Gnome.IconLookupFlags) 0, out result); if (icon_name == null) return null; Gtk.IconInfo icon_info = icon_theme.LookupIcon (icon_name, size, 0); if (icon_info == null) return null; try { return icon_info.LoadIcon (); } catch (System.Exception e) { System.Console.Write (e.ToString ()); } return null; }
public static Cairo.Surface Surface(Cairo.Context context, string stockid, int size) { string id = SurfaceId(stockid, size); Cairo.Surface surf; if (!s_surfaceCache.TryGetValue(id, out surf)) { Gtk.IconTheme theme = Gtk.IconTheme.Default; Gdk.Pixbuf pix = theme.LoadIcon(Gtk.Stock.DialogInfo, size, Gtk.IconLookupFlags.UseBuiltin); surf = context.Target.CreateSimilar(Cairo.Content.ColorAlpha, pix.Width, pix.Height); using (Cairo.Context ctx = new Cairo.Context(surf)) { Gdk.CairoHelper.SetSourcePixbuf(ctx, pix, 0, 0); ctx.Paint(); } s_surfaceCache[id] = surf; } return(surf); }
public static void Main (string [] args) { // TODO: Extract to a PreInit in Application, or something #if WIN32 string tomboy_path = Environment.GetEnvironmentVariable ("TOMBOY_PATH_PREFIX"); string tomboy_gtk_basepath = Environment.GetEnvironmentVariable ("TOMBOY_GTK_BASEPATH"); Environment.SetEnvironmentVariable ("GTK_BASEPATH", tomboy_gtk_basepath ?? string.Empty); if (string.IsNullOrEmpty (tomboy_path)) { string gtk_lib_path = null; try { gtk_lib_path = (string) Microsoft.Win32.Registry.GetValue (@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\AssemblyFolders\GtkSharp", string.Empty, string.Empty); } catch (Exception e) { Console.WriteLine ("Exception while trying to get GTK# install path: " + e.ToString ()); } if (!string.IsNullOrEmpty (gtk_lib_path)) tomboy_path = gtk_lib_path.Replace ("lib\\gtk-sharp-2.0", "bin"); } if (!string.IsNullOrEmpty (tomboy_path)) Environment.SetEnvironmentVariable ("PATH", tomboy_path + Path.PathSeparator + Environment.GetEnvironmentVariable ("PATH")); #endif Catalog.Init ("tomboy", Defines.GNOME_LOCALE_DIR); TomboyCommandLine cmd_line = new TomboyCommandLine (args); debugging = cmd_line.Debug; uninstalled = cmd_line.Uninstalled; if (!RemoteControlProxy.FirstInstance) { if (!cmd_line.NeedsExecute) cmd_line = new TomboyCommandLine (new string [] {"--search"}); // Execute args at an existing tomboy instance... cmd_line.Execute (); Console.WriteLine ("Tomboy is already running. Exiting..."); return; } Logger.LogLevel = debugging ? Level.DEBUG : Level.INFO; #if PANEL_APPLET is_panel_applet = cmd_line.UsePanelApplet; #else is_panel_applet = false; #endif // NOTE: It is important not to use the Preferences // class before this call. Initialize ("tomboy", "Tomboy", "tomboy", args); // Add private icon dir to search path icon_theme = Gtk.IconTheme.Default; icon_theme.AppendSearchPath (Path.Combine (Path.Combine (Defines.DATADIR, "tomboy"), "icons")); // Create the default note manager instance. string note_path = GetNotePath (cmd_line.NotePath); manager = new NoteManager (note_path); manager.CommandLine = cmd_line; SetupGlobalActions (); ActionManager am = Tomboy.ActionManager; // TODO: Instead of just delaying, lazy-load // (only an issue for add-ins that need to be // available at Tomboy startup, and restoring // previously-opened notes) GLib.Timeout.Add (500, () => { manager.Initialize (); SyncManager.Initialize (); ApplicationAddin [] addins = manager.AddinManager.GetApplicationAddins (); foreach (ApplicationAddin addin in addins) { addin.Initialize (); } // Register the manager to handle remote requests. RegisterRemoteControl (manager); if (cmd_line.NeedsExecute) { // Execute args on this instance cmd_line.Execute (); } #if WIN32 if (Environment.OSVersion.Platform == PlatformID.Win32NT) { var os_version = Environment.OSVersion.Version; if (( os_version.Major == 6 && os_version.Minor > 0 ) || os_version.Major > 6) { JumpListManager.CreateJumpList (manager); manager.NoteAdded += delegate (object sender, Note changed) { JumpListManager.CreateJumpList (manager); }; manager.NoteRenamed += delegate (Note sender, string old_title) { JumpListManager.CreateJumpList (manager); }; manager.NoteDeleted += delegate (object sender, Note changed) { JumpListManager.CreateJumpList (manager); }; } } #endif return false; }); #if PANEL_APPLET if (is_panel_applet) { tray_icon_showing = true; // Show the Close item and hide the Quit item am ["CloseWindowAction"].Visible = true; am ["QuitTomboyAction"].Visible = false; RegisterPanelAppletFactory (); Logger.Debug ("All done. Ciao!"); Exit (0); } #endif RegisterSessionManagerRestart ( Environment.GetEnvironmentVariable ("TOMBOY_WRAPPER_PATH"), args, new string [] { "TOMBOY_PATH=" + note_path }); // TODO: Pass along XDG_*? StartTrayIcon (); Logger.Debug ("All done. Ciao!"); }
public static void Main(string [] args) { // TODO: Extract to a PreInit in Application, or something #if WIN32 string tomboy_path = Environment.GetEnvironmentVariable("TOMBOY_PATH_PREFIX"); string tomboy_gtk_basepath = Environment.GetEnvironmentVariable("TOMBOY_GTK_BASEPATH"); Environment.SetEnvironmentVariable("GTK_BASEPATH", tomboy_gtk_basepath ?? string.Empty); if (string.IsNullOrEmpty(tomboy_path)) { string gtk_lib_path = null; try { gtk_lib_path = (string) Microsoft.Win32.Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\AssemblyFolders\GtkSharp", string.Empty, string.Empty); } catch (Exception e) { Console.WriteLine("Exception while trying to get GTK# install path: " + e.ToString()); } if (!string.IsNullOrEmpty(gtk_lib_path)) { tomboy_path = gtk_lib_path.Replace("lib\\gtk-sharp-2.0", "bin"); } } if (!string.IsNullOrEmpty(tomboy_path)) { Environment.SetEnvironmentVariable("PATH", tomboy_path + Path.PathSeparator + Environment.GetEnvironmentVariable("PATH")); } #endif Catalog.Init("tomboy", Defines.GNOME_LOCALE_DIR); TomboyCommandLine cmd_line = new TomboyCommandLine(args); debugging = cmd_line.Debug; uninstalled = cmd_line.Uninstalled; if (!RemoteControlProxy.FirstInstance) { if (!cmd_line.NeedsExecute) { cmd_line = new TomboyCommandLine(new string [] { "--search" }); } // Execute args at an existing tomboy instance... cmd_line.Execute(); Console.WriteLine("Tomboy is already running. Exiting..."); return; } Logger.LogLevel = debugging ? Level.DEBUG : Level.INFO; #if PANEL_APPLET is_panel_applet = cmd_line.UsePanelApplet; #else is_panel_applet = false; #endif // NOTE: It is important not to use the Preferences // class before this call. Initialize("tomboy", "Tomboy", "tomboy", args); // Add private icon dir to search path icon_theme = Gtk.IconTheme.Default; icon_theme.AppendSearchPath(Path.Combine(Path.Combine(Defines.DATADIR, "tomboy"), "icons")); // Create the default note manager instance. string note_path = GetNotePath(cmd_line.NotePath); manager = new NoteManager(note_path); manager.CommandLine = cmd_line; SetupGlobalActions(); ActionManager am = Tomboy.ActionManager; // TODO: Instead of just delaying, lazy-load // (only an issue for add-ins that need to be // available at Tomboy startup, and restoring // previously-opened notes) GLib.Timeout.Add(500, () => { manager.Initialize(); SyncManager.Initialize(); ApplicationAddin [] addins = manager.AddinManager.GetApplicationAddins(); foreach (ApplicationAddin addin in addins) { addin.Initialize(); } // Register the manager to handle remote requests. RegisterRemoteControl(manager); if (cmd_line.NeedsExecute) { // Execute args on this instance cmd_line.Execute(); } #if WIN32 if (Environment.OSVersion.Platform == PlatformID.Win32NT) { var os_version = Environment.OSVersion.Version; if ((os_version.Major == 6 && os_version.Minor > 0) || os_version.Major > 6) { JumpListManager.CreateJumpList(manager); manager.NoteAdded += delegate(object sender, Note changed) { JumpListManager.CreateJumpList(manager); }; manager.NoteRenamed += delegate(Note sender, string old_title) { JumpListManager.CreateJumpList(manager); }; manager.NoteDeleted += delegate(object sender, Note changed) { JumpListManager.CreateJumpList(manager); }; } } #endif return(false); }); #if PANEL_APPLET if (is_panel_applet) { tray_icon_showing = true; // Show the Close item and hide the Quit item am ["CloseWindowAction"].Visible = true; am ["QuitTomboyAction"].Visible = false; RegisterPanelAppletFactory(); Logger.Debug("All done. Ciao!"); Exit(0); } #endif RegisterSessionManagerRestart( Environment.GetEnvironmentVariable("TOMBOY_WRAPPER_PATH"), args, new string [] { "TOMBOY_PATH=" + note_path }); // TODO: Pass along XDG_*? StartTrayIcon(); Logger.Debug("All done. Ciao!"); }