LCOV - code coverage report
Current view: top level - src/plugins/sftp - valent-sftp-preferences.c (source / functions) Coverage Total Hit
Test: Code Coverage Lines: 75.0 % 44 33
Test Date: 2024-05-05 22:34:11 Functions: 87.5 % 8 7
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 15.0 % 20 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-sftp-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-sftp-preferences.h"
      14                 :             : 
      15                 :             : 
      16                 :             : struct _ValentSftpPreferences
      17                 :             : {
      18                 :             :   ValentDevicePreferencesGroup  parent_instance;
      19                 :             : 
      20                 :             :   /* template */
      21                 :             :   GtkSwitch                    *auto_mount;
      22                 :             :   AdwExpanderRow               *local_allow;
      23                 :             :   GtkAdjustment                *local_port;
      24                 :             : };
      25                 :             : 
      26   [ +  +  +  - ]:           7 : G_DEFINE_FINAL_TYPE (ValentSftpPreferences, valent_sftp_preferences, VALENT_TYPE_DEVICE_PREFERENCES_GROUP)
      27                 :             : 
      28                 :             : 
      29                 :             : static void
      30                 :           0 : on_toggle_row (GtkListBox    *box,
      31                 :             :                GtkListBoxRow *row,
      32                 :             :                gpointer       user_data)
      33                 :             : {
      34                 :           0 :   gboolean active;
      35                 :           0 :   GtkWidget *grid;
      36                 :           0 :   GtkWidget *toggle;
      37                 :             : 
      38   [ #  #  #  #  :           0 :   g_assert (GTK_IS_LIST_BOX (box));
             #  #  #  # ]
      39   [ #  #  #  #  :           0 :   g_assert (GTK_IS_LIST_BOX_ROW (row));
             #  #  #  # ]
      40                 :             : 
      41                 :           0 :   grid = gtk_list_box_row_get_child (row);
      42                 :           0 :   toggle = gtk_grid_get_child_at (GTK_GRID (grid), 1, 0);
      43                 :             : 
      44                 :           0 :   g_object_get (toggle, "active", &active, NULL);
      45                 :           0 :   g_object_set (toggle, "active", !active, NULL);
      46                 :           0 : }
      47                 :             : 
      48                 :             : /*
      49                 :             :  * GObject
      50                 :             :  */
      51                 :             : static void
      52                 :           1 : valent_sftp_preferences_constructed (GObject *object)
      53                 :             : {
      54                 :           1 :   ValentSftpPreferences *self = VALENT_SFTP_PREFERENCES (object);
      55                 :           1 :   ValentDevicePreferencesGroup *group = VALENT_DEVICE_PREFERENCES_GROUP (self);
      56                 :           1 :   GSettings *settings;
      57                 :             : 
      58                 :           1 :   settings = valent_device_preferences_group_get_settings (group);
      59                 :           1 :   g_settings_bind (settings,         "auto-mount",
      60                 :           1 :                    self->auto_mount, "active",
      61                 :             :                    G_SETTINGS_BIND_DEFAULT);
      62                 :           1 :   g_settings_bind (settings,          "local-allow",
      63                 :           1 :                    self->local_allow, "enable-expansion",
      64                 :             :                    G_SETTINGS_BIND_DEFAULT);
      65                 :           1 :   g_settings_bind (settings,         "local-port",
      66                 :           1 :                    self->local_port, "value",
      67                 :             :                    G_SETTINGS_BIND_DEFAULT);
      68                 :             : 
      69                 :           1 :   G_OBJECT_CLASS (valent_sftp_preferences_parent_class)->constructed (object);
      70                 :           1 : }
      71                 :             : 
      72                 :             : static void
      73                 :           1 : valent_sftp_preferences_dispose (GObject *object)
      74                 :             : {
      75                 :           1 :   GtkWidget *widget = GTK_WIDGET (object);
      76                 :             : 
      77                 :           1 :   gtk_widget_dispose_template (widget, VALENT_TYPE_SFTP_PREFERENCES);
      78                 :             : 
      79                 :           1 :   G_OBJECT_CLASS (valent_sftp_preferences_parent_class)->dispose (object);
      80                 :           1 : }
      81                 :             : 
      82                 :             : static void
      83                 :           2 : valent_sftp_preferences_class_init (ValentSftpPreferencesClass *klass)
      84                 :             : {
      85                 :           2 :   GObjectClass *object_class = G_OBJECT_CLASS (klass);
      86                 :           2 :   GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
      87                 :             : 
      88                 :           2 :   object_class->constructed = valent_sftp_preferences_constructed;
      89                 :           2 :   object_class->dispose = valent_sftp_preferences_dispose;
      90                 :             : 
      91                 :           2 :   gtk_widget_class_set_template_from_resource (widget_class, "/plugins/sftp/valent-sftp-preferences.ui");
      92                 :           2 :   gtk_widget_class_bind_template_child (widget_class, ValentSftpPreferences, auto_mount);
      93                 :           2 :   gtk_widget_class_bind_template_child (widget_class, ValentSftpPreferences, local_allow);
      94                 :           2 :   gtk_widget_class_bind_template_child (widget_class, ValentSftpPreferences, local_port);
      95                 :             : 
      96                 :           2 :   gtk_widget_class_bind_template_callback (widget_class, on_toggle_row);
      97                 :           2 : }
      98                 :             : 
      99                 :             : static void
     100                 :           1 : valent_sftp_preferences_init (ValentSftpPreferences *self)
     101                 :             : {
     102                 :           1 :   gtk_widget_init_template (GTK_WIDGET (self));
     103                 :           1 : }
     104                 :             : 
        

Generated by: LCOV version 2.0-1