LCOV - code coverage report
Current view: top level - src/plugins/connectivity_report - valent-connectivity_report-preferences.c (source / functions) Coverage Total Hit
Test: Code Coverage Lines: 100.0 % 29 29
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-connectivity_report-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-connectivity_report-preferences.h"
      14                 :             : 
      15                 :             : 
      16                 :             : struct _ValentConnectivityReportPreferences
      17                 :             : {
      18                 :             :   ValentDevicePreferencesGroup  parent_instance;
      19                 :             : 
      20                 :             :   /* template */
      21                 :             :   GtkSwitch                    *share_state;
      22                 :             :   GtkSwitch                    *offline_notification;
      23                 :             : };
      24                 :             : 
      25   [ +  +  +  - ]:          10 : G_DEFINE_FINAL_TYPE (ValentConnectivityReportPreferences, valent_connectivity_report_preferences, VALENT_TYPE_DEVICE_PREFERENCES_GROUP)
      26                 :             : 
      27                 :             : 
      28                 :             : /*
      29                 :             :  * GObject
      30                 :             :  */
      31                 :             : static void
      32                 :           1 : valent_connectivity_report_preferences_constructed (GObject *object)
      33                 :             : {
      34                 :           1 :   ValentConnectivityReportPreferences *self = VALENT_CONNECTIVITY_REPORT_PREFERENCES (object);
      35                 :           1 :   ValentDevicePreferencesGroup *group = VALENT_DEVICE_PREFERENCES_GROUP (self);
      36                 :           1 :   GSettings *settings;
      37                 :             : 
      38                 :           1 :   settings = valent_device_preferences_group_get_settings (group);
      39                 :           1 :   g_settings_bind (settings,          "share-state",
      40                 :           1 :                    self->share_state, "active",
      41                 :             :                    G_SETTINGS_BIND_DEFAULT);
      42                 :           1 :   g_settings_bind (settings,                   "offline-notification",
      43                 :           1 :                    self->offline_notification, "active",
      44                 :             :                    G_SETTINGS_BIND_DEFAULT);
      45                 :             : 
      46                 :           1 :   G_OBJECT_CLASS (valent_connectivity_report_preferences_parent_class)->constructed (object);
      47                 :           1 : }
      48                 :             : 
      49                 :             : static void
      50                 :           1 : valent_connectivity_report_preferences_dispose (GObject *object)
      51                 :             : {
      52                 :           1 :   GtkWidget *widget = GTK_WIDGET (object);
      53                 :             : 
      54                 :           1 :   gtk_widget_dispose_template (widget, VALENT_TYPE_CONNECTIVITY_REPORT_PREFERENCES);
      55                 :             : 
      56                 :           1 :   G_OBJECT_CLASS (valent_connectivity_report_preferences_parent_class)->dispose (object);
      57                 :           1 : }
      58                 :             : 
      59                 :             : static void
      60                 :           3 : valent_connectivity_report_preferences_class_init (ValentConnectivityReportPreferencesClass *klass)
      61                 :             : {
      62                 :           3 :   GObjectClass *object_class = G_OBJECT_CLASS (klass);
      63                 :           3 :   GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
      64                 :             : 
      65                 :           3 :   object_class->constructed = valent_connectivity_report_preferences_constructed;
      66                 :           3 :   object_class->dispose = valent_connectivity_report_preferences_dispose;
      67                 :             : 
      68                 :           3 :   gtk_widget_class_set_template_from_resource (widget_class, "/plugins/connectivity_report/valent-connectivity_report-preferences.ui");
      69                 :           3 :   gtk_widget_class_bind_template_child (widget_class, ValentConnectivityReportPreferences, share_state);
      70                 :           3 :   gtk_widget_class_bind_template_child (widget_class, ValentConnectivityReportPreferences, offline_notification);
      71                 :           3 : }
      72                 :             : 
      73                 :             : static void
      74                 :           1 : valent_connectivity_report_preferences_init (ValentConnectivityReportPreferences *self)
      75                 :             : {
      76                 :           1 :   gtk_widget_init_template (GTK_WIDGET (self));
      77                 :           1 : }
      78                 :             : 
        

Generated by: LCOV version 2.0-1