How do you force a screen refresh in GTK 3.8? - c

Found a solution. See below.
I am using GTK 3.8 gtk_grid in a scrolled window. The C code works through a lot of data and displays some in the grid. GTK does not draw the grid until the program finishes processing all data. How do you force GTK 3 to refresh the screen when you add data?
I tried gtk_widget_queue_draw but nothing happens.
I also tested gtk_widget_show_now but nothing happened.
The process might run for a few seconds or many minutes. The user can select the range of data to display and the refresh. The refresh might be every 5 seconds or every 10 rows. I would be happy if either worked.
The only relevant question I can find is on GTK 2 and recommends gtk_widget_queue_draw which does not work. I read all the GTK documentation and that recommends the same function. Something is missing in the documentation, examples, and answers.
From what I can see, I would have to process 100 rows then stop and display a button to request the next 100. This is not viable. The user needs the data scrolling through to the end.
GTK_grid appears to have changed a few times in version 3. I am not locked into GTK_grid if there is a more efficient or effective way to display rows and columns. There is no option to revert to an earlier GTK.
I found something that works in GTK 3.8. Add a line after gtk_widget_queue_draw:
gtk_widget_queue_draw(results);
while (g_main_context_pending(NULL)) {
g_main_context_iteration(NULL,FALSE);
}
Read The Main Event Loop for more details.

Related

React batching commit phase across renders

I've looked far and wide and can't find the answer to this:
Use case is scrolling a mouse wheel to zoom in.
Every time the wheel is moved a notch, an update is issued with a new level of zoom.
If a new setState is called before the previous one is finished and displayed, it will start processing the next call. However, react will not display the results of the previous render on the screen!
So, if i molest the scroll wheel, it will push dozens of render calls before actually showing anything on the screen, causing very poor user experience. (Here's the video: https://youtu.be/YRVK8uoVml0)
I don't know hot to force it to draw each render on screen.
And please, not answers like "You shouldn't be doing that", or "Just fire one update at a time". Only answer if you actually know the answer. Thank you.

How to animate CN1 Slider progress on load

Please can you help me work out how to build a Codenameone Slider control that simply animates its Progress when it renders initially, so the user sees the progress bar increase over the course of a few seconds.
My actual implementation is to use Chen's awesome ArcProgress control to show how far something has grown, so as the control renders the arc is filled to its 70% or so level over a few seconds. I have the image above all built and working so far.
Many thanks
You just need to invoke setValue to indicate the current position. I'm guessing you don't see the progress moving because you're doing the progress on the EDT thus blocking painting.
All paint operations are performed on the EDT thread and so if your loading/processing code runs on that thread (the main thread) you're effectively blocking the paint operations. There's a long discussion of this in the EDT section of the developer guide.

Is there any limitations for oxyplot line graph refresh rate?

I'm plotting two Line Graphs using the Oxyplot Library in a WPF application, which works pretty well. There are a maximum of 8 lines, but for the sake of the test, I'm only using 2.
The program allows the user to choose the refresh rate of the data, which is also used to refresh both Plots. All works as it should, unless when the user choose a Refresh rate under 1 second.
Some seconds after the refresh has been set to under 1 sec, the Plot just vanishes and its area turns blank. A weird fact tho, the Tracker still works if I can find the right spot in the line, i.e. the points of the graph are still there, but it's not been shown anymore. It happens first with one Graph, than some time later the second Graph also turns into a deep white area.
I wonder, is there any limitation for the refresh rate for Line Graphs of the Oxyplot library? I mean, does it use some buffer or cache memory that is probably been blown by the high refresh rate? And yes, I would need it to refresh this fast in some cases.

Loop video file placed in interactive pdf

I have an interactive pdf document that is displayed fullscreen. there's a navigation bar that users can press to jump to different pages.
What I need is some sort of looping screensaver (a collection of photos) that can be enabled by the user pressing a button.
I considered dropping in a video of a slideshow that I made in after effects, until I realised it's not that easy to loop the playback of that video!
How can I loop a video that I have placed onto a page in a pdf? I've read somewhere about swf's looping but I've tried that and there's no loop option when I place the file in acrobat?
Can someone give me some advice as I thought it would be pretty straightforward to loop a video and now it's looking far from easy.
Thanks
If it is just a slide show, meaning changing images at regular intervals, a few things could be done with Acrobat/Reader's on-board means.
In Full Screen, Acrobat allows to cycle through pages every whatever second. A button on those "screensaver" pages would get back to a "real" page. The question is whether that would interfere with the rest of the document.
Another approach would be having a Button field, icon only, read-only, no action, where you would show an image (preferably PDF) as an icon, and have a control loop running (using interval, timeout) loading different icons. This could be implemented with quite little JavaScript.

wpf progress bar slows 10x times serial port communications... how could be possible that?

I know that this could look a dumb question, but here's my problem.
I have a worker dialog that "hides" a backgroundworker, so in a worker thread I do my job, I report the progress in a standard way and then I show the results in my WPF program.
The dialog contains a simply animated gif and a standard wpf progress bar, and when a progress is notified I set Value property. All lokks as usual and works well for any kind of job, like web service calls, db queries, background elaboration and so on.
For my job we use also many "couplers", card readers that reads data from smart card, that are managed with native C code that access to serial port (so, I don't use .NET SerialPort object).
I have some nunit tests and I read a sample card in 10 seconds, but using my actual program, under the backgroundworker and showing my worker dialog, I need 1.30 minutes to do the SAME job.
I struggled into problem for days until I decide to remove the worker dialog, and without dialog I obtain the same performances of the tests!
So I investigated, and It's not the dialog, not the animated gif, but the wpf progress bar!
Simply the fact that a progress bar is shown (so, no animation, no Value set called, nothing of nothing) slows serialport communicatitons.
Looks incredible? I've tested this behavior and it's exactly what happens.
What you describe sounds completely normal. Updating a progress bar's value once is a relatively trivial task, but if your code is performing a large number of operations, then updating the progress bar each time can end up taking much more total time than just the operations would themselves.
If your code performs, say, 10,000 operations, try setting your progress bar's maximimum value to 10, and only update the bar every 1,000 operations.
Another possibility is to set the bar's value using BeginInvoke instead of Invoke (if this is how you're doing it in the first place). Invoke blocks until the invoked method is completed, which means each operation in your loop has to wait for the progress bar to be updated before continuing.
I always use the following code for updating progress bars (has to be run in the UI thread)
private int UpdateCount = 0;
public void UpdateProgress(int value)
{
// We are updating every tenth time.
if (((UpdateCount % 10) == 0)) {
ProgressBar1.Value = value;
}
UpdateCount += 1;
}

Resources