File: simple-custom-quick-setting.c

package info (click to toggle)
phosh 0.52.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 9,732 kB
  • sloc: ansic: 82,495; xml: 3,912; python: 717; sh: 456; makefile: 34; lisp: 22; javascript: 6
file content (72 lines) | stat: -rw-r--r-- 1,960 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/*
 * Copyright (C) 2024 Tether Operations Limited
 *
 * SPDX-License-Identifier: GPL-3.0-or-later
 *
 * Author: Arun Mani J <arunmani@peartree.to>
 */

#include "simple-custom-quick-setting.h"

#include <glib/gi18n.h>

/**
 * PhoshSimpleCustomQuickSetting:
 *
 * A simple custom quick setting for demonstration purposes.
 */

struct _PhoshSimpleCustomQuickSetting {
  PhoshQuickSetting        parent;

  PhoshStatusIcon         *info;
};

G_DEFINE_TYPE (PhoshSimpleCustomQuickSetting, phosh_simple_custom_quick_setting, PHOSH_TYPE_QUICK_SETTING);


static void
on_clicked (PhoshSimpleCustomQuickSetting *self)
{
  gboolean active = phosh_quick_setting_get_active (PHOSH_QUICK_SETTING (self));

  if (active) {
    phosh_status_icon_set_icon_name (self->info, "face-shutmouth-symbolic");
    phosh_status_icon_set_info (self->info, _("I'm Inactive"));
  } else {
    phosh_status_icon_set_icon_name (self->info, "face-smile-big-symbolic");
    phosh_status_icon_set_info (self->info, _("I'm Active"));
  }

  phosh_quick_setting_set_active (PHOSH_QUICK_SETTING (self), !active);
}


static void
on_footer_clicked (PhoshSimpleCustomQuickSetting *self)
{
  g_message ("Footer clicked; open settings panel of the plugin");
}


static void
phosh_simple_custom_quick_setting_class_init (PhoshSimpleCustomQuickSettingClass *klass)
{
  GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);

  gtk_widget_class_set_template_from_resource (widget_class,
                                               "/mobi/phosh/plugins/simple-custom-quick-setting/qs.ui");

  gtk_widget_class_bind_template_child (widget_class, PhoshSimpleCustomQuickSetting, info);

  gtk_widget_class_bind_template_callback (widget_class, on_clicked);
  gtk_widget_class_bind_template_callback (widget_class, on_footer_clicked);
}


static void
phosh_simple_custom_quick_setting_init (PhoshSimpleCustomQuickSetting *self)
{
  gtk_widget_init_template (GTK_WIDGET (self));
  on_clicked (self);
}