datastructure behind browsing history - data-structures

Im writing a QML file browser. Now, I want to implement a back and forward function. This function is similar to browser back and forward functionality. Example :
I start in "/home/text/folder1" and browse to "/home/text/folder1/src". Now I browse to "/home/text/folder1/src/java". If I press back twice, I should be at "/home/text/folder1", and I cannot press back anymore (the button should be grayed out or in some other way indicate that there are no more "previous" items to be shown).
I was thinking of implementing this via a double-linked list. However, I am having troubles understanding where I should insert new items to the list, and when I should do it.
Take the previous example :
If instead of pressing back twice, I press back only once (I am now in "/home/text/folder1/src"). If I suddenly go to "/home/text/folder2" , what now? How should my double linked list look now?
This is a datastructure question, and not implementation, so code is not required.

I think your idea using a doubly LinkedList is a good point to start. If you enter a new directory, you add the new item after the current item, discarding the tail of the linked list.
Assume we were in folders 1,2,3 (i.e. we have the list 1->2->[3], square brackets indicating current node). Now we go back twice, resulting in [1]->2->3 if we now go to a new folder 4, we obtain 1->[4], so we have discarded the 2->3 part.

I would have a stack, rather than a list. Every forward navigation puts a link on the stack; every time you go back, you remove the item from the stack.

Related

Keep GtkWidget from destroying when parent does

I'm currently writing a plugin for a GTK+ Software (Pidgin). I haven't worked with GTK before, so I'm only somewhat familiar with how objects work from the documentation.
I'm creating a few thousand buttons with images on them (smileys) and storing them in a doubly linked list. Then, on user request, a portion of these buttons is showed on a dialog, organized in hboxes and vboxes. As soon as the user closes the dialog, it gets destroyed and so do the hboxes, vboxes, buttons and images. But I don't want the buttons and its images to be destroyed since I'm trying to keep them in the doubly linked list to be able to quickly show them again.
What I tried:
Creating extra references to the buttons using g_object_ref() or g_object_ref_sink(). This did not change anything.
Connecting to a "delete" signal which is supposed to be called before finalization. This signal isn't emitted though.
Edit: I also checked the GObject.ref_count field, and it's not going to zero. So that's not the cause of the problem.
I'd be grateful for any hints on how to keep the buttons from being destroyed as efficiently as possible

Representing hierarchy in a mobile app

Normally to represent hierarchy of items (parent-child) we use a tree control.
But on mobile devices it may be inconvenient. I have hardly seen any app that shows tree controls. Is there any alternative UI design that can represent hierarchy?
Thanks.
Regards,
Gautam Jain
First thing that comes to mind would be like a menu. You would see a list of items and every time you click on one, the list would be replaced by the child list. You could use a back button to move back up the levels. This would make it easy to navigate at the disadvantage of not being able to see the whole structure at one time.

Order in the Windows Explorer context menu

