|
|
|
@ -5,8 +5,10 @@ struct _MousePanel |
|
|
|
|
Panel parent_instance; |
|
|
|
|
|
|
|
|
|
GtkImage* mouse_image; |
|
|
|
|
GtkLabel* mouse_manufacturer; |
|
|
|
|
GtkLabel* mouse_name; |
|
|
|
|
AdwPreferencesGroup* dpi_preference_group; |
|
|
|
|
AdwButtonContent* dpi_stage_add_button; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
G_DEFINE_TYPE (MousePanel, mouse_panel, panel_get_type()) |
|
|
|
@ -14,15 +16,15 @@ G_DEFINE_TYPE (MousePanel, mouse_panel, panel_get_type()) |
|
|
|
|
static void |
|
|
|
|
mouse_panel_class_init(MousePanelClass* klass) |
|
|
|
|
{ |
|
|
|
|
GObjectClass* object_class = G_OBJECT_CLASS(klass); |
|
|
|
|
GtkWidgetClass* widget_class = GTK_WIDGET_CLASS(klass); |
|
|
|
|
PanelClass* panel_class = GINPUT_PANEL_CLASS(klass); |
|
|
|
|
|
|
|
|
|
gtk_widget_class_set_template_from_resource(widget_class, "/v/ginput/panel-mouse.ui"); |
|
|
|
|
|
|
|
|
|
gtk_widget_class_bind_template_child(widget_class, MousePanel, mouse_image); |
|
|
|
|
gtk_widget_class_bind_template_child(widget_class, MousePanel, mouse_manufacturer); |
|
|
|
|
gtk_widget_class_bind_template_child(widget_class, MousePanel, mouse_name); |
|
|
|
|
gtk_widget_class_bind_template_child(widget_class, MousePanel, dpi_preference_group); |
|
|
|
|
gtk_widget_class_bind_template_child(widget_class, MousePanel, dpi_stage_add_button); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static void |
|
|
|
@ -44,15 +46,26 @@ void mouse_panel_set_device(MousePanel* self, device_t* device) |
|
|
|
|
gtk_image_set_from_file(self->mouse_image, image); |
|
|
|
|
free(image); |
|
|
|
|
|
|
|
|
|
// Set device manufacturer
|
|
|
|
|
char* (*getmanufacturer_fn)(void*) = dlsym(device_driver(device), "driver_get_manufacturer"); |
|
|
|
|
gtk_label_set_label(self->mouse_manufacturer, getmanufacturer_fn(device_handle(device))); |
|
|
|
|
|
|
|
|
|
// Set device name
|
|
|
|
|
gtk_label_set_label(self->mouse_name, device_get_name(device)); |
|
|
|
|
|
|
|
|
|
// TODO inner window title
|
|
|
|
|
char* device_name = device_get_name(device); |
|
|
|
|
gtk_label_set_label(self->mouse_name, device_name); |
|
|
|
|
|
|
|
|
|
// Set mouse dpi
|
|
|
|
|
struct MOUSE_DPI_LEVELS dpi; |
|
|
|
|
int (*driver_mouse_dpi_get)(void*, void*) = dlsym(device_driver(device), "driver_mouse_dpi_get"); |
|
|
|
|
int dpi_res = driver_mouse_dpi_get(device_handle(device), &dpi); |
|
|
|
|
if(!dpi_res) |
|
|
|
|
{ |
|
|
|
|
// Set dpi used/max label in add button
|
|
|
|
|
char dpi_used_max[10]; |
|
|
|
|
sprintf(dpi_used_max, "%u/%u", dpi.level_count, dpi.max_level_count); |
|
|
|
|
adw_button_content_set_label(self->dpi_stage_add_button, dpi_used_max); |
|
|
|
|
|
|
|
|
|
// Set dpi list
|
|
|
|
|
for(size_t i = 0; i < dpi.level_count; i++) |
|
|
|
|
{ |
|
|
|
|