Herdentrieb

Mastodon - get hype

Warnung

Dieser Beitrag wird bedarfs- und kapazitätsabhängig aktualisiert. Da sich Mastodon in massiver, aktiver Entwicklung befindet, können Teile des Inhaltes veraltet sein.

Was bisher geschah

Mastodon ist ein freies, verteiltes soziales Netzwerk und gleichzeitig der Name dessen Server-Komponente. Ein Mastodon-Server innhalb des gesamten Netzwerkes (Fediverse) ist eine Instanz. Die Nutzung lehnt sich im Wesentlichen an Twitter an: ein Post (Toot, dt. Tröt) enthält bis zu 500 Zeichen, die wiederum favorisiert und erneut geteilt (Boost) werden können, es gibt das Follower-Prinzip und diverse Timelines (Nutzer, lokal, öffentlich).

Was passiert gerade?

Ein junges, Open-Source-Netzwerk zieht naturgemäß primär technikaffines Volk an, gefolgt von den üblichen Early Adopter-Kandidaten. Das führt derzeit in eine inhaltliche Mischung aus Tech-Themen, darunter viel, was sich um Mastodon selbst dreht, Rollenspiele, Manga, Furries, NSFW-Content und lahme SJW-Ansprachen.

Wer bis jetzt noch nicht abgeschreckt ist, fragt sich:

Welche Instanz ist die richtige für mich?

Da prinzipbedingt jeder einen Mastodon-Server betreiben kann, tun dies auch viele. So explodiert aktuell die Zahl der Instanzen. Aber es ist eben auch damit zu rechnen, dass die Mehrheit nur kurzfristig aus Experimentierfreude existieren wird. Verschwindet eine Instanz, verschwinden auch alle Accounts (und deren Inhalte) in dieser.

Ein weiterer Punkt ist die Ausrichtung der Instanz, sei sie themenbezogen (Spaß/Memes/Aktivismus/Tech) oder lokal/landessprachlich oder der Grad an Moderation.

Hier zeichnet sich gerade eine Art Sortierungsbewegung ab: Benutzer migrieren zu Instanzen, die eher ihren Interessen bzw. ihrem Umfeld entsprechen.

Bisher ist es nicht möglich, die lokale Timeline einer Instanz ohne Registrierung anzusehen und man hier nahezu die Katze im Sack kauft. Jüngst gibt es aber Abhilfe unter

Wenn man also nicht genau eine Instanz favorisiert, weil sie thematisch passt oder man dort schon Nutzer kennt, sucht man sich am besten eine größere, allgemeine Instanz aus, bei der eine größere Chance besteht, die erste Euphoriewelle zu überleben.

Wichtiger Hinweis

Accounts können zur Zeit nicht gelöscht werden. Auch können Accounts nicht in andere Instanzen migriert werden. Es ist zwar möglich, eine Liste der Accounts, denen man selbst folgt, zu exportieren und in neue Accounts zu importieren, dies funktioniert aber nicht für Follower.

Okay, ich bin dabei, was muss ich tun?

Hashtags

Tags sind die (aktuell) beste Art, bei Mastodon nach Stichwörtern zu suchen. Entweder sucht man direkt in der Suchleiste in der linken Spalte oder man ruft die URL <instance>/tags/<tag> auf. In den Suchergebnissen werden auch Beiträge anderer Instanzen angezeigt, dies erfolgt aber nicht kongruent, man vergleiche beispielsweise den Tag #bicycle auf

User-Feed

Für jeden Nutzer wird ein Atom-Feed bereitgestellt. Leider gibt es dies nicht für Tags.

Klingt irgendwie nicht nach dem großen Twitter-Killer

Korrekt, ist es möglicherweise auch nicht. Man merkt dem Projekt definitiv an, dass es noch in den Kinderschuhen steckt. Es ist recht aufwändig, sich nach Inhalten und Usern umzusehen.

Das erinnert mich ein wenig an den "Facebook-Killer" Google+, als soziales Netzwerk hat es seine Nische gefunden, aber gerade große Medien, Blogger und die egomane Twitter-"Elite" haben die Funktionsweise von G+ nie verstanden (und wollten das auch größtenteils nicht). Damit will ich die Versäumnisse und das akkurate und stete Verschlimmbessern der Plattform seitens Google in keiner Weise in Schutz nehmen.

BeeLine - first impressions

Tech stuff

BeeLine

