src/applet.c
static void trash_applet_init(TrashApplet *self) {
    // Create our 'private' struct
    self->priv = trash_applet_get_instance_private(self);
    self->priv->trash_count = 0;
    self->priv->mounts = g_hash_table_new(g_str_hash, g_str_equal);
    self->priv->settings = g_settings_new(TRASH_SETTINGS_SCHEMA_ID);
    g_signal_connect_object(self->priv->settings, "changed", G_CALLBACK(trash_handle_setting_changed), self, 0);

    // Load our CSS
    GtkCssProvider *provider = gtk_css_provider_new();
    gtk_css_provider_load_from_resource(provider, "/com/github/EbonJaeger/budgie-trash-applet/style.css");
    gtk_style_context_add_provider_for_screen(gdk_screen_get_default(),
                                              GTK_STYLE_PROVIDER(provider),
                                              GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);

    // Create our panel widget
    self->priv->icon_button = trash_icon_button_new();
    g_signal_connect_object(GTK_BUTTON(self->priv->icon_button), "clicked", G_CALLBACK(trash_toggle_popover), self, 0);
    gtk_container_add(GTK_CONTAINER(self), GTK_WIDGET(self->priv->icon_button));

    // Create our popover widget
    self->priv->popover = budgie_popover_new(GTK_WIDGET(self->priv->icon_button));

    self->priv->stack = gtk_stack_new();
    gtk_stack_set_transition_type(GTK_STACK(self->priv->stack), GTK_STACK_TRANSITION_TYPE_SLIDE_LEFT_RIGHT);

    TrashSortMode sort_mode = g_settings_get_enum(self->priv->settings, TRASH_SETTINGS_KEY_SORT_MODE);
    GtkWidget *main_view = trash_create_main_view(self, sort_mode);
    gtk_widget_set_size_request(main_view, 300, -1);
    gtk_stack_add_named(GTK_STACK(self->priv->stack), main_view, "main");

    TrashSettings *settings_view = trash_settings_new();
    gtk_stack_add_named(GTK_STACK(self->priv->stack), GTK_WIDGET(settings_view), "settings");
    g_signal_connect_object(settings_view, "return-clicked", G_CALLBACK(trash_handle_return), self, 0);

    gtk_stack_set_visible_child_name(GTK_STACK(self->priv->stack), "main");
    gtk_widget_show_all(GTK_WIDGET(self->priv->stack));

    gtk_container_add(GTK_CONTAINER(self->priv->popover), self->priv->stack);
    gtk_widget_show_all(GTK_WIDGET(self));

    // Register notifications
    notify_init("com.github.EbonJaeger.budgie-trash-applet");

    // Setup our volume monitor to get trashbins for
    // removable drives
    self->priv->uid = getuid();
    self->priv->volume_monitor = g_volume_monitor_get();
    g_autoptr(GList) mounts = g_volume_monitor_get_mounts(self->priv->volume_monitor);
    g_list_foreach(mounts, (GFunc) trash_add_mount, self);

    g_signal_connect_object(self->priv->volume_monitor, "mount-added", G_CALLBACK(trash_handle_mount_added), self, G_CONNECT_AFTER);
    g_signal_connect_object(self->priv->volume_monitor, "mount-removed", G_CALLBACK(trash_handle_mount_removed), self, G_CONNECT_AFTER);

    // Setup drag and drop to trash files
    gtk_drag_dest_set(GTK_WIDGET(self),
                      GTK_DEST_DEFAULT_ALL,
                      gtk_target_entry_new("text/uri-list", 0, 0),
                      1,
                      GDK_ACTION_COPY);

    g_signal_connect_object(self, "drag-data-received", G_CALLBACK(trash_drag_data_received), self, 0);
}
/**
 * Initialization of basic UI elements and loads our CSS
 * style stuff.
 */
