File: support.c

package info (click to toggle)
gpr 0.12deb1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 1,568 kB
  • ctags: 250
  • sloc: sh: 6,138; ansic: 3,684; makefile: 86; sed: 16
file content (112 lines) | stat: -rw-r--r-- 2,748 bytes parent folder | download | duplicates (2)
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
/*
 * GPR
 *
 * Copyright (C) 2006 A. Mennucci
 *
 * Copyright (C) 2000 CompuMetric Labs, Inc.
 *
 * For more information contact:
 *        Thomas Hubbell
 *        CompuMetric Labs, Inc.
 *        5920 Grelot Road, Suite C-2
 *        Mobile, AL 36609
 * 
 * Voice: (334) 342-2220
 *   Fax: (334) 343-2261
 * Email: thubbell@compumetric.com
 *   Web: http://www.compumetric.com
 *
 * 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 2
 * 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.
 *    
 *        File: Support.c
 * 
 * Description: Support functions needed by gpr.
 */


#ifdef HAVE_CONFIG_H
#  include <config.h>
#endif

#include <sys/stat.h>
#include <unistd.h>
#include <string.h>

#include <gtk/gtk.h>

#include "support.h"

GtkWidget *lookup_widget(GtkWidget * widget, const gchar * widget_name)
{
	GtkWidget *parent, *found_widget;

	for (;;) {
		if (GTK_IS_MENU(widget))
			parent = gtk_menu_get_attach_widget(GTK_MENU(widget));
		else
			parent = widget->parent;
		if (parent == NULL)
			break;
		widget = parent;
	}

	found_widget =
	    (GtkWidget *) gtk_object_get_data(GTK_OBJECT(widget), widget_name);
	if (!found_widget)
		g_warning(_("Widget not found: %s"), widget_name);
	return found_widget;
}

/* This is a dummy pixmap we use when a pixmap can't be found. */
static char *dummy_pixmap_xpm[] = {
/* columns rows colors chars-per-pixel */
	"1 1 1 1",
	"  c None",
/* pixels */
	" ",
	" "
};







GtkWidget *create_pixmap_from_data
(
 GtkWidget * widget,
 gchar ** xpm_data,
 gboolean gnome_pixmap
) {

        GdkColormap *colormap;
        GdkPixmap *gdkpixmap;
        GdkBitmap *mask;
        GtkWidget *pixmap;

        g_assert (!gnome_pixmap);      

        colormap = gtk_widget_get_colormap(widget);
        gdkpixmap =
            gdk_pixmap_colormap_create_from_xpm_d(NULL, colormap, &mask, NULL,
                                                  xpm_data);
        if (gdkpixmap == NULL)
                g_error(_("Couldn't create pixmap from data."));
        pixmap = gtk_pixmap_new(gdkpixmap, mask);
        gdk_pixmap_unref(gdkpixmap);
        gdk_bitmap_unref(mask);
        return pixmap;
}