当前位置: 首页>>代码示例>>Golang>>正文


Golang tran.Slate函数代码示例

本文整理汇总了Golang中github.com/sqp/godock/libs/text/tran.Slate函数的典型用法代码示例。如果您正苦于以下问题:Golang Slate函数的具体用法?Golang Slate怎么用?Golang Slate使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了Slate函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: getChangelog

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
}
开发者ID:sqp,项目名称:godock,代码行数:27,代码来源:maindock.go

示例2: New

// New creates the config menu with add or save buttons.
//
func New(control Controller) *MenuBar {
	wmb := &MenuBar{
		Box:     *newgtk.Box(gtk.ORIENTATION_HORIZONTAL, 0),
		Save:    newgtk.ButtonWithMnemonic("_Save"),
		control: control,
	}

	wmb.Save.Set("no-show-all", true)

	sep := newgtk.Box(gtk.ORIENTATION_HORIZONTAL, 0)

	/// Actions
	wmb.Save.Connect("clicked", wmb.control.ClickedSave)

	mainBtn, _ := gtk.MenuButtonNew()

	img := newgtk.ImageFromIconName("preferences-system", IconSize)
	mainBtn.SetImage(img)

	mainBtn.SetPopup(menus.NewMenu(
		menus.NewItem(tran.Slate("Help"), func() { control.Select("Config", "Help") }),
		menus.NewItem(tran.Slate("About"), func() { about.New() }),
		nil,
		menus.NewItem(tran.Slate("Close"), wmb.control.ClickedQuit),
	))

	/// Packing: End list = reversed.

	wmb.PackEnd(mainBtn, false, false, 0)
	wmb.PackEnd(sep, false, false, 3) // separator add 3x2px.
	wmb.PackEnd(wmb.Save, false, false, 0)
	return wmb
}
开发者ID:sqp,项目名称:godock,代码行数:35,代码来源:confmenu.go

示例3: New

// New creates a welcome widget with informations about the program.
//
func New(source cftype.Source, log cdtype.Logger) cftype.Grouper {
	const group = "Welcome"
	title := tran.Slate("Welcome to cairo-dock-rework")
	header := tran.Slate(`This is a reworked version of cairo-dock, with all the user interface rewritten in Go.
It's still under development, but should now be very close to the original version.`)
	warningSave := `Warning, save configuration is disabled by default.
As it shares its files with the original dock, it requires more tests to ensure nothing will be broken.
It's better to save your current theme, and check nothing wrong will be changed in your files.
Then, you can enable the save option under the "GUI Settings" config tab, at your own risks.`

	keys := []*cftype.Key{
		newkey.TextLabel(group, "title", common.Bold(common.Big(title))),
		newkey.TextLabel(group, "header", header),
		newkey.Separator(group, "sep_title"),
		newkey.TextLabel(group, "warningSave", warningSave),
		newkey.Separator(group, "sep_warning"),
		newkey.Link(group, "URLwebsite", "Project website", "github", URLwebsite),
		newkey.Link(group, "URLdocumentation", "Documentation", "godoc", URLdocumentation),
		newkey.Link(group, "URLdockInfo", "Cairo-Dock forum related thread", "glx-dock forum", URLdockInfo),
	}
	for _, link := range links {
		str := common.Big(common.Bold(common.URI(link.URL, link.Title)))
		keys = append(keys,
			// newkey.Frame(group, "F_"+title, str, link.Icon),
			newkey.Separator(group, "sep_"+link.Title),
			newkey.TextLabel(group, "T_"+link.Title, str),
			newkey.TextLabel(group, "L_"+link.Title, link.Text),
		)
	}

	build := cfbuild.NewVirtual(source, log, "", "", "")
	return build.BuildSingle(group, cfbuild.TweakAddGroup(group, keys...))
}
开发者ID:sqp,项目名称:godock,代码行数:35,代码来源:welcome.go

示例4: ListThemeDesktopIcon

// ListThemeDesktopIcon adds a desktop icon-themes list widget.
//
func ListThemeDesktopIcon(key *cftype.Key) {
	getList := fieldsPrepend(key.Source().ListThemeDesktopIcon(),
		datatype.Field{},
		datatype.Field{Key: "_Custom Icons_", Name: tran.Slate("_Custom Icons_")},
	)
	PackComboBoxWithListField(key, false, false, getList)
}
开发者ID:sqp,项目名称:godock,代码行数:9,代码来源:widgets.go

示例5: ListDeskletDecoration

