/**
 * construct_workspaces:
 * @plugin: the xfce plugin object
 *
 * Create the plugin.
 *
 * Returns: the plugin
 */
static i3WorkspacesPlugin *
construct_workspaces(XfcePanelPlugin *plugin)
{
    i3WorkspacesPlugin *i3_workspaces;
    GtkOrientation orientation;

    /* allocate memory for the plugin structure */
    i3_workspaces = panel_slice_new0(i3WorkspacesPlugin);

    /* pointer to plugin */
    i3_workspaces->plugin = plugin;

    /* plugin configuration */
    i3_workspaces->config = i3_workspaces_config_new();
    i3_workspaces_config_load(i3_workspaces->config, plugin);

    /* get the current orientation */
    orientation = xfce_panel_plugin_get_orientation (plugin);

    /* create some panel widgets */
    i3_workspaces->ebox = gtk_event_box_new();
    gtk_widget_show(i3_workspaces->ebox);

    /* listen for scroll events */
    gtk_widget_add_events(i3_workspaces->ebox, GDK_SCROLL_MASK);
    g_signal_connect(G_OBJECT(i3_workspaces->ebox), "scroll-event",
            G_CALLBACK(on_workspace_scrolled), i3_workspaces);

    i3_workspaces->hvbox = xfce_hvbox_new(orientation, FALSE, 2);
    gtk_widget_show(i3_workspaces->hvbox);
    gtk_container_add(GTK_CONTAINER(i3_workspaces->ebox), i3_workspaces->hvbox);

    i3_workspaces->workspace_buttons = g_hash_table_new(g_direct_hash, g_direct_equal);

    GError *err = NULL;
    i3_workspaces->i3wm = i3wm_construct(&err);
    if (NULL != err)
    {
        //TODO: error_state_on();
        recover_from_disconnect(i3_workspaces);
        //TODO: error_state_off();
    }

    connect_callbacks(i3_workspaces);

    add_workspaces(i3_workspaces);

    return i3_workspaces;
}
static void
on_ipc_shutdown(gpointer i3_w)
{
    i3WorkspacesPlugin *i3_workspaces = (i3WorkspacesPlugin *) i3_w;

    remove_workspaces(i3_workspaces);
    i3wm_destruct(i3_workspaces->i3wm);
    i3_workspaces->i3wm = NULL;

    recover_from_disconnect(i3_workspaces);

    connect_callbacks(i3_workspaces);

    add_workspaces(i3_workspaces);
}