Commit 39208cd2 authored by simonmar's avatar simonmar
Browse files

[project @ 2005-12-09 11:35:44 by simonmar]

Make the front panel compile again, submitted by Duncan Coutts
<duncan.coutts@worc.ox.ac.uk>.  From his email:

Attached is a patch to port the GHC RTS font panel to Gtk+ 2.x rather
than the obsolete Gtk+ 1.2.

There were basically two changes needed. Change the configure check to
look for the pkg-config utility rather than the old gtk-config. At it's
just checking for Gtk+ 2.0 or later. It may be that the new code
actually needs a slightly later version than that. I'm not quite sure.

The other change was to convert the ghc-fontpanel.glade file to the
glade-2 format using the libglade-convert script and then to re-generate
the C code for constructing the GUI, that is the Vis*.c Vis*.h files in
ghc/rts.

The front panel has been bit-rotting for quite some time so it has not
kept up with changes in the rts structures. So I had to comment out
references to 3 bits that no longer exist. I've left FIXMEs in the code
at the appropriate places so that someone wiser than me can make the
appropriate changes.

So the thing does now build though I have no doubt that it will not run,
or at least will not do the right thing because it has not yet been
updated to the current state of the rts. However hopefully now that it
is at least buildable with a modern Gtk+ version someone else might be
able to fix it up.

This also relates to trac ticket #599:

