Visual changes, radiobutton for dpi stages

master
vhaudiquet 12 months ago
parent 6ed60bea1c
commit c535c91a48
  1. 29
      src/ui/panels/mouse-panel.c
  2. 57
      ui/panel-mouse.ui

@ -66,25 +66,32 @@ void mouse_panel_set_device(MousePanel* self, device_t* device)
sprintf(dpi_used_max, "%u/%u", dpi.level_count, dpi.max_level_count); 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); adw_button_content_set_label(self->dpi_stage_add_button, dpi_used_max);
GtkCheckButton* group = 0;
// 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++)
{ {
AdwPreferencesRow* row = ADW_PREFERENCES_ROW(adw_preferences_row_new()); AdwActionRow* row = ADW_ACTION_ROW(adw_action_row_new());
// Convert dpi int to string // Add radiobutton
char dpi_str[15]; if(dpi.level_count > 1)
sprintf(dpi_str, "%u DPI", dpi.level[i].dpi_x); {
GtkCheckButton* radio_button = GTK_CHECK_BUTTON(gtk_check_button_new());
GtkLabel* label = GTK_LABEL(gtk_label_new(dpi_str)); if(!group) group = radio_button;
gtk_widget_set_margin_top(GTK_WIDGET(label), 10); else gtk_check_button_set_group(radio_button, group);
gtk_widget_set_margin_bottom(GTK_WIDGET(label), 10);
gtk_list_box_row_set_child(GTK_LIST_BOX_ROW(row), GTK_WIDGET(label));
if(dpi.level_current == i) if(dpi.level_current == i)
{ gtk_check_button_set_active(radio_button, true);
gtk_list_box_row_set_activatable(GTK_LIST_BOX_ROW(row), false);
adw_action_row_add_prefix(row, GTK_WIDGET(radio_button));
} }
// Convert dpi int to string, and set it as title
char dpi_str[15];
sprintf(dpi_str, "%u DPI", dpi.level[i].dpi_x);
adw_preferences_row_set_title(ADW_PREFERENCES_ROW(row), dpi_str);
//gtk_list_box_row_set_activatable(GTK_LIST_BOX_ROW(row), false);
adw_preferences_group_add(self->dpi_preference_group, GTK_WIDGET(row)); adw_preferences_group_add(self->dpi_preference_group, GTK_WIDGET(row));
} }
} }

@ -4,15 +4,20 @@
<template class="MousePanel" parent="Panel"> <template class="MousePanel" parent="Panel">
<child type="content"> <child type="content">
<object class="GtkBox">
<property name="halign">center</property>
<property name="valign">start</property>
<property name="hexpand">false</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkBox"> <object class="GtkBox">
<property name="halign">start</property> <property name="halign">start</property>
<property name="spacing">10</property>
<property name="valign">start</property> <property name="valign">start</property>
<property name="hexpand">false</property>
<child> <child>
<object class="GtkBox" id="presentation_box"> <object class="GtkBox" id="presentation_box">
<property name="halign">start</property> <property name="halign">start</property>
<property name="orientation">vertical</property> <property name="orientation">vertical</property>
<property name="spacing">10</property>
<child> <child>
<object class="GtkImage" id="mouse_image"> <object class="GtkImage" id="mouse_image">
<property name="halign">start</property> <property name="halign">start</property>
@ -49,16 +54,7 @@
<property name="margin-top">30</property> <property name="margin-top">30</property>
<property name="orientation">vertical</property> <property name="orientation">vertical</property>
<property name="valign">start</property> <property name="valign">start</property>
<child> <property name="hexpand">false</property>
<object class="GtkLabel">
<property name="halign">start</property>
<property name="label">Basic settings</property>
<property name="valign">start</property>
<style>
<class name="title-3" />
</style>
</object>
</child>
<child> <child>
<object class="GtkBox" id="dpi_box"> <object class="GtkBox" id="dpi_box">
<property name="halign">start</property> <property name="halign">start</property>
@ -66,6 +62,7 @@
<property name="valign">start</property> <property name="valign">start</property>
<child> <child>
<object class="AdwPreferencesGroup" id="dpi_preference_group"> <object class="AdwPreferencesGroup" id="dpi_preference_group">
<property name="height-request">200</property>
<property name="header-suffix"> <property name="header-suffix">
<object class="GtkButton"> <object class="GtkButton">
<property name="child"> <property name="child">
@ -77,15 +74,49 @@
</property> </property>
</object> </object>
</property> </property>
<property name="width-request">300</property> <property name="width-request">350</property>
<property name="title">DPI Stages</property> <property name="title">DPI Stages</property>
<property name="description">DPI Stages of the mouse</property> <property name="description">DPI Stages of the mouse</property>
</object> </object>
</child> </child>
</object> </object>
</child> </child>
</object>
</child>
</object> </object>
</child> </child>
<child>
<object class="GtkBox">
<property name="halign">center</property>
<property name="margin-top">25</property>
<child>
<object class="AdwSwitchRow">
<property name="activatable">false</property>
<property name="width-request">200</property>
<property name="hexpand">false</property>
<property name="hexpand-set">true</property>
<property name="title">Motion sync</property>
<property name="subtitle">Motion sync makes the mouse send sensor data at
the rate of the computer update requests </property>
</object>
</child>
<child>
<object class="AdwSwitchRow">
<property name="activatable">false</property>
<property name="width-request">200</property>
<property name="hexpand">false</property>
<property name="hexpand-set">true</property>
<property name="title">Angle snap</property>
<property name="subtitle">Angle snap detects when you try to draw a straight
line and locks the mouse on that line</property>
</object>
</child>
</object>
</child>
</object> </object>
</child> </child>

Loading…
Cancel
Save