Esempio n. 1
0
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
}
Esempio n. 2
0
// 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
}
Esempio n. 3
0
// 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...))
}
Esempio n. 4
0
// 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)
}
Esempio n. 5
0
// 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);
	}
}
Esempio n. 6
0
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)
}
Esempio n. 7
0
// 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
}
Esempio n. 8
0
File: about.go Progetto: sqp/godock
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
}
Esempio n. 9
0
// 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
}
Esempio n. 10
0
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)
	}
}
Esempio n. 11
0
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)
	}
}
Esempio n. 12
0
File: about.go Progetto: sqp/godock
// 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)
}
Esempio n. 13
0
// 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,
	}
}
Esempio n. 14
0
// 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)
		})
	}()

}
Esempio n. 15
0
// 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)
			}
		}
	}
}
Esempio n. 16
0
// Link adds a link widget.
//
func Link(key *cftype.Key) {
	var text, link string
	if len(key.AuthorizedValues) > 0 {
		text = key.AuthorizedValues[0]
	} else {
		text = tran.Slate("link")
	}

	if len(key.AuthorizedValues) > 1 { // Custom keys have to use this input way.
		link = key.AuthorizedValues[1]
	} else {
		link = key.Value().String()
	}

	widget := newgtk.LinkButtonWithLabel(link, text)

	key.PackKeyWidget(key,
		func() interface{} { return widget.GetUri() },
		func(val interface{}) { widget.SetUri(val.(string)) },
		widget)
}
Esempio n. 17
0
// ListDock adds a dock list widget.
//
func ListDock(key *cftype.Key) {
	// Get current Icon name if its a Subdock.
	iIconType, _ := key.Storage().Int(key.Group, "Icon Type")
	SubdockName := ""
	if iIconType == cftype.UserIconStack { // it's a stack-icon
		SubdockName, _ = key.Storage().String(key.Group, "Name") // It's a subdock, get its name to remove the selection of a recursive position (inside itself).
	}

	list := key.Source().ListDocks("", SubdockName) // Get the list of available docks. Keep parent, but remove itself from the list.
	list = append(list, datatype.Field{
		Key:  datatype.KeyNewDock,
		Name: tran.Slate("New main dock")},
	)

	model := newModelSimple()
	current := key.Value().String()

	if current == "" {
		current = datatype.KeyMainDock
	}

	model.SetSortColumnId(RowName, gtk.SORT_ASCENDING)
	widget := newgtk.ComboBoxWithModel(model)
	renderer := newgtk.CellRendererText()
	widget.PackStart(renderer, false)
	widget.AddAttribute(renderer, "text", RowName)

	saved := indexiter.NewByString(widget, key.Log())
	iter := fillModelWithFields(key, model, list, current, saved)
	widget.SetActiveIter(iter)

	key.PackKeyWidget(key,
		getValueListCombo(widget, model, key.Log()),
		func(uncast interface{}) { saved.SetActive(uncast.(string)) },
		widget)
}
Esempio n. 18
0
func newMenuMoveToDesktop(icon gldi.Icon, useAll bool) *menuMoveToDesktop {
	// Create object and set work mode.
	desk := &menuMoveToDesktop{nbx: desktops.NbViewportX()}
	switch {
	case desktops.NbDesktops() > 1 && (desktops.NbViewportX() > 1 || desktops.NbViewportY() > 1):
		desk.mode = 2

	case desktops.NbDesktops() > 1:
		desk.mode = 1
	}

	// Set label format string.
	switch {
	case desk.mode == 2 && useAll:
		desk.format = tran.Slate("Move all to desktop %d - face %d")

	case desk.mode == 2:
		desk.format = tran.Slate("Move to desktop %d - face %d")

	case desk.mode == 1 && useAll:
		desk.format = tran.Slate("Move all to desktop %d")

	case desk.mode == 1:
		desk.format = tran.Slate("Move to desktop %d")

	case desk.mode == 0 && useAll:
		desk.format = tran.Slate("Move all to face %d")

	case desk.mode == 0:
		desk.format = tran.Slate("Move to face %d")
	}

	// Set the window action method.
	if useAll {
		desk.cbAction = icon.CallbackActionSubWindows // All windows of class.
	} else {
		desk.cbAction = icon.CallbackActionWindow // One window.
	}

	return desk
}
Esempio n. 19
0
// FormatCategory formats the applet category text.
//
func (v *AppletDownload) FormatCategory() string {
	txt, color := packages.FormatCategory(int(v.Category))
	return "<span fgcolor='#" + color + "'>" + tran.Slate(txt) + "</span>"
}
Esempio n. 20
0
// GetDescription returns the book description.
//
func (dv *HandbookDescTranslate) GetDescription() string {
	return tran.Slate(dv.Handbooker.GetDescription())
}
Esempio n. 21
0
// ListIcons builds the list of all icons.
//
func (Data) ListIcons() *datatype.ListIcon {
	list := datatype.NewListIcon()

	// Add icons in docks.
	taskbarSet := false
	for _, dock := range gldi.GetAllAvailableDocks(nil, nil) {
		// for _, dock := range gldi.ListDocksRoot() {

		var found []datatype.Iconer
		for _, icon := range dock.Icons() {
			if dock.GetRefCount() == 0 { // Maindocks.

				// Group taskbar icons and separators.
				if icon.ConfigPath() == "" || icon.IsSeparatorAuto() {
					// if icon.IsTaskbar() || icon.IsSeparatorAuto() {
					if !taskbarSet {
						taskbarSet = true
						ic := datatype.NewIconSimple(
							globals.ConfigFile(),
							datatype.FieldTaskBar,
							datatype.TitleTaskBar,
							globals.DirShareData("icons/icon-taskbar.png"))

						ic.Taskbar = true

						found = append(found, ic)
					}

				} else {
					found = append(found, &IconConf{icon})
				}

			} else { // Subdock.
				parentName := icon.GetParentDockName()
				list.Subdocks[parentName] = append(list.Subdocks[parentName], &IconConf{icon})
			}
		}

		if len(found) > 0 {
			var file, group string

			if dock.IsMainDock() {
				// Only maindocks after the first one have a config file.
				// So the first maindock use a custom group.
				group = datatype.KeyMainDock

			} else {
				// Other maindocks have a dedicated config file.
				// So the group is empty to load all of them (auto find).
				file = globals.CurrentThemePath(dock.GetDockName() + ".conf")
			}
			container := datatype.NewIconSimple(
				file,
				group,
				dock.GetReadableName(),
				"") // TODO: maybe get an icon for the maindock.

			list.Add(container, found)
		}
	}

	// Add modules in desklets.
	var desklets []datatype.Iconer
	for _, desklet := range docklist.Desklet() {
		icon := desklet.GetIcon()
		if icon != nil {
			desklets = append(desklets, &IconConf{icon})
		}
	}

	if len(desklets) > 0 {
		container := datatype.NewIconSimple(
			globals.ConfigFile(),
			datatype.GroupDesklets,
			datatype.TitleDesklets,
			"") // TODO: maybe get an icon for the desklets group.

		list.Add(container, desklets)
	}

	// Add other modules (not in a dock or a desklet) : plug-in or detached applet.
	// We need to create custom icons for them.
	var services []datatype.Iconer
	for _, mod := range docklist.Module() {
		cat := mod.VisitCard().GetCategory()

		if cat != gldi.CategoryBehavior && cat != gldi.CategoryTheme && !mod.IsAutoLoaded() {
			for _, mi := range mod.InstancesList() {

				if mi.Icon() == nil || (mi.Dock() != nil && mi.Icon().GetContainer() == nil) {
					icon := datatype.NewIconSimple(
						mi.GetConfFilePath(),
						"", // no group, we need all of them for an applet.
						mod.VisitCard().GetTitle(),
						mod.VisitCard().GetIconFilePath())

					services = append(services, icon)
				}
			}
		}
	}
	if len(services) > 0 {
		container := datatype.NewIconSimple(
			"", // no config file available.
			datatype.GroupServices, // so we set a custom group.
			tran.Slate(datatype.TitleServices),
			"") // TODO: maybe get an icon for the services group.

		list.Add(container, services)
	}

	return list
}
Esempio n. 22
0
func (o *btnAction) SetCancel() { o.setShow(tran.Slate("Cancel")) }
Esempio n. 23
0
File: others.go Progetto: sqp/godock
func onFileChooserOpen(obj *gtk.Button, data fileChooserData) {
	var parent *gtk.Window

	var title string
	var action gtk.FileChooserAction

	switch data.key.Type {
	case cftype.KeyFolderSelector:
		title = tran.Slate("Pick up a directory")
		action = gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER

	case cftype.KeyImageSelector:
		title = tran.Slate("Pick up an image")
		action = gtk.FILE_CHOOSER_ACTION_OPEN

	default:
		title = tran.Slate("Pick up a file")
		action = gtk.FILE_CHOOSER_ACTION_OPEN
	}

	dialog, _ := gtk.FileChooserDialogNewWith2Buttons(title, parent, action,
		"_OK", gtk.RESPONSE_OK, "_Cancel", gtk.RESPONSE_CANCEL)

	// Set the current folder to the current value in conf.
	value, _ := data.entry.GetText()
	if value == "" || value[0] != '/' {
		if data.key.IsType(cftype.KeyImageSelector) {
			println("need dir pictures")
			// dialog.SetCurrentFolder(filepath.Dir(value)) // g_get_user_special_dir (G_USER_DIRECTORY_PICTURES) :
		} else {
			println(os.Getenv("HOME"))
			dialog.SetCurrentFolder(os.Getenv("HOME"))
		}
	} else {
		dialog.SetCurrentFolder(filepath.Dir(value))
	}

	if data.key.IsType(cftype.KeyImageSelector) { // Add shortcuts to icons of the system.
		dialog.AddShortcutFolder("/usr/share/icons")
		dialog.AddShortcutFolder("/usr/share/pixmaps")
	}

	if data.key.IsType(cftype.KeyFileSelector, cftype.KeySoundSelector) { // Add shortcuts to system icons directories.
		filter := newgtk.FileFilter()
		filter.SetName(tran.Slate("All"))
		filter.AddPattern("*")
		dialog.AddFilter(filter)
	}

	if data.key.IsType(cftype.KeyFileSelector, cftype.KeyImageSelector) { // Preview and images filter.
		filter := newgtk.FileFilter()
		filter.SetName(tran.Slate("Image"))
		filter.AddPixbufFormats()
		dialog.AddFilter(filter)

		img := newgtk.Image()
		dialog.SetPreviewWidget(img)
		dialog.Connect("update-preview", onFileChooserUpdatePreview, img)
	}

	dialog.Show()
	answer := dialog.Run()
	if gtk.ResponseType(answer) == gtk.RESPONSE_OK {
		data.entry.SetText(dialog.GetFilename())
	}
	dialog.Destroy()
}
Esempio n. 24
0
func (o *btnAction) SetSave()   { o.setShow(tran.Slate("Save")) }
Esempio n. 25
0
func (o *btnAction) SetApply()  { o.setShow(tran.Slate("Apply")) }
Esempio n. 26
0
func (o *btnAction) SetAdd()    { o.setShow(tran.Slate("Add")) }
Esempio n. 27
0
func (o *btnAction) SetTest()   { o.setShow(tran.Slate("Test")) }
Esempio n. 28
0
// BuildMenuContainer builds the dock container menu (1st line).
//
func BuildMenuContainer(m *backendmenu.DockMenu) bool {

	if m.Container.IsDesklet() && m.Icon != nil && !m.Icon.IsApplet() { // not on the icons of a desklet, except the applet icon (on a desklet, it's easy to click out of any icon).
		return notif.AnswerLetPass
	}

	if m.Dock != nil && m.Dock.GetRefCount() > 0 { // not on the sub-docks, except user sub-docks.
		pointingIcon := m.Dock.SearchIconPointingOnDock(nil)
		if pointingIcon != nil && !pointingIcon.IsStackIcon() {
			return notif.AnswerLetPass
		}
	}

	if m.Dock != nil && (m.Icon == nil || m.Icon.IsSeparatorAuto()) {
		return notif.AnswerLetPass
	}

	//\_________________________ First item is the Cairo-Dock sub-menu.
	dockmenu := m.AddSubMenu("Cairo-Dock", globals.FileCairoDockIcon())

	if !current.DockIsLocked() {
		dockmenu.Entry(backendmenu.MenuConfigure)

		if m.Dock != nil && !m.Dock.IsMainDock() && m.Dock.GetRefCount() == 0 { // root dock settings
			dockmenu.Entry(backendmenu.MenuEditDock)
			dockmenu.Entry(backendmenu.MenuDeleteDock)
		}

		// 	if backendgui.CanManageThemes () {// themes. won't have a menu entry.
		// dockmenu.Entry(backendmenu.MenuThemes)
		// 	}

		// Show edit icon below edit dock when icons are locked (only thing needed from the icon submenu).
		if current.Docks.LockIcons() {
			dockmenu.Entry(backendmenu.MenuEditTarget)

		} else {

			// Submenu add new item.
			if m.Dock != nil {
				sub := dockmenu.AddSubMenu(tran.Slate("Add"), globals.IconNameAdd)
				sub.Entry(backendmenu.MenuAddSubDock)
				sub.Entry(backendmenu.MenuAddMainDock)
				sub.Entry(backendmenu.MenuAddSeparator)
				sub.Entry(backendmenu.MenuAddLauncher)
				sub.Entry(backendmenu.MenuAddApplet)
			}
		}

		dockmenu.AddSeparator()
		dockmenu.Entry(backendmenu.MenuLockIcons)
	}

	if m.Dock != nil && !m.Dock.IsAutoHide() {
		dockmenu.Entry(backendmenu.MenuQuickHide)
	}

	if !globals.FullLock {
		// dockmenu.Entry(backendmenu.MenuAutostart) // removed crap.
		// dockmenu.Entry(backendmenu.MenuThirdParty) // not needed with the download page.

		dockmenu.Entry(backendmenu.MenuHelp) // Don't show if locked, because it would open the configuration window.
	}

	dockmenu.Entry(backendmenu.MenuAbout)

	if !globals.FullLock {
		dockmenu.Entry(backendmenu.MenuQuit)
	}

	// //\_________________________ Second item is the Icon sub-menu.

	// Icon *pIcon = icon;
	// if (pIcon == NULL && CAIRO_DOCK_IS_DESKLET (pContainer))  // on a desklet, the main applet icon may not be drawn; therefore we add the applet sub-menu if we clicked outside of an icon.
	// {
	// 	pIcon = CAIRO_DESKLET (pContainer)->pIcon;
	// }

	// pIcon := GetIconForDesklet(icon, container)

	if m.Icon != nil && !m.Icon.IsSeparatorAuto() && !current.Docks.LockIcons() {

		items := m.AddSubMenu(m.Icon.DefaultNameIcon())

		// 	GtkWidget *pItemSubMenu = _add_item_sub_menu (pIcon, menu);

		if current.DockIsLocked() {
			switch {
			case m.Icon.IsAppli() && m.Icon.GetCommand() != "":
				items.Entry(backendmenu.MenuLaunchNew)

			case m.Icon.IsApplet():
				items.Entry(backendmenu.MenuHandbook)

			default:
				items.SetSensitive(false) // empty, the submenu is added for consistency between icons, but disabled.
			}

		} else {
			if m.Icon.IsAppli() && m.Icon.GetCommand() != "" {
				items.Entry(backendmenu.MenuLaunchNew)
			}

			switch {
			case m.Icon.GetDesktopFileName() != "" &&
				(m.Icon.IsLauncher() || m.Icon.IsStackIcon() || m.Icon.IsSeparator()):

				items.Entry(backendmenu.MenuEditIcon)
				items.Entry(backendmenu.MenuRemoveIcon)
				items.Entry(backendmenu.MenuMoveToDock)

			case (m.Icon.IsAppli() || m.Icon.IsStackIcon()) && // appli with no launcher
				!m.Icon.ClassIsInhibited(): // if the class doesn't already have an inhibator somewhere.
				items.Entry(backendmenu.MenuMakeLauncher)

				if !current.Docks.LockAll() && m.Icon.IsAppli() {

					if current.Taskbar.OverWriteXIcons() {
						items.Entry(backendmenu.MenuCustomIconRemove)
					}

					items.Entry(backendmenu.MenuCustomIconSet)
				}

			case m.Icon.IsApplet(): // applet (icon or desklet) (the sub-icons have been filtered before and won't have this menu).
				items.Entry(backendmenu.MenuEditApplet)

				if m.Icon.IsDetachableApplet() {
					items.Entry(backendmenu.MenuDetachApplet)
				}

				items.Entry(backendmenu.MenuRemoveApplet)

				if m.Icon.ModuleInstance().Module().VisitCard().IsMultiInstance() {
					items.Entry(backendmenu.MenuDuplicateApplet)
				}

				if m.Dock != nil && m.Icon.GetContainer() != nil {
					items.Entry(backendmenu.MenuMoveToDock)
				}

				items.AddSeparator()

				items.Entry(backendmenu.MenuHandbook)

			}
		}
	}

	return notif.AnswerLetPass
}
Esempio n. 29
0
// BuildMenuIcon builds the dock icon menu (2nd line).
//
func BuildMenuIcon(m *backendmenu.DockMenu) bool {

	//\_________________________ Clic en-dehors d'une icone utile => on s'arrete la.
	if m.Dock != nil && (m.Icon == nil || m.Icon.IsSeparatorAuto()) {
		return notif.AnswerLetPass
	}

	needSeparator := true

	if m.Container.IsDesklet() && m.Icon != nil && !m.Icon.IsApplet() { // not on the icons of a desklet, except the applet icon (on a desklet, it's easy to click out of any icon).
		needSeparator = false
	}

	if m.Dock != nil && m.Dock.GetRefCount() > 0 { // not on the sub-docks, except user sub-docks.
		pointingIcon := m.Dock.SearchIconPointingOnDock(nil)
		if pointingIcon != nil && !pointingIcon.IsStackIcon() {
			needSeparator = false
		}
	}

	// 	//\_________________________ class actions.
	if m.Icon != nil && m.Icon.GetClass().String() != "" && !m.Icon.GetIgnoreQuickList() {
		if needSeparator {
			m.AddSeparator()
		}
		needSeparator = m.Entry(backendmenu.MenuClassItems)
	}

	//\_________________________ Actions on applications.
	if m.Icon.IsAppli() {
		if needSeparator {
			m.AddSeparator()
		}
		needSeparator = true

		appli := m.Icon.Window()
		canMin, canMax, canClose := appli.CanMinMaxClose()

		var btns []backendmenu.MenuBtn
		if canClose {
			btns = append(btns, backendmenu.MenuWindowClose)
		}

		if !appli.IsHidden() {
			if canMax {
				btns = append(btns, backendmenu.MenuWindowMax)
			}
			if canMin {
				btns = append(btns, backendmenu.MenuWindowMin)
			}
		}

		if appli.IsHidden() || !appli.IsActive() || !appli.IsOnCurrentDesktop() {
			btns = append(btns, backendmenu.MenuWindowShow)
		}

		m.AddButtonsEntry(tran.Slate("Window"), btns...)

		//\_________________________ Other actions

		otherActions := m.AddSubMenu(tran.Slate("Other actions"), "")

		otherActions.Entry(backendmenu.MenuWindowMoveHere)
		otherActions.Entry(backendmenu.MenuWindowFullScreen)
		otherActions.Entry(backendmenu.MenuWindowBelow)
		otherActions.Entry(backendmenu.MenuWindowAbove)
		otherActions.Entry(backendmenu.MenuWindowSticky)
		otherActions.Entry(backendmenu.MenuMoveToDesktopWindow)

		otherActions.AddSeparator()

		otherActions.Entry(backendmenu.MenuWindowKill)

	} else if m.Icon.IsMultiAppli() { // Window management
		if needSeparator {
			m.AddSeparator()
		}
		needSeparator = true

		m.AddButtonsEntry("Windows",
			backendmenu.MenuWindowCloseAll,
			backendmenu.MenuWindowMinAll,
			backendmenu.MenuWindowShowAll,
		)

		otherActions := m.AddSubMenu(tran.Slate("Other actions"), "")
		otherActions.Entry(backendmenu.MenuWindowMoveAllHere)
		otherActions.Entry(backendmenu.MenuMoveToDesktopClass)
	}

	//\_________________________ Desklet positioning actions.

	if !current.DockIsLocked() && m.Container.IsDesklet() {
		if needSeparator {
			m.AddSeparator()
		}
		// needSeparator = true

		m.Entry(backendmenu.MenuDeskletVisibility)
		m.Entry(backendmenu.MenuDeskletSticky)
		m.Entry(backendmenu.MenuDeskletLock)
	}

	return notif.AnswerLetPass
}
Esempio n. 30
0
func (o *btnAction) SetGrab()   { o.setShow(tran.Slate("Grab")) }