本文整理匯總了Golang中github.com/sqp/godock/widgets/cfbuild/cftype.Key.Source方法的典型用法代碼示例。如果您正苦於以下問題:Golang Key.Source方法的具體用法?Golang Key.Source怎麽用?Golang Key.Source使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/sqp/godock/widgets/cfbuild/cftype.Key
的用法示例。
在下文中一共展示了Key.Source方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: 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);
}
}
示例2: 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)
}
示例3: ListScreens
// ListScreens adds a screen selection widget.
//
func ListScreens(key *cftype.Key) {
list := key.Source().ListScreens()
combo := PackComboBoxWithListField(key, false, false, fieldsPrepend(list))
if len(list) <= 1 {
combo.SetSensitive(false)
}
// gldi_object_register_notification (&myDesktopMgr,
// NOTIFICATION_DESKTOP_GEOMETRY_CHANGED,
// (GldiNotificationFunc) _on_screen_modified,
// GLDI_RUN_AFTER, pScreensListStore);
// g_signal_connect (pOneWidget, "destroy", G_CALLBACK (_on_list_destroyed), NULL);
}
示例4: ListThemeApplet
// ListThemeApplet adds an theme list widget.
//
func ListThemeApplet(key *cftype.Key) {
var index map[string]datatype.Handbooker
if len(key.AuthorizedValues) > 2 {
if key.AuthorizedValues[1] == "gauges" {
index = key.Source().ListThemeXML(key.AuthorizedValues[0], key.AuthorizedValues[1], key.AuthorizedValues[2])
} else {
index = key.Source().ListThemeINI(key.AuthorizedValues[0], key.AuthorizedValues[1], key.AuthorizedValues[2])
}
}
PackComboBoxWithIndexHandbooker(key, index)
// // list local packages first.
// _allocate_new_buffer;
// data[0] = pOneWidget;
// data[1] = pMainWindow;
// data[2] = g_key_file_get_string (pKeyFile, cGroupName, cKeyName, NULL); // freed in the callback '_got_themes_combo_list'.
// data[3] = g_strdup (cHint); // idem
// GHashTable *pThemeTable = cairo_dock_list_packages (cShareThemesDir, cUserThemesDir, NULL, NULL);
// _got_themes_combo_list (pThemeTable, (gpointer*)data);
// // list distant packages asynchronously.
// if (cDistantThemesDir != NULL)
// {
// cairo_dock_set_status_message_printf (pMainWindow, _("Listing themes in '%s' ..."), cDistantThemesDir);
// data[2] = g_key_file_get_string (pKeyFile, cGroupName, cKeyName, NULL); // freed in the callback '_got_themes_combo_list'.
// data[3] = g_strdup (cHint);
// CairoDockTask *pTask = cairo_dock_list_packages_async (NULL, NULL, cDistantThemesDir, (CairoDockGetPackagesFunc) _got_themes_combo_list, data, pThemeTable); // the table will be freed along with the task.
// g_object_set_data (G_OBJECT (pOneWidget), "cd-task", pTask);
// g_signal_connect (G_OBJECT (pOneWidget), "destroy", G_CALLBACK (on_delete_async_widget), NULL);
// }
// else
// {
// g_hash_table_destroy (pThemeTable);
// }
// g_free (cUserThemesDir);
// g_free (cShareThemesDir);
}
示例5: ListDock
// 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)
}
示例6: Handbook
// Handbook adds a handbook widget to show basic applet informations.
//
func Handbook(key *cftype.Key) {
appletName := key.Value().String()
widget := handbook.New(key.Log())
widget.ShowVersion = true
book := key.Source().Handbook(appletName)
if widget == nil || book == nil {
key.Log().NewErr("Handbook no widget")
return
}
widget.SetPackage(book)
key.BoxPage().PackStart(widget, true, true, 0)
key.PackKeyWidget(key,
func() interface{} { return appletName },
func(uncast interface{}) {
appletName = uncast.(string)
book := key.Source().Handbook(appletName)
widget.SetPackage(book)
},
)
}
示例7: TestValues
//.........這裏部分代碼省略.........
if newval[i] > 1 {
newval[i]--
}
}
if len(newval) == 3 {
newval = append(newval, 1)
}
key.ValueSet(newval)
case cftype.KeyLink:
val := key.Value().String()
list := []string{urlDock, urlGoTour}
newval := cycleNextString(list, val, key)
key.ValueSet(newval)
case cftype.KeyStringEntry,
cftype.KeyFileSelector, cftype.KeyFolderSelector,
cftype.KeyImageSelector, cftype.KeySoundSelector,
cftype.KeyShortkeySelector, cftype.KeyClassSelector,
cftype.KeyPasswordEntry,
cftype.KeyListEntry:
val := key.Value().String()
newval := cycleNextString(otherStrings, val, nil)
key.ValueSet(newval)
case cftype.KeyFontSelector:
val := key.Value().String()
list := []string{"Arial 8", "Monospace 8"}
newval := cycleNextString(list, val, key)
key.ValueSet(newval)
case cftype.KeyTreeViewSortSimple,
cftype.KeyTreeViewSortModify:
val := key.Value().ListString()
newval := reverseStrings(val)
key.ValueSet(newval)
case cftype.KeyListNumbered,
cftype.KeyListNbCtrlSimple,
cftype.KeyListNbCtrlSelect:
val := key.Value().Int()
step := ternary.Int(key.IsType(cftype.KeyListNbCtrlSelect), 3, 1)
newval := cycleNextID(len(key.AuthorizedValues), val, step)
key.ValueSet(newval)
case cftype.KeyListSimple:
val := key.Value().String()
newval := cycleNextString(key.AuthorizedValues, val, key)
key.ValueSet(newval)
case cftype.KeyListDocks:
val := key.Value().String()
list := []string{datatype.KeyMainDock, datatype.KeyNewDock}
newval := cycleNextString(list, val, key)
key.ValueSet(newval)
case cftype.KeyListThemeApplet:
val := key.Value().String()
list := []string{"Turbo-night-fuel[0]", "Sound-Mono[0]"}
newval := cycleNextString(list, val, key)
key.ValueSet(newval)
case cftype.KeyHandbook:
val := key.Value().String()
list := datatype.ListHandbooksKeys(Handbooks)
newval := cycleNextString(list, val, key)
key.ValueSet(newval)
case cftype.KeyListViews:
val := key.Value().String()
books := key.Source().ListViews()
list := datatype.IndexHandbooksKeys(books)
newval := cycleNextString(list, val, key)
key.ValueSet(newval)
case cftype.KeyListIconsMainDock:
val := key.Value().String()
fields := key.Source().ListIconsMainDock()
newval := cycleNextField(fields, val, key)
key.ValueSet(newval)
case cftype.KeyListThemeDesktopIcon:
val := key.Value().String()
fields := key.Source().ListThemeDesktopIcon()
newval := cycleNextField(fields, val, key)
key.ValueSet(newval)
}
}
示例8: ListIconsMainDock
// ListIconsMainDock adds an icon list widget.
//
func ListIconsMainDock(key *cftype.Key) {
// {
// if (g_pMainDock == NULL) // maintenance mode... no dock, no icons
// {
// cValue = g_key_file_get_string (pKeyFile, cGroupName, cKeyName, NULL);
// pOneWidget = gtk_entry_new ();
// gtk_entry_set_text (GTK_ENTRY (pOneWidget), cValue); // if there is a problem, we can edit it.
// _pack_subwidget (pOneWidget);
// g_free (cValue);
// break;
// }
//
//
current := key.Value().String()
model := newModelSimple()
widget := newgtk.ComboBoxWithModel(model)
rp := newgtk.CellRendererPixbuf()
widget.PackStart(rp, false)
widget.AddAttribute(rp, "pixbuf", RowIcon)
renderer := newgtk.CellRendererText()
widget.PackStart(renderer, true)
widget.AddAttribute(renderer, "text", RowName)
list := key.Source().ListIconsMainDock()
saved := indexiter.NewByString(widget, key.Log())
iter := fillModelWithFields(key, model, list, current, saved)
widget.SetActiveIter(iter)
//
// // build the modele and combo
// modele = _cairo_dock_gui_allocate_new_model ();
// pOneWidget = gtk_combo_box_new_with_model (GTK_TREE_MODEL (modele));
// rend = gtk_cell_renderer_pixbuf_new ();
// gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (pOneWidget), rend, FALSE);
// gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (pOneWidget), rend, "pixbuf", CAIRO_DOCK_MODEL_ICON, NULL);
// rend = gtk_cell_renderer_text_new ();
// gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (pOneWidget), rend, FALSE);
// gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (pOneWidget), rend, "text", CAIRO_DOCK_MODEL_NAME, NULL);
// _pack_subwidget (pOneWidget);
// // get the dock
// CairoDock *pDock = NULL;
// if (pAuthorizedValuesList != NULL && pAuthorizedValuesList[0] != NULL)
// pDock = gldi_dock_get (pAuthorizedValuesList[0]);
// if (!pDock)
// pDock = g_pMainDock;
// // insert each icon
// cValue = g_key_file_get_string (pKeyFile, cGroupName, cKeyName, NULL);
// gint iDesiredIconSize = cairo_dock_search_icon_size (GTK_ICON_SIZE_LARGE_TOOLBAR); // 24 by default
// GtkTreeIter iter;
// Icon *pIcon;
// gchar *cImagePath, *cID;
// const gchar *cName;
// GdkPixbuf *pixbuf;
// GList *ic;
// for (ic = pDock->icons; ic != NULL; ic = ic->next)
// {
// pIcon = ic->data;
// if (pIcon->cDesktopFileName != NULL
// || pIcon->pModuleInstance != NULL)
// {
// pixbuf = NULL;
// cImagePath = NULL;
// cName = NULL;
// // get the ID
// if (pIcon->cDesktopFileName != NULL)
// cID = pIcon->cDesktopFileName;
// else
// cID = pIcon->pModuleInstance->cConfFilePath;
// // get the image
// if (pIcon->cFileName != NULL)
// {
// cImagePath = cairo_dock_search_icon_s_path (pIcon->cFileName, iDesiredIconSize);
// }
// if (cImagePath == NULL || ! g_file_test (cImagePath, G_FILE_TEST_EXISTS))
// {
// g_free (cImagePath);
// if (GLDI_OBJECT_IS_SEPARATOR_ICON (pIcon))
// {
// if (myIconsParam.cSeparatorImage)
// cImagePath = cairo_dock_search_image_s_path (myIconsParam.cSeparatorImage);
// }
// else if (CAIRO_DOCK_IS_APPLET (pIcon))
// {
// cImagePath = g_strdup (pIcon->pModuleInstance->pModule->pVisitCard->cIconFilePath);
// }
// else
//.........這裏部分代碼省略.........
示例9: ListDialogDecorator
// ListDialogDecorator adds an dialog decorator list widget.
//
func ListDialogDecorator(key *cftype.Key) {
PackComboBoxWithListField(key, false, false, key.Source().ListDialogDecorator)
}
示例10: ListAnimation
// ListAnimation adds an animation list widget.
//
func ListAnimation(key *cftype.Key) {
getList := fieldsPrepend(key.Source().ListAnimations(),
datatype.Field{},
)
PackComboBoxWithListField(key, false, false, getList)
}
示例11: ListView
// ListView adds a view list widget.
//
func ListView(key *cftype.Key) {
index := key.Source().ListViews()
PackComboBoxWithIndexHandbooker(key, index)
}
示例12: Strings
// Strings adds a string widget. Many options included.
// TODO: need password cypher, G_USER_DIRECTORY_PICTURES, play sound.
//
func Strings(key *cftype.Key) {
value := key.Value().String()
widget := newgtk.Entry()
widget.SetText(value)
if key.IsType(cftype.KeyPasswordEntry) { // Hide text and decrypt value.
widget.SetVisibility(false)
value = key.Source().DecryptString(value)
}
// Pack the widget before any other (in full size if needed).
// So we do it now and fill the callbacks later
key.PackKeyWidget(key, nil, nil, widget)
var setValue func(interface{})
// Add special buttons to fill the entry box.
switch key.Type {
case cftype.KeyFileSelector, cftype.KeyFolderSelector,
cftype.KeySoundSelector, cftype.KeyImageSelector: // Add a file selector.
fileChooser := newgtk.Button()
img := newgtk.ImageFromIconName("document-open", gtk.ICON_SIZE_SMALL_TOOLBAR)
fileChooser.SetImage(img)
fileChooser.Connect("clicked", onFileChooserOpen, fileChooserData{widget, key})
key.PackSubWidget(fileChooser)
if key.IsType(cftype.KeySoundSelector) { //Sound Play Button
play := newgtk.Button()
imgPlay := newgtk.ImageFromIconName("media-playback-start", gtk.ICON_SIZE_SMALL_TOOLBAR)
play.SetImage(imgPlay)
// play.Connect("clicked", C._cairo_dock_play_a_sound, data)
key.PackSubWidget(play)
}
case cftype.KeyShortkeySelector, cftype.KeyClassSelector: // Add a key/class grabber.
grab := newgtk.ButtonWithLabel("Grab")
key.PackSubWidget(grab)
// gtk_widget_add_events(pMainWindow, GDK_KEY_PRESS_MASK);
switch key.Type {
case cftype.KeyClassSelector:
grab.Connect("clicked", func() {
widget.SetSensitive(false) // Block widgets.
grab.SetSensitive(false)
go func() {
class, e := key.Source().GrabWindowClass() // Wait user selection in a routine.
glib.IdleAdd(func() { // And resync with the GTK loop to display results.
widget.SetSensitive(true) // Reactivate widgets.
grab.SetSensitive(true)
if !key.Log().Err(e, "ClassSelector", key.Group, key.Name) {
setValue(class) // On success.
key.Log().Debug("KeyClassSelector window selected", class)
}
})
}()
})
case cftype.KeyShortkeySelector:
grab.Connect("clicked", onKeyGrabClicked, &textGrabData{entry: widget, win: key.Source().GetWindow()})
}
// for _, sk := range key.Source().ListShortkeys() {
// if sk.GetConfFilePath() == key.Storage().FilePath() {
// println("found file shortkey")
// }
// }
}
// Display a default value when empty.
if len(key.AuthorizedValues) > 0 && key.AuthorizedValues[0] != "" {
defaultText := key.Translate(key.AuthorizedValues[0])
cbChanged, _ := widget.Connect("changed", onTextDefaultChanged, key)
data := textDefaultData{key: key, text: defaultText, cbID: cbChanged}
widget.Connect("focus-in-event", onTextDefaultFocusIn, data)
widget.Connect("focus-out-event", onTextDefaultFocusOut, data)
// TODO: check other use of those fields.
// g_object_set_data (G_OBJECT (pEntry), "ignore-value", GINT_TO_POINTER (TRUE));
// g_object_set_data (G_OBJECT (pOneWidget), "default-text", cDefaultText);
context, _ := widget.GetStyleContext()
context.AddProvider(MainCSS(), gtk.STYLE_PROVIDER_PRIORITY_APPLICATION)
setValue = func(uncast interface{}) {
// if !key.IsDefault { // not sure why this was here.
widget.SetText(uncast.(string))
onTextDefaultFocusOut(widget, nil, data)
}
//.........這裏部分代碼省略.........