|
|
@ -5,8 +5,10 @@ struct _MousePanel |
|
|
|
Panel parent_instance; |
|
|
|
Panel parent_instance; |
|
|
|
|
|
|
|
|
|
|
|
GtkImage* mouse_image; |
|
|
|
GtkImage* mouse_image; |
|
|
|
|
|
|
|
GtkLabel* mouse_manufacturer; |
|
|
|
GtkLabel* mouse_name; |
|
|
|
GtkLabel* mouse_name; |
|
|
|
AdwPreferencesGroup* dpi_preference_group; |
|
|
|
AdwPreferencesGroup* dpi_preference_group; |
|
|
|
|
|
|
|
AdwButtonContent* dpi_stage_add_button; |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
G_DEFINE_TYPE (MousePanel, mouse_panel, panel_get_type()) |
|
|
|
G_DEFINE_TYPE (MousePanel, mouse_panel, panel_get_type()) |
|
|
@ -14,15 +16,15 @@ G_DEFINE_TYPE (MousePanel, mouse_panel, panel_get_type()) |
|
|
|
static void |
|
|
|
static void |
|
|
|
mouse_panel_class_init(MousePanelClass* klass) |
|
|
|
mouse_panel_class_init(MousePanelClass* klass) |
|
|
|
{ |
|
|
|
{ |
|
|
|
GObjectClass* object_class = G_OBJECT_CLASS(klass); |
|
|
|
|
|
|
|
GtkWidgetClass* widget_class = GTK_WIDGET_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_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_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, mouse_name); |
|
|
|
gtk_widget_class_bind_template_child(widget_class, MousePanel, dpi_preference_group); |
|
|
|
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 |
|
|
|
static void |
|
|
@ -44,8 +46,14 @@ void mouse_panel_set_device(MousePanel* self, device_t* device) |
|
|
|
gtk_image_set_from_file(self->mouse_image, image); |
|
|
|
gtk_image_set_from_file(self->mouse_image, image); |
|
|
|
free(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
|
|
|
|
// 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
|
|
|
|
// Set mouse dpi
|
|
|
|
struct MOUSE_DPI_LEVELS dpi; |
|
|
|
struct MOUSE_DPI_LEVELS dpi; |
|
|
@ -53,6 +61,11 @@ void mouse_panel_set_device(MousePanel* self, device_t* device) |
|
|
|
int dpi_res = driver_mouse_dpi_get(device_handle(device), &dpi); |
|
|
|
int dpi_res = driver_mouse_dpi_get(device_handle(device), &dpi); |
|
|
|
if(!dpi_res) |
|
|
|
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
|
|
|
|
// Set dpi list
|
|
|
|
for(size_t i = 0; i < dpi.level_count; i++) |
|
|
|
for(size_t i = 0; i < dpi.level_count; i++) |
|
|
|
{ |
|
|
|
{ |
|
|
|