This application is aimed to exemplify the slideshow widget.
It consists of a window with a slideshow widget set as "resize object", along with a control bar, in the form of a notify. Those controls will exercise most of the slideshow's API functions.
We create the slideshow, itself, first, making it loop on its image items, when in slideshow mode:
Next, we define the item class for our slideshow items. Slideshow images are going to be Elementary photo widgets, here, as pointed by our get
class function. We'll let the Elementary infrastructure to delete those objects for us, and, as there's no additional data attached to our slideshow items, the del
class function can be left undefined:
We now get to populate the slideshow widget with items. Our images are going to be some randomly chosen from the Elementary package, nine of them. For the first eight, we insert them ordered in the widget, by using elm_slideshow_item_sorted_insert(). The comparing function will use the image names to sort items. The last item is inserted at the end of the slideshow's items list, with elm_slideshow_item_add(). We check out how that list ends with elm_slideshow_items_get(), than:
Note that we save the pointers to the first and last items in the slideshow, for future use.
What follows is the code creating a notify, to be shown over the slideshow's viewport, with knobs to act on it. We're not showing that boilerplate code, but only the callbacks attached to the interesting smart events of those knobs. The first four are buttons, which will:
Check out the code for those four actions, being the two last data
pointers the same first
and last
pointers we save before, respectively:
What follow are two hoversels, meant for one to change the slideshow's transition and layout styles, respectively. We fetch all the available transition and layout names to populate those widgets and, when one selects any of them, we apply the corresponding setters on the slideshow:
For one to change the transition time on the slideshow widget, we use a spinner widget. We set it to the initial value of 3 (seconds), which will be probed by the next knob – a button starting the slideshow, de facto. Note that changing the transition time while a slideshow is already happening will adjust its transition time:
Finally, we have two buttons which will, respectively, start and stop the slideshow on our widget. Here are their "clicked" callbacks:
This is how the example program's window looks like:
See the full source code for this example.