~ubuntu-branches/debian/experimental/synaptic/experimental

« back to all changes in this revision

Viewing changes to gtk/rgmisc.cc

  • Committer: Bazaar Package Importer
  • Author(s): Michael Vogt
  • Date: 2008-06-18 10:17:31 UTC
  • Revision ID: james.westby@ubuntu.com-20080618101731-fb77n5hy28hcq3g3
Tags: 0.62.1
* po/es.po:
  - updated Spanish translation (thanks to
     Francisco Javier Cuadrado)
* debian/control:
  - added "menu" to the recommends (closes: #478250)
* gtk/glade/window_main.glade:
  - make the main vpane shinkable
* gtk/rgmainwindow.cc:
  - do not loose the keyboard focus after a package 
    action in the listview
* debian/control:
  - switch bzr branch to bzr.debian.org

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
#include "i18n.h"
28
28
#include "rgmisc.h"
29
29
#include <stdio.h>
 
30
#include <cstdlib>
 
31
#include <cstring>
30
32
 
31
33
 
32
34
void RGFlushInterface()
159
161
   return _str;
160
162
}
161
163
 
162
 
GtkWidget *get_gtk_image(const char *name)
163
 
{
164
 
   gchar *filename;
165
 
   GtkWidget *img;
166
 
   filename = g_strdup_printf("../pixmaps/%s.png", name);
167
 
   if (!FileExists(filename)) {
168
 
      g_free(filename);
169
 
      filename = g_strdup_printf(SYNAPTIC_PIXMAPDIR "%s.png", name);
170
 
   }
171
 
   img = gtk_image_new_from_file(filename);
172
 
   if (img == NULL)
173
 
      std::cerr << "Warning, failed to load: " << filename << std::endl;
174
 
   g_free(filename);
175
 
   return img;
 
164
static GdkPixbuf *
 
165
get_gdk_pixbuf(const gchar *name, int size=16)
 
166
{
 
167
   GtkIconTheme *theme;
 
168
   GdkPixbuf *pixbuf;
 
169
   GError *error = NULL;
 
170
 
 
171
   theme = gtk_icon_theme_get_default();
 
172
   pixbuf = gtk_icon_theme_load_icon(theme, name, size, 
 
173
                                     (GtkIconLookupFlags)0, &error);
 
174
   if (pixbuf == NULL) 
 
175
      std::cerr << "Warning, failed to load: " << name 
 
176
                << error->message << std::endl;
 
177
 
 
178
   return pixbuf;
 
179
}
 
180
 
 
181
GtkWidget *get_gtk_image(const gchar *name, int size)
 
182
{
 
183
   GdkPixbuf *buf;
 
184
   buf = get_gdk_pixbuf(name, size);
 
185
   if(!buf)
 
186
      return NULL;
 
187
   return gtk_image_new_from_pixbuf(buf);
176
188
}
177
189
 
178
190
 
212
224
 
213
225
void RGPackageStatus::initPixbufs()
214
226
{
215
 
   gchar *filename = NULL;
216
 
 
 
227
   gchar *s;
217
228
   for (int i = 0; i < N_STATUS_COUNT; i++) {
218
 
      filename = g_strdup_printf("../pixmaps/package-%s.png",
219
 
                                 PackageStatusShortString[i]);
220
 
      if (!FileExists(filename)) {
221
 
         g_free(filename);
222
 
         filename = g_strdup_printf(SYNAPTIC_PIXMAPDIR "package-%s.png",
223
 
                                    PackageStatusShortString[i]);
224
 
      }
225
 
      StatusPixbuf[i] = gdk_pixbuf_new_from_file(filename, NULL);
226
 
      if (StatusPixbuf[i] == NULL)
227
 
         std::cerr << "Warning, failed to load: " << filename << std::endl;
228
 
      g_free(filename);
 
229
      s = g_strdup_printf("package-%s", PackageStatusShortString[i]);
 
230
      StatusPixbuf[i] = get_gdk_pixbuf(s);
229
231
   }
230
 
 
231
 
   filename = "../pixmaps/package-supported.png";
232
 
   if (!FileExists(filename)) 
233
 
      filename = SYNAPTIC_PIXMAPDIR "package-supported.png";
234
 
   
235
 
   supportedPix = gdk_pixbuf_new_from_file(filename, NULL);
236
 
   if (supportedPix == NULL)
237
 
      std::cerr << "Warning, failed to load: " << filename << std::endl;
 
232
   supportedPix = get_gdk_pixbuf("package-supported");
238
233
}
239
234
 
240
235
// class that finds out what do display to get user