// ListDeskletDecoration adds a desklet decoration list widget.
//
func ListDeskletDecoration(key *cftype.Key) {
	current := key.Value().String()
	getList := key.Source().ListDeskletDecorations
	if key.IsType(cftype.KeyListDeskletDecoDefault) {
		getList = fieldsPrepend(getList(),
			datatype.Field{Key: "default", Name: tran.Slate("default")},
		)
	}
	PackComboBoxWithListField(key, false, false, getList)

	// 	gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (pListStore), CAIRO_DOCK_MODEL_NAME, GTK_SORT_ASCENDING);

	// _allocate_new_buffer;
	// data[0] = pKeyBox;
	// data[1] = (pFrameVBox != NULL ? pFrameVBox : pGroupBox);
	// NbControlled = 9;
	// data[2] = GINT_TO_POINTER (NbControlled);
	// NbControlled --;  // car dans cette fonction, on ne compte pas le separateur.
	// g_signal_connect (G_OBJECT (pOneWidget), "changed", G_CALLBACK (_cairo_dock_select_custom_item_in_combo), data);

	if current == "personnal" { // Disable the next widgets.
		// 		CDControlWidget *cw = g_new0 (CDControlWidget, 1);
		// 		pControlWidgets = g_list_prepend (pControlWidgets, cw);
		// 		cw->NbControlled = NbControlled;
		// 		cw->iNbSensitiveWidgets = 0;
		// 		cw->iFirstSensitiveWidget = 1;
		// 		cw->pControlContainer = (pFrameVBox != NULL ? pFrameVBox : pGroupBox);
	}
}
开发者ID:sqp,项目名称:godock,代码行数:31,代码来源:widgets.go

示例6: dialogNoPlugins

func dialogNoPlugins() {
	// Need to keep the string as it is for translation.
	str := "No plug-in were found.\nPlug-ins provide most of the functionalities (animations, applets, views, etc).\nSee http://glx-dock.org for more information.\nThere is almost no meaning in running the dock without them and it's probably due to a problem with the installation of these plug-ins.\nBut if you really want to use the dock without these plug-ins, you can launch the dock with the '-f' option to no longer have this message.\n"
	icon := gldi.IconsGetAnyWithoutDialog()
	container := globals.Maindock().ToContainer()
	iconpath := globals.FileCairoDockIcon()
	dialog.ShowTemporaryWithIcon(tran.Slate(str), icon, container, 0, iconpath)
}
开发者ID:sqp,项目名称:godock,代码行数:8,代码来源:maindock.go

示例7: AddButtonsEntry

// AddButtonsEntry adds an item with button entries to the menu.
//
func (m *DockMenu) AddButtonsEntry(label string, btns ...MenuBtn) *menus.ButtonsEntry {
	entry := m.Menu.AddButtonsEntry(label)

	for _, btnID := range btns {
		switch btnID {
		case MenuWindowClose:
			entry.AddButton(
				tran.Slate("Close")+actionMiddleClick(m.Icon, 1),
				globals.DirShareData("icons", "icon-close.svg"),
				m.Icon.CallbackActionWindow((cdglobal.Window).Close))

		case MenuWindowCloseAll:
			entry.AddButton(
				tran.Slate("Close all")+actionMiddleClick(m.Icon, 1),
				globals.DirShareData("icons", "icon-close.svg"),
				m.Icon.CallbackActionSubWindows((cdglobal.Window).Close))

		case MenuWindowMax:
			max := m.Icon.Window().IsMaximized()
			entry.AddButton(
				ternary.String(max, tran.Slate("Unmaximise"), tran.Slate("Maximise")),
				globals.DirShareData("icons", ternary.String(max, "icon-restore.svg", "icon-maximize.svg")),
				m.Icon.CallbackActionWindowToggle((cdglobal.Window).Maximize, (cdglobal.Window).IsMaximized))

		case MenuWindowMin:
			entry.AddButton(
				tran.Slate("Minimise")+actionMiddleClick(m.Icon, 2),
				globals.DirShareData("icons", "icon-minimize.svg"),
				m.Icon.CallbackActionWindow((cdglobal.Window).Minimize))

		case MenuWindowMinAll:
			entry.AddButton(
				tran.Slate("Minimise all")+actionMiddleClick(m.Icon, 2),
				globals.DirShareData("icons", "icon-minimize.svg"),
				m.Icon.CallbackActionSubWindows((cdglobal.Window).Minimize))

		case MenuWindowShow:
			entry.AddButton(
				tran.Slate("Show"),
				globals.IconNameFind,
				m.Icon.CallbackActionWindow((cdglobal.Window).Show))

		case MenuWindowShowAll:
			entry.AddButton(
				tran.Slate("Show all"),
				globals.IconNameFind,
				m.Icon.CallbackActionSubWindows((cdglobal.Window).Show))

		default:
			log.NewWarn(fmt.Sprintf("invalid id: %d", btnID), "AddButtonsEntry")
		}
	}
	return entry
}
开发者ID:sqp,项目名称:godock,代码行数:56,代码来源:backendmenu.go

