[473884]: src / systray_icon.c  Maximize  Restore  History

Download this file

145 lines (117 with data), 4.3 kB

  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
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
/*
rox-media (Media) - DeviceKit-disks utility for ROX
Copyright (C) 2009 Tony Houghton <h@realh.co.uk>
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 3 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, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "systray_icon.h"
#include "systray_icon_priv.h"
#define H_SYSTEM_TRAY_ICON_GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE((obj), \
H_TYPE_SYSTEM_TRAY_ICON, HSystemTrayIconPrivate))
static gboolean
size_changed(GtkWidget *widget, int size, HSystemTrayIcon *self)
{
h_panel_icon_size_set(H_PANEL_ICON(self), size, size);
return TRUE;
}
static void
show_pixbuf(HPanelIcon *iself, GdkPixbuf *pixbuf)
{
gtk_status_icon_set_from_pixbuf(GTK_STATUS_ICON(iself), pixbuf);
}
static GtkOrientation
get_panel_orientation(HPanelIcon *iself)
{
GtkOrientation orientation = GTK_ORIENTATION_HORIZONTAL;
gtk_status_icon_get_geometry(GTK_STATUS_ICON(iself), NULL, NULL,
&orientation);
return orientation;
}
static GtkMenuPositionFunc
get_menu_position_func(HPanelIcon *iself)
{
return gtk_status_icon_position_menu;
}
static HPanelIconData *
get_icon_data(HPanelIcon *iself)
{
return &(H_SYSTEM_TRAY_ICON(iself)->priv->icon_data);
}
static void destroy(HPanelIcon *iself)
{
g_object_unref(G_OBJECT(iself));
}
typedef void (*SetTooltipFunc)(HPanelIcon *, const char *);
typedef char *(*GetTooltipFunc)(HPanelIcon *);
static void
h_system_tray_icon_init_h_panel_icon(HPanelIconInterface *iface)
{
iface->set_icon_source = h_panel_icon_standard_set_icon_source;
iface->destroy = destroy;
iface->set_tooltip_text =
(SetTooltipFunc) gtk_status_icon_set_tooltip_text;
iface->get_tooltip_text =
(GetTooltipFunc) gtk_status_icon_get_tooltip_text;
iface->set_tooltip_markup =
(SetTooltipFunc) gtk_status_icon_set_tooltip_markup;
iface->get_tooltip_markup =
(GetTooltipFunc) gtk_status_icon_get_tooltip_markup;
iface->size_set = h_panel_icon_standard_size_set;
iface->show_pixbuf = show_pixbuf;
iface->get_panel_orientation = get_panel_orientation;
iface->get_menu_position_func = get_menu_position_func;
iface->get_data = get_icon_data;
}
G_DEFINE_TYPE_WITH_CODE(HSystemTrayIcon, h_system_tray_icon,
GTK_TYPE_STATUS_ICON,
G_IMPLEMENT_INTERFACE(H_TYPE_PANEL_ICON,
h_system_tray_icon_init_h_panel_icon));
static void
h_system_tray_icon_init(HSystemTrayIcon *self)
{
HSystemTrayIconPrivate *priv = self->priv =
H_SYSTEM_TRAY_ICON_GET_PRIVATE(self);
h_panel_icon_data_init(&priv->icon_data);
g_signal_connect(self, "size-changed", G_CALLBACK(size_changed), self);
}
static void
h_system_tray_icon_dispose(GObject *gobj)
{
HSystemTrayIcon *self = H_SYSTEM_TRAY_ICON(gobj);
HSystemTrayIconPrivate *priv = self->priv;
h_panel_icon_data_dispose(&priv->icon_data);
G_OBJECT_CLASS(h_system_tray_icon_parent_class)->dispose(gobj);
}
static void
h_system_tray_icon_finalize(GObject *gobj)
{
G_OBJECT_CLASS(h_system_tray_icon_parent_class)->finalize(gobj);
}
static void
h_system_tray_icon_class_init(HSystemTrayIconClass *klass)
{
GObjectClass *gclass;
g_type_class_add_private(klass, sizeof(HSystemTrayIconPrivate));
gclass = G_OBJECT_CLASS(klass);
gclass->dispose = h_system_tray_icon_dispose;
gclass->finalize = h_system_tray_icon_finalize;
}
HSystemTrayIcon *
h_system_tray_icon_new(HIconSource *source)
{
HSystemTrayIcon *self =
H_SYSTEM_TRAY_ICON(g_object_new(H_TYPE_SYSTEM_TRAY_ICON, NULL));
if (source)
h_panel_icon_set_icon_source(H_PANEL_ICON(self), source);
return self;
}