File: action-holder.c

package info (click to toggle)
gtk4 4.20.3%2Bds-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 187,060 kB
  • sloc: ansic: 779,084; xml: 3,093; javascript: 3,054; python: 1,911; java: 752; sh: 682; makefile: 315; perl: 162; cpp: 21
file content (78 lines) | stat: -rw-r--r-- 1,454 bytes parent folder | download | duplicates (3)
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
73
74
75
76
77
78

#include "action-holder.h"

struct _ActionHolder {
  GObject instance;

  GObject *owner;
  char *name;
};

static guint changed_signal;

G_DEFINE_TYPE (ActionHolder, action_holder, G_TYPE_OBJECT)

static void
action_holder_init (ActionHolder *holder)
{
}

static void
action_holder_finalize (GObject *object)
{
  ActionHolder *holder = ACTION_HOLDER (object);

  g_object_unref (holder->owner);
  g_free (holder->name);

  G_OBJECT_CLASS (action_holder_parent_class)->finalize (object);
}

static void
action_holder_class_init (ActionHolderClass *class)
{
  GObjectClass *object_class = G_OBJECT_CLASS (class);

  object_class->finalize = action_holder_finalize;

  changed_signal =
    g_signal_new ("changed",
                  G_TYPE_FROM_CLASS (object_class),
                  G_SIGNAL_RUN_FIRST,
                  0,
                  NULL, NULL,
                  NULL,
                  G_TYPE_NONE, 0);
}

ActionHolder *
action_holder_new (GObject    *owner,
                   const char *name)
{
  ActionHolder *holder;

  holder = g_object_new (ACTION_TYPE_HOLDER, NULL);

  holder->owner = g_object_ref (owner);
  holder->name = g_strdup (name);

  return holder;
}

GObject *
action_holder_get_owner (ActionHolder *holder)
{
  return holder->owner;
}

const char *
action_holder_get_name (ActionHolder *holder)
{
  return holder->name;
}

void
action_holder_changed (ActionHolder *holder)
{
  g_signal_emit (holder, changed_signal, 0);
}