The intern battery is supposed to last at least 30 hours of usage. The E-Ink display is weather resistant, energy saving and readable at sunlight, with a shiftable LED for riding the dark. The device has four touch buttons to access some functionalities, everything else is done via app.

App

/images/BeeLine/app_main.thumbnail.png

App: Select destination

After logging into the BeeLine account and pairing the device via Bluetooth you are ready to start. Choose "Where to?" and point on a destination on the map. Then press the yellow "BeeLine" button. Another option is choosing a destination ("Destinations") which can be saved and retrieved again. Destinations with additional waypoints can be saved as route.

The app also possesses the BeeLine compass view so it ia also possible to navigate without the dedicated device.

/images/BeeLine/app_compass.thumbnail.png

App: Compass view

Bike

The device is mounted to the various parts of the bicycle by the rubber band being part of the BeeLine case. The orientation can be turned by 90° by the app so mount points could be the handlebar, stem or top tube.

/images/BeeLine/mount.thumbnail.jpg

BeeLine mounted to stem

The mounting using the rubber band appears quite flexible, stable and trustworthy.

Are we there yet?

BeeLine now points to the destination, the shown distance just being linear distance or, well...beeline.

/images/BeeLine/app_map.thumbnail.jpg

App: current location and destination

Watching the compass needle pointing the destination actually piqued my curiosity to shorten my ride. That didn't work out for me on the first try but at least I know now this exists in Berlin Treptow:

/images/BeeLine/unicorn.thumbnail.jpg

Unicorn street

The navigation is ended via app and not by reaching the destination. The ride is saved.

/images/BeeLine/app_route.thumbnail.png

App: saved routes

Room for improvement

Waypoints

It is possible to switch between waypoints but it is not obvious which one is currently displayed. Also it seems waypoints can be scrolled through forward. (need to figure out more on this)

Accidentally finishing ride

This happened to me twice now. The ride was ended and the route wasn't saved. This possibly is more than just a handling error. (need to figure out more on this)

Handling

There are four touch buttons on the device but the functions bound to the buttons are not apparent.

Import routes

The app is able to save routes so it might be feasable to also import routes. A killer feature for me was an alternatve navigation mode guiding by given routes. That would make the BeeLine a good looking Garmin replacement, a Swiss navi knife.

Pros and Cons

Pro Contra
easy mounting material fatigue of the rubber of the mounting case, spare parts shall be available in the future
long lasting battery does not work without app
minimalistic navigation minimalistic navigation
pleasant design value for money (115 Euro)
legible display  
not distracting while riding  
explore new ways  

File chooser dialog

FileChooserDialog

The GtkFileChooserDialog is a subclass of GtkDialog (see diaogue article) and provides opening and saving of files and folders.

/images/16_fcd.thumbnail.png

Glade

The dialog can be added from the "Toplevel" section of the widget sidebar. In addition to the file browser itself the widget has an intern GtkBox for additional widgets and a GtkButtonBox as "action area" for buttons.

First the Gtk.FileChooserAction mode must be defined (see Python GI API Reference): open or save file, choose or create a folder.

Action area and Responses

The response signal is emitted on widget interaction in the action area which also passes the response value. So for these widgets there is no need to activate the clicked signal of buttons.

By default the "action area" is generated beneath the file browser area.

/images/16_fcd_glade.thumbnail.png

If the FileChooserDialog is used without Glade (see below) the buttons are created in the headerbar. This seems to be standard procedure because Glade generated dialogs induce the warning

Gtk-WARNING **: Content added to the action area of a dialog using header bars

This message is not shown if buttons are not added to the intern action area.

If a headerbar with buttons is created in Glade the buttons cannot be assigned to a response value.

There may be several solutions to the problem:

XML file

After creating a headerbar with button(s) the Glade file is opened in a text editor and add line(s) to the <action-widgets> element:

<object class="GtkFileChooserDialog" id="filechooser_dialog">
  <property ... ></property>
  <property ... ></property>
  <!-- ... -->
  <action-widgets>
    <!-- Buttons innerhalb der action area -->
    <action-widget response="0">button1</action-widget>
    <action-widget response="1">button2</action-widget>
    <!-- Button in Headerbar -->
    <action-widget response="-1">hb_button</action-widget>
  </action-widgets>
  <!-- ... -->
</object>

This works but this procedure is surely not the intended way to deal with the problem because after altering the Glade file the edit is retracted.

add_action_widget function