Initialization of basic UI elements and loads our CSS
style stuff.
Initialization of basic UI elements and loads our CSS style stuff .
static void trash_applet_init(TrashApplet *self) {
    self->priv = trash_applet_get_instance_private(self);
    self->priv->trash_count = 0;
    self->priv->mounts = g_hash_table_new(g_str_hash, g_str_equal);
    self->priv->settings = g_settings_new(TRASH_SETTINGS_SCHEMA_ID);
    g_signal_connect_object(self->priv->settings, "changed", G_CALLBACK(trash_handle_setting_changed), self, 0);
    GtkCssProvider *provider = gtk_css_provider_new();
    gtk_css_provider_load_from_resource(provider, "/com/github/EbonJaeger/budgie-trash-applet/style.css");
    gtk_style_context_add_provider_for_screen(gdk_screen_get_default(),
                                              GTK_STYLE_PROVIDER(provider),
                                              GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
    self->priv->icon_button = trash_icon_button_new();
    g_signal_connect_object(GTK_BUTTON(self->priv->icon_button), "clicked", G_CALLBACK(trash_toggle_popover), self, 0);
    gtk_container_add(GTK_CONTAINER(self), GTK_WIDGET(self->priv->icon_button));
    self->priv->popover = budgie_popover_new(GTK_WIDGET(self->priv->icon_button));
    self->priv->stack = gtk_stack_new();
    gtk_stack_set_transition_type(GTK_STACK(self->priv->stack), GTK_STACK_TRANSITION_TYPE_SLIDE_LEFT_RIGHT);
    TrashSortMode sort_mode = g_settings_get_enum(self->priv->settings, TRASH_SETTINGS_KEY_SORT_MODE);
    GtkWidget *main_view = trash_create_main_view(self, sort_mode);
    gtk_widget_set_size_request(main_view, 300, -1);
    gtk_stack_add_named(GTK_STACK(self->priv->stack), main_view, "main");
    TrashSettings *settings_view = trash_settings_new();
    gtk_stack_add_named(GTK_STACK(self->priv->stack), GTK_WIDGET(settings_view), "settings");
    g_signal_connect_object(settings_view, "return-clicked", G_CALLBACK(trash_handle_return), self, 0);
    gtk_stack_set_visible_child_name(GTK_STACK(self->priv->stack), "main");
    gtk_widget_show_all(GTK_WIDGET(self->priv->stack));
    gtk_container_add(GTK_CONTAINER(self->priv->popover), self->priv->stack);
    gtk_widget_show_all(GTK_WIDGET(self));
    notify_init("com.github.EbonJaeger.budgie-trash-applet");
    self->priv->uid = getuid();
    self->priv->volume_monitor = g_volume_monitor_get();
    g_autoptr(GList) mounts = g_volume_monitor_get_mounts(self->priv->volume_monitor);
    g_list_foreach(mounts, (GFunc) trash_add_mount, self);
    g_signal_connect_object(self->priv->volume_monitor, "mount-added", G_CALLBACK(trash_handle_mount_added), self, G_CONNECT_AFTER);
    g_signal_connect_object(self->priv->volume_monitor, "mount-removed", G_CALLBACK(trash_handle_mount_removed), self, G_CONNECT_AFTER);
    gtk_drag_dest_set(GTK_WIDGET(self),
                      GTK_DEST_DEFAULT_ALL,
                      gtk_target_entry_new("text/uri-list", 0, 0),
                      1,
                      GDK_ACTION_COPY);
    g_signal_connect_object(self, "drag-data-received", G_CALLBACK(trash_drag_data_received), self, 0);
}
static void trash_applet_init ( TrashApplet * self ) { self -> priv = trash_applet_get_instance_private ( self ) ; self -> priv -> trash_count = 0 ; self -> priv -> mounts = g_hash_table_new ( g_str_hash , g_str_equal ) ; self -> priv -> settings = g_settings_new ( TRASH_SETTINGS_SCHEMA_ID ) ; g_signal_connect_object ( self -> priv -> settings , " " , G_CALLBACK ( trash_handle_setting_changed ) , self , 0 ) ; GtkCssProvider * provider = gtk_css_provider_new ( ) ; gtk_css_provider_load_from_resource ( provider , " " ) ; gtk_style_context_add_provider_for_screen ( gdk_screen_get_default ( ) , GTK_STYLE_PROVIDER ( provider ) , GTK_STYLE_PROVIDER_PRIORITY_APPLICATION ) ; self -> priv -> icon_button = trash_icon_button_new ( ) ; g_signal_connect_object ( GTK_BUTTON ( self -> priv -> icon_button ) , " " , G_CALLBACK ( trash_toggle_popover ) , self , 0 ) ; gtk_container_add ( GTK_CONTAINER ( self ) , GTK_WIDGET ( self -> priv -> icon_button ) ) ; self -> priv -> popover = budgie_popover_new ( GTK_WIDGET ( self -> priv -> icon_button ) ) ; self -> priv -> stack = gtk_stack_new ( ) ; gtk_stack_set_transition_type ( GTK_STACK ( self -> priv -> stack ) , GTK_STACK_TRANSITION_TYPE_SLIDE_LEFT_RIGHT ) ; TrashSortMode sort_mode = g_settings_get_enum ( self -> priv -> settings , TRASH_SETTINGS_KEY_SORT_MODE ) ; GtkWidget * main_view = trash_create_main_view ( self , sort_mode ) ; gtk_widget_set_size_request ( main_view , 300 , -1 ) ; gtk_stack_add_named ( GTK_STACK ( self -> priv -> stack ) , main_view , " " ) ; TrashSettings * settings_view = trash_settings_new ( ) ; gtk_stack_add_named ( GTK_STACK ( self -> priv -> stack ) , GTK_WIDGET ( settings_view ) , " " ) ; g_signal_connect_object ( settings_view , " " , G_CALLBACK ( trash_handle_return ) , self , 0 ) ; gtk_stack_set_visible_child_name ( GTK_STACK ( self -> priv -> stack ) , " " ) ; gtk_widget_show_all ( GTK_WIDGET ( self -> priv -> stack ) ) ; gtk_container_add ( GTK_CONTAINER ( self -> priv -> popover ) , self -> priv -> stack ) ; gtk_widget_show_all ( GTK_WIDGET ( self ) ) ; notify_init ( " " ) ; self -> priv -> uid = getuid ( ) ; self -> priv -> volume_monitor = g_volume_monitor_get ( ) ; g_autoptr ( GList ) mounts = g_volume_monitor_get_mounts ( self -> priv -> volume_monitor ) ; g_list_foreach ( mounts , ( GFunc ) trash_add_mount , self ) ; g_signal_connect_object ( self -> priv -> volume_monitor , " " , G_CALLBACK ( trash_handle_mount_added ) , self , G_CONNECT_AFTER ) ; g_signal_connect_object ( self -> priv -> volume_monitor , " " , G_CALLBACK ( trash_handle_mount_removed ) , self , G_CONNECT_AFTER ) ; gtk_drag_dest_set ( GTK_WIDGET ( self ) , GTK_DEST_DEFAULT_ALL , gtk_target_entry_new ( " " , 0 , 0 ) , 1 , GDK_ACTION_COPY ) ; g_signal_connect_object ( self , " " , G_CALLBACK ( trash_drag_data_received ) , self , 0 ) ; }
Initialization of basic UI elements and loads our CSS
 style stuff.
Initialization of basic UI elements and loads our CSS style stuff .
// Create our 'private' struct // Load our CSS // Create our panel widget // Create our popover widget // Register notifications // Setup our volume monitor to get trashbins for // removable drives // Setup drag and drop to trash files