// Init will try to load the own config data from the file, and create it if missing. // func Init(log cdtype.Logger, file string, e error) error { if e != nil { return e } // Create file if needed. if !files.IsExist(file) { source := globals.DirShareData(GuiFilename) e := files.CopyFile(source, file, os.FileMode(0644)) if e != nil { return e } log.Info("created config file", file) } // Create our user settings Settings = ConfigSettings{ File: file, log: log, } return Settings.Load() }
// Init is the first step to initialize the dock. // func (settings *DockSettings) Init() { confdir := cdglobal.ConfigDirDock(settings.UserDefinedDataDir) settings.isFirstLaunch = !files.IsExist(confdir) // TODO: need test is dir. hidden := loadHidden(confdir) settings.isNewVersion = hidden.LastVersion != globals.Version() settings.sessionWasUsed = hidden.SessionWasUsed // MISSING // //\___________________ build the command line used to respawn, and check if we have been launched from another life. // mute all output messages if CD is not launched from a terminal // if (getenv("TERM") == NULL) /// why not isatty(stdout) ?... // g_set_print_handler(PrintMuteFunc); gldi.DbusGThreadInit() // it's a wrapper: it will use dbus_threads_init_default (); gtk.Init(nil) //\___________________ C dock log. if settings.Verbosity != "" { gldi.LogSetLevelFromName(settings.Verbosity) } if settings.ForceColor { gldi.LogForceUseColor() } //\___________________ delay the startup if specified. if settings.Delay > 0 { <-time.After(time.Duration(settings.Delay) * time.Second) } //\___________________ initialize libgldi. var rendering gldi.RenderingMethod switch { case settings.ForceOpenGL: rendering = gldi.RenderingOpenGL case settings.ForceCairo: rendering = gldi.RenderingCairo default: rendering = gldi.RenderingDefault } gldi.Init(int(rendering)) //\___________________ set custom user options. if settings.KeepAbove { gldi.ForceDocksAbove() } if settings.NoSticky { gldi.SetContainersNonSticky() } if settings.MetacityWorkaround { gldi.DisableContainersOpacity() } env := DesktopEnvironment(settings.Env) if env != gldi.DeskEnvUnknown { gldi.FMForceDeskEnv(env) } if settings.IndirectOpenGL { gldi.GLBackendForceIndirectRendering() } if settings.ThemeServer == "" { settings.ThemeServer = cdglobal.DownloadServerURL } gldi.SetPaths(confdir, // will later be available as DirDockData (g_cCairoDockDataDir) cdglobal.ConfigDirExtras, cdglobal.ConfigDirDockThemes, cdglobal.ConfigDirCurrentTheme, cdglobal.CairoDockShareThemesDir, cdglobal.DockThemeServerTag, settings.ThemeServer) about.Img = globals.DirShareData(cdglobal.ConfigDirDockImages, cdglobal.FileCairoDockLogo) //\___________________ Check that OpenGL is safely usable, if not ask the user what to do. // Unsafe OpenGL requires to be confirmed to use (need forced in conf or user validation). if settings.AskBackend || (gldi.GLBackendIsUsed() && !gldi.GLBackendIsSafe() && !settings.ForceOpenGL && !settings.IndirectOpenGL) { if settings.AskBackend || hidden.DefaultBackend == "" { // no backend defined. dialogAskBackend() } else if hidden.DefaultBackend != "opengl" { // disable opengl if unused, revert to cairo. gldi.GLBackendDeactivate() } } // Remove excluded applets. for _, name := range settings.Exclude { cdtype.Applets.Unregister(name) } //\___________________ load plug-ins (must be done after everything is initialized). if !settings.SafeMode { err := gldi.ModulesNewFromDirectory("") log.Err(err, "no module will be available") if settings.ModulesDir != "" { err := gldi.ModulesNewFromDirectory(settings.ModulesDir) log.Err(err, "no additionnal module will be available") } } }
func (up *Uploader) uploadOne(data string) Links { var fileType FileType var filePath string var isFile bool // File reference from desktop drop. Some cleaning to do. if strings.HasPrefix(data, "file://") { data = FileNameFromURI(data) } // Get full file path if needed. abs, e := filepath.Abs(data) if e == nil && files.IsExist(abs) { data = abs } // Test file and get type. clean := filepath.Clean(data) switch { case files.IsExist(clean): // use input as file location. isFile = true filePath = clean fileType = getFileType(filePath) if fileType == FileTypeUnknown { up.Log.NewWarn(filePath, "file type unknown, uploaded as 'file'") fileType = FileTypeFile } default: // use input as text as default/fallback. fileType = FileTypeText } up.Log.Debug("file upload", "type:", fileType, "path:", filePath) // Get the sender for the type. sender := up.getSender(&fileType) if sender == nil { return linkWarn("nothing to do with " + filePath) } // Get the data reader. var rdr io.Reader var size int64 if isFile { var close func() error rdr, size, close, e = files.Reader(data) if e != nil { return linkErr(e, "open file:"+data) } defer func() { up.Log.Err(close(), "file close") }() } else { rdr = strings.NewReader(data) size = int64(len(data)) } // And try to send. list := sender.Send(rdr, size, filePath) if len(list) == 0 { return linkWarn("upload: nothing returned for " + filePath) } // Should be a valid link. Add common info. list["file"] = filePath list["type"] = strconv.Itoa(int(fileType)) list["date"] = time.Now().Format("20060102 15:04:05") // Time isn't used for now. Just display something readable. "YMD H:M:S" return list }
// Start starts the dock theme and apply last settings. // func (settings *DockSettings) Start() { //\___________________ handle crashes. // if (! bTesting) // _cairo_dock_set_signal_interception (); //\___________________ handle terminate signals to quit properly (especially when the system shuts down). // signal (SIGTERM, _cairo_dock_quit); // Term // kill -15 (system) // signal (SIGHUP, _cairo_dock_quit); // sent to a process when its controlling terminal is closed // MISSING //\___________________ Disable modules that have crashed //\___________________ maintenance mode -> show the main config panel. // Copy the default theme if needed. if !files.IsExist(globals.ConfigFile()) { createConfigDir(settings) } // MISSING // The first time the Cairo-Dock session is used but not the first time the dock is launched: propose to use the Default-Panel theme // s_bCDSessionLaunched => settings.sessionWasUsed gldi.CurrentThemeLoad() // was moved before registration when I had some problems with refresh on start. Removed here for now. //\___________________ lock mode. if settings.Locked { println("Cairo-Dock will be locked.") // was cd_warning (so it was set just before Verbosity). TODO: improve // As the config window shouldn't be opened, those settings won't change. current.Docks.LockIcons(true) current.Docks.LockAll(true) globals.FullLock = true } if !settings.SafeMode && gldi.ModulesGetNb() <= 1 { // 1 including Help. dialogNoPlugins() } if settings.isNewVersion { // update the version in the file. updateHiddenFile("last version", globals.Version()) // If any operation must be done on the user theme (like activating // a module by default, or disabling an option), it should be done // here once (when CAIRO_DOCK_VERSION matches the new version). } //\___________________ display the changelog in case of a new version. if settings.isFirstLaunch { // first launch => set up config time.AfterFunc(4*time.Second, firstLaunchSetup) } else if settings.isNewVersion { // new version -> changelog (if it's the first launch, useless to display what's new, we already have the Welcome message). dialogChangelog() // In case something has changed in Compiz/Gtk/others, we also run the script on a new version of the dock. time.AfterFunc(4*time.Second, firstLaunchSetup) } // else if (cExcludeModule != NULL && ! bMaintenance && s_iNbCrashes > 1) { // gchar *cMessage; // if (s_iNbCrashes == 2) // <=> second crash: display a dialogue // cMessage = g_strdup_printf (_("The module '%s' may have encountered a problem.\nIt has been restored successfully, but if it happens again, please report it at http://glx-dock.org"), cExcludeModule); // else // since the 3th crash: the applet has been disabled // cMessage = g_strdup_printf (_("The module '%s' has been deactivated because it may have caused some problems.\nYou can reactivate it, if it happens again thanks to report it at http://glx-dock.org"), cExcludeModule); // GldiModule *pModule = gldi_module_get (cExcludeModule); // Icon *icon = gldi_icons_get_any_without_dialog (); // gldi_dialog_show_temporary_with_icon (cMessage, icon, CAIRO_CONTAINER (g_pMainDock), 15000., (pModule ? pModule->pVisitCard->cIconFilePath : NULL)); // g_free (cMessage); // } // if (! bTesting) // g_timeout_add_seconds (5, _cairo_dock_successful_launch, GINT_TO_POINTER (bFirstLaunch)); }