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

             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 <glib/gi18n.h>
       9                 :             : #include <gtk/gtk.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                 :             :   /* Button */
      51                 :           1 :   self->button = g_object_new (GTK_TYPE_TOGGLE_BUTTON,
      52                 :             :                                "action-name", "device.lock.state",
      53                 :             :                                "icon-name",   "channel-secure-symbolic",
      54                 :             :                                "has-frame",   FALSE,
      55                 :             :                                NULL);
      56                 :           1 :   gtk_accessible_update_property (GTK_ACCESSIBLE (self->button),
      57                 :             :                                   GTK_ACCESSIBLE_PROPERTY_LABEL, _("Lock"),
      58                 :             :                                   -1);
      59                 :           1 :   g_object_bind_property (self->button, "sensitive",
      60                 :           1 :                           self->button, "visible",
      61                 :             :                           G_BINDING_SYNC_CREATE);
      62                 :             : 
      63                 :           1 :   gtk_widget_set_parent (self->button, GTK_WIDGET (self));
      64                 :           1 : }
      65                 :             : 
        

Generated by: LCOV version 2.0-1