Github User Fetcher 1.0.0
C Application with Server and GUI
|
#include <gtk/gtk.h>
Go to the source code of this file.
Data Structures | |
struct | AppWidgets |
Holds references to key GTK widgets used in the application. More... | |
Functions | |
static void | display_output (GtkTextBuffer *buffer, const gchar *output) |
Display text output in the GtkTextBuffer. | |
static void | on_button_clicked (GtkButton *button, gpointer user_data) |
Callback triggered when the "Fetch" button is clicked. | |
static void | activate (GtkApplication *app, gpointer user_data) |
Activates the application window and sets up the UI. | |
int | main (int argc, char *argv[]) |
Main entry point. | |
|
static |
Activates the application window and sets up the UI.
Creates the window, applies CSS styling, sets up the layout, connects signals, and displays the window.
app | The GtkApplication instance. |
user_data | User data (unused). |
Definition at line 83 of file gui.c.
References AppWidgets::entry, FALSE, G_CALLBACK, g_new0, g_signal_connect, gdk_display_get_default(), gtk_application_window_new(), GTK_BOX, gtk_box_append(), gtk_box_new(), gtk_button_new_with_label(), gtk_css_provider_load_from_path(), gtk_css_provider_new(), GTK_ENTRY, gtk_entry_new(), gtk_entry_set_placeholder_text(), GTK_ORIENTATION_VERTICAL, GTK_SCROLLED_WINDOW, gtk_scrolled_window_new(), gtk_scrolled_window_set_child(), gtk_style_context_add_provider_for_display(), GTK_STYLE_PROVIDER, GTK_STYLE_PROVIDER_PRIORITY_APPLICATION, GTK_TEXT_VIEW, gtk_text_view_get_buffer(), gtk_text_view_new(), gtk_text_view_set_editable(), gtk_text_view_set_wrap_mode(), GTK_WIDGET, gtk_widget_add_css_class(), gtk_widget_set_margin_bottom(), gtk_widget_set_margin_end(), gtk_widget_set_margin_start(), gtk_widget_set_margin_top(), gtk_widget_set_vexpand(), GTK_WINDOW, gtk_window_destroy(), gtk_window_present(), gtk_window_set_child(), gtk_window_set_default_size(), gtk_window_set_title(), GTK_WRAP_WORD_CHAR, NULL, on_button_clicked(), AppWidgets::output_buffer, and TRUE.
Referenced by main().
|
static |
Display text output in the GtkTextBuffer.
buffer | The GtkTextBuffer where the output will be shown. |
output | The text to display. |
Definition at line 18 of file gui.c.
References gtk_text_buffer_set_text(), and output.
Referenced by on_button_clicked().
int main | ( | int | argc, |
char * | argv[] ) |
Main entry point.
Initializes the GtkApplication, connects the activate signal, and runs the application loop.
argc | Argument count. |
argv | Argument vector. |
Definition at line 147 of file gui.c.
References activate(), G_APPLICATION, g_application_run(), G_CALLBACK, g_object_unref(), g_signal_connect, gtk_application_new(), and NULL.
Callback triggered when the "Fetch" button is clicked.
It reads the username from the entry, spawns the external fetcher process, captures its output or error, and displays it.
button | The GtkButton that was clicked. |
user_data | Pointer to AppWidgets containing references to UI elements. |
Definition at line 31 of file gui.c.
References display_output(), AppWidgets::entry, error(), g_free(), G_SPAWN_DEFAULT, g_spawn_sync(), g_strdup_printf(), gchar, GTK_EDITABLE, gtk_editable_get_text(), NULL, and AppWidgets::output_buffer.
Referenced by activate().