IconManager

1. Overview

The IconManager module provides icon discovery and image composition for BastionGuard Backup. It initializes icon search paths, resolves theme or packaged icons, creates GTK images and buttons, and applies emblems, overlays, resizing, and transparency.

The implementation is written in Vala and uses GLib/GIO together with the application utility namespaces required by the file.


2. Dependencies and Integration

The module imports:

  • Gtk
  • Gee
  • Cairo
  • TeeJee.Logging
  • TeeJee.FileSystem
  • TeeJee.JsonHelper
  • TeeJee.ProcessHelper
  • TeeJee.GtkHelper
  • TeeJee.System
  • TeeJee.Misc

Key runtime integrations include:

  • GTK – graphical widgets, dialogs, images, event processing, or window lifecycle
  • Gee – typed lists, maps, queues, or collection operations

3. Declared Types

3.1 IconManager

public class IconManager : GLib.Object

This class encapsulates the state and operations described by this source file.


4. State, Properties, Constants, and Signals

Public and protected state

  • public static Gtk.IconTheme theme – GTK/VTE presentation object retained by the component.
  • public static Gee.ArrayList<string> search_paths – Collection storing runtime data for this component.
  • public static bool use_dark – Boolean state controlling or reporting use dark.
  • public const int SHIELD_ICON_SIZE – Compile-time constant used by this module.
  • public const string GENERIC_ICON_IMAGE – Compile-time constant used by this module.
  • public const string GENERIC_ICON_IMAGE_MISSING – Compile-time constant used by this module.
  • public const string GENERIC_ICON_VIDEO – Compile-time constant used by this module.
  • public const string GENERIC_ICON_FILE – Compile-time constant used by this module.
  • public const string GENERIC_ICON_ARCHIVE_FILE – Compile-time constant used by this module.
  • public const string GENERIC_ICON_DIRECTORY – Compile-time constant used by this module.
  • public const string GENERIC_ICON_ISO – Compile-time constant used by this module.
  • public const string GENERIC_ICON_PDF – Compile-time constant used by this module.
  • public const string ICON_HARDDRIVE – Compile-time constant used by this module.
  • public const string SHIELD_LIVE – Compile-time constant used by this module.
  • public const string SHIELD_LOW – Compile-time constant used by this module.
  • public const string SHIELD_MED – Compile-time constant used by this module.
  • public const string SHIELD_HIGH – Compile-time constant used by this module.

5. Public API and Operational Methods

5.1 init()

public static void init(string[] args, string app_name)

Initializes requested value and prepares it for use.

5.2 refresh_icon_theme()

public static void refresh_icon_theme()

Implements the refresh icon theme operation for this module.

  • Interacts with GTK/VTE objects and must execute UI changes on the graphical main context.

5.3 lookup()

public static Gdk.Pixbuf? lookup(string icon_name, int icon_size, bool symbolic = false, bool use_hardcoded = false, int scale = 1)

Resolves an icon from the current GTK theme or configured hardcoded search paths and scales it to the requested logical size.

  • Catches runtime errors locally and reports them through the logging layer or return value.

5.4 lookup_gicon()

public static Gdk.Pixbuf? lookup_gicon(GLib.Icon gicon, int icon_size)

Implements the lookup gicon operation for this module.

5.5 lookup_image()

public static Gtk.Image lookup_image(string icon_name, int icon_size, bool symbolic = false, bool use_hardcoded = false)

Implements the lookup image operation for this module.

  • Interacts with GTK/VTE objects and must execute UI changes on the graphical main context.

5.6 button_from_icon()

public static Gtk.Button button_from_icon(string icon_name, int icon_size, string? tooltip = null)

Implements the button from icon operation for this module.

  • Interacts with GTK/VTE objects and must execute UI changes on the graphical main context.

5.7 lookup_surface()

public static Cairo.Surface? lookup_surface(string icon_name, int icon_size, int scale = 1, bool symbolic = false, bool use_hardcoded = false)

Implements the lookup surface operation for this module.

5.8 add_emblem()

public static Gdk.Pixbuf? add_emblem (Gdk.Pixbuf pixbuf, string icon_name, int emblem_size, bool emblem_symbolic, Gtk.CornerType corner_type)

Creates or appends emblem to the relevant GTK container, collection, or system configuration.

  • Interacts with GTK/VTE objects and must execute UI changes on the graphical main context.

5.9 add_overlay()

public static Gdk.Pixbuf? add_overlay(Gdk.Pixbuf pixbuf_base, Gdk.Pixbuf pixbuf_overlay)

Creates or appends overlay to the relevant GTK container, collection, or system configuration.

5.10 resize_icon()

public static Gdk.Pixbuf? resize_icon(Gdk.Pixbuf pixbuf_image, int icon_size)

Implements the resize icon operation for this module.

5.11 add_transparency()

public static Gdk.Pixbuf? add_transparency (Gdk.Pixbuf pixbuf, int opacity = 130)

Creates or appends transparency to the relevant GTK container, collection, or system configuration.

5.12 load_pixbuf_from_file()

public static Gdk.Pixbuf? load_pixbuf_from_file(string file_path, int icon_size)

Loads pixbuf from file from persistent or system resources.

  • Catches runtime errors locally and reports them through the logging layer or return value.

6. Filesystem Paths and Resource Locations

The source references the following absolute or template paths:

/usr/local/share/%s/images
/usr/local/share/%s/images-dark
/usr/local/share/%s/images-light
/usr/local/share/pixmaps
/usr/share/%s/images
/usr/share/%s/images-dark
/usr/share/%s/images-light
/usr/share/pixmaps

Some values are templates completed at runtime with application names, process IDs, device identifiers, or file names.


7. Operational Flow

  1. Initialize object state, widgets, regular expressions, paths, or generated scripts.
  2. Read or discover source data and normalize it into the module data model.
  3. Apply the requested operation and update runtime or persistent state.

8. Error Handling and Diagnostics

  • GLib and filesystem exceptions are caught locally in the operations that can fail.
  • The TeeJee logging layer records errors, debug state, generated commands, and operational messages.
  • Boolean, nullable, or empty-string return values communicate recoverable failures to callers.

9. Runtime and Security Considerations

  • Shared state: static caches and global switches are shared by all callers and are not automatically thread-isolated.
  • GTK lifecycle: widgets and local main loops require a valid graphical context and careful close/destroy handling.

10. Licensing

The source is distributed under the GNU General Public License version 2 or any later version.

The source header identifies:

Copyright 2012-2018 Tony George &lt;teejeetech@gmail.com&gt;