I'm using GTK+3 and I would like to do a recent-files submenu which it could update programmatically, not just by the GUI user interaction (that is working). I've used GtkRecentChooserMenu.
I've made this for setting the submenu:
GtkWidget * recentChooser = gtk_recent_chooser_menu_new ();
gtk_menu_item_set_submenu (GTK_MENU_ITEM (win->menuItemRecent), recentChooser); //win->menuItemRecent is a GtkMenuItem
gtk_recent_chooser_menu_set_show_numbers (GTK_RECENT_CHOOSER_MENU (recentChooser), TRUE);
GtkRecentFilter *filter = gtk_recent_filter_new ();
gtk_recent_chooser_set_sort_type (GTK_RECENT_CHOOSER (recentChooser), GTK_RECENT_SORT_MRU);
gtk_recent_filter_add_pattern (filter, "*.tnt");
gtk_recent_filter_add_pattern (filter, "*.run");
gtk_recent_filter_add_pattern (filter, "*.tre");
gtk_recent_filter_add_pattern (filter, "*.dat");
gtk_recent_chooser_add_filter (GTK_RECENT_CHOOSER (recentChooser), filter);
g_signal_connect (G_OBJECT (recentChooser), "item-activated", G_CALLBACK (on_recentFile_activated), NULL);
gtk_recent_chooser_set_show_icons(GTK_RECENT_CHOOSER (recentChooser), FALSE);
As I said, all this is working. Now, for the programmatic submenu update, I've tried this:
submenu = gtk_menu_item_get_submenu (GTK_MENU_ITEM(win->menuItemRecent));
GtkRecentChooser * chooser = GTK_RECENT_CHOOSER(submenu);
GtkRecentManager * manager = GTK_RECENT_CHOOSER_GET_IFACE(chooser)->get_recent_manager (chooser);
gtk_recent_manager_add_item(manager, file); //file is a file name to add into submenu
But this isn't working. The gtk_recent_manager_add_item() seems add (because it returns TRUE) but the submenu doesn't update.
Thanks in advance.
MartÃn
Related
I'm using Action Sheet Popup of the library Rg.Plugins.Popup on Xamarin Forms.
I want to display the image as below:
How to add an icon to Action Sheet Popup on Xamarin forms?
This is my code:
public Task<string> ShowActionSheetDialogAsync(string title, string cancelString = null, string destructive = null, CancellationToken? token = null, string[] arrayButtons = null)
{
return UserDialogs.Instance.ActionSheetAsync(title, cancelString,destructive, cancelToken: token,buttons:arrayButtons);
}
Or you can suggest another idea which might also show.
Please help me!
Use aritchie/userdialogs instead, it provides icon option for the item in list , check API .
Usage
IUserDialogs d = UserDialogs.Instance;
ActionSheetConfig config = new ActionSheetConfig();
List<ActionSheetOption> Options = new List<ActionSheetOption>();
Options.Add(new ActionSheetOption("1" , null , "info.png"));
Options.Add(new ActionSheetOption("2", null, "info.png"));
ActionSheetOption cancel = new ActionSheetOption("Cancel",null,null);
config.Options = Options;
config.Cancel = cancel;
d.ActionSheet(config);
Screen shot
This is platform-specific, so wrap it in DependencyService for example.
This is how you add image to an ActionSheet action:
UIImage img; //the image
var action = new UIAlertAction();
action.SetValueForKey("image", img);
Then add this UIAlertAction to a UIActionSheet. (You should also set Title and Action, of course)
I have just started coding a simple windows form, but when I compile it the buttons/textboxes does not display.
Only a blank window pops up.
It looks like there is nothing in your InitializeComponent function.
Add this code in the function and you should see a button with "Connect" written on it.
private void InitializeComponent()
{
System.Windows.Forms.Button ConnectBtn = new System.Windows.Forms.Button();
ConnectBtn.Location = new System.Drawing.Point(10, 10);
ConnectBtn.Name = "ConnectBtn";
ConnectBtn.Size = new System.Drawing.Size(75, 23);
ConnectBtn.Text = "Connect";
this.Controls.Add(ConnectBtn);
}
I am developing one application and i have added one button (CButton) which is calling SHBrowseForFolder() function. But the problem is that the button is still active and also it is letting me to click my parent window. Also i can click again and again that button and multiple browsing window are coming.
What i want to know that is there any way to use SHBrowseForFolder() in a DoModal() way, so that the control did not return to the parent window till user click that Ok/Cancel button of the folder browse window? I do not want to disable that button after clicking once or something like that.
I am using Visual Studio 2010.
Thanks in advance.
Sure it's possible:
void CUtility::BrowseFolder(CWnd* pParentWnd, const CString& sTitle, CEdit& Edit)
{
LPMALLOC pMalloc = NULL;
::SHGetMalloc(&pMalloc);
TCHAR pBuffer[MAX_PATH] = {0};
LPITEMIDLIST pidlRoot = NULL;
BROWSEINFO bi;
bi.hwndOwner = pParentWnd->m_hWnd;
bi.pidlRoot = NULL;
bi.pszDisplayName = pBuffer;
bi.lpszTitle = sTitle;
bi.ulFlags = BIF_USENEWUI;
bi.lpfn = NULL;
if((pidlRoot = ::SHBrowseForFolder(&bi)) == NULL)
return;
if(::SHGetPathFromIDList(pidlRoot, pBuffer))
Edit.SetWindowText(pBuffer);
if(pidlRoot)
pMalloc->Free(pidlRoot);
}
hi i have created a user control.
now i want to add this control to a page e.g. when the user clicks a button (important is, that i dont want to add it direcly in xaml, i want to add id in the c# code section)
how to so this?
In your button's Click event, you could do something like:
MyControl control = new MyControl();
// Set whatever properties you need in your control here
LayoutRoot.Children.Add(control);
if (listBox1.Items.Count == 0)
{
Popup popup = new Popup();
WPCpopup po = new WPCpopup(popup);
popup.Width = System.Windows.Application.Current.Host.Content.ActualWidth;
popup.Child = po;
popup.VerticalOffset = 300;
popup.IsOpen = true;
}
WPCpopup is usercontrol
I'm trying to figure out how to programatically add a folder to Finder's Places sidebar. I've seen ways to modify it through the Finder Preferences, but I've also seen some applications actually add folders to the sidebar.
If someone has any advice/pointers on what I should look up, it would be greatly appreciated
(This is for Snow Leopard and Leopard... hopefully it didn't change)
Try this:
-(void) addPathToSharedItem:(NSString *)path
{
CFURLRef url = (CFURLRef)[NSURL fileURLWithPath:path];
// Create a reference to the shared file list.
LSSharedFileListRef favoriteItems = LSSharedFileListCreate(NULL,
kLSSharedFileListFavoriteItems, NULL);
if (favoriteItems) {
//Insert an item to the list.
LSSharedFileListItemRef item = LSSharedFileListInsertItemURL(favoriteItems,
kLSSharedFileListItemLast, NULL, NULL,
url, NULL, NULL);
if (item){
CFRelease(item);
}
}
CFRelease(favoriteItems);
}