http://cvs.haskell.org/trac/ghc/ticket/599
parent 7836463f
# Initialise and check sanity.
AC_INIT([The Glorious Glasgow Haskell Compilation System], [6.5], [glasgow-haskell-bugs@haskell.org], [ghc])
AC_INIT([The Glorious Glasgow Haskell Compilation System], [6.5.20051208], [glasgow-haskell-bugs@haskell.org], [ghc])
AC_CONFIG_SRCDIR([ghc.spec.in])
# duplicate from ../configure.ac
......@@ -24,13 +24,14 @@ FP_GCC_NEEDS_NO_OMIT_LFPTR
FP_GHC_HAS_READLINE
# test for GTK+
AC_PATH_PROGS([GTK_CONFIG], [gtk-config gtk12-config])
AC_PATH_PROGS([GTK_CONFIG], [pkg-config])
if test -n "$GTK_CONFIG"; then
AC_CACHE_CHECK([for version of GTK+], [fp_cv_gtk_version],
[fp_cv_gtk_version=`$GTK_CONFIG --version`])
FP_COMPARE_VERSIONS([$fp_cv_gtk_version], [-lt], [1.2],
[AC_MSG_WARN([GTK+ not usable, need at least version 1.2])
GTK_CONFIG=])
if $GTK_CONFIG gtk+-2.0 --atleast-version=2.0; then
GTK_CONFIG="$GTK_CONFIG gtk+-2.0"
else
AC_MSG_WARN([GTK+ not usable, need at least version 2.0])
GTK_CONFIG=
fi
fi
AC_SUBST([GTK_CONFIG])
......
......@@ -20,9 +20,9 @@
#include "RtsFlags.h"
#include "Schedule.h"
#include <unistd.h>
#include <gdk/gdktypes.h>
#include <gtk/gtk.h>
#include <unistd.h>
#include <string.h>
#include "VisSupport.h"
#include "VisWindow.h"
......@@ -605,7 +605,7 @@ residencyCensus( void )
g == 0 && s == 0) continue;
if (RtsFlags.GcFlags.generations == 1) {
bd = generations[g].steps[s].to_blocks;
/* bd = generations[g].steps[s].to_blocks; FIXME to_blocks does not exist */
} else {
bd = generations[g].steps[s].blocks;
}
......@@ -668,7 +668,7 @@ residencyCensus( void )
case SE_CAF_BLACKHOLE:
case SE_BLACKHOLE:
case BLACKHOLE:
case BLACKHOLE_BQ:
/* case BLACKHOLE_BQ: FIXME: case does not exist */
size = sizeW_fromITBL(info);
type = BlackHole;
break;
......@@ -703,7 +703,7 @@ residencyCensus( void )
case STABLE_NAME:
case MVAR:
case MUT_VAR:
case MUT_CONS:
/* case MUT_CONS: FIXME: case does not exist */
case IND_PERM:
case IND_OLDGEN_PERM:
size = sizeW_fromITBL(info);
......
......@@ -10,18 +10,12 @@
#include <sys/stat.h>
#include <unistd.h>
#include <string.h>
#include <stdio.h>
#include <gtk/gtk.h>
#include "VisSupport.h"
/* This is an internally used function to check if a pixmap file exists. */
static gchar* check_file_exists (const gchar *directory,
const gchar *filename);
/* This is an internally used function to create pixmaps. */
static GtkWidget* create_dummy_pixmap (GtkWidget *widget);
GtkWidget*
lookup_widget (GtkWidget *widget,
const gchar *widget_name)
......@@ -34,47 +28,20 @@ lookup_widget (GtkWidget *widget,
parent = gtk_menu_get_attach_widget (GTK_MENU (widget));
else
parent = widget->parent;
if (!parent)
parent = (GtkWidget*) g_object_get_data (G_OBJECT (widget), "GladeParentKey");
if (parent == NULL)
break;
widget = parent;
}
found_widget = (GtkWidget*) gtk_object_get_data (GTK_OBJECT (widget),
widget_name);
found_widget = (GtkWidget*) g_object_get_data (G_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 */
" "
};
/* This is an internally used function to create pixmaps. */
static GtkWidget*
create_dummy_pixmap (GtkWidget *widget)
{
GdkColormap *colormap;
GdkPixmap *gdkpixmap;
GdkBitmap *mask;
GtkWidget *pixmap;
colormap = gtk_widget_get_colormap (widget);
gdkpixmap = gdk_pixmap_colormap_create_from_xpm_d (NULL, colormap, &mask,
NULL, dummy_pixmap_xpm);
if (gdkpixmap == NULL)
g_error ("Couldn't create replacement pixmap.");
pixmap = gtk_pixmap_new (gdkpixmap, mask);
gdk_pixmap_unref (gdkpixmap);
gdk_bitmap_unref (mask);
return pixmap;
}
static GList *pixmaps_directories = NULL;
/* Use this function to set the directory containing installed pixmaps. */
......@@ -85,78 +52,93 @@ add_pixmap_directory (const gchar *directory)
g_strdup (directory));
}
/* This is an internally used function to find pixmap files. */
static gchar*
find_pixmap_file (const gchar *filename)
{
GList *elem;
/* We step through each of the pixmaps directory to find it. */
elem = pixmaps_directories;
while (elem)
{
gchar *pathname = g_strdup_printf ("%s%s%s", (gchar*)elem->data,
G_DIR_SEPARATOR_S, filename);
if (g_file_test (pathname, G_FILE_TEST_EXISTS))
return pathname;
g_free (pathname);
elem = elem->next;
}
return NULL;
}
/* This is an internally used function to create pixmaps. */
GtkWidget*
create_pixmap (GtkWidget *widget,
const gchar *filename)
{
gchar *found_filename = NULL;
GdkColormap *colormap;
GdkPixmap *gdkpixmap;
GdkBitmap *mask;
gchar *pathname = NULL;
GtkWidget *pixmap;
GList *elem;
if (!filename || !filename[0])
return create_dummy_pixmap (widget);
return gtk_image_new ();
/* We first try any pixmaps directories set by the application. */
elem = pixmaps_directories;
while (elem)
{
found_filename = check_file_exists ((gchar*)elem->data, filename);
if (found_filename)
break;
elem = elem->next;
}
pathname = find_pixmap_file (filename);
/* If we haven't found the pixmap, try the source directory. */
if (!found_filename)
if (!pathname)
{
found_filename = check_file_exists ("../pixmaps", filename);
g_warning ("Couldn't find pixmap file: %s", filename);
return gtk_image_new ();
}
if (!found_filename)
pixmap = gtk_image_new_from_file (pathname);
g_free (pathname);
return pixmap;
}
/* This is an internally used function to create pixmaps. */
GdkPixbuf*
create_pixbuf (const gchar *filename)
{
gchar *pathname = NULL;
GdkPixbuf *pixbuf;
GError *error = NULL;
if (!filename || !filename[0])
return NULL;
pathname = find_pixmap_file (filename);
if (!pathname)
{
g_warning ("Couldn't find pixmap file: %s", filename);
return create_dummy_pixmap (widget);
return NULL;
}
colormap = gtk_widget_get_colormap (widget);
gdkpixmap = gdk_pixmap_colormap_create_from_xpm (NULL, colormap, &mask,
NULL, found_filename);
if (gdkpixmap == NULL)
pixbuf = gdk_pixbuf_new_from_file (pathname, &error);
if (!pixbuf)
{
g_warning ("Error loading pixmap file: %s", found_filename);
g_free (found_filename);
return create_dummy_pixmap (widget);
fprintf (stderr, "Failed to load pixbuf file: %s: %s\n",
pathname, error->message);
g_error_free (error);
}
g_free (found_filename);
pixmap = gtk_pixmap_new (gdkpixmap, mask);
gdk_pixmap_unref (gdkpixmap);
gdk_bitmap_unref (mask);
return pixmap;
g_free (pathname);
return pixbuf;
}
/* This is an internally used function to check if a pixmap file exists. */
gchar*
check_file_exists (const gchar *directory,
const gchar *filename)
/* This is used to set ATK action descriptions. */
void
glade_set_atk_action_description (AtkAction *action,
const gchar *action_name,
const gchar *description)
{
gchar *full_filename;
struct stat s;
gint status;
full_filename = (gchar*) g_malloc (strlen (directory) + 1
+ strlen (filename) + 1);
strcpy (full_filename, directory);
strcat (full_filename, G_DIR_SEPARATOR_S);
strcat (full_filename, filename);
status = stat (full_filename, &s);
if (status == 0 && S_ISREG (s.st_mode))
return full_filename;
g_free (full_filename);
return NULL;
gint n_actions, i;
n_actions = atk_action_get_n_actions (action);
for (i = 0; i < n_actions; i++)
{
if (!strcmp (atk_action_get_name (action, i), action_name))
atk_action_set_description (action, i, description);
}
}
......@@ -21,8 +21,6 @@
GtkWidget* lookup_widget (GtkWidget *widget,
const gchar *widget_name);
/* get_widget() is deprecated. Use lookup_widget instead. */
#define get_widget lookup_widget
/* Use this function to set the directory containing installed pixmaps. */
void add_pixmap_directory (const gchar *directory);
......@@ -32,7 +30,15 @@ void add_pixmap_directory (const gchar *directory);
* Private Functions.
*/
/* This is used to create the pixmaps in the interface. */
/* This is used to create the pixmaps used in the interface. */
GtkWidget* create_pixmap (GtkWidget *widget,
const gchar *filename);
/* This is used to create the pixbufs used in the interface. */
GdkPixbuf* create_pixbuf (const gchar *filename);
/* This is used to set ATK action descriptions. */
void glade_set_atk_action_description (AtkAction *action,
const gchar *action_name,
const gchar *description);
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment