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

Download this file

icon_group.c    121 lines (99 with data), 3.1 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
/*
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 <glib.h>
#include "icon_group.h"
#include "rox_panel_icon.h"
#include "rox_panel_info.h"
#include "systray_icon.h"
struct _IconGroup {
HPanelIcon *(*add_icon)(IconGroup * group, HIconSource *source);
GList *icons;
GtkWidget *plug;
GtkWidget *box;
};
GtkWindow *
icon_group_get_window(IconGroup *group)
{
return group->plug ? GTK_WINDOW(group->plug) : NULL;
}
static IconGroup *
icon_group_new(void)
{
return g_new0(IconGroup, 1);
}
static HPanelIcon *
add_h_rox_panel_icon(IconGroup *group, HIconSource *source)
{
HRoxPanelIcon *icon = h_rox_panel_icon_new(source);
gtk_box_pack_start(GTK_BOX(group->box), GTK_WIDGET(icon), TRUE, TRUE, 0);
gtk_widget_show_all(GTK_WIDGET(icon));
return H_PANEL_ICON(icon);
}
static HPanelIcon *
add_status_icon(IconGroup *group, HIconSource *source)
{
return H_PANEL_ICON(h_system_tray_icon_new(source));
}
IconGroup *
icon_group_new_for_rox_panel(int xid)
{
IconGroup *group = icon_group_new();
group->add_icon = add_h_rox_panel_icon;
group->plug = gtk_plug_new(xid);
g_signal_connect(group->plug, "destroy", G_CALLBACK(gtk_main_quit), NULL);
if (rox_panel_info_get_orientation(group->plug) == GTK_ORIENTATION_VERTICAL)
group->box = gtk_vbox_new(FALSE, 0);
else
group->box = gtk_hbox_new(FALSE, 0);
gtk_container_add(GTK_CONTAINER(group->plug), group->box);
return group;
}
IconGroup *
icon_group_new_for_systray(void)
{
IconGroup *group = icon_group_new();
group->add_icon = add_status_icon;
return group;
}
HPanelIcon *
icon_group_add_icon(IconGroup *group, HIconSource *source)
{
HPanelIcon *icon = group->add_icon(group, source);
group->icons = g_list_append(group->icons, icon);
return icon;
}
void
icon_group_remove_icon(IconGroup *group, HPanelIcon *icon)
{
GList *link = g_list_find(group->icons, icon);
g_return_if_fail(link != NULL);
g_object_unref(icon);
group->icons = g_list_delete_link(group->icons, link);
}
gboolean
icon_group_show(IconGroup *group)
{
if (group->plug)
gtk_widget_show(group->plug);
return FALSE;
}
gboolean
icon_group_show_all(IconGroup *group)
{
if (group->plug)
gtk_widget_show_all(group->plug);
return FALSE;
}