The add_action_widget adds activatable widgets to the action area and hold a response value. This includes widgets of the Gtk.Activatable class: Buttons, MenuItem, RecentChooserMenu, Switch and ToolItem.

The scheme for creating a button is

widget.add_action_widget(button,response)

The widget property "can-default" of the button must be activated:

button.set_property("can-default",True)

In the example the standard buttons "apply/cancel" are added to the file dialog:

button = Gtk.Button.new_from_stock(Gtk.STOCK_CANCEL)
button.set_property("can-default",True)
self.obj("filechooser_dialog").add_action_widget(button, Gtk.ResponseType.CANCEL)
button = Gtk.Button.new_from_stock(Gtk.STOCK_APPLY)
button.set_property("can-default",True)
self.obj("filechooser_dialog").add_action_widget(button, Gtk.ResponseType.OK)

To apply file selection on doubleclick the file-activated is also required in addition to the response signal.

Preview widget

The dialogue can contain an optional preview widget. To use it activate "Preview Widget Active" and choose a free widget (p.e. a GtkImage). It may be necessary to create the preview widget in an empty container widget and pull it into a free area.

If the preview requires a refresh the update-preview signal is emitted.

FileFilter

Files can be filtered according to certain criteria by using FileFilter. There can be defined several (shell style glob) patterns or MIME-types for each filter.

In Glade filters can be found in the widget sidebar in the "Miscellaneous" group. A filter for a dialog can be selected in the general widget properties. This corresponds to the set_filter function.

Python

Dialog without Glade

The FileChooserDialog is a complex but also easy to use graphic interface item. Realizing the dialog without Glade also avoids the headerbar problem discussed above. Creating a dialog follows the scheme

dialog = Gtk.FileChooserDialog("window title",
                               parent_window,
                               file_chooser_action,
                               (button1,response1,
                               button2,response2))

The dialog then can be directly run and processed:

response = dialog.run()
if response == response1:
    ...
elif response == response2:
    ...
dialog.destroy()

FileFilter

There are two possibilities to apply a FileFilter:

  1. No user choice. The applied filter is preset:
dialog.set_filter(filter)
  1. Selection per dropdown menu. The user can choose between different defined filters:
dialog.add_filter(filter1)
dialog.add_filter(filter2)
...

Read more…

Desktop integration

Desktop integration: icon, headerbar, commndline options

(Continuation if the GtkApplication article)

/images/15_application.thumbnail.png

Glade

Icon

To assign an icon to an window just select "General Appearance > Icon File". Problematic here is that Glade only shows image files located in the same folder as the Glade file even if an image from another folder is chosen.

A simple solution is editing the Glade file in a text editor and add the relative path to the icon. This edit is preserved even when changing and saving the file with Glade again:

<object class="GtkApplicationWindow" id="window">
  ...
  <!-- <property name="icon">duckyou.svg</property> -->
  <property name="icon">../files/duckyou.svg</property>
  ...

Headerbar

Headerbars were introduced in GNOME 3.10 and unite titlebar and toolbar. Besides title and subtitle there is room for widgets such as buttons or menus and client side window controls.

A headerbar is optional. To make use of it "General > Appearance > Client side window decorations" has to be activated if not set yet. This prepares a reserved container area in the upper window area to add the headerbar widget in. If a headerbar is placed out of this specific area a regular titlebar is generated in addition to the headerbar.

/images/15_headerbarglade.png

Commandline options

GtkApplication provides functions to define individual commandline options of the applications (Handling command line options in GApplication).

Create Options

Options are added by the add_main_option_entries(entrylist) function. The entries must be GLib.OptionEntry formatted which requires a bunch of parameters.

def __init__(self):
    self.app = Gtk.Application.new("org.application.test", Gio.ApplicationFlags(0))
    self.app.add_main_option_entries([
        self.create_option_entry("--version", description="Show version numbers and exit"),
        self.create_option_entry("--setlabel", description="Set label widget", arg=GLib.OptionArg.STRING,),
        self.create_option_entry("--bollocks", description="Additional test option - exit"),
    ])

def create_option_entry(self,
                        long_name,
                        short_name=None,
                        flags=0,
                        arg=GLib.OptionArg.NONE,
                        arg_data=None,
                        description=None,
                        arg_description=None):
    option = GLib.OptionEntry()
    option.long_name = long_name.lstrip('-')
    option.short_name = 0 if not short_name else ord(short_name.lstrip('-'))
    option.flags = flags
    option.arg = arg
    option.arg_data = arg_data
    option.description = description
    option.arg_description = arg_description
    return option

