本文整理匯總了Golang中github.com/sqp/godock/widgets/cfbuild/cftype.Key.Label方法的典型用法代碼示例。如果您正苦於以下問題:Golang Key.Label方法的具體用法?Golang Key.Label怎麽用?Golang Key.Label使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/sqp/godock/widgets/cfbuild/cftype.Key
的用法示例。
在下文中一共展示了Key.Label方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: LaunchCommand
// LaunchCommand adds a launch command widget.
// HELP ONLY
//
func LaunchCommand(key *cftype.Key) {
if len(key.AuthorizedValues) == 0 || key.AuthorizedValues[0] == "" {
key.Log().NewErrf("command missing", "widget LaunchCommand: %s", key.Name)
return
}
// log.Info(key.Name, key.AuthorizedValues)
if key.IsType(cftype.KeyLaunchCmdIf) {
if len(key.AuthorizedValues) < 2 {
key.Label().SetSensitive(false)
return
}
key.Log().Info("KeyLaunchCmdIf : disabled for now")
return
// key.Log().Info("test", key.AuthorizedValues[1])
// key.Log().Err(key.Log().ExecShow(key.AuthorizedValues[1]), "exec test")
// gchar *cSecondCommand = pAuthorizedValuesList[1];
// gchar *cResult = cairo_dock_launch_command_sync (cSecondCommand);
// cd_debug ("%s: %s => %s", __func__, cSecondCommand, cResult);
// if (cResult == NULL || *cResult == '0' || *cResult == '\0') // result is 'fail'
// {
// gtk_widget_set_sensitive (pLabel, FALSE);
// g_free (cResult);
// break ;
// }
// g_free (cResult);
}
spinner := newgtk.Spinner()
spinner.SetNoShowAll(true)
key.PackSubWidget(spinner)
btn := newgtk.ButtonFromIconName("go-jump", gtk.ICON_SIZE_BUTTON)
key.PackSubWidget(btn)
btn.Connect("clicked", func() {
cmd, e := key.Log().ExecShlex(key.AuthorizedValues[0])
if key.Log().Err(e, "widget LaunchCommand parse command", key.Name, ":", key.AuthorizedValues[0]) {
return
}
e = cmd.Start()
if key.Log().Err(e, "widget LaunchCommand exec", key.AuthorizedValues[0]) {
return
}
btn.Hide()
spinner.Show()
spinner.Start()
// Wait the external program in a go routine.
// When finished, restore buttons state in the gtk idle loop.
go func() {
cmd.Wait()
glib.IdleAdd(func() {
btn.Show()
spinner.Hide()
spinner.Stop()
})
}()
})
// G_CALLBACK (_cairo_dock_widget_launch_command),
}
示例2: Text
// Text just enlarges the widget label (nothing more intended).
//
func Text(key *cftype.Key) {
key.Label().SetLineWrap(true)
key.Label().SetJustify(gtk.JUSTIFY_FILL)
}