LCOV - code coverage report
Current view: top level - src/plugins/battery - valent-battery-preferences.c (source / functions) Coverage Total Hit
Test: Code Coverage Lines: 100.0 % 35 35
Test Date: 2024-04-23 06:02:46 Functions: 100.0 % 7 7
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 75.0 % 4 3

             Branch data     Line data    Source code
       1                 :             : // SPDX-License-Identifier: GPL-3.0-or-later
       2                 :             : // SPDX-FileCopyrightText: Andy Holmes <andrew.g.r.holmes@gmail.com>
       3                 :             : 
       4                 :             : #define G_LOG_DOMAIN "valent-battery-preferences"
       5                 :             : 
       6                 :             : #include "config.h"
       7                 :             : 
       8                 :             : #include <glib/gi18n.h>
       9                 :             : #include <adwaita.h>
      10                 :             : #include <gtk/gtk.h>
      11                 :             : #include <valent.h>
      12                 :             : 
      13                 :             : #include "valent-battery-preferences.h"
      14                 :             : 
      15                 :             : 
      16                 :             : struct _ValentBatteryPreferences
      17                 :             : {
      18                 :             :   ValentDevicePreferencesGroup  parent_instance;
      19                 :             : 
      20                 :             :   /* template */
      21                 :             :   AdwExpanderRow               *full_notification;
      22                 :             :   GtkAdjustment                *full_notification_level;
      23                 :             :   AdwExpanderRow               *low_notification;
      24                 :             :   GtkAdjustment                *low_notification_level;
      25                 :             : };
      26                 :             : 
      27   [ +  +  +  - ]:          10 : G_DEFINE_FINAL_TYPE (ValentBatteryPreferences, valent_battery_preferences, VALENT_TYPE_DEVICE_PREFERENCES_GROUP)
      28                 :             : 
      29                 :             : 
      30                 :             : /*
      31                 :             :  * GObject
      32                 :             :  */
      33                 :             : static void
      34                 :           1 : valent_battery_preferences_constructed (GObject *object)
      35                 :             : {
      36                 :           1 :   ValentBatteryPreferences *self = VALENT_BATTERY_PREFERENCES (object);
      37                 :           1 :   ValentDevicePreferencesGroup *group = VALENT_DEVICE_PREFERENCES_GROUP (self);
      38                 :           1 :   GSettings *settings;
      39                 :             : 
      40                 :           1 :   settings = valent_device_preferences_group_get_settings (group);
      41                 :           1 :   g_settings_bind (settings,                "full-notification",
      42                 :           1 :                    self->full_notification, "enable-expansion",
      43                 :             :                    G_SETTINGS_BIND_DEFAULT);
      44                 :           1 :   g_settings_bind (settings,                      "full-notification-level",
      45                 :           1 :                    self->full_notification_level, "value",
      46                 :             :                    G_SETTINGS_BIND_DEFAULT);
      47                 :           1 :   g_settings_bind (settings,               "low-notification",
      48                 :           1 :                    self->low_notification, "enable-expansion",
      49                 :             :                    G_SETTINGS_BIND_DEFAULT);
      50                 :           1 :   g_settings_bind (settings,                     "low-notification-level",
      51                 :           1 :                    self->low_notification_level, "value",
      52                 :             :                    G_SETTINGS_BIND_DEFAULT);
      53                 :             : 
      54                 :           1 :   G_OBJECT_CLASS (valent_battery_preferences_parent_class)->constructed (object);
      55                 :           1 : }
      56                 :             : 
      57                 :             : static void
      58                 :           1 : valent_battery_preferences_dispose (GObject *object)
      59                 :             : {
      60                 :           1 :   GtkWidget *widget = GTK_WIDGET (object);
      61                 :             : 
      62                 :           1 :   gtk_widget_dispose_template (widget, VALENT_TYPE_BATTERY_PREFERENCES);
      63                 :             : 
      64                 :           1 :   G_OBJECT_CLASS (valent_battery_preferences_parent_class)->dispose (object);
      65                 :           1 : }
      66                 :             : 
      67                 :             : static void
      68                 :           3 : valent_battery_preferences_class_init (ValentBatteryPreferencesClass *klass)
      69                 :             : {
      70                 :           3 :   GObjectClass *object_class = G_OBJECT_CLASS (klass);
      71                 :           3 :   GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
      72                 :             : 
      73                 :           3 :   object_class->constructed = valent_battery_preferences_constructed;
      74                 :           3 :   object_class->dispose = valent_battery_preferences_dispose;
      75                 :             : 
      76                 :           3 :   gtk_widget_class_set_template_from_resource (widget_class, "/plugins/battery/valent-battery-preferences.ui");
      77                 :           3 :   gtk_widget_class_bind_template_child (widget_class, ValentBatteryPreferences, full_notification);
      78                 :           3 :   gtk_widget_class_bind_template_child (widget_class, ValentBatteryPreferences, full_notification_level);
      79                 :           3 :   gtk_widget_class_bind_template_child (widget_class, ValentBatteryPreferences, low_notification);
      80                 :           3 :   gtk_widget_class_bind_template_child (widget_class, ValentBatteryPreferences, low_notification_level);
      81                 :           3 : }
      82                 :             : 
      83                 :             : static void
      84                 :           1 : valent_battery_preferences_init (ValentBatteryPreferences *self)
      85                 :             : {
      86                 :           1 :   gtk_widget_init_template (GTK_WIDGET (self));
      87                 :           1 : }
      88                 :             : 
        

Generated by: LCOV version 2.0-1