示例8: addLinks

func addLinks() *gtk.Box {
	linksData := []struct {
		uri     string
		label   string
		tooltip string
	}{{
		uri:   URLdockSite,
		label: "Cairo-Dock (2007-2014)", //GLDI_VERSION;
	}, {
		uri:     URLdockCode,
		label:   tran.Slate("Development site"),
		tooltip: tran.Slate("Find the latest version of Cairo-Dock here !"),
	}, {
		uri:     URLdockFlattr,
		label:   tran.Slate("Donate") + " (Flattr)",
		tooltip: tran.Slate("Support the people who spend countless hours to bring you the best dock ever."),
	}, {
		uri:     URLdockPayPal,
		label:   tran.Slate("Donate") + " (Paypal)",
		tooltip: tran.Slate("Support the people who spend countless hours to bring you the best dock ever."),
	}}

	box := newgtk.Box(gtk.ORIENTATION_VERTICAL, 0)
	for _, item := range linksData {
		link := newgtk.LinkButtonWithLabel(item.uri, item.label)
		box.PackStart(link, false, false, 0)
		if item.tooltip != "" {
			link.SetTooltipText(item.tooltip)
		}
	}
	return box
}
开发者ID:sqp,项目名称:godock,代码行数:32,代码来源:about.go

示例9: New

// New creates a welcome widget with informations about the program.
//
func New(source cftype.Source, log cdtype.Logger, switcher *pageswitch.Switcher) cftype.Grouper {
	const group = "Dev"
	title := tran.Slate("hi")

	// all packages in the application gopath.
	pathGoTest := strings.Join(append(cdglobal.AppBuildPath, "..."), "/")

	pathTestConfCmd := cdglobal.AppBuildPathFull("test", "confcmd", "confcmd.go")
	pathTestConfGUI := cdglobal.AppBuildPathFull("test", "confgui", "confgui.go")
	pathTestConfCmd, _ = filepath.EvalSymlinks(pathTestConfCmd)
	pathTestConfGUI, _ = filepath.EvalSymlinks(pathTestConfGUI)

	printConfig := func(showAll bool) {
		path := source.MainConfigFile()
		def := source.MainConfigDefault()

		otherSw := pageswitch.New()
		defer otherSw.Destroy()
		build, e := cfbuild.NewFromFile(source, log, path, def, "")
		if !log.Err(e, "load current dock config file") {
			// build.BuildSingle("TaskBar")
			build.BuildAll(otherSw)
			println("conf", path, def)
			cfprint.Default(build, showAll)
			build.Destroy()
		}
	}

	buildInfo := cfbuild.TweakAddGroup(group,
		newkey.TextLabel(group, "txt_title", common.Bold(common.Big(title))),
		newkey.Separator(group, "sep_title"),
		newkey.TextLabel(group, "txt_dev_page", "Test page, with useful tools for the developer."),
		newkey.CustomButtonLabel(group, "printConfig", "Print configuration", "show mainconf edited", func() { printConfig(false) }),
		newkey.CustomButtonLabel(group, "printConfig", "Print configuration", "show mainconf all", func() { printConfig(true) }),
		newkey.Separator(group, "sep_go_area"),
		newkey.TextLabel(group, "txt_go_area", "<b>Those commands requires the application sources in their Go environment</b>."),
		newkey.Separator(group, "sep_tests_gui"),
		newkey.LaunchCommand(group, "testConfGUI", "Launch config GUI test", "go run "+pathTestConfGUI),
		newkey.Separator(group, "sep_tests_cmd"),
		newkey.LaunchCommand(group, "testConfGUI", "Launch config console test", "go run "+pathTestConfCmd),
		newkey.LaunchCommand(group, "testConfGUI", "Launch config console mainconf diff", "go run "+pathTestConfCmd+" "+source.MainConfigFile()),
		newkey.Separator(group, "sep_tests_go"),
		newkey.LaunchCommand(group, "gotest", "Launch go tests", "go test "+pathGoTest),
		newkey.LaunchCommand(group, "golint", "Launch go lint", "golint "+pathGoTest),
		newkey.LaunchCommand(group, "govet", "Launch go vet", "go vet "+pathGoTest),
	)

	build := cfbuild.NewVirtual(source, log, "", "", "").BuildAll(switcher, buildInfo)

	build.ShowAll()
	return build
}
开发者ID:sqp,项目名称:godock,代码行数:54,代码来源:devpage.go

