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
79
80
81
82
83
84
85
86
87
88
89
90
91
/*
 * Copyright (C) 2016 Alberts Muktupāvels
 * Copyright (C) 2017 Colomban Wendling <cwendling@hypra.fr>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 */

#include "config.h"

#include "na-item.h"

G_DEFINE_INTERFACE_WITH_CODE (NaItem, na_item, CTK_TYPE_WIDGET,<--- There is an unknown macro here somewhere. Configuration is required. If G_DEFINE_INTERFACE_WITH_CODE is a macro then please configure it.
                              g_type_interface_add_prerequisite (g_define_type_id,
                                                                 CTK_TYPE_ORIENTABLE);)

static gboolean
na_item_draw_on_parent_default (NaItem     *item,
                                CtkWidget  *parent,
                                cairo_t    *parent_cr)
{
  return FALSE;
}

static void
na_item_default_init (NaItemInterface *iface)
{
  iface->draw_on_parent = na_item_draw_on_parent_default;
}

const gchar *
na_item_get_id (NaItem *item)
{
  NaItemInterface *iface;

  g_return_val_if_fail (NA_IS_ITEM (item), NULL);

  iface = NA_ITEM_GET_IFACE (item);
  g_return_val_if_fail (iface->get_id != NULL, NULL);

  return iface->get_id (item);
}

NaItemCategory
na_item_get_category (NaItem *item)
{
  NaItemInterface *iface;

  g_return_val_if_fail (NA_IS_ITEM (item),
                        NA_ITEM_CATEGORY_APPLICATION_STATUS);

  iface = NA_ITEM_GET_IFACE (item);
  g_return_val_if_fail (iface->get_category != NULL,
                        NA_ITEM_CATEGORY_APPLICATION_STATUS);

  return iface->get_category (item);
}

/*
 * Fairly ugly hack because system-tray/NaTrayChild uses a weird hack for
 * drawing itself.  I'm not sure it's still needed with the current CTK3
 * drawing where not all widgets have an own window, but well.
 *
 * Should return %TRUE if it handled itself, or %FALSE if the parent should
 * draw normally.  Default is to draw normally.
 */
gboolean
na_item_draw_on_parent (NaItem    *item,
                        CtkWidget *parent,
                        cairo_t   *parent_cr)
{
  NaItemInterface *iface;

  g_return_val_if_fail (NA_IS_ITEM (item), FALSE);
  g_return_val_if_fail (CTK_IS_WIDGET (parent), FALSE);

  iface = NA_ITEM_GET_IFACE (item);
  g_return_val_if_fail (iface->draw_on_parent != NULL, FALSE);

  return iface->draw_on_parent (item, parent, parent_cr);
}