LCOV - code coverage report
Current view: top level - src/plugins/lock - valent-lock-gadget.c (source / functions) Hit Total Coverage
Test: Code Coverage Lines: 14 14 100.0 %
Date: 2023-06-06 02:20:50 Functions: 5 5 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 4 6 66.7 %

           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-lock-gadget"
       5                 :            : 
       6                 :            : #include "config.h"
       7                 :            : 
       8                 :            : #include <gtk/gtk.h>
       9                 :            : #include <glib/gi18n.h>
      10                 :            : #include <valent.h>
      11                 :            : 
      12                 :            : #include "valent-lock-gadget.h"
      13                 :            : 
      14                 :            : 
      15                 :            : struct _ValentLockGadget
      16                 :            : {
      17                 :            :   ValentDeviceGadget  parent_instance;
      18                 :            : 
      19                 :            :   /* widgets */
      20                 :            :   GtkWidget          *button;
      21                 :            : };
      22                 :            : 
      23   [ +  +  +  - ]:          6 : G_DEFINE_FINAL_TYPE (ValentLockGadget, valent_lock_gadget, VALENT_TYPE_DEVICE_GADGET)
      24                 :            : 
      25                 :            : 
      26                 :            : /*
      27                 :            :  * GObject
      28                 :            :  */
      29                 :            : static void
      30                 :          1 : valent_lock_gadget_dispose (GObject *object)
      31                 :            : {
      32                 :          1 :   ValentLockGadget *self = VALENT_LOCK_GADGET (object);
      33                 :            : 
      34         [ +  - ]:          1 :   g_clear_pointer (&self->button, gtk_widget_unparent);
      35                 :            : 
      36                 :          1 :   G_OBJECT_CLASS (valent_lock_gadget_parent_class)->dispose (object);
      37                 :          1 : }
      38                 :            : 
      39                 :            : static void
      40                 :          2 : valent_lock_gadget_class_init (ValentLockGadgetClass *klass)
      41                 :            : {
      42                 :          2 :   GObjectClass *object_class = G_OBJECT_CLASS (klass);
      43                 :            : 
      44                 :          2 :   object_class->dispose = valent_lock_gadget_dispose;
      45                 :            : }
      46                 :            : 
      47                 :            : static void
      48                 :          1 : valent_lock_gadget_init (ValentLockGadget *self)
      49                 :            : {
      50                 :          1 :   self->button = g_object_new (GTK_TYPE_TOGGLE_BUTTON,
      51                 :            :                                "action-name",  "device.lock.state",
      52                 :            :                                "icon-name",    "channel-secure-symbolic",
      53                 :            :                                "has-frame",    FALSE,
      54                 :            :                                "tooltip-text", _("Lock"),
      55                 :            :                                NULL);
      56                 :          1 :   g_object_bind_property (self->button, "sensitive",
      57                 :            :                           self->button, "visible",
      58                 :            :                           G_BINDING_SYNC_CREATE);
      59                 :            : 
      60                 :          1 :   gtk_widget_set_parent (self->button, GTK_WIDGET (self));
      61                 :          1 : }
      62                 :            : 

Generated by: LCOV version 1.14