示例10: TestTranslate

func TestTranslate(t *testing.T) {
	os.Setenv("LANGUAGE", "fr")

	// Translate dock strings.
	for in, out := range map[string]string{
		"Add":    "Ajouter",
		"Edit":   "Éditer",
		"Window": "Fenêtre",
	} {
		ret := tran.Slate(in)
		assert.Equal(t, ret, out, "translate %s != %s", ret, out)
	}

	// Translate plugins directly.
	for in, out := range map[string]string{
		"Animation when music changes:": "Animation au changement de musique",
		"Saturday":                      "Samedi",
	} {
		ret := tran.Splug(in)
		assert.Equal(t, ret, out, "translate %s != %s", ret, out)
	}

	// Translate plugins with domain name.
	for in, out := range map[string]string{
		"Lock position?":    "Verrouiller la position ?",
		"Image filename:":   "Nom du fichier de l'image :",
		"Font:":             "Police",
		"Use a custom font": "Utiliser une police personnalisée",
	} {
		ret := tran.Sloc("cairo-dock-plugins", in)
		assert.Equal(t, ret, out, "translate %s != %s", ret, out)
	}

	// Other string unchanged.
	for _, str := range []string{"unknown", "unchanged"} {
		ret := tran.Slate(str)
		assert.Equal(t, ret, str, "untranslated %s != %s", ret, str)
	}
}
开发者ID:sqp,项目名称:godock,代码行数:39,代码来源:tran_test.go

示例11: dialogAskBackend

func dialogAskBackend() {
	// Need to keep the string as it is for translation.
	str := "OpenGL allows you to use the hardware acceleration, reducing the CPU load to the minimum.\nIt also allows some pretty visual effects similar to Compiz.\nHowever, some cards and/or their drivers don't fully support it, which may prevent the dock from running correctly.\nDo you want to activate OpenGL ?\n (To not show this dialog, launch the dock from the Application menu,\n  or with the -o option to force OpenGL and -c to force cairo.)"

	dialog := newgtk.Dialog()
	dialog.SetTitle(tran.Slate("Use OpenGL in Cairo-Dock"))
	dialog.AddButton(tran.Slate("Yes"), gtk.RESPONSE_YES)
	dialog.AddButton(tran.Slate("No"), gtk.RESPONSE_NO)

	labelTxt := newgtk.Label(tran.Slate(str))

	content, _ := dialog.GetContentArea()
	content.PackStart(labelTxt, false, false, 0)

	askBox := newgtk.Box(gtk.ORIENTATION_HORIZONTAL, 3)
	content.PackStart(askBox, false, false, 0)

	labelSave := newgtk.Label(tran.Slate("Remember this choice"))
	check := newgtk.CheckButton()
	askBox.PackEnd(check, false, false, 0)
	askBox.PackEnd(labelSave, false, false, 0)

	dialog.ShowAll()

	answer := dialog.Run() // has its own main loop, so we can call it before gtk_main.
	remember := check.GetActive()
	dialog.Destroy()

	if answer == int(gtk.RESPONSE_NO) {
		gldi.GLBackendDeactivate()
	}

	if remember { // save user choice to file.
		value := ternary.String(gtk.ResponseType(answer) == gtk.RESPONSE_YES, "opengl", "cairo")
		updateHiddenFile("default backend", value)
	}
}
开发者ID:sqp,项目名称:godock,代码行数:37,代码来源:maindock.go

示例12: New

