Re: Issue with gtk+ 2.8.15 for win32
- From: Elden Armbrust <earmbrust xero-soft com>
- To: Gtk <gtk-app-devel-list gnome org>
- Subject: Re: Issue with gtk+ 2.8.15 for win32
- Date: Fri, 24 Mar 2006 16:04:53 -0500
Elden Armbrust wrote:
I'm not sure if this is a bug, error on my part, or otherwise, so I
figured it best to ask the list.
When exiting out of a program written in C using GTK+ 2.8.15, the
process does not end (ever) but the window does close.
Another question: Is there anyone knowledgable in how to use gtk-wimp
on a per application basis, rather than a system wide GTK implementation?
Oh yes, and this is my first mailing to the list. Howdy all :)
-Elden Armbrust
I've added the source code (relevant) in this message.
It might be worthwhile to know that ALL of this code was generated by
wGlade 0.2.
(I've yet to add any of my own code, aside from commenting out the
pixmap additions in main.c.)
Code - interface.c:
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <string.h>
#include <gdk/gdkkeysyms.h>
#include <gtk/gtk.h>
#include "callbacks.h"
#include "interface.h"
#include "support.h"
GtkWidget*
create_wndMain (void)
{
GtkWidget *wndMain;
GtkWidget *fixed1;
GtkWidget *button2;
GtkWidget *button3;
GtkWidget *frame2;
GtkWidget *fixed2;
GtkWidget *combo2;
GtkWidget *combo_entry2;
GtkWidget *combo1;
GtkWidget *combo_entry1;
GtkWidget *label2;
GtkWidget *checkbutton1;
GtkWidget *checkbutton2;
GtkWidget *label1;
GtkWidget *checkbutton3;
wndMain = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_object_set_data (GTK_OBJECT (wndMain), "wndMain", wndMain);
gtk_window_set_title (GTK_WINDOW (wndMain), "BubblePop! Settings");
fixed1 = gtk_fixed_new ();
gtk_widget_ref (fixed1);
gtk_object_set_data_full (GTK_OBJECT (wndMain), "fixed1", fixed1,
(GtkDestroyNotify) gtk_widget_unref);
gtk_widget_show (fixed1);
gtk_container_add (GTK_CONTAINER (wndMain), fixed1);
button2 = gtk_button_new_with_label ("OK");
gtk_widget_ref (button2);
gtk_object_set_data_full (GTK_OBJECT (wndMain), "button2", button2,
(GtkDestroyNotify) gtk_widget_unref);
gtk_widget_show (button2);
gtk_fixed_put (GTK_FIXED (fixed1), button2, 264, 152);
gtk_widget_set_uposition (button2, 264, 152);
gtk_widget_set_usize (button2, 49, 24);
button3 = gtk_button_new_with_label ("Cancel");
gtk_widget_ref (button3);
gtk_object_set_data_full (GTK_OBJECT (wndMain), "button3", button3,
(GtkDestroyNotify) gtk_widget_unref);
gtk_widget_show (button3);
gtk_fixed_put (GTK_FIXED (fixed1), button3, 208, 152);
gtk_widget_set_uposition (button3, 208, 152);
gtk_widget_set_usize (button3, 49, 24);
frame2 = gtk_frame_new ("Settings");
gtk_widget_ref (frame2);
gtk_object_set_data_full (GTK_OBJECT (wndMain), "frame2", frame2,
(GtkDestroyNotify) gtk_widget_unref);
gtk_widget_show (frame2);
gtk_fixed_put (GTK_FIXED (fixed1), frame2, 0, 0);
gtk_widget_set_uposition (frame2, 0, 0);
gtk_widget_set_usize (frame2, 313, 145);
fixed2 = gtk_fixed_new ();
gtk_widget_ref (fixed2);
gtk_object_set_data_full (GTK_OBJECT (wndMain), "fixed2", fixed2,
(GtkDestroyNotify) gtk_widget_unref);
gtk_widget_show (fixed2);
gtk_container_add (GTK_CONTAINER (frame2), fixed2);
combo2 = gtk_combo_new ();
gtk_widget_ref (combo2);
gtk_object_set_data_full (GTK_OBJECT (wndMain), "combo2", combo2,
(GtkDestroyNotify) gtk_widget_unref);
gtk_widget_show (combo2);
gtk_fixed_put (GTK_FIXED (fixed2), combo2, 168, 32);
gtk_widget_set_uposition (combo2, 168, 32);
gtk_widget_set_usize (combo2, 113, 24);
combo_entry2 = GTK_COMBO (combo2)->entry;
gtk_widget_ref (combo_entry2);
gtk_object_set_data_full (GTK_OBJECT (wndMain), "combo_entry2",
combo_entry2,
(GtkDestroyNotify) gtk_widget_unref);
gtk_widget_show (combo_entry2);
combo1 = gtk_combo_new ();
gtk_widget_ref (combo1);
gtk_object_set_data_full (GTK_OBJECT (wndMain), "combo1", combo1,
(GtkDestroyNotify) gtk_widget_unref);
gtk_widget_show (combo1);
gtk_fixed_put (GTK_FIXED (fixed2), combo1, 16, 32);
gtk_widget_set_uposition (combo1, 16, 32);
gtk_widget_set_usize (combo1, 123, 24);
combo_entry1 = GTK_COMBO (combo1)->entry;
gtk_widget_ref (combo_entry1);
gtk_object_set_data_full (GTK_OBJECT (wndMain), "combo_entry1",
combo_entry1,
(GtkDestroyNotify) gtk_widget_unref);
gtk_widget_show (combo_entry1);
label2 = gtk_label_new ("Audio Buffer Size");
gtk_widget_ref (label2);
gtk_object_set_data_full (GTK_OBJECT (wndMain), "label2", label2,
(GtkDestroyNotify) gtk_widget_unref);
gtk_widget_show (label2);
gtk_fixed_put (GTK_FIXED (fixed2), label2, 168, 16);
gtk_widget_set_uposition (label2, 168, 16);
gtk_widget_set_usize (label2, 109, 18);
checkbutton1 = gtk_check_button_new_with_label ("Sound Effects");
gtk_widget_ref (checkbutton1);
gtk_object_set_data_full (GTK_OBJECT (wndMain), "checkbutton1",
checkbutton1,
(GtkDestroyNotify) gtk_widget_unref);
gtk_widget_show (checkbutton1);
gtk_fixed_put (GTK_FIXED (fixed2), checkbutton1, 176, 64);
gtk_widget_set_uposition (checkbutton1, 176, 64);
gtk_widget_set_usize (checkbutton1, 102, 26);
checkbutton2 = gtk_check_button_new_with_label ("Music");
gtk_widget_ref (checkbutton2);
gtk_object_set_data_full (GTK_OBJECT (wndMain), "checkbutton2",
checkbutton2,
(GtkDestroyNotify) gtk_widget_unref);
gtk_widget_show (checkbutton2);
gtk_fixed_put (GTK_FIXED (fixed2), checkbutton2, 176, 88);
gtk_widget_set_uposition (checkbutton2, 176, 88);
gtk_widget_set_usize (checkbutton2, 102, 26);
label1 = gtk_label_new ("Video Resolution");
gtk_widget_ref (label1);
gtk_object_set_data_full (GTK_OBJECT (wndMain), "label1", label1,
(GtkDestroyNotify) gtk_widget_unref);
gtk_widget_show (label1);
gtk_fixed_put (GTK_FIXED (fixed2), label1, 8, 16);
gtk_widget_set_uposition (label1, 8, 16);
gtk_widget_set_usize (label1, 113, 18);
checkbutton3 = gtk_check_button_new_with_label ("Full Screen");
gtk_widget_ref (checkbutton3);
gtk_object_set_data_full (GTK_OBJECT (wndMain), "checkbutton3",
checkbutton3,
(GtkDestroyNotify) gtk_widget_unref);
gtk_widget_show (checkbutton3);
gtk_fixed_put (GTK_FIXED (fixed2), checkbutton3, 16, 64);
gtk_widget_set_uposition (checkbutton3, 16, 64);
gtk_widget_set_usize (checkbutton3, 102, 26);
gtk_widget_grab_default (button2);
return wndMain;
}
Code - support.c:
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <string.h>
#include <gtk/gtk.h>
#include "support.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)
{
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 */
" "
};
/* 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. */
void
add_pixmap_directory (const gchar *directory)
{
pixmaps_directories = g_list_prepend (pixmaps_directories,
g_strdup (directory));
}
/* 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;
GtkWidget *pixmap;
GList *elem;
if (!filename || !filename[0])
return create_dummy_pixmap (widget);
/* 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;
}
/* If we haven't found the pixmap, try the source directory. */
if (!found_filename)
{
found_filename = check_file_exists ( "pixmaps", filename);
}
if (!found_filename)
{
g_warning ("Couldn't find pixmap file: %s", filename);
return create_dummy_pixmap (widget);
}
colormap = gtk_widget_get_colormap (widget);
gdkpixmap = gdk_pixmap_colormap_create_from_xpm (NULL, colormap, &mask,
NULL, found_filename);
if (gdkpixmap == NULL)
{
g_warning ("Error loading pixmap file: %s", found_filename);
g_free (found_filename);
return create_dummy_pixmap (widget);
}
g_free (found_filename);
pixmap = gtk_pixmap_new (gdkpixmap, mask);
gdk_pixmap_unref (gdkpixmap);
gdk_bitmap_unref (mask);
return pixmap;
}
/* This is an internally used function to check if a pixmap file exists. */
gchar*
check_file_exists (const gchar *directory,
const gchar *filename)
{
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;
}
Code - main.c:
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <gtk/gtk.h>
#include "interface.h"
#include "support.h"
int
main (int argc, char *argv[])
{
GtkWidget *wndMain;
gtk_set_locale ();
gtk_init (&argc, &argv);
//add_pixmap_directory ("pixmaps");
//add_pixmap_directory ("pixmaps");
/*
* The following code was added by Glade to create one of each component
* (except popup menus), just so that you see something after building
* the project. Delete any components that you don't want shown initially.
*/
wndMain = create_wndMain ();
gtk_widget_show (wndMain);
gtk_main ();
return 0;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]