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

           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-clipboard-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-clipboard-preferences.h"
      14                 :            : 
      15                 :            : 
      16                 :            : struct _ValentClipboardPreferences
      17                 :            : {
      18                 :            :   ValentDevicePreferencesGroup  parent_instance;
      19                 :            : 
      20                 :            :   /* template */
      21                 :            :   GtkSwitch                   *sync_pull;
      22                 :            :   GtkSwitch                   *sync_push;
      23                 :            : };
      24                 :            : 
      25   [ +  +  +  - ]:          7 : G_DEFINE_FINAL_TYPE (ValentClipboardPreferences, valent_clipboard_preferences, VALENT_TYPE_DEVICE_PREFERENCES_GROUP)
      26                 :            : 
      27                 :            : 
      28                 :            : /*
      29                 :            :  * GObject
      30                 :            :  */
      31                 :            : static void
      32                 :          1 : valent_clipboard_preferences_constructed (GObject *object)
      33                 :            : {
      34                 :          1 :   ValentClipboardPreferences *self = VALENT_CLIPBOARD_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,        "auto-pull",
      40                 :          1 :                    self->sync_pull, "active",
      41                 :            :                    G_SETTINGS_BIND_DEFAULT);
      42                 :            : 
      43                 :          1 :   g_settings_bind (settings,        "auto-push",
      44                 :          1 :                    self->sync_push, "active",
      45                 :            :                    G_SETTINGS_BIND_DEFAULT);
      46                 :            : 
      47                 :          1 :   G_OBJECT_CLASS (valent_clipboard_preferences_parent_class)->constructed (object);
      48                 :          1 : }
      49                 :            : 
      50                 :            : static void
      51                 :          1 : valent_clipboard_preferences_dispose (GObject *object)
      52                 :            : {
      53                 :          1 :   GtkWidget *widget = GTK_WIDGET (object);
      54                 :            : 
      55                 :          1 :   gtk_widget_dispose_template (widget, VALENT_TYPE_CLIPBOARD_PREFERENCES);
      56                 :            : 
      57                 :          1 :   G_OBJECT_CLASS (valent_clipboard_preferences_parent_class)->dispose (object);
      58                 :          1 : }
      59                 :            : 
      60                 :            : static void
      61                 :          2 : valent_clipboard_preferences_class_init (ValentClipboardPreferencesClass *klass)
      62                 :            : {
      63                 :          2 :   GObjectClass *object_class = G_OBJECT_CLASS (klass);
      64                 :          2 :   GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
      65                 :            : 
      66                 :          2 :   object_class->constructed = valent_clipboard_preferences_constructed;
      67                 :          2 :   object_class->dispose = valent_clipboard_preferences_dispose;
      68                 :            : 
      69                 :          2 :   gtk_widget_class_set_template_from_resource (widget_class, "/plugins/clipboard/valent-clipboard-preferences.ui");
      70                 :          2 :   gtk_widget_class_bind_template_child (widget_class, ValentClipboardPreferences, sync_pull);
      71                 :          2 :   gtk_widget_class_bind_template_child (widget_class, ValentClipboardPreferences, sync_push);
      72                 :          2 : }
      73                 :            : 
      74                 :            : static void
      75                 :          1 : valent_clipboard_preferences_init (ValentClipboardPreferences *self)
      76                 :            : {
      77                 :          1 :   gtk_widget_init_template (GTK_WIDGET (self));
      78                 :          1 : }
      79                 :            : 

Generated by: LCOV version 1.14