Short names

An option can have a one character synonym ("a printable ASCII character different from ‘-‘" to be precise), the short name. Lokking at the option --help this commonly is -h.

The short_name variable of OptionEntry ist surprisingly integer. The not very obvious solution here is to pass the character's decimal code, p.e. 97 for "a". An error message will be thrown when trying to pass invalid numbers. Options without a short code get a value of 0.

Connect signal

The "handle-local-options" signal of Gtk.Application handles commandline options. If the signal is connected the signal is emitted before the "startup" signal.

self.app.connect("handle-local-options", self.on_local_option)

Processing options

The option will be passed as an element of the GLib.VariantDict class which can be searched for by calling contains("option"):

def on_local_option(self, app, option):
    if option.contains("option1"):
        #do something and exit normally
        return 0
    elif option.contains("option2"):
        #do something different and exit
        return 0
    elif option.contains("option3"):
        #do more and continue
    return -1

A string can be extracted by calling end() which converts GLib.VariantDict to a GLib.Variant element. That GLib.Variant then can be culled by calling keys():

var = GLib.VariantDict.end(option)
option_string = var[var.keys()[0]]

The handler function demands a return value that corresponds to the exit status:

  • -1: application execution will be continued
  • 0: execution successful, application will be quit, "startup/activate" will not be emitted
  • 1 or positive value: execution was not successful, application will be quit

Run application with options

The option --help is always available and lists all defined options of the application and their descriptions.

The options of the example file now can be executed:

$ python script.py --version
Python: 3.6.0
GTK+:   3.22.6

or pass a string to the application's Gtk.Label:

$ python script.py --setlabel "I can haz options!"

Read more…

Stand-alone

Run program as GtkApplication

GtkApplication handles different important aspects of a GTK+ application like GTK+ initialization, session management and desktop integration.

/images/14_application.thumbnail.png

XML files

Glade

Glade is used as usual, main windows should be **GtkApplicationWindows*. As example the file from the dialogue article is reused.

System Message: WARNING/2 (<string>, line 17); backlink

Inline strong start-string without end-string.

GMenu

The GNOME Shell supports appmenus residing in the (top) panel. The Gmenu XML file must be formatted to be recognized as GioMenu:

<?xml version="1.0"?>
<interface>
 <menu id="appmenu">
    <section>
      <item>
        <attribute name="label" translatable="yes">Menu Item</attribute>
        <attribute name="action">app.item</attribute>
      </item>
    </section>
  </menu>
</interface>

Glade identifies this file format as an outdated Glade file and refuses to open it. Apart from that GtkBuilder can handle the menu and address identifiers.

Python

Initialize GtkApplication

The initialization process requires the parameters application_id and flags. Flags can normally set to 0 being the same as FLAGS_NONE (see Gio.ApplicationFlags), naming conventions for application_id are listed here.

The application can be connected to different signals being emitted on preassigned events. It is mandatory to at least define an activate signal:

def __init__(self):

    self.app = Gtk.Application.new("org.application.test", 0)
    #self.app.connect("startup", self.on_app_startup) #optional
    self.app.connect("activate", self.on_app_activate)
    #self.app.connect("shutdown", self.on_app_shutdown) #optional

def on_app_activate(self, app):

    #setting up GtkBuilder etc.
    ...
    ...
    ...

Appmenu

GMenu XML files are loaded by GtkBuilder:

builder.add_from_file("menu.ui")
app.set_app_menu(builder.get_object("appmenu"))

Menu entries now have to be connected to actions which are created as GioSimpleActions:

def add_simple_action(self, name, callback):
    action = Gio.SimpleAction.new(name)
    action.connect("activate", callback)
    self.app.add_action(action)

In the example file actions invokes dialog windows.

Start and quit

GtkApplication takes over the handling of the GTK+ mainloop so there is no need of starting and quitting GTK+ manually and run() and quit() called instead:

Gtk.main()      ->  app.run(argv)
Gtk.main_quit() ->  app.quit()

If the application is quit by the [X] button or the "Quit" appmenu entry the "shutdown" signal is emitted (see above) and the program is terminated. That means there is no need to define these signals like in previous examples using GtkWindow. The "shutdown" also works even if the signal is not explicitly connected to a function during the initialization process.