Dialogues do not close in Vala - gnome

For some reason, dialogue boxes don't close in my program, even though shown by standard dialog.run() call. They show and they return codes, but buttons don't close them. Here's some code with which this happens:
//Inside constructor for my window class
load_dlg = new FileChooserDialog("Select file to open...", this,
FileChooserAction.OPEN,
Gtk.Stock.CANCEL, ResponseType.CANCEL,
Gtk.Stock.OPEN, ResponseType.ACCEPT, null);
//...
//Inside an event handler method
if(load_dlg.run() == Gtk.ResponseType.ACCEPT){
image_backend = new Pixbuf.from_file(load_dlg.get_filename()); // This works, and it's in a try clause.
And everything is fine except that the dialogue just won't close after returning a code. Same with AboutDialog. Everything works just fine in Python, though.

You can just load_dlg.hide() after load_dlg.run() has returned.

Related

Need help in GMS2 pls, trigger works again and save menu opens again, even though it should just close

I've run into this problem.
I have a save menu with two options: "Save" and "Return", which is selected by the option heart. When selecting the "Return" option, the option arrow going back to "Save" even though it should close the save menu(It seems that when menu is closing, the trigger works again and menu opens again, even though it should just close).
The second problem is that when you select the "Save" option, the "File saved" window appears, after which it does not disappear when im pressing "Z" key, and I do not understand what is the reason for these two errors, no matter how I tried to fix them.
It seems that I write the code correctly, but nevertheless it does not work.
Key Press "Z" Event:
if image_index = 0
{
instance_change(obj_saveconfirm, true);
audio_play_sound(snd_save, 10, false);
}
else {
if image_index = 1
{
instance_destroy();
}
}
Code that opens the save menu:
if place_meeting(x, y, obj_player) && keyboard_check_pressed(ord("Z")) && !instance_exists(obj_savemenu) && !instance_exists(obj_saveconfirm)
{
instance_create_depth(x, y, -9999, obj\_savemenu);
}
It seems that I write the code correctly, but nevertheless it does not work.
I also used "keyboard_check_released" in code that opens the save menu, and menu is closing, but after half a second it opens again.

MFC MDI dynamically changing tab style from a property dialog

It has been 10 months since I worked on my app due to a death in the family, just started looking at it again and still not sure how to solve the problem.
The project inquires/help started here:
MFC MDI Collecting control states for the "apply" button routine
Since this is a specific focused question, I didn't want to muck up my other thread, so what I'd like to do is change the documents tab styles after the view is loaded. I know that this can be done because the master repository from Microsoft with all the code examples has a project called VCSamples-master\VCSamples-master\VC2010Samples\MFC\Visual C++ 2008 Feature Pack\TabControl which I have looked at. It dawns on me that even though I can follow its code, the calls are from within the MDI window itself where my issue is I'm trying to do this via a property page dialog using OnApply which changes things.
I was able to do part of this properly with the help of the thread above to the OutputPane successfully because I was able to get the Pane handle and execute. I was told that for the MDI tabs after creation that I need to parse the tabs, count them, and then execute. So my issue here is after I capture the tabs......how to change their styles.
Here is the code as it stands:
BOOL CSettingsUserTabs::OnApply()
{
BOOL bResult = CMFCPropertyPage::OnApply();
if (bResult)
{
// Update Output Pane Tab Styles (Works 100%)
AfxGetApp()->WriteProfileInt(_T("Settings"), _T("UserTabStyle"), m_style_tabs); // Save value to registry
((CMainFrame*)AfxGetMainWnd())->m_wndOutput.m_wndTabs.ModifyTabStyle((CMFCTabCtrl::Style)m_style_tabs);
((CMainFrame*)AfxGetMainWnd())->m_wndOutput.m_wndTabs.RecalcLayout();
//Get the open file tabs in the MDI
for (POSITION pos = AfxGetApp()->GetFirstDocTemplatePosition(); pos != NULL; )
{
CDocTemplate* pTempl = AfxGetApp()->GetNextDocTemplate(pos);
for (POSITION pos1 = pTempl->GetFirstDocPosition(); pos1 != NULL; )
{
CDocument* pDoc = pTempl->GetNextDoc(pos1);
for (POSITION pos2 = pDoc->GetFirstViewPosition(); pos2 != NULL; )
{
CView* pView = pDoc->GetNextView(pos2);
if (pView->IsKindOf(RUNTIME_CLASS(CTrainView)))
{
// THIS IS WHERE MY ISSUE IS, NOW THAT ALL THE TABS ARE
// CAPTURED, HOW DO I ADDRESS THEM LIKE WHAT IS SHOWN
// ABOVE:
//((CMainFrame*)AfxGetMainWnd())->xxxxxx.yyyyyy.ModifyTabStyle((CMFCTabCtrl::Style)m_style_tabs);
}
}
}
}
}
return bResult;
}
If I can figure this last piece out, I'll be basically finished, I just can't seem to find a solution on how to do this via property sheet via OnApply.
Any suggestions or actual code examples I can see to solve my problem?
FYI: No, I haven't had any time to take additional OOP to solve this. I'm hoping someone can provide some guidance so I can move on after getting this sorted.
Thanks,
Chris
EDIT 1:
So I took a closer look at Constantine's suggestion and here is what I came up with:
BOOL CSettingsUserTabs::OnApply()
{
BOOL bResult = CMFCPropertyPage::OnApply();
if (bResult)
{
// Update Output Pane Tab Styles
AfxGetApp()->WriteProfileInt(_T("Settings"), _T("UserTabStyle"), m_style_tabs); // Save value to registry
((CMainFrame*)AfxGetMainWnd())->m_wndOutput.m_wndTabs.ModifyTabStyle((CMFCTabCtrl::Style)m_style_tabs);
((CMainFrame*)AfxGetMainWnd())->m_wndOutput.m_wndTabs.RecalcLayout();
CMFCTabCtrl& MDI_STYLES = ((CMainFrame*)AfxGetMainWnd())->GetMDITabs();
MDI_STYLES.ModifyTabStyle((CMFCTabCtrl::Style)m_style_tabs);
MDI_STYLES.RecalcLayout();
CMDIFrameWndEx* pMainFrame = DYNAMIC_DOWNCAST(CMDIFrameWndEx, GetTopLevelFrame());
pMainFrame->SetFocus();
pMainFrame->RecalcLayout();
}
return bResult;
}
The m_styles_tabs is getting the index value of 0-8 when I select the radio button. The code compiles and runs and I see the index value change when I break on it, but the tabs for the MDI are still not updating. Does the edited code make sense based on the members shown here:
https://learn.microsoft.com/en-us/cpp/mfc/reference/cmfctabctrl-class?view=msvc-170#modifytabstyle
I think this the right direction, am I missing something?

Quitting a GTK popup window properly

I am not sure if there may be a memory leak here - its about quitting a simple popup window in GTK.
if (alertWindow == NULL) {
alertWindow = gtk_window_new(GTK_WINDOW_TOPLEVEL);
alertLabel = gtk_label_new (" wrong input! connection should be either s,S,p or P.\n All other data as floating numbers" );
gtk_container_add(GTK_CONTAINER(alertWindow), alertLabel);
g_signal_connect (alertWindow, "destroy", G_CALLBACK (destroyAlert), NULL); //avslutar applikation
}
and the callback
static void destroyAlert(GtkWidget *widget, gpointer data) {
alertWindow = NULL;
}
I set the alertWindow to NULL so it can be created once again next time the user enters wrong input.
That should not leak memory. The window assumes a reference to the label, so the label will get destroyed and freed with the window. The window will get destroyed and freed when you click on the window title bar's close button (which is the only way to close that window according to the code that you have.)
However, I'd suggest doing it a different way:
GtkWidget *alertWindow = gtk_message_dialog_new(parentWindow,
GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_USE_HEADER_BAR,
GTK_MESSAGE_WARNING, GTK_BUTTONS_CLOSE,
"Wrong input! Connection should be either s, S, p or P.\n"
"All other data as floating point numbers.");
gtk_dialog_run(GTK_DIALOG(alertWindow));
gtk_widget_destroy(alertWindow);
This has a few advantages; first, you get a more full-featured dialog with a friendly button for closing it. Second, you don't have to use a global variable that you then have to worry about whether it is NULL or not. Third, the dialog is modal (the rest of the application is disabled while the dialog is open), which is appropriate for an error message like this.
Even better would be to detect the wrong input as the user types, and use something like a GtkPopover to inform them of what kind of input belongs in each field.

Coded UI: Test cases having recording action are failed while executing through custom code

public void RecordedMethod_Sample(int x)
{
#region Variable Declarations
HtmlCell uISALESREVENUECell = this.UIDashboardWindowsInteWindow1.UIDashboardDocument.UITblWrapperOnlineStorTable.UISALESREVENUECell;
HtmlImage uIImagegifbase64R0lGODImage = this.UIDashboardWindowsInteWindow1.UIDashboardDocument.UIImagegifbase64R0lGODImage;
HtmlHyperlink uIPostPurchase4Hyperlink = this.UISalesRevenueandGrossWindow.UISalesRevenueandGrossDocument.UIPostPurchase4ReturnsCustom.UIPostPurchase4Hyperlink;
HtmlDiv uISalesRevenueByDataSoPane = this.UISalesRevenueandGrossWindow.UISalesRevenueandGrossDocument.UISalesRevenueByDataSoPane;
#endregion
// Set flag to allow play back to continue if non-essential actions fail. (For example, if a mouse hover action fails.)
Playback.PlaybackSettings.ContinueOnError = true;
// Mouse hover 'SALES REVENUE' cell at (82, 27)
Mouse.Hover(uISALESREVENUECell, new Point(82, 27));
// Reset flag to ensure that play back stops if there is an error.
Playback.PlaybackSettings.ContinueOnError = true;
// Click 'image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAA...' image
Mouse.Click(uIImagegifbase64R0lGODImage, new Point(139, 64));
// Set flag to allow play back to continue if non-essential actions fail. (For example, if a mouse hover action fails.)
Playback.PlaybackSettings.ContinueOnError = true;
// Mouse hover 'Post Purchase4' link at (144, 19)
Mouse.Hover(uIPostPurchase4Hyperlink, new Point(144, 19));
// Reset flag to ensure that play back stops if there is an error.
Playback.PlaybackSettings.ContinueOnError = true;
// Move 'Sales Revenue By Data Source' pane
Mouse.StartDragging(uISalesRevenueByDataSoPane, new Point(79, 15));
Mouse.StopDragging(uISalesRevenueByDataSoPane, 224, -4);
string title = uISalesRevenueByDataSoPane.InnerText.ToString();
if (title == "Sales Revenue By Data Source")
{
}
while Executing Mouse.Hover(uISALESREVENUECell, new Point(82, 27)); it is giving
following error
Specified method is not supported.
whenever i try to execute it as test case then everything is working as expected
while executing through custom code it is giving above mentioned error
can anybody please help me out...
thanks in advance for all your inputs
What does "custom code" mean? If it means custom controls then the error is likely because the custom control has not been written to support Coded UI. For a custom control to work with Coded UI it must support MSAA or UIA interfaces, or have support from the newer proxy mechanisms.
For more details try web searching for Coded UI, MSAA and UIA. Also have look at this blog http://blogs.msdn.com/b/visualstudioalm/archive/2012/05/24/coded-ui-test-new-extensibility-qfe.aspx
I had this exact problem.
Your best bet is to use the recorder as much as possible ,and then only move stuff away from UI map when you need dynamic execution and only for those bits.
Let the recorder do all the work for you, and you will get much better reliability during playback.

Hold-Hover drop down menu Delay Time

Im creating a drop down menu and i want to know if there is anyway to implement the following:
I need to keep the sub-menu open for like 1 sec if the user moves the mouse away from the tab he selected. Much likely like in current intel web page www.intel.com , here u hover over menu, but if u take the mouse away from the tab or the sub-menu is opens it takes a few to hide the sub menu.
Im using .mouseover from jquery to show the menu (a div) but i cant find a way to make it stay for a few moments.
Thanks in advance
This may be of service
What is the JavaScript version of sleep()?
If you want to do something in the interim setTimeout() takes the arguments as shown where continue execution is another subroutine. If you just want this one tab to work this way have mouseover call doStuff and set a boolean (e.g. mouseStillIn) to TRUE. When the mouse exits set this boolean to FALSE, call a recursive function everytime mouseStillIn is TRUE.
e.g.
var mouseStillIn : boolean = false;
function MouseIn()
{
mouseStillIn=true;
CheckMouse();
}
function CheckMouse()
{
if(mouseStillIn)
{
setTimeout(CheckMouse, 1000);
}
}
function MouseOut()
{
mouseStillIn=false;
}

Resources