Added device_array, array util, list mainwindow
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
#include "main-window.h"
|
||||
#include "panels/empty-panel.h"
|
||||
#include "device/device.h"
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
@@ -43,6 +44,7 @@ enum
|
||||
static gboolean activate_panel(MainWindow* self, Panel* panel, const gchar* id)
|
||||
{
|
||||
self->current_panel = GTK_WIDGET(panel);
|
||||
self->active_panel = panel;
|
||||
gtk_stack_add_named(self->stack, self->current_panel, id);
|
||||
gtk_stack_set_visible_child_name (self->stack, id);
|
||||
}
|
||||
@@ -88,9 +90,9 @@ main_window_get_property(GObject* object, guint property_id, GValue* value, GPar
|
||||
|
||||
switch(property_id)
|
||||
{
|
||||
// case PROP_ACTIVE_PANEL:
|
||||
// g_value_set_object (value, self->active_panel);
|
||||
// break;
|
||||
case PROP_ACTIVE_PANEL:
|
||||
g_value_set_object (value, self->active_panel);
|
||||
break;
|
||||
|
||||
// case PROP_MODEL:
|
||||
// g_value_set_object (value, self->store);
|
||||
@@ -115,9 +117,9 @@ main_window_set_property(GObject* object,
|
||||
|
||||
switch(property_id)
|
||||
{
|
||||
// case PROP_ACTIVE_PANEL:
|
||||
// set_active_panel(self, g_value_get_object(value));
|
||||
// break;
|
||||
// case PROP_ACTIVE_PANEL:
|
||||
// set_active_panel(self, g_value_get_object(value));
|
||||
// break;
|
||||
|
||||
// case PROP_MODEL:
|
||||
// g_assert(self->store == NULL);
|
||||
@@ -153,6 +155,14 @@ load_window_state(MainWindow* self)
|
||||
gtk_window_maximize(GTK_WINDOW(self));
|
||||
}
|
||||
|
||||
void main_window_add_all_devices(MainWindow* self)
|
||||
{
|
||||
// Obtain devices, and iterate over the array to add them
|
||||
array_t* devices = device_get_array();
|
||||
for(size_t i = 0; i < array_count(devices); i++)
|
||||
main_window_add_device_to_list(self, array_get(devices, i));
|
||||
}
|
||||
|
||||
static void
|
||||
main_window_constructed(GObject* object)
|
||||
{
|
||||
@@ -160,6 +170,8 @@ main_window_constructed(GObject* object)
|
||||
|
||||
load_window_state(self);
|
||||
|
||||
main_window_add_all_devices(self);
|
||||
|
||||
/* Add the panels */
|
||||
// setup_model (self);
|
||||
|
||||
@@ -198,12 +210,6 @@ main_window_finalize(GObject* object)
|
||||
{
|
||||
MainWindow* self = GINPUT_MAIN_WINDOW(object);
|
||||
|
||||
// if (self->previous_panels)
|
||||
// {
|
||||
// g_queue_free_full (self->previous_panels, g_free);
|
||||
// self->previous_panels = NULL;
|
||||
// }
|
||||
|
||||
g_clear_object(&self->settings);
|
||||
|
||||
G_OBJECT_CLASS(main_window_parent_class)->finalize(object);
|
||||
@@ -243,8 +249,6 @@ main_window_init(MainWindow* self)
|
||||
gtk_widget_init_template(GTK_WIDGET(self));
|
||||
|
||||
self->settings = g_settings_new("v.ginput");
|
||||
// self->previous_panels = g_queue_new ();
|
||||
// self->previous_list_view = cc_panel_list_get_view (self->panel_list);
|
||||
|
||||
g_object_bind_property(self->main_leaflet,
|
||||
"folded",
|
||||
@@ -271,3 +275,17 @@ main_window_new(AdwApplication* application)
|
||||
"show-menubar", FALSE,
|
||||
NULL);
|
||||
}
|
||||
|
||||
void main_window_add_device_to_list(MainWindow* self, device_t* device)
|
||||
{
|
||||
// Setup row
|
||||
GtkListBoxRow* row = (GtkListBoxRow*) gtk_list_box_row_new();
|
||||
GtkLabel* label = (GtkLabel*) gtk_label_new(device_get_name(device));
|
||||
gtk_widget_add_css_class(GTK_WIDGET(label), "body");
|
||||
gtk_widget_set_margin_top(GTK_WIDGET(label), 7);
|
||||
gtk_widget_set_margin_bottom(GTK_WIDGET(label), 7);
|
||||
gtk_list_box_row_set_child(row, GTK_WIDGET(label));
|
||||
|
||||
// Add row to listbox
|
||||
gtk_list_box_append(GTK_LIST_BOX(self->device_list), GTK_WIDGET(row));
|
||||
}
|
||||
|
Reference in New Issue
Block a user