// New creates a GuiIcons widget to edit cairo-dock icons config.
//
func New() *About {
	// GtkWidget *pDialog = gtk_dialog_new_with_buttons (_(""),
	// 	GTK_WINDOW (pContainer->pWidget),
	// 	GTK_DIALOG_DESTROY_WITH_PARENT,
	// 	GLDI_ICON_NAME_CLOSE,
	// 	GTK_RESPONSE_CLOSE,
	// 	NULL);

	dialog := newgtk.Dialog()
	dialog.SetTitle(tran.Slate("About Cairo-Dock"))
	// dialog.SetParentWindow(parentWindow)
	dialog.AddButton(tran.Slate("_Close"), gtk.RESPONSE_CLOSE)
	dialog.Connect("response", dialog.Destroy)

	// Widgets.
	image := newgtk.ImageFromFile(Img)
	notebook := addNotebook()
	links := addLinks()

	// Packing.
	header := newgtk.Box(gtk.ORIENTATION_HORIZONTAL, 0)
	header.PackStart(image, false, false, 0)
	header.PackStart(links, false, false, 0)

	content, _ := dialog.GetContentArea()
	content.PackStart(header, false, false, 0)
	content.PackStart(notebook, true, true, 0)

	dialog.Resize(AboutWidth, AboutHeight) // had check min size compared to desktop size...
	dialog.ShowAll()

	//don't use gtk_dialog_run(), as we don't want to block the dock
	dialog.SetKeepAbove(true)

	return (*About)(dialog)
}
开发者ID:sqp,项目名称:godock,代码行数:38,代码来源:about.go

示例13: AddPage

// AddPage adds a tab to the main config switcher with its widget.
//
func (widget *GuiConfigure) AddPage(name, iconName string, saver Saver, btn btnaction.Tune, onShow, onHide func()) {
	widget.stack.AddNamed(saver, name)

	widget.mainSwitch.AddPage(&pageswitch.Page{
		Key:    name,
		Name:   tran.Slate(name),
		Icon:   iconName,
		OnShow: func() { widget.OnSelectPage(name) },
	})

	widget.pages[name] = &Page{
		Widget: saver,
		OnShow: onShow,
		OnHide: onHide,
		btn:    btn,
	}
}
开发者ID:sqp,项目名称:godock,代码行数:19,代码来源:confgui.go

示例14: Load

// Load loads an applet or theme in the preview. Handbooker and Appleter can be used.
//
func (widget *Preview) Load(pack Previewer) {
	widget.title.SetMarkup(common.Big(common.Bold(pack.GetTitle())))
	author := pack.GetAuthor()
	if author != "" {
		author = fmt.Sprintf(tran.Slate("by %s"), author)
	}
	widget.author.SetMarkup(common.Small(common.Mono(author)))

	apl, ok := pack.(Appleter)
	if ok {
		widget.stateText.SetMarkup(apl.FormatState())
		widget.size.SetMarkup(common.Small(apl.FormatSize()))

		if icon := apl.IconState(); icon != "" {
			if pixbuf, e := common.PixbufAtSize(icon, 24, 24); !widget.log.Err(e, "Load image pixbuf") {
				widget.stateIcon.SetFromPixbuf(pixbuf)
				widget.stateIcon.Show()
			}
		}
	}

	// widget.RemoveTmpFile()

	widget.previewFrame.Hide() // Hide the preview frame until we have an image.

	// Async calls for description and image. They can have to be downloaded and be slow at it.

	chDesc := make(chan (string))
	go func() { // Go routines to get data.
		chDesc <- pack.GetDescription()
	}()
	go func() {
		imageLocation := pack.GetPreviewFilePath()
		// imageLocation, isTemp := pack.GetPreview(widget.TmpFile) // reuse the same tmp location if needed.

		desc := <-chDesc
		glib.IdleAdd(func() { // glib Idle to show the result.
			widget.description.SetMarkup(desc)
			widget.setImage(imageLocation)
		})
	}()

}
开发者ID:sqp,项目名称:godock,代码行数:45,代码来源:appletpreview.go

示例15: Load

// Load loads the widget fields.
//
func (widget *List) Load(shareData string) {
	for _, item := range coreItems {
		iter := widget.model.Append()
		widget.rows[item.Key] = &row{iter, item}

		args := gtk.Cols{
			rowKey:     item.Key,
			rowName:    tran.Slate(item.Title),
			rowTooltip: item.Tooltip,
		}
		widget.model.SetCols(iter, args)

		if item.Icon != "" {
			path := filepath.Join(shareData, item.Icon)
			if pix, e := common.PixbufNewFromFile(path, iconSize); !widget.log.Err(e, "Load icon") {
				widget.model.SetValue(iter, rowIcon, pix)
			}
		}
	}
}
开发者ID:sqp,项目名称:godock,代码行数:22,代码来源:confcore.go


注:本文中的github.com/sqp/godock/libs/text/tran.Slate函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。