How can I change the order of the entries in the context menu?(e.g. for Directories) I need to know how Windows determines the order when showing that so I can control it. For example I want to place my custom action at the end of the context menu list
Thank in advance!
My Google-fu led me to this:
So the sorting is based on the following elements in decision order:
Key priority (eg, txtfile, *, AFSO)
Registry Enumeration order of shellex\contextmenuhandlers with a special case for static verbs always being first
IContextMenu Implementation order
So if there is any contention for position, there is no consistent way for an extension to guarantee their relative position within the menu.
Obviously you can't do anything about phase 1. Phase 3 only applies to the verbs implemented in your handler. That leaves phase 2. The only thing you can do is name your entry under ContextMenuHandlers such that it would be enumerated first, but nothing's stopping someone else from doing the same thing.
This is for Windows 7, maybe same for newer versions. It was inspired by the other answers, all is affecting the order.
I'm explaining entries for "*" (all files), but the same goes for special extensions.
I take no responsibility for any changes made in registry!
There are three sections in the context menu, as it says in How to Change the Order of Options in Context Menu (from answer by #Anonymouse)
They call them:
2 - Default menu position (at the top).
1 - Send to, copy to folder and move to folder menu part (in the middle).
0 - Rename menu part (at the bottom).
Within these sections the position is decided by the rules in answer by #Luke
The easiest way to change the order within the "section" is to change the name of the registry key under HKCR-*-shell or HKCR-*-shellex. All under subkey shell will be before them under shellex. Keys that have the CLSID as the key name will be as last entry since they are last in the used order.
As an example, I was following a sample from MSDN to build a Context Menu Handler
EDIT 2021-04-14:
The MSDN link is no longer valid, it redirects to a "Browse code samples" page. You can search there for Context menu sample, but the one I followed seems to have been removed.
The closest to the old one I followed is perhaps this
The one I followed is using the CLSID as the name for the key under shellex, and a "friendly name" as default value. It was placed at the bottom of "section" 2 (top section). I changed the key name to something like Asample and changed the default value to be the CLSID instead. Now it was directly after entries under shell.
There are some more ways of changing the order.
For keys under shell you can add the value Position with string data Top or Bottom. Not possible to decide in what "section".
For keys under shellex the value Position has no effect. Instead it's possible to decide in what "section" the entry will be using flags, described in the link above.
Use the CLSID for the shellext you want to move. It's like
{XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX}. Get it either from the key name or the default value, it depends on how the entry is done.
Find the entry under HKCR-CLSID, the key has the name of the CLSID.
Add a value with name flags and data DWORD with the "section" number described above under the found CLSID.
This did it for me... Steps 4 through 7 - setting the "flags"
http://techoqueries.blogspot.de/2012/08/how-to-change-order-of-options-in.html
This Q&A shows a simple way to CREATE (not move) an item within the context menu. I managed to duplicate an existing item. Then I moved my item to a higher and more accessible position within the context menu, by renaming the key to start with something "aMyItem" or "0MyItem".
I've been trying to find a way to re-order things, it irritates me that the daily use options are pushed to the end, when obscure utilities you might use once in a blue moon are filling up the top of the list.
I found a lazy way to do this, using a little utility package called "Windows 10 Manager" Windows 10 Manager - it's a few quid, but it's a lot easier than registry hacking. It can't do everything, but it does let you add items into the top section at least - and also to suppress cheeky ones that installed themselves in there without asking.
As you can see, it's actually duplicated some entries rather than moving them, but never mind.

UI icon - should it be A-Z or Z-A when the current list is sorted in ascending order?

I have a "sort by alphabet" icon in the application bar. If the list of items is currently listing:
1
a
b
Then should the icon show what the listing is currently sorted by (A-Z) or what it WILL be sorted by if you press the button (Z-A)?
The only example I can find on the phone is setting the volume to ring or vibrate (If it is set to ring, it shows a bell) but would like more examples / confirmation from people here.
If it's clear how the list is currently sorted by looking at it then I'd recommend displaying what the list will be changed to by pressing the button.
If the list can be sorted in any ways other than just ascending or descending alphabetical order you will probably need a button for setting each of the sort orders.
If it's not clear how the list is sorted by looking at it then this indicator should be separate.
Overall I'd question the value of having this sorting functionality. If you have a long list I'd use the LongListSelector from the Toolkit and then always have it sorted A-Z. This will simplify your UI (by not requiring a button to change the sort order) and will require less code.
If the button is closely associated visually with the list, like a column header is with a column in a grid, then I would say you could show what the current state is just like headers in columns of grids tend to do that offer this capability.
In this case, whichever way you do it, I would say the user would adapt fairly quickly by looking at the list to see how it works. There will be some who initially expect one way, and some the other I expect. Arguably there isn't a correct way to do it. It's a good idea to look at what other apps on the platform are doing, but there may not really be much to go on just yet.
The visual cue in this case is the tight visual association of the list and the button, suggesting to me that that button reflects the lists current state and that you can press to change it.
If however you had some form of a label that the button was associated visually to, then that button's text could provide the necessary context and your decision could be driven by that. For example your label could read "change sort to" or it could read "current sort is". This probably offers the most clarity, alleviating unsure users of the need to press the button a couple of times to learn how it works, but comes at the expense of valuable screen real estate.
If you walk into a hotel and your room number is 301, you want to go to the 3rd floor.
So you step inside the elevator and press the '3rd floor' button.
Therefore I think buttons should always show possible options, not the current state (i.e. ground floor).
So I think the button should show 'Z-A'.

Inno Setup jump to specified wizard page

Is there a way to jump to the specified wizard page? Backward and forward?
For example, I would add "Configure again" button in the wpReady, and when the button is clicked, I want to jump to wpInfoBefore.
You can't, at least not sanely. It's possible to fake mouseclicks on the Back/Next buttons, and use ShouldSkipPage, which would get you the desired effect, but it's very bad practice and potentially fragile.
If the user has made a mistake in the previous pages, then they should just go back however many pages are actually required (which might not be the full complement) and fix it. This is especially important when the contents of one page are dependent on the selections made on an earlier page, as jumping back too far would typically result in some of the user's choices being discarded.

Resources