示例#1
0
文件: maindock.go 项目: sqp/godock
func getChangelog() string {
	changelogPath := globals.DirShareData(cdglobal.FileChangelog)
	msg := ""
	e := config.GetFromFile(log, changelogPath, func(cfg cdtype.ConfUpdater) {
		major, minor, micro := globals.VersionSplit()

		// Get first line
		strver := fmt.Sprintf("%d.%d.%d", major, minor, micro) // version without "alpha", "beta", "rc", etc.
		msg = cfg.Valuer("ChangeLog", strver).String()
		if msg == "" {
			log.Debug("changelog", "no info for version", globals.Version())
			return
		}
		msg = tran.Slate(msg)

		// Add all changelog lines for that version.
		i := 0
		for {
			strver := fmt.Sprintf("%d.%d.%d.%d", major, minor, micro, i)
			sub := cfg.Valuer("ChangeLog", strver).String()
			msg += "\n " + tran.Slate(sub)
			i++
		}
	})
	log.Err(e, "load changelog", changelogPath)
	return msg
}
示例#2
0
func init() {
	Name = "Custom Dock"

	List = append(List,
		Field{"  gldi     ", globals.Version()},
		Field{"  OpenGL   ", ternary.String(gldi.GLBackendIsUsed(), "Yes", "No")},
	)
}
示例#3
0
文件: dock.go 项目: sqp/godock
// runDock starts dock routines and locks the main thread with gtk.
//
func runDock(cmd *Command, args []string) {
	if *pprofFile {
		defer profile.Start().Stop()
	}

	switch {
	case *showVersionGldi:
		fmt.Println(globals.Version()) // -v option only prints gldi version.

	case *showVersionAll:
		versions.Print() // -vv option only prints all versions.

	case dock.Run(logger, dockSettings): // Start dock success => lock gtk.
		dockSettings = nil // free
		gldi.LockGTK()
		maindock.Clean() // may be better with defer, but cause confused panic messages.
	}
}
示例#4
0
文件: maindock.go 项目: sqp/godock
// 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")
		}
	}
}
示例#5
0
文件: maindock.go 项目: sqp/godock
// 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));
}