1
/* rgpackagestatus.cc - package status UI stuff
3
* Copyright (c) 2003 Michael Vogt
5
* Author: Michael Vogt <mvo@debian.org>
7
* This program is free software; you can redistribute it and/or
8
* modify it under the terms of the GNU General Public License as
9
* published by the Free Software Foundation; either version 2 of the
10
* License, or (at your option) any later version.
12
* This program is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
* GNU General Public License for more details.
17
* You should have received a copy of the GNU General Public License
18
* along with this program; if not, write to the Free Software
19
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
31
#include "rgpackagestatus.h"
35
get_gdk_pixbuf(const gchar *name, int size=16)
41
theme = gtk_icon_theme_get_default();
42
pixbuf = gtk_icon_theme_load_icon(theme, name, size,
43
(GtkIconLookupFlags)0, &error);
45
std::cerr << "Warning, failed to load: " << name
46
<< error->message << std::endl;
51
GtkWidget *get_gtk_image(const gchar *name, int size)
54
buf = get_gdk_pixbuf(name, size);
57
return gtk_image_new_from_pixbuf(buf);
60
// RPackageStatus stuff
61
RGPackageStatus RGPackageStatus::pkgStatus;
63
void RGPackageStatus::initColors()
65
char *default_status_colors[N_STATUS_COUNT] = {
67
"#4e9a06", // re-install
69
"#ad7fa8", // downgrade
73
"#a40000", // available-locked
74
NULL, // installed-updated
75
NULL, // installed-outdated
76
"#a40000", // installed-locked
82
for (int i = 0; i < N_STATUS_COUNT; i++) {
83
config_string = g_strdup_printf("Synaptic::color-%s",
84
PackageStatusShortString[i]);
85
gtk_get_color_from_string(_config->
87
default_status_colors[i]).c_str(),
89
g_free(config_string);
93
void RGPackageStatus::initPixbufs()
96
for (int i = 0; i < N_STATUS_COUNT; i++) {
97
s = g_strdup_printf("package-%s", PackageStatusShortString[i]);
98
StatusPixbuf[i] = get_gdk_pixbuf(s);
100
supportedPix = get_gdk_pixbuf("package-supported");
103
// class that finds out what do display to get user
104
void RGPackageStatus::init()
106
RPackageStatus::init();
113
GdkColor *RGPackageStatus::getBgColor(RPackage *pkg)
115
return StatusColors[getStatus(pkg)];
118
GdkPixbuf *RGPackageStatus::getSupportedPix(RPackage *pkg)
126
GdkPixbuf *RGPackageStatus::getPixbuf(RPackage *pkg)
128
return StatusPixbuf[getStatus(pkg)];
131
void RGPackageStatus::setColor(int i, GdkColor * new_color)
133
StatusColors[i] = new_color;
136
void RGPackageStatus::saveColors()
138
gchar *color_string, *config_string;
139
for (int i = 0; i < N_STATUS_COUNT; i++) {
140
color_string = gtk_get_string_from_color(StatusColors[i]);
141
config_string = g_strdup_printf("Synaptic::color-%s",
142
PackageStatusShortString[i]);
144
_config->Set(config_string, color_string);
145
g_free(config_string);