~bratsche/ubuntu/maverick/gtk+2.0/menu-activation-fix

« back to all changes in this revision

Viewing changes to tests/pixbuf-threads.c

  • Committer: Bazaar Package Importer
  • Author(s): Robert Ancell
  • Date: 2010-07-22 21:41:30 UTC
  • mfrom: (1.11.7 upstream) (72.1.16 experimental)
  • Revision ID: james.westby@ubuntu.com-20100722214130-5uzyvpb9g4m0ts2c
Tags: 2.21.5-1ubuntu1
* Merge with Debian experimental, Ubuntu changes:
* debian/control.in:
  - Add introspection build-depends
  - Add Vcs-Bzr link
  - Add gir1.0-gtk-2.0 package
  - libgtk2.0-dev replaces gir-repository-dev
  - Conflict with appmenu-gtk (<< 0.1.3) to prevent menu proxy breakage
* debian/rules:
  - Build with --enable-introspection
  - Add gir1.0-gtk-2.0 package to BINARY_ARCH_PKGS
  - Add dh_girepository call
  - Disable devhelp files
* debian/dh_gtkmodules.in:
  - Remove obsolete script content
* debian/libgtk2.0-0.symbols:
  - Add Ubuntu specific symbols
* debian/libgtk2.0-dev.install.in:
  - Add gir files
* debian/libgtk2.0-doc.install.in
  - Disable devhelp files
* debian/gir1.0-gtk-2.0.install.in
  - Introspection package
* debian/patches/043_menu_proxy.patch
  - Add GtkMenuProxy support for remoting menus.
* debian/patches/062_dnd_menubar.patch:
  - Allow click on menubars for dnd
* debian/patches/063_treeview_almost_fixed.patch:
  - Add an ubuntu-almost-fixed-height-mode property, (required for
    software-center)
* debian/patches/071_no_offscreen_widgets_grabbing.patch:
  - Don't let offscreen widgets do grabbing
* debian/patches/072_indicator_menu_update.patch:
  - change by Cody Russell to send an update event on menu changes,
    should make the bluetooth indicator refresh correctly
* debian/patches/091_bugzilla_tooltip_refresh.patch:
  - Upstream bugzilla change to have better looking tooltips the gtk theme
    need to set "new-tooltip-style" to use those
* debian/watch:
  - Watch for unstable versions

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* -*- Mode: C; c-basic-offset: 2; -*- */
2
 
/* GdkPixbuf library - test loaders
3
 
 *
4
 
 * Copyright (C) 2004 Matthias Clasen <mclasen@redhat.com>
5
 
 *
6
 
 * This program is free software; you can redistribute it and/or modify
7
 
 * it under the terms of the GNU General Public License as published by
8
 
 * the Free Software Foundation; either version 2 of the License, or
9
 
 * (at your option) any later version.
10
 
 *
11
 
 * This program is distributed in the hope that it will be useful,
12
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 
 * GNU General Public License for more details.
15
 
 *
16
 
 * You should have received a copy of the GNU General Public License
17
 
 * along with this program; if not, write to the Free Software
18
 
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
19
 
 */
20
 
 
21
 
#include "config.h"
22
 
#include "gdk-pixbuf/gdk-pixbuf.h"
23
 
#include <stdio.h>
24
 
#include <stdlib.h>
25
 
#include <string.h>
26
 
 
27
 
static gboolean verbose = FALSE;
28
 
 
29
 
static void
30
 
load_image (gpointer  data, 
31
 
            gpointer user_data)
32
 
{
33
 
  gchar *filename = data;
34
 
  FILE *file;
35
 
  int nbytes;
36
 
  guchar buf[1024];
37
 
  size_t bufsize = 1024;
38
 
  GdkPixbufLoader *loader;
39
 
  GError *error = NULL;
40
 
  GThread *self;
41
 
 
42
 
  self = g_thread_self ();
43
 
  loader = gdk_pixbuf_loader_new ();
44
 
 
45
 
  file = fopen (filename, "r");
46
 
  g_assert (file);
47
 
 
48
 
  if (verbose) g_print ("%p start image %s\n", self, filename);
49
 
  while (!feof (file)) 
50
 
    {
51
 
      nbytes = fread (buf, 1, bufsize, file);
52
 
      if (!gdk_pixbuf_loader_write (loader, buf, nbytes, &error)) 
53
 
        {
54
 
          g_warning ("Error writing %s to loader: %s", filename, error->message);
55
 
          g_error_free (error);
56
 
          error = NULL;
57
 
          break;
58
 
        }
59
 
      if (verbose) g_print ("%p read %d bytes\n", self, nbytes);
60
 
 
61
 
      g_thread_yield ();      
62
 
    }
63
 
 
64
 
  fclose (file);
65
 
 
66
 
  if (verbose) g_print ("%p finish image %s\n", self, filename);
67
 
 
68
 
  if (!gdk_pixbuf_loader_close (loader, &error)) 
69
 
    {
70
 
      g_warning ("Error closing loader for %s: %s", filename, error->message);
71
 
      g_error_free (error);
72
 
    }
73
 
 
74
 
  g_object_unref (loader);
75
 
}
76
 
 
77
 
static void
78
 
usage (void)
79
 
{
80
 
  g_print ("usage: pixbuf-threads [--verbose] <files>\n");
81
 
  exit (EXIT_FAILURE);
82
 
}
83
 
 
84
 
int
85
 
main (int argc, char **argv)
86
 
{
87
 
  int i, start;
88
 
  GThreadPool *pool;
89
 
  
90
 
  g_type_init ();
91
 
 
92
 
  if (!g_thread_supported ())
93
 
    g_thread_init (NULL);
94
 
 
95
 
  g_log_set_always_fatal (G_LOG_LEVEL_WARNING | G_LOG_LEVEL_ERROR | G_LOG_LEVEL_CRITICAL);
96
 
 
97
 
  if (argc == 1)
98
 
    usage();
99
 
 
100
 
  start = 1;
101
 
  if (strcmp (argv[1], "--verbose") == 0)
102
 
    {
103
 
      verbose = TRUE;
104
 
      start = 2;
105
 
    }
106
 
  
107
 
  pool = g_thread_pool_new (load_image, NULL, 20, FALSE, NULL);
108
 
 
109
 
  i = start;
110
 
  while (1) {
111
 
    i++;
112
 
    if (i == argc)
113
 
      i = start;
114
 
    g_thread_pool_push (pool, argv[i], NULL);
115
 
  }
116
 
  
117
 
  return 0;
118
 
}