TeplAbstractFactory: libgedit-tepl 6 Reference Manual

## TeplAbstractFactory TeplAbstractFactory — Abstract factory singleton class |

## Functions

void | tepl_abstract_factory_set_singleton ()
TeplAbstractFactory * | tepl_abstract_factory_get_singleton ()
GtkApplicationWindow * | tepl_abstract_factory_create_main_window ()
TeplTab * | tepl_abstract_factory_create_tab ()
GtkWidget * | tepl_abstract_factory_create_tab_label ()
TeplFile * | tepl_abstract_factory_create_file ()
GFile * | tepl_abstract_factory_create_metadata_manager_file ()
void | tepl_abstract_factory_fill_prefs_dialog ()

## Types and Values

struct | TeplAbstractFactory
struct | TeplAbstractFactoryClass

## Object Hierarchy

        GObject
        ╰── TeplAbstractFactory

## Includes

    #include <tepl/tepl.h>

## Description

Tepl uses the TeplAbstractFactory singleton to create some objects and widgets. By creating a subclass of TeplAbstractFactory (to override the desired virtual functions) and setting the instance with `tepl_abstract_factory_set_singleton()`, an application can tell Tepl to create custom objects and widgets.

Note that GtkTextViewClass has the ::create_buffer factory method, that TeplView overrides to create a TeplBuffer. How the TeplView and TeplBuffer are created can be customized with the ::create_tab vfunc of TeplAbstractFactory.

Recommendation for the subclass name: in Tepl, TeplAbstractFactory is an abstract class, but in an application it is a concrete class. So “MyappFactory” is a better name than “MyappAbstractFactory”.

## Functions

### tepl_abstract_factory_set_singleton ()

    void
    tepl_abstract_factory_set_singleton (TeplAbstractFactory *factory);

Sets the TeplAbstractFactory singleton. This should be called early in `main()`, for example just after calling `tepl_init()`.

This function must be called only once, before the first call to `tepl_abstract_factory_get_singleton()`.

Tepl takes ownership of the `factory` reference.

#### Parameters

factory | a TeplAbstractFactory. | [transfer full]

Since: 3.0

### tepl_abstract_factory_get_singleton ()

    TeplAbstractFactory *
    tepl_abstract_factory_get_singleton (void);

Gets the TeplAbstractFactory singleton instance.

If `tepl_abstract_factory_set_singleton()` has not been called, the singleton is created with a TeplAbstractFactory instance.

#### Returns

the TeplAbstractFactory singleton instance.

[transfer none]

Since: 3.0

### tepl_abstract_factory_create_main_window ()

    GtkApplicationWindow *
    tepl_abstract_factory_create_main_window
                                   (TeplAbstractFactory *factory,
                                    GtkApplication *app);

Creates a main GtkApplicationWindow in the sense of `tepl_application_window_is_main_window()`.

#### Parameters

factory | the TeplAbstractFactory. |
app | a GtkApplication. |

#### Returns

a new main application window, or `NULL` if the vfunc is not implemented.

[transfer floating][nullable]

### tepl_abstract_factory_create_tab ()

    TeplTab *
    tepl_abstract_factory_create_tab (TeplAbstractFactory *factory);

#### Parameters

factory | the TeplAbstractFactory. |

#### Returns

a new TeplTab.

[transfer floating]

Since: 3.0

### tepl_abstract_factory_create_tab_label ()

    GtkWidget *
    tepl_abstract_factory_create_tab_label
                                   (TeplAbstractFactory *factory,
                                    TeplTab *tab);

Creates a new tab label for `tab` , suitable for `gtk_notebook_set_tab_label()`.

#### Parameters

factory | the TeplAbstractFactory. |
tab | a TeplTab. |

#### Returns

a new GtkWidget, or `NULL` for the default tab label (“page N” with GtkNotebook).

[transfer floating][nullable]

Since: 3.0

### tepl_abstract_factory_create_file ()

    TeplFile *
    tepl_abstract_factory_create_file (TeplAbstractFactory *factory);

#### Parameters

factory | the TeplAbstractFactory. |

#### Returns

a new TeplFile.

[transfer full]

Since: 4.0

### tepl_abstract_factory_create_metadata_manager_file ()

    GFile *
    tepl_abstract_factory_create_metadata_manager_file
                                   (TeplAbstractFactory *factory);

Creates a new GFile that is then intended to be used as an argument to `tepl_metadata_manager_load_from_disk()` and `tepl_metadata_manager_save_to_disk()`. This function just creates the GFile object, it doesn't call any TeplMetadataManager function.

#### Parameters

factory | the TeplAbstractFactory. |

#### Returns

a new GFile, or `NULL` if the vfunc is not implemented.

[transfer full][nullable]

Since: 5.0

### tepl_abstract_factory_fill_prefs_dialog ()

    void
    tepl_abstract_factory_fill_prefs_dialog
                                   (TeplAbstractFactory *factory,
                                    TeplPrefsDialog *dialog);

`dialog` is a newly-created TeplPrefsDialog. This function fills `dialog` with the intended content.

#### Parameters

factory | the TeplAbstractFactory. |
dialog | a TeplPrefsDialog. |

Since: 6.2

## Types and Values

### struct TeplAbstractFactory

    struct TeplAbstractFactory;

### struct TeplAbstractFactoryClass

    struct TeplAbstractFactoryClass {
    	GObjectClass parent_class;

    	GtkApplicationWindow * (* create_main_window)			(TeplAbstractFactory *factory,
    									 GtkApplication      *app);

    	TeplTab *		(* create_tab)				(TeplAbstractFactory *factory);

    	GtkWidget *		(* create_tab_label)			(TeplAbstractFactory *factory,
    									 TeplTab             *tab);

    	TeplFile *		(* create_file)				(TeplAbstractFactory *factory);

    	GFile *			(* create_metadata_manager_file) (TeplAbstractFactory *factory);

    	void			(* fill_prefs_dialog)			(TeplAbstractFactory *factory,
    									 TeplPrefsDialog     *dialog);
    };

#### Members

`create_main_window` () | Virtual function pointer for `tepl_abstract_factory_create_main_window()`. It is not implemented by default. |
`create_tab` () | Virtual function pointer for `tepl_abstract_factory_create_tab()`. By default the TeplTab is created with `tepl_tab_new()`. |
`create_tab_label` () | Virtual function pointer for `tepl_abstract_factory_create_tab_label()`. By default the tab label is created with `tepl_tab_label_new()`. |
`create_file` () | Virtual function pointer for `tepl_abstract_factory_create_file()`. By default the TeplFile is created with `tepl_file_new()`. |
`create_metadata_manager_file` () | Virtual function pointer for `tepl_abstract_factory_create_metadata_manager_file()`. It is not implemented by default. |
`fill_prefs_dialog` () | Virtual function pointer for `tepl_abstract_factory_fill_prefs_dialog()`. It is not implemented by default. |