diff -uNr gnome-0.7/ChangeLog gnome-0.8/ChangeLog --- gnome-0.7/ChangeLog Wed Sep 24 18:14:33 1997 +++ gnome-0.8/ChangeLog Thu Oct 9 20:55:34 1997 @@ -1,3 +1,13 @@ +Thu Oct 9 20:54:55 1997 Federico Mena + + * programs/panel/panel.c: Lots of bug fixes and new features. Can + now save configuration properly, add new applets to the panel, etc. + +Fri Oct 3 15:21:36 1997 Federico Mena + + * libgnomeui/gnome-pixmap.c (gnome_create_pixmap_widget): Make + sure the widget is realized before creating pixmap. + Tue Sep 23 01:47:56 1997 Radek Doulik * programs/desktop-properties/main.c (display_properties_setup): diff -uNr gnome-0.7/configure gnome-0.8/configure --- gnome-0.7/configure Thu Oct 2 23:07:03 1997 +++ gnome-0.8/configure Thu Oct 9 20:56:07 1997 @@ -538,7 +538,7 @@ -VERSION=0.7 +VERSION=0.8 cat >> confdefs.h <file = strtok (p->path, sep); p->section = strtok (NULL, "/="); - p->key = strtok (NULL, "/="); + p->key = strtok (NULL, "="); p->def = strtok (NULL, "="); /* Was it a Gnome-relative pathname? */ @@ -340,7 +340,8 @@ if (!p) return; dump_keys (profile, p->link); - fprintf (profile, "%s=%s\n", p->key_name, p->value); + if (*p->key_name) + fprintf (profile, "%s=%s\n", p->key_name, p->value); } static void @@ -473,8 +474,8 @@ TKeys *keys = (TKeys *) s; if (keys){ - *key = keys->key_name; - *value = keys->value; + *key = g_strdup (keys->key_name); + *value = g_strdup (keys->value); keys = keys->link; } return keys; @@ -502,6 +503,34 @@ if (strcasecmp (section->section_name, pp->section)) continue; section->section_name [0] = 0; + } + release_path (pp); +} + +void +gnome_config_clean_key (char *path) + /* *section_name, char *file */ +{ + TSecHeader *section; + TKeys *key; + ParsedPath *pp; + + pp = parse_path (path); + + /* We assume the user has called one of the other initialization funcs */ + if (!is_loaded (pp->file, §ion)){ + fprintf (stderr,"Warning: profile_clean_section called before init\n"); + release_path (pp); + return; + } + for (; section; section = section->link){ + if (strcasecmp (section->section_name, pp->section)) + continue; + for (key = section->keys; key; key = key->link){ + if (strcasecmp (key->key_name, pp->key)) + continue; + key->key_name [0] = 0; + } } release_path (pp); } diff -uNr gnome-0.7/libgnome/gnome-config.h gnome-0.8/libgnome/gnome-config.h --- gnome-0.7/libgnome/gnome-config.h Wed Oct 1 16:20:07 1997 +++ gnome-0.8/libgnome/gnome-config.h Mon Oct 6 20:50:23 1997 @@ -29,6 +29,8 @@ /* This routine drops all of the information related to /file/section */ void gnome_config_clean_section (char *path); +/* Drops the information for a specific key */ +void gnome_config_clean_key (char *path); void gnome_config_set_prefix (char *path); void gnome_config_drop_prefix (void); diff -uNr gnome-0.7/libgnome/gnome-dentry.c gnome-0.8/libgnome/gnome-dentry.c --- gnome-0.7/libgnome/gnome-dentry.c Wed Dec 31 18:00:00 1969 +++ gnome-0.8/libgnome/gnome-dentry.c Thu Oct 9 14:27:20 1997 @@ -0,0 +1,150 @@ +/* + * Support for manipulating .desktop files + * + * (C) 1997 the Free Software Foundation + * + * Author: Miguel de Icaza. + */ +#include +#include +#include +#include +#include +#include +#include "gnome-defs.h" +#include "gnome-util.h" +#include "gnome-config.h" +#include "gnome-dentry.h" + +#define free_if_empty(x) { if (x) g_free (x); } + +int +gnome_is_program_in_path (char *program) +{ + static char *path; + static char **paths; + char **p; + char *f; + + if (!path){ + char *p; + int i, pc = 1; + + path = strdup (getenv ("PATH")); + for (p = path; *p; p++) + if (*p == ':') + pc++; + + paths = (char **) g_malloc (sizeof (char *) * (pc+1)); + + for (p = path, i = 0; i < pc; i++){ + paths [i] = strtok (p, ":"); + p = NULL; + } + paths [pc] = NULL; + } + p = paths; + while (*p){ + f = g_concat_dir_and_file (*p, program); + if (g_file_exists (f)){ + g_free (f); + return 1; + } + g_free (f); + p++; + } + return 0; +} + +struct gnome_desktop_entry * +gnome_desktop_entry_load (char *file) + +{ + struct gnome_desktop_entry *newitem; + char *prefix = g_copy_strings ("=", file, "=/Desktop Entry/", NULL); + char *exec_file, *try_file, *dot; + + gnome_config_set_prefix (prefix); + g_free (prefix); + + exec_file = gnome_config_get_string ("Exec"); + if (!exec_file){ + gnome_config_drop_prefix (); + return 0; + } + try_file = gnome_config_get_string ("TryExec"); + if (try_file){ + if (!gnome_is_program_in_path (try_file)){ + g_free (try_file); + g_free (exec_file); + gnome_config_drop_prefix (); + return 0; + } + } + g_free (try_file); + newitem = g_malloc (sizeof (struct gnome_desktop_entry)); + newitem->exec = exec_file; + newitem->icon_base = gnome_config_get_string ("Icon"); + newitem->docpath = gnome_config_get_string ("DocPath"); + newitem->info = gnome_config_get_string ("Info"); + newitem->terminal = gnome_config_get_int ("Terminal"); + newitem->type = gnome_config_get_string ("Type"); + newitem->location = strdup (file); + + if (newitem->icon_base && *newitem->icon_base){ + dot = strstr (newitem->icon_base, ".xpm"); + + if (dot){ + *dot = 0; + + newitem->small_icon = g_copy_strings (newitem->icon_base, + "-small.xpm", NULL); + newitem->transparent_icon = g_copy_strings (newitem->icon_base, + "-transparent.xpm", NULL); + *dot = '.'; + } + + /* Sigh, now we need to make them local to the gnome install */ + if (*newitem->icon_base != '/'){ + char *s = newitem->small_icon; + char *t = newitem->transparent_icon; + + newitem->small_icon = gnome_pixmap_file (s); + newitem->transparent_icon = gnome_pixmap_file (t); + g_free (s); + g_free (t); + } + } else { + newitem->small_icon = newitem->transparent_icon = 0; + } + gnome_config_drop_prefix (); + return newitem; +} + +void +gnome_desktop_entry_free (struct gnome_desktop_entry *item) +{ + free_if_empty (item->exec); + free_if_empty (item->icon_base); + free_if_empty (item->docpath); + free_if_empty (item->info); + free_if_empty (item->type); + free_if_empty (item->small_icon); + free_if_empty (item->transparent_icon); + free_if_empty (item->location); + g_free (item); +} + +void +gnome_desktop_entry_launch (struct gnome_desktop_entry *item) +{ + char *command; + + if (item->terminal) + command = g_copy_strings ("(xterm -e \"", item->exec, "\") &", NULL); + else + command = g_copy_strings ("(true;", item->exec, ") &", NULL); + system (command); + g_free (command); +} + diff -uNr gnome-0.7/libgnome/gnome-dentry.h gnome-0.8/libgnome/gnome-dentry.h --- gnome-0.7/libgnome/gnome-dentry.h Wed Dec 31 18:00:00 1969 +++ gnome-0.8/libgnome/gnome-dentry.h Wed Oct 8 17:10:20 1997 @@ -0,0 +1,28 @@ +#ifndef __GNOME_DENTRY_H__ +#define __GNOME_DENTRY_H__ + +BEGIN_GNOME_DECLS + +struct gnome_desktop_entry { + char *exec; + char *icon_base; + char *docpath; + char *info; + int terminal; + char *type; + char *location; + + /* These are computed from icon_base */ + char *small_icon; + char *transparent_icon; +}; + +struct gnome_desktop_entry *gnome_desktop_entry_load (char *file); +void gnome_desktop_entry_free (struct gnome_desktop_entry *item); +void gnome_desktop_entry_launch (struct gnome_desktop_entry *item); + +int gnome_is_program_in_path (char *progname); + +END_GNOME_DECLS + +#endif diff -uNr gnome-0.7/libgnome/libgnome.h gnome-0.8/libgnome/libgnome.h --- gnome-0.7/libgnome/libgnome.h Wed Sep 24 18:24:23 1997 +++ gnome-0.8/libgnome/libgnome.h Wed Oct 8 16:37:54 1997 @@ -6,6 +6,7 @@ #include "libgnome/gnome-hook.h" #include "libgnome/gnome-config.h" #include "libgnome/gnome-dns.h" +#include "libgnome/gnome-dentry.h" extern char *gnome_user_home_dir; extern char *gnome_user_dir; diff -uNr gnome-0.7/libgnomeui/Makefile.am gnome-0.8/libgnomeui/Makefile.am --- gnome-0.7/libgnomeui/Makefile.am Wed Oct 1 12:42:10 1997 +++ gnome-0.8/libgnomeui/Makefile.am Mon Oct 6 19:27:33 1997 @@ -14,6 +14,7 @@ gnome-actionarea.c \ gnome-messagebox.c \ gnome-pixmap.c \ + gnome-toolbar.c \ gnome-colors.c libgnomeuiinclude_HEADERS = \ @@ -23,6 +24,7 @@ gnome-messagebox.h \ gnome-properties.h \ gnome-pixmap.h \ + gnome-toolbar.h \ libgnomeui.h diff -uNr gnome-0.7/libgnomeui/Makefile.in gnome-0.8/libgnomeui/Makefile.in --- gnome-0.7/libgnomeui/Makefile.in Fri Oct 3 01:04:27 1997 +++ gnome-0.8/libgnomeui/Makefile.in Fri Oct 10 00:35:38 1997 @@ -96,6 +96,7 @@ gnome-actionarea.c \ gnome-messagebox.c \ gnome-pixmap.c \ + gnome-toolbar.c \ gnome-colors.c libgnomeuiinclude_HEADERS = \ @@ -105,6 +106,7 @@ gnome-messagebox.h \ gnome-properties.h \ gnome-pixmap.h \ + gnome-toolbar.h \ libgnomeui.h libgnomeui_la_LDFLAGS = -version-info 0:0:0 -rpath $(libdir) @@ -123,7 +125,7 @@ libgnomeui_la_LIBADD = libgnomeui_la_OBJECTS = gnome-color-selector.lo gnome-properties.lo \ gnome-init.lo gnome-actionarea.lo gnome-messagebox.lo gnome-pixmap.lo \ -gnome-colors.lo +gnome-toolbar.lo gnome-colors.lo COMPILE = $(CC) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) LINK = $(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(LDFLAGS) -o $@ @@ -260,13 +262,15 @@ ../libgnome/libgnome.h ../libgnome/gnome-defs.h \ ../libgnome/gnome-util.h ../libgnome/gnome-hook.h \ ../libgnome/gnome-config.h ../libgnome/gnome-dns.h \ - gnome-colors.h + ../libgnome/gnome-dentry.h gnome-colors.h gnome-messagebox.o gnome-messagebox.lo: gnome-messagebox.c \ ../libgnome/gnome-defs.h gnome-messagebox.h gnome-pixmap.o gnome-pixmap.lo: gnome-pixmap.c ../libgnome/gnome-defs.h \ gnome-messagebox.h gnome-properties.o gnome-properties.lo: gnome-properties.c \ ../libgnome/gnome-defs.h gnome-properties.h gnome-actionarea.h +gnome-toolbar.o gnome-toolbar.lo: gnome-toolbar.c gnome-toolbar.h \ + ../libgnome/gnome-defs.h gnome-pixmap.h info: dvi: diff -uNr gnome-0.7/libgnomeui/gnome-init.c gnome-0.8/libgnomeui/gnome-init.c --- gnome-0.7/libgnomeui/gnome-init.c Wed Sep 24 18:24:45 1997 +++ gnome-0.8/libgnomeui/gnome-init.c Fri Oct 3 15:12:01 1997 @@ -15,11 +15,11 @@ { /* now we replace gtk_init() with gnome_init() in our apps */ gtk_init(argc, argv); + gnome_colors_init(); gnome_rc_parse(*argv[0]); gnomelib_init (argc, argv); - gnome_colors_init(); } /* perhaps this belongs in libgnome.. move it if you like. */ diff -uNr gnome-0.7/libgnomeui/gnome-pixmap.c gnome-0.8/libgnomeui/gnome-pixmap.c --- gnome-0.7/libgnomeui/gnome-pixmap.c Wed Oct 1 12:41:22 1997 +++ gnome-0.8/libgnomeui/gnome-pixmap.c Thu Oct 9 14:39:44 1997 @@ -8,19 +8,65 @@ #include "gnome-messagebox.h" #include +struct pixmap_item { + GdkPixmap *pixmap; + GdkBitmap *mask; +}; + +static GHashTable *pixmap_hash; + GtkWidget * gnome_create_pixmap_widget (GtkWidget *window, GtkWidget *holder, char *file) { + struct pixmap_item *pit; GtkStyle *style; GtkWidget *pixmap_widget; - GdkPixmap *pixmap; - GdkBitmap *mask; + void *s; + + g_assert(window != NULL); + + if (!file) + return NULL; + + if (!pixmap_hash) + pixmap_hash = g_hash_table_new (g_string_hash, g_string_equal); + + if (!GTK_WIDGET_REALIZED(window)) + gtk_widget_realize(window); style = holder ? gtk_widget_get_style (holder) : 0; - pixmap = gdk_pixmap_create_from_xpm (window->window, &mask, - &style->bg [GTK_STATE_NORMAL], - file); - pixmap_widget = gtk_pixmap_new (pixmap, mask); + if ((s = g_hash_table_lookup (pixmap_hash, file))){ + pit = s; + return gtk_pixmap_new (pit->pixmap, pit->mask); + } + + pit = g_new (struct pixmap_item, 1); + pit->pixmap = gdk_pixmap_create_from_xpm (window->window, &pit->mask, + &style->bg [GTK_STATE_NORMAL], + file); + pixmap_widget = gtk_pixmap_new (pit->pixmap, pit->mask); + g_hash_table_insert (pixmap_hash, g_strdup (file), pit); + return pixmap_widget; } +static void +destroy_hash_element (void *key, void *val, void *data) +{ + struct pixmap_item *pi = val; + + gdk_pixmap_destroy (pi->pixmap); + gdk_pixmap_destroy (pi->mask); + g_free (val); + g_free (key); +} + +void +gnome_destroy_pixmap_cache (void) +{ + if (!pixmap_hash) + return; + + g_hash_table_foreach (pixmap_hash, destroy_hash_element, 0); + g_hash_table_destroy (pixmap_hash); +} diff -uNr gnome-0.7/libgnomeui/gnome-toolbar.c gnome-0.8/libgnomeui/gnome-toolbar.c --- gnome-0.7/libgnomeui/gnome-toolbar.c Wed Dec 31 18:00:00 1969 +++ gnome-0.8/libgnomeui/gnome-toolbar.c Mon Oct 6 19:49:35 1997 @@ -0,0 +1,156 @@ +/* GNOME GUI Library + * Copyright (C) 1997 The Free Software Foundation + * + * Author: Aldy Hernandez (aldy@uaa.edu) + * + * GNOME toolbar implementation + */ + +#include +#include "gnome-toolbar.h" +#include "libgnome/gnome-defs.h" +#include "libgnomeui/gnome-pixmap.h" + +/* Make sure these match ``enum ToolbarDefaultItem'' */ +static struct { + char *label; + char *pixmap_filename; +} ToolbarDefaultItems [] = + { + { "Open", "gnome-open-icon.xpm" }, + { "Close", "gnome-close-icon.xpm" }, + { "Reload", "gnome-reload-icon.xpm" }, + { "Print", "gnome-print-icon.xpm" }, + { "Exit", "gnome-exit-icon.xpm" } + }; + +GnomeToolbar * +gnome_create_toolbar (void *parent, + enum GnomePackMethod packmethod) +{ + GnomeToolbar *tb; + + tb = (GnomeToolbar *) g_malloc (sizeof (GnomeToolbar)); + tb->toolbar = NULL; + tb->box = gtk_hbox_new (FALSE, 0); + tb->style = GNOME_TB_NOTHING; + tb->items = NULL; + tb->nitems = 0; + + switch (packmethod){ + case GNOME_TB_CONTAINER_ADD: + gtk_container_add (GTK_CONTAINER ((GtkWidget *)parent), tb->box); + break; + + case GNOME_TB_PACK_START: + gtk_box_pack_start (GTK_BOX ((GtkWidget *) parent), tb->box, FALSE, FALSE, 0); + break; + + case GNOME_TB_PACK_END: + gtk_box_pack_end (GTK_BOX ((GtkWidget *) parent), tb->box, FALSE, FALSE, 0); + break; + + default: + printf ("gnome_create_toolbar: invalid packmethod %d\n", packmethod); + } + + gtk_container_border_width (GTK_CONTAINER (tb->box), 2); + gtk_widget_show (tb->box); + + return tb; +} + +/* Destroy toolbar permanently */ +void +gnome_destroy_toolbar (GnomeToolbar *toolbar) +{ + gtk_widget_destroy (toolbar->box); +} + +void +gnome_toolbar_add (GnomeToolbar *toolbar, char *label, char *pixmap_filename, + GnomeToolbarFunc func, void *data) +{ + int i = toolbar->nitems; + + toolbar->items = g_realloc (toolbar->items, sizeof (GnomeToolbarItem) * (toolbar->nitems + 1)); + + toolbar->items[i].label = label; + toolbar->items[i].func = func; + toolbar->items[i].data = data; + toolbar->items[i].pixmap_filename = pixmap_filename; + ++toolbar->nitems; +} + +void +gnome_toolbar_add_default (GnomeToolbar *toolbar, + enum GnomeToolbarDefaultItem tb_default, + GnomeToolbarFunc func, void *data) +{ + gnome_toolbar_add (toolbar, ToolbarDefaultItems[tb_default].label, + ToolbarDefaultItems[tb_default].pixmap_filename, + func, data); +} + +void +gnome_toolbar_set_style (GnomeToolbar *toolbar, + enum GnomeToolbarStyle style) +{ + int i; + + toolbar->style = style; + + if (toolbar->toolbar) + gtk_widget_destroy (toolbar->toolbar); + + if (style & GNOME_TB_VERTICAL) + toolbar->toolbar = gtk_vbox_new (FALSE, 0); + else + toolbar->toolbar = gtk_hbox_new (FALSE, 0); + + gtk_container_border_width (GTK_CONTAINER (toolbar->toolbar), 3); + gtk_box_pack_start (GTK_BOX (toolbar->box), toolbar->toolbar, FALSE, FALSE, 3); + + for (i=0; i < toolbar->nitems; ++i){ + GtkWidget *button; + GtkWidget *vbox; + GtkWidget *label = NULL; + GtkWidget *pixmap = NULL; + + button = gtk_button_new (); + vbox = gtk_vbox_new (FALSE, 0); + + if (style & GNOME_TB_TEXT && toolbar->items[i].label) + label = gtk_label_new (toolbar->items[i].label); + + if (style & GNOME_TB_ICONS && toolbar->items[i].pixmap_filename) + pixmap = gnome_create_pixmap_widget (toolbar->box, + toolbar->box, + toolbar->items[i].pixmap_filename); + + if (style & GNOME_TB_ICONS && !pixmap) + label = gtk_label_new ("undefined"); + + gtk_container_add (GTK_CONTAINER (button), vbox); + gtk_container_border_width (GTK_CONTAINER (button), 1); + + if (pixmap) { /* Place pixmap */ + gtk_box_pack_start (GTK_BOX (vbox), pixmap, FALSE, FALSE, 0); + gtk_widget_show (pixmap); + } + + if (label) { /* Place label */ + gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0); + gtk_widget_show (label); + } + + gtk_box_pack_start (GTK_BOX (toolbar->toolbar), button, FALSE, FALSE, 0); + gtk_widget_show (button); + gtk_widget_show (vbox); + + gtk_signal_connect (GTK_OBJECT (button), "clicked", + (GtkSignalFunc) toolbar->items[i].func, + toolbar->items[i].data); + } + gtk_widget_show (toolbar->toolbar); +} diff -uNr gnome-0.7/libgnomeui/gnome-toolbar.h gnome-0.8/libgnomeui/gnome-toolbar.h --- gnome-0.7/libgnomeui/gnome-toolbar.h Wed Dec 31 18:00:00 1969 +++ gnome-0.8/libgnomeui/gnome-toolbar.h Mon Oct 6 19:47:39 1997 @@ -0,0 +1,91 @@ +/* GNOME GUI Library + * Copyright (C) 1997 The Free Software Foundation + * + * Author: Aldy Hernandez (aldy@uaa.edu) + * + * GNOME toolbar support definitions + */ + +#ifndef __GNOME_TOOLBAR_H__ +#define __GNOME_TOOLBAR_H__ + +#include "libgnome/gnome-defs.h" + +BEGIN_GNOME_DECLS + +typedef struct _GnomeToolbar GnomeToolbar; +typedef struct _GnomeToolbarItem GnomeToolbarItem; + +typedef void (*GnomeToolbarFunc) (void *data); + +enum GnomeToolbarStyle +{ + GNOME_TB_NOTHING = 0, + GNOME_TB_TEXT = 2, + GNOME_TB_ICONS = 4, + GNOME_TB_VERTICAL = 8, + GNOME_TB_HORIZONTAL = 16, + GNOME_TB_AXIS = 24 +}; + +enum GnomePackMethod +{ + GNOME_TB_CONTAINER_ADD, + GNOME_TB_PACK_START, + GNOME_TB_PACK_END +}; + +enum GnomeToolbarDefaultItem +{ + GNOME_TOOLBAR_OPEN, + GNOME_TOOLBAR_CLOSE, + GNOME_TOOLBAR_RELOAD, + GNOME_TOOLBAR_PRINT, + GNOME_TOOLBAR_EXIT +}; + +struct _GnomeToolbar +{ + /* Actual toolbar widget */ + GtkWidget *toolbar; + + /* Parent box in which to put ``toolbar''. We need a separate box + * in which to put the toolbar in so we can destroy and recreate the + * toolbar at will. + */ + GtkWidget *box; + + enum GnomeToolbarStyle style; + + int nitems; + + GnomeToolbarItem *items; +}; + +struct _GnomeToolbarItem +{ + char *label; + char *pixmap_filename; + void *data; + GnomeToolbarFunc func; +}; + +GnomeToolbar* gnome_create_toolbar (void *parent, + enum GnomePackMethod packmethod); +void gnome_destroy_toolbar (GnomeToolbar *toolbar); +void gnome_toolbar_add (GnomeToolbar *toolbar, + char *label, + char *pixmap_filename, + GnomeToolbarFunc func, + void *data); +void gnome_toolbar_add_default (GnomeToolbar *toolbar, + enum GnomeToolbarDefaultItem tb_default, + GnomeToolbarFunc func, + void *data); +void gnome_toolbar_set_style (GnomeToolbar *toolbar, + enum GnomeToolbarStyle style); + +END_GNOME_DECLS + +#endif /* __GNOME_TOOLBAR_H__ */ + diff -uNr gnome-0.7/libgnomeui/libgnomeui.h gnome-0.8/libgnomeui/libgnomeui.h --- gnome-0.7/libgnomeui/libgnomeui.h Wed Oct 1 19:13:55 1997 +++ gnome-0.8/libgnomeui/libgnomeui.h Mon Oct 6 19:51:32 1997 @@ -6,6 +6,7 @@ #include "libgnomeui/gnome-color-selector.h" #include "libgnomeui/gnome-messagebox.h" #include "libgnomeui/gnome-pixmap.h" +#include "libgnomeui/gnome-toolbar.h" BEGIN_GNOME_DECLS diff -uNr gnome-0.7/programs/Makefile.am gnome-0.8/programs/Makefile.am --- gnome-0.7/programs/Makefile.am Thu Oct 2 22:33:28 1997 +++ gnome-0.8/programs/Makefile.am Thu Oct 9 15:27:32 1997 @@ -1 +1 @@ -SUBDIRS = desktop-properties network-utilities gmix cromagnon panel +SUBDIRS = desktop-properties network-utilities gmix cromagnon panel gnomine diff -uNr gnome-0.7/programs/Makefile.in gnome-0.8/programs/Makefile.in --- gnome-0.7/programs/Makefile.in Fri Oct 3 01:04:30 1997 +++ gnome-0.8/programs/Makefile.in Fri Oct 10 00:35:41 1997 @@ -83,7 +83,7 @@ RANLIB = @RANLIB@ VERSION = @VERSION@ -SUBDIRS = desktop-properties network-utilities gmix cromagnon panel +SUBDIRS = desktop-properties network-utilities gmix cromagnon panel gnomine mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs CONFIG_HEADER = ../config.h CONFIG_CLEAN_FILES = diff -uNr gnome-0.7/programs/desktop-properties/Makefile.in gnome-0.8/programs/desktop-properties/Makefile.in --- gnome-0.7/programs/desktop-properties/Makefile.in Fri Oct 3 01:04:32 1997 +++ gnome-0.8/programs/desktop-properties/Makefile.in Fri Oct 10 00:35:43 1997 @@ -264,42 +264,46 @@ main.o main.lo: main.c ../../gnome.h ../../libgnome/libgnome.h \ ../../libgnome/gnome-defs.h ../../libgnome/gnome-util.h \ ../../libgnome/gnome-hook.h ../../libgnome/gnome-config.h \ - ../../libgnome/gnome-dns.h ../../libgnomeui/libgnomeui.h \ - ../../libgnomeui/gnome-colors.h \ + ../../libgnome/gnome-dns.h ../../libgnome/gnome-dentry.h \ + ../../libgnomeui/libgnomeui.h ../../libgnomeui/gnome-colors.h \ ../../libgnomeui/gnome-color-selector.h \ ../../libgnomeui/gnome-messagebox.h \ - ../../libgnomeui/gnome-pixmap.h gnome-desktop.h \ + ../../libgnomeui/gnome-pixmap.h \ + ../../libgnomeui/gnome-toolbar.h gnome-desktop.h \ ../../libgnomeui/gnome-properties.h property-background.o property-background.lo: property-background.c \ ../../gnome.h ../../libgnome/libgnome.h \ ../../libgnome/gnome-defs.h ../../libgnome/gnome-util.h \ ../../libgnome/gnome-hook.h ../../libgnome/gnome-config.h \ - ../../libgnome/gnome-dns.h ../../libgnomeui/libgnomeui.h \ - ../../libgnomeui/gnome-colors.h \ + ../../libgnome/gnome-dns.h ../../libgnome/gnome-dentry.h \ + ../../libgnomeui/libgnomeui.h ../../libgnomeui/gnome-colors.h \ ../../libgnomeui/gnome-color-selector.h \ ../../libgnomeui/gnome-messagebox.h \ - ../../libgnomeui/gnome-pixmap.h gnome-desktop.h \ + ../../libgnomeui/gnome-pixmap.h \ + ../../libgnomeui/gnome-toolbar.h gnome-desktop.h \ ../../libgnomeui/gnome-properties.h gdkx.h property-screensaver.o property-screensaver.lo: property-screensaver.cc \ property-screensaver.h screensaver.h ghash.h xlockmore.h \ ../../gnome.h ../../libgnome/libgnome.h \ ../../libgnome/gnome-defs.h ../../libgnome/gnome-util.h \ ../../libgnome/gnome-hook.h ../../libgnome/gnome-config.h \ - ../../libgnome/gnome-dns.h ../../libgnomeui/libgnomeui.h \ - ../../libgnomeui/gnome-colors.h \ + ../../libgnome/gnome-dns.h ../../libgnome/gnome-dentry.h \ + ../../libgnomeui/libgnomeui.h ../../libgnomeui/gnome-colors.h \ ../../libgnomeui/gnome-color-selector.h \ ../../libgnomeui/gnome-messagebox.h \ - ../../libgnomeui/gnome-pixmap.h gnome-desktop.h \ + ../../libgnomeui/gnome-pixmap.h \ + ../../libgnomeui/gnome-toolbar.h gnome-desktop.h \ ../../libgnomeui/gnome-properties.h xlockmore.o xlockmore.lo: xlockmore.cc xlockmore.h screensaver.h ghash.h \ gnome-desktop.h ../../gnome.h ../../libgnome/libgnome.h \ ../../libgnome/gnome-defs.h ../../libgnome/gnome-util.h \ ../../libgnome/gnome-hook.h ../../libgnome/gnome-config.h \ - ../../libgnome/gnome-dns.h ../../libgnomeui/libgnomeui.h \ - ../../libgnomeui/gnome-colors.h \ + ../../libgnome/gnome-dns.h ../../libgnome/gnome-dentry.h \ + ../../libgnomeui/libgnomeui.h ../../libgnomeui/gnome-colors.h \ ../../libgnomeui/gnome-color-selector.h \ ../../libgnomeui/gnome-messagebox.h \ ../../libgnomeui/gnome-pixmap.h \ + ../../libgnomeui/gnome-toolbar.h \ ../../libgnomeui/gnome-properties.h xlockparse.o xlockparse.lo: xlockparse.cc xlockmore.h screensaver.h \ ghash.h diff -uNr gnome-0.7/programs/gnomine/AUTHORS gnome-0.8/programs/gnomine/AUTHORS --- gnome-0.7/programs/gnomine/AUTHORS Wed Dec 31 18:00:00 1969 +++ gnome-0.8/programs/gnomine/AUTHORS Thu Oct 9 15:29:24 1997 @@ -0,0 +1,2 @@ +Szekeres Istvan +Pista. \ No newline at end of file diff -uNr gnome-0.7/programs/gnomine/Makefile.am gnome-0.8/programs/gnomine/Makefile.am --- gnome-0.7/programs/gnomine/Makefile.am Wed Dec 31 18:00:00 1969 +++ gnome-0.8/programs/gnomine/Makefile.am Fri Oct 10 00:06:14 1997 @@ -0,0 +1,23 @@ +INCLUDES = \ + -I../.. \ + -I$(srcdir)/../.. \ + -I$(includedir) \ + $(X_CFLAGS) + +bin_PROGRAMS = gnomine + +gnomine_SOURCES = \ + gnomine.c \ + minefield.h \ + minefield.c + +gnomine_LDADD = \ + $(top_builddir)/libgnomeui/libgnomeui.la \ + $(top_builddir)/libgnome/libgnome.la \ + $(X_LIBS) + +EXTRA_DIST = flag.xpm mine.xpm gnomine.desktop README AUTHORS + +install-data-local: + cp $(srcdir)/gnomine.desktop $(datadir)/apps/Games/"Gnome Mines.desktop" + cp $(srcdir)/flag.xpm $(srcdir)/mine.xpm $(datadir)/pixmaps diff -uNr gnome-0.7/programs/gnomine/Makefile.in gnome-0.8/programs/gnomine/Makefile.in --- gnome-0.7/programs/gnomine/Makefile.in Wed Dec 31 18:00:00 1969 +++ gnome-0.8/programs/gnomine/Makefile.in Fri Oct 10 00:35:52 1997 @@ -0,0 +1,316 @@ +# Makefile.in generated automatically by automake 1.2 from Makefile.am + +# Copyright (C) 1994, 1995, 1996, 1997 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy, distribute and modify it. + + +SHELL = /bin/sh + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +prefix = @prefix@ +exec_prefix = @exec_prefix@ + +bindir = @bindir@ +sbindir = @sbindir@ +libexecdir = @libexecdir@ +datadir = @datadir@ +sysconfdir = @sysconfdir@ +sharedstatedir = @sharedstatedir@ +localstatedir = @localstatedir@ +libdir = @libdir@ +infodir = @infodir@ +mandir = @mandir@ +includedir = @includedir@ +oldincludedir = /usr/include + +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ + +top_builddir = ../.. + +ACLOCAL = @ACLOCAL@ +AUTOCONF = @AUTOCONF@ +AUTOMAKE = @AUTOMAKE@ +AUTOHEADER = @AUTOHEADER@ + +INSTALL = @INSTALL@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +transform = @program_transform_name@ + +NORMAL_INSTALL = true +PRE_INSTALL = true +POST_INSTALL = true +NORMAL_UNINSTALL = true +PRE_UNINSTALL = true +POST_UNINSTALL = true +host_alias = @host_alias@ +host_triplet = @host@ +CATALOGS = @CATALOGS@ +CATOBJEXT = @CATOBJEXT@ +CC = @CC@ +CFLAGS = @CFLAGS@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +DATADIRNAME = @DATADIRNAME@ +ELCFILES = @ELCFILES@ +EMACS = @EMACS@ +GENCAT = @GENCAT@ +GMOFILES = @GMOFILES@ +GMSGFMT = @GMSGFMT@ +INSTOBJEXT = @INSTOBJEXT@ +INTLDEPS = @INTLDEPS@ +INTLLIBS = @INTLLIBS@ +INTLOBJS = @INTLOBJS@ +INTLSUB = @INTLSUB@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LEX = @LEX@ +LIBTOOL = @LIBTOOL@ +LISPDIR = @LISPDIR@ +LN_S = @LN_S@ +MAKEINFO = @MAKEINFO@ +MSGFMT = @MSGFMT@ +NM = @NM@ +PACKAGE = @PACKAGE@ +POFILES = @POFILES@ +POSUB = @POSUB@ +RANLIB = @RANLIB@ +VERSION = @VERSION@ + +INCLUDES = \ + -I../.. \ + -I$(srcdir)/../.. \ + -I$(includedir) \ + $(X_CFLAGS) + +bin_PROGRAMS = gnomine + +gnomine_SOURCES = \ + gnomine.c \ + minefield.h \ + minefield.c + +gnomine_LDADD = \ + $(top_builddir)/libgnomeui/libgnomeui.la \ + $(top_builddir)/libgnome/libgnome.la \ + $(X_LIBS) + +EXTRA_DIST = flag.xpm mine.xpm gnomine.desktop README AUTHORS +mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +CONFIG_HEADER = ../../config.h +CONFIG_CLEAN_FILES = +PROGRAMS = $(bin_PROGRAMS) + + +DEFS = @DEFS@ -I. -I$(srcdir) -I../.. +LIBS = @LIBS@ +X_CFLAGS = @X_CFLAGS@ +X_LIBS = @X_LIBS@ +X_EXTRA_LIBS = @X_EXTRA_LIBS@ +X_PRE_LIBS = @X_PRE_LIBS@ +gnomine_OBJECTS = gnomine.o minefield.o +gnomine_DEPENDENCIES = $(top_builddir)/libgnomeui/libgnomeui.la \ +$(top_builddir)/libgnome/libgnome.la +gnomine_LDFLAGS = +COMPILE = $(CC) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) +LINK = $(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(LDFLAGS) -o $@ +DIST_COMMON = README AUTHORS Makefile.am Makefile.in + + +DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) + +TAR = tar +GZIP = --best +SOURCES = $(gnomine_SOURCES) +OBJECTS = $(gnomine_OBJECTS) + +default: all + +.SUFFIXES: +.SUFFIXES: .c .lo .o +$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) + cd $(top_srcdir) && $(AUTOMAKE) --gnu --include-deps programs/gnomine/Makefile + +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + cd $(top_builddir) \ + && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status + + +mostlyclean-binPROGRAMS: + +clean-binPROGRAMS: + test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS) + +distclean-binPROGRAMS: + +maintainer-clean-binPROGRAMS: + +install-binPROGRAMS: $(bin_PROGRAMS) + @$(NORMAL_INSTALL) + $(mkinstalldirs) $(bindir) + @list='$(bin_PROGRAMS)'; for p in $$list; do \ + if test -f $$p; then \ + echo " $(LIBTOOL) --mode=install $(INSTALL_PROGRAM) $$p $(bindir)/`echo $$p|sed '$(transform)'`"; \ + $(LIBTOOL) --mode=install $(INSTALL_PROGRAM) $$p $(bindir)/`echo $$p|sed '$(transform)'`; \ + else :; fi; \ + done + +uninstall-binPROGRAMS: + $(NORMAL_UNINSTALL) + list='$(bin_PROGRAMS)'; for p in $$list; do \ + rm -f $(bindir)/`echo $$p|sed '$(transform)'`; \ + done + +.c.o: + $(COMPILE) -c $< + +mostlyclean-compile: + rm -f *.o core + +clean-compile: + +distclean-compile: + rm -f *.tab.c + +maintainer-clean-compile: + +.c.lo: + $(LIBTOOL) --mode=compile $(COMPILE) -c $< + +mostlyclean-libtool: + rm -f *.lo + +clean-libtool: + rm -rf .libs + +distclean-libtool: + +maintainer-clean-libtool: + +gnomine: $(gnomine_OBJECTS) $(gnomine_DEPENDENCIES) + @rm -f gnomine + $(LINK) $(gnomine_LDFLAGS) $(gnomine_OBJECTS) $(gnomine_LDADD) $(LIBS) + +tags: TAGS + +ID: $(HEADERS) $(SOURCES) + here=`pwd` && cd $(srcdir) && mkid -f$$here/ID $(SOURCES) $(HEADERS) + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) + tags=; \ + here=`pwd`; \ + test -z "$(ETAGS_ARGS)$(SOURCES)$(HEADERS)$$tags" \ + || (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags $(SOURCES) $(HEADERS) -o $$here/TAGS) + +mostlyclean-tags: + +clean-tags: + +distclean-tags: + rm -f TAGS ID + +maintainer-clean-tags: + +distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir) + +subdir = programs/gnomine + +distdir: $(DISTFILES) + @for file in $(DISTFILES); do \ + d=$(srcdir); \ + test -f $(distdir)/$$file \ + || ln $$d/$$file $(distdir)/$$file 2> /dev/null \ + || cp -p $$d/$$file $(distdir)/$$file; \ + done +gnomine.o gnomine.lo: gnomine.c ../../gnome.h ../../libgnome/libgnome.h \ + ../../libgnome/gnome-defs.h ../../libgnome/gnome-util.h \ + ../../libgnome/gnome-hook.h ../../libgnome/gnome-config.h \ + ../../libgnome/gnome-dns.h ../../libgnome/gnome-dentry.h \ + ../../libgnomeui/libgnomeui.h ../../libgnomeui/gnome-colors.h \ + ../../libgnomeui/gnome-color-selector.h \ + ../../libgnomeui/gnome-messagebox.h \ + ../../libgnomeui/gnome-pixmap.h \ + ../../libgnomeui/gnome-toolbar.h minefield.h +minefield.o minefield.lo: minefield.c minefield.h + +info: +dvi: +check: all + $(MAKE) +installcheck: +install-exec: install-binPROGRAMS + @$(NORMAL_INSTALL) + +install-data: install-data-local + @$(NORMAL_INSTALL) + +install: install-exec install-data all + @: + +uninstall: uninstall-binPROGRAMS + +all: Makefile $(PROGRAMS) + +install-strip: + $(MAKE) INSTALL_PROGRAM='$(INSTALL_PROGRAM) -s' INSTALL_SCRIPT='$(INSTALL_PROGRAM)' install +installdirs: + $(mkinstalldirs) $(bindir) + + +mostlyclean-generic: + test -z "$(MOSTLYCLEANFILES)" || rm -f $(MOSTLYCLEANFILES) + +clean-generic: + test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) + +distclean-generic: + rm -f Makefile $(DISTCLEANFILES) + rm -f config.cache config.log stamp-h stamp-h[0-9]* + test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES) + test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES) +mostlyclean: mostlyclean-binPROGRAMS mostlyclean-compile \ + mostlyclean-libtool mostlyclean-tags \ + mostlyclean-generic + +clean: clean-binPROGRAMS clean-compile clean-libtool clean-tags \ + clean-generic mostlyclean + +distclean: distclean-binPROGRAMS distclean-compile distclean-libtool \ + distclean-tags distclean-generic clean + rm -f config.status + rm -f libtool + +maintainer-clean: maintainer-clean-binPROGRAMS maintainer-clean-compile \ + maintainer-clean-libtool maintainer-clean-tags \ + maintainer-clean-generic distclean + @echo "This command is intended for maintainers to use;" + @echo "it deletes files that may require special tools to rebuild." + +.PHONY: default mostlyclean-binPROGRAMS distclean-binPROGRAMS \ +clean-binPROGRAMS maintainer-clean-binPROGRAMS uninstall-binPROGRAMS \ +install-binPROGRAMS mostlyclean-compile distclean-compile clean-compile \ +maintainer-clean-compile mostlyclean-libtool distclean-libtool \ +clean-libtool maintainer-clean-libtool tags mostlyclean-tags \ +distclean-tags clean-tags maintainer-clean-tags distdir info dvi \ +installcheck install-exec install-data install uninstall all \ +installdirs mostlyclean-generic distclean-generic clean-generic \ +maintainer-clean-generic clean mostlyclean distclean maintainer-clean + + +install-data-local: + cp $(srcdir)/gnomine.desktop $(datadir)/apps/Games/"Gnome Mines.desktop" + cp $(srcdir)/flag.xpm $(srcdir)/mine.xpm $(datadir)/pixmaps + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff -uNr gnome-0.7/programs/gnomine/README gnome-0.8/programs/gnomine/README --- gnome-0.7/programs/gnomine/README Wed Dec 31 18:00:00 1969 +++ gnome-0.8/programs/gnomine/README Thu Oct 9 15:29:45 1997 @@ -0,0 +1,2 @@ +Constructive comments on this program are welcome, +send your messages to: Szekeres Istvan . diff -uNr gnome-0.7/programs/gnomine/flag.xpm gnome-0.8/programs/gnomine/flag.xpm --- gnome-0.7/programs/gnomine/flag.xpm Wed Dec 31 18:00:00 1969 +++ gnome-0.8/programs/gnomine/flag.xpm Wed Oct 8 14:19:06 1997 @@ -0,0 +1,20 @@ +/* XPM */ +static char *magick[] = { +/* columns rows colors chars-per-pixel */ +"11 11 3 1", +" c Black", +". c #fe0204", +"X c None", +/* pixels */ +"XXXX... XXX", +"XX..... XXX", +"....... XXX", +"....... XXX", +"XX..... XXX", +"XXXX... XXX", +"XXXXX XXX", +"XXXXX XXX", +"XXXXX XXX", +"XXXX X", +"XX " +}; diff -uNr gnome-0.7/programs/gnomine/gnomine.c gnome-0.8/programs/gnomine/gnomine.c --- gnome-0.7/programs/gnomine/gnomine.c Wed Dec 31 18:00:00 1969 +++ gnome-0.8/programs/gnomine/gnomine.c Wed Oct 8 16:43:00 1997 @@ -0,0 +1,265 @@ + +#include +#include +#include "minefield.h" + +static GtkWidget *mfield; +GtkWidget *flags_label; +GtkWidget *setupdialog; +GtkWidget *mfieldbox; +GtkWidget *xentry; +GtkWidget *yentry; +GtkWidget *mentry; + +int ysize, xsize; +int nmines; + +void quit_game(GtkWidget *widget, gpointer data) +{ + gtk_main_quit(); +} + +void new_game(GtkWidget *widget, gpointer data) +{ + gtk_minefield_restart(GTK_MINEFIELD(mfield)); + gtk_widget_draw(mfield, NULL); +} + +void setupdialog_destroy(GtkWidget *widget, int mode) +{ + if (mode == 1) { + gtk_widget_destroy(setupdialog); + } else { + setupdialog = NULL; + } +} + +void marks_changed(GtkWidget *widget, gpointer data) +{ + GtkMineField *mf = GTK_MINEFIELD(widget); + char val[16]; + + sprintf(val, "Flags: %d", mf->flags); + gtk_label_set(GTK_LABEL(flags_label), val); +} + +void lose_game(GtkWidget *widget, gpointer data) +{ + gtk_label_set(GTK_LABEL(flags_label), "Boink!"); +} + +void create_mfield(void) +{ + mfield = gtk_minefield_new(xsize, ysize); + gtk_minefield_set_mines(GTK_MINEFIELD(mfield), (guint)nmines); + new_game(mfield, NULL); + gtk_box_pack_start(GTK_BOX(mfieldbox), mfield, TRUE, TRUE, 0); + + gtk_signal_connect(GTK_OBJECT(mfield), "marks_changed", + GTK_SIGNAL_FUNC(marks_changed), NULL); + gtk_signal_connect(GTK_OBJECT(mfield), "explode", + GTK_SIGNAL_FUNC(lose_game), NULL); + + gtk_widget_show(mfield); +} + +void do_setup(GtkWidget *widget, gpointer data) +{ + int xs, ys, nm; + int restart; + + restart = 0; + xs = atoi(gtk_entry_get_text(GTK_ENTRY(xentry))); + ys = atoi(gtk_entry_get_text(GTK_ENTRY(yentry))); + nm = atoi(gtk_entry_get_text(GTK_ENTRY(mentry))); + + if (xs != xsize || ys != ysize) { + xsize = xs; + ysize = ys; + gtk_widget_destroy(mfield); + create_mfield(); + restart = 1; + } + + if (nm != nmines) { + nmines = nm; + gtk_minefield_set_mines(GTK_MINEFIELD(mfield), (guint)nmines); + restart = 1; + } + + if (restart) new_game(mfield, NULL); + gtk_widget_destroy(setupdialog); +} + +void setup_game(GtkWidget *widget, gpointer data) +{ + GtkWidget *all_boxes; + GtkWidget *box; + GtkWidget *label; + GtkWidget *button; + gchar numstr[8]; + + if (setupdialog) return; + setupdialog = gtk_window_new(GTK_WINDOW_DIALOG); + gtk_container_border_width(GTK_CONTAINER(setupdialog), 10); + gtk_window_set_title(GTK_WINDOW(setupdialog), "Gnomine setup"); + gtk_signal_connect(GTK_OBJECT(setupdialog), + "destroy", + GTK_SIGNAL_FUNC(setupdialog_destroy), + 0); + + all_boxes = gtk_vbox_new(TRUE, 5); + gtk_container_add(GTK_CONTAINER(setupdialog), all_boxes); + + box = gtk_hbox_new(FALSE, 0); + gtk_box_pack_start(GTK_BOX(all_boxes), box, TRUE, TRUE, 0); + label = gtk_label_new("Horizontal size:"); + gtk_box_pack_start(GTK_BOX(box), label, TRUE, TRUE, 0); + gtk_widget_show(label); + xentry = gtk_entry_new(); + gtk_widget_set_usize(xentry, 50, -1); + gtk_box_pack_start(GTK_BOX(box), xentry, FALSE, TRUE, 0); /*fold00*/ + sprintf(numstr, "%d", xsize); + gtk_entry_set_text(GTK_ENTRY(xentry),numstr); + gtk_widget_show(xentry); + gtk_widget_show(box); + + box = gtk_hbox_new(FALSE, 0); + gtk_box_pack_start(GTK_BOX(all_boxes), box, TRUE, TRUE, 0); + label = gtk_label_new("Vertical size:"); + gtk_box_pack_start(GTK_BOX(box), label, TRUE, TRUE, 0); + gtk_widget_show(label); + yentry = gtk_entry_new(); + gtk_widget_set_usize(yentry, 50, -1); + gtk_box_pack_start(GTK_BOX(box), yentry, FALSE, TRUE, 0); /*fold00*/ + sprintf(numstr, "%d", ysize); + gtk_entry_set_text(GTK_ENTRY(yentry),numstr); + gtk_widget_show(yentry); + gtk_widget_show(box); + + box = gtk_hbox_new(FALSE, 0); + gtk_box_pack_start(GTK_BOX(all_boxes), box, TRUE, TRUE, 0); + label = gtk_label_new("Number of mines:"); + gtk_box_pack_start(GTK_BOX(box), label, TRUE, TRUE, 0); + gtk_widget_show(label); + mentry = gtk_entry_new(); + gtk_widget_set_usize(mentry, 50, -1); + gtk_box_pack_start(GTK_BOX(box), mentry, FALSE, TRUE, 0); /*FOLD00*/ + sprintf(numstr, "%d", nmines); + gtk_entry_set_text(GTK_ENTRY(mentry),numstr); + gtk_widget_show(mentry); + gtk_widget_show(box); + + box = gtk_hbox_new(TRUE, 5); + gtk_box_pack_start(GTK_BOX(all_boxes), box, TRUE, TRUE, 0); + button = gtk_button_new_with_label("Ok"); + gtk_signal_connect(GTK_OBJECT(button), "clicked", + GTK_SIGNAL_FUNC(do_setup), NULL); + gtk_box_pack_start(GTK_BOX(box), button, TRUE, TRUE, 5); /*FOLD00*/ + gtk_widget_show(button); + button = gtk_button_new_with_label("Cancel"); + gtk_signal_connect(GTK_OBJECT(button), "clicked", + (GtkSignalFunc)setupdialog_destroy, + (gpointer)1); + gtk_box_pack_start(GTK_BOX(box), button, TRUE, TRUE, 5); /*FOLD00*/ + gtk_widget_show(button); + gtk_widget_show(box); + + gtk_widget_show(all_boxes); + gtk_widget_show(setupdialog); +} + +void main(int argc, char *argv[]) +{ + GtkWidget *window; + GtkWidget *all_boxes; + GtkWidget *menu_box; + GtkWidget *status_table; + GtkWidget *menu; + GtkWidget *menubar; + GtkWidget *menubar_item; + GtkWidget *menu_item; + + gtk_init(&argc, &argv); + gnome_init(&argc, &argv); + + window = gtk_window_new(GTK_WINDOW_TOPLEVEL); + gtk_window_set_title(GTK_WINDOW(window), "Gnomine"); +// gtk_container_border_width(GTK_CONTAINER(window), 30); + + gtk_signal_connect(GTK_OBJECT(window), "destroy", + GTK_SIGNAL_FUNC(quit_game), NULL); + + all_boxes = gtk_vbox_new(FALSE, 0); + gtk_container_add(GTK_CONTAINER(window), all_boxes); + + + + menu_box = gtk_hbox_new(FALSE, 0); + gtk_box_pack_start(GTK_BOX(all_boxes), menu_box, TRUE, TRUE, 0); + + menu = gtk_menu_new(); + + menubar_item = gtk_menu_item_new_with_label("Game"); + + menu_item = gtk_menu_item_new_with_label("New"); + gtk_signal_connect(GTK_OBJECT(menu_item), "activate", + GTK_SIGNAL_FUNC(new_game), NULL); + gtk_menu_append(GTK_MENU(menu), menu_item); + gtk_widget_show(menu_item); + + menu_item = gtk_menu_item_new_with_label("Setup"); + gtk_signal_connect(GTK_OBJECT(menu_item), "activate", + GTK_SIGNAL_FUNC(setup_game), NULL); + gtk_menu_append(GTK_MENU(menu), menu_item); + gtk_widget_show(menu_item); + + menu_item = gtk_menu_item_new_with_label("Quit"); + gtk_signal_connect(GTK_OBJECT(menu_item), "activate", + GTK_SIGNAL_FUNC(quit_game), NULL); + gtk_menu_append(GTK_MENU(menu), menu_item); + gtk_widget_show(menu_item); + + gtk_menu_item_set_submenu(GTK_MENU_ITEM(menubar_item), menu); + gtk_widget_show(menubar_item); + + menubar = gtk_menu_bar_new(); + gtk_widget_show(menubar); + gtk_menu_bar_append(GTK_MENU_BAR(menubar), menubar_item); + + gtk_box_pack_start(GTK_BOX(menu_box), menubar, TRUE, TRUE, 0); + + gtk_widget_show(menu_box); + + xsize = gnome_config_get_int("/gnomine/geometry/xsize=20"); + ysize = gnome_config_get_int("/gnomine/geometry/ysize=20"); + nmines = gnome_config_get_int("/gnomine/geometry/nmines=20"); + + mfieldbox = gtk_vbox_new(FALSE, 0); + gtk_box_pack_start(GTK_BOX(all_boxes), mfieldbox, TRUE, TRUE, 0); + gtk_widget_show(mfieldbox); + + create_mfield(); + status_table = gtk_table_new(1, 3, TRUE); + gtk_box_pack_start(GTK_BOX(all_boxes), status_table, TRUE, TRUE, 0); + + flags_label = gtk_label_new("Flags: "); + gtk_table_attach(GTK_TABLE(status_table), flags_label, + 0, 1, 0, 1, 0, 0, 3, 3); + gtk_widget_show(flags_label); + + gtk_widget_show(status_table); + + gtk_widget_show(all_boxes); + gtk_widget_show(window); + + gtk_main(); + + gnome_config_set_int("/gnomine/geometry/xsize", xsize); + gnome_config_set_int("/gnomine/geometry/ysize", ysize); + gnome_config_set_int("/gnomine/geometry/nmines", nmines); + gnome_config_sync(); +} + + + diff -uNr gnome-0.7/programs/gnomine/gnomine.desktop gnome-0.8/programs/gnomine/gnomine.desktop --- gnome-0.7/programs/gnomine/gnomine.desktop Wed Dec 31 18:00:00 1969 +++ gnome-0.8/programs/gnomine/gnomine.desktop Thu Oct 9 15:31:05 1997 @@ -0,0 +1,6 @@ +[Desktop Entry] +Exec=gnomine +Icon= +Info=Gnome Mines program +Terminal=0 +Type=Application diff -uNr gnome-0.7/programs/gnomine/mine.xpm gnome-0.8/programs/gnomine/mine.xpm --- gnome-0.7/programs/gnomine/mine.xpm Wed Dec 31 18:00:00 1969 +++ gnome-0.8/programs/gnomine/mine.xpm Wed Oct 8 14:49:46 1997 @@ -0,0 +1,19 @@ +/* XPM */ +static char *magick[] = { +/* columns rows colors chars-per-pixel */ +"11 11 2 1", +" c Black", +"X c None", +/* pixels */ +"XXXXX XXXXX", +"X X", +"X XXX X", +"X XXX X", +" X", +" ", +"X X", +"X X", +"X X", +"X X", +"XXXXX XXXXX" +}; diff -uNr gnome-0.7/programs/gnomine/minefield.c gnome-0.8/programs/gnomine/minefield.c --- gnome-0.7/programs/gnomine/minefield.c Wed Dec 31 18:00:00 1969 +++ gnome-0.8/programs/gnomine/minefield.c Thu Oct 9 23:50:05 1997 @@ -0,0 +1,560 @@ + +#include + +#include "minefield.h" + +#define MINESIZE 17 + +static gint minefield_signals[LAST_SIGNAL] = { 0 }; + +static void gtk_minefield_realize(GtkWidget *widget) +{ + GtkMineField *mfield; + GdkWindowAttr attributes; + gint attributes_mask; + + g_return_if_fail(widget != NULL); + g_return_if_fail(GTK_IS_MINEFIELD (widget)); + + mfield = GTK_MINEFIELD(widget); + GTK_WIDGET_SET_FLAGS(widget, GTK_REALIZED); + + attributes.window_type = GDK_WINDOW_CHILD; + attributes.x = widget->allocation.x; + attributes.y = widget->allocation.y; + attributes.width = widget->allocation.width; + attributes.height = widget->allocation.height; + attributes.wclass = GDK_INPUT_OUTPUT; + attributes.visual = gtk_widget_get_visual(widget); + attributes.colormap = gtk_widget_get_colormap(widget); + attributes.event_mask = gtk_widget_get_events(widget); + attributes.event_mask |= GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK | + GDK_BUTTON_RELEASE_MASK; + + attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP; + + widget->window = gdk_window_new(widget->parent->window, &attributes, attributes_mask); + gdk_window_set_user_data(widget->window, mfield); + + widget->style = gtk_style_attach(widget->style, widget->window); + gtk_style_set_background(widget->style, widget->window, GTK_STATE_ACTIVE); +} + +static void gtk_minefield_size_allocate(GtkWidget *widget, + GtkAllocation *allocation) +{ + g_return_if_fail(widget != NULL); + g_return_if_fail(GTK_IS_MINEFIELD (widget)); + g_return_if_fail(allocation != NULL); + + widget->allocation = *allocation; + + if (GTK_WIDGET_REALIZED(widget)) { + gdk_window_move_resize(widget->window, + allocation->x, allocation->y, + GTK_MINEFIELD(widget)->xsize*MINESIZE, + GTK_MINEFIELD(widget)->ysize*MINESIZE); + } +} + +static void gtk_minefield_size_request(GtkWidget *widget, + GtkRequisition *requisition) +{ + requisition->width = GTK_MINEFIELD(widget)->xsize*MINESIZE; + requisition->height = GTK_MINEFIELD(widget)->ysize*MINESIZE; +} + +static void gtk_mine_draw(GtkMineField *mfield, guint x, guint y) +{ + int c = x+mfield->xsize*y; + int shadow_type = (mfield->cdown == c ? GTK_SHADOW_IN : GTK_SHADOW_OUT); + int n; + GtkWidget *widget = GTK_WIDGET(mfield); + + + if (mfield->lose == 1) { + gdk_window_clear_area(widget->window, + x*MINESIZE, y*MINESIZE, + MINESIZE, + MINESIZE); + if (!mfield->mines[c].shown) { + gtk_draw_shadow(widget->style, widget->window, + GTK_WIDGET_STATE (widget), GTK_SHADOW_OUT, + x*MINESIZE, y*MINESIZE, + MINESIZE, + MINESIZE); + } + if (mfield->mines[c].marked == 1) { + if (mfield->marked_sign_mask) { + gdk_gc_set_clip_mask(widget->style->black_gc, + mfield->marked_sign_mask); + gdk_gc_set_clip_origin(widget->style->black_gc, + x*MINESIZE+3, y*MINESIZE+3); + } + + gdk_draw_pixmap (widget->window, + widget->style->black_gc, + mfield->marked_sign, + 0, 0, x*MINESIZE+3, y*MINESIZE+3, -1, -1); + + if (mfield->marked_sign_mask) { + gdk_gc_set_clip_mask(widget->style->black_gc, NULL); + } + if (mfield->mines[c].mined != 1) { + gdk_draw_line(widget->window, + widget->style->black_gc, + x*MINESIZE+2, + y*MINESIZE+3, + x*MINESIZE+MINESIZE-4, + y*MINESIZE+MINESIZE-3); + gdk_draw_line(widget->window, + widget->style->black_gc, + x*MINESIZE+3, + y*MINESIZE+2, + x*MINESIZE+MINESIZE-3, + y*MINESIZE+MINESIZE-4); + gdk_draw_line(widget->window, + widget->style->black_gc, + x*MINESIZE+2, + y*MINESIZE+MINESIZE-4, + x*MINESIZE+MINESIZE-4, + y*MINESIZE+2); + gdk_draw_line(widget->window, + widget->style->black_gc, + x*MINESIZE+3, + y*MINESIZE+MINESIZE-3, + x*MINESIZE+MINESIZE-3, + y*MINESIZE+3); + } + } else if (mfield->mines[c].mined == 1) { + if (mfield->mine_sign_mask) { + gdk_gc_set_clip_mask(widget->style->black_gc, + mfield->mine_sign_mask); + gdk_gc_set_clip_origin(widget->style->black_gc, + x*MINESIZE+3, y*MINESIZE+3); + } + + gdk_draw_pixmap (widget->window, + widget->style->black_gc, + mfield->mine_sign, + 0, 0, x*MINESIZE+3, y*MINESIZE+3, -1, -1); + + if (mfield->marked_sign_mask) { + gdk_gc_set_clip_mask(widget->style->black_gc, NULL); + } + } else if (mfield->mines[c].shown == 1) { + if ((n = mfield->mines[c].neighbours) != 0) { + gdk_draw_string(widget->window, + widget->style->font, + widget->style->black_gc, + x*MINESIZE+mfield->numstr[n].dx, + y*MINESIZE+mfield->numstr[n].dy, + mfield->numstr[n].text); + } + } + return; + } + + + + + if (mfield->mines[c].shown == 1) { + gdk_window_clear_area(widget->window, + x*MINESIZE, y*MINESIZE, + MINESIZE, + MINESIZE); + if ((n = mfield->mines[c].neighbours) != 0) { + gdk_draw_string(widget->window, + widget->style->font, + widget->style->black_gc, + x*MINESIZE+mfield->numstr[n].dx, + y*MINESIZE+mfield->numstr[n].dy, + mfield->numstr[n].text); + } + } else { + gtk_draw_shadow(widget->style, widget->window, + GTK_WIDGET_STATE (widget), shadow_type, + x*MINESIZE, y*MINESIZE, + MINESIZE, + MINESIZE); + + if (mfield->mines[c].marked == 1) { + if (mfield->marked_sign_mask) { + gdk_gc_set_clip_mask(widget->style->black_gc, + mfield->marked_sign_mask); + gdk_gc_set_clip_origin(widget->style->black_gc, + x*MINESIZE+3, y*MINESIZE+3); + } + + gdk_draw_pixmap (widget->window, + widget->style->black_gc, + mfield->marked_sign, + 0, 0, x*MINESIZE+3, y*MINESIZE+3, -1, -1); + + if (mfield->marked_sign_mask) { + gdk_gc_set_clip_mask(widget->style->black_gc, NULL); + } + + } else { + + gdk_window_clear_area(widget->window, + x*MINESIZE+2, y*MINESIZE+2, + MINESIZE-4, + MINESIZE-4); + gdk_gc_set_clip_origin(widget->style->black_gc, + 0, 0); + } +/* + if (mfield->mines[c].mined == 1) { + gdk_draw_rectangle(widget->window, widget->style->black_gc, + 0, + x*MINESIZE+MINESIZE-3, y*MINESIZE+2, + 1,1); + } +*/ + } +} + +void gtk_minefield_draw(GtkMineField *mfield) +{ + guint x, y; + + for (x = 0; xxsize; x++) { + for (y = 0; yysize; y++) { + gtk_mine_draw(mfield, x, y); + } + } +} + +static gint gtk_minefield_expose(GtkWidget *widget, + GdkEventExpose *event) +{ + g_return_val_if_fail(widget != NULL, FALSE); + g_return_val_if_fail(GTK_IS_MINEFIELD(widget), FALSE); + g_return_val_if_fail(event != NULL, FALSE); + + if (GTK_WIDGET_DRAWABLE(widget)) { + gtk_minefield_draw(GTK_MINEFIELD(widget)); + + } + return FALSE; +} + +#define SS(x,y) \ + do { \ + if (mfield->mines[(x)+mfield->xsize*(y)].shown == 0 && \ + mfield->mines[(x)+mfield->xsize*(y)].marked == 0) { \ + mfield->mines[(x)+mfield->xsize*(y)].shown = 1; \ + gtk_mine_draw(mfield, x, y); \ + changed=1; \ + } \ + } while (0) + +static void gtk_minefield_check_field(GtkMineField *mfield) +{ + guint x, y; + int changed; + + changed = 1; + while (changed) { + changed = 0; + for (x=0; xxsize; x++) { + for (y=0; yysize; y++) { + if (mfield->mines[x+mfield->xsize*y].neighbours == 0 && + mfield->mines[x+mfield->xsize*y].shown == 1) { + if (x>0) { + SS(x-1, y); + if (y>0) SS(x-1, y-1); + if (yysize-1) SS(x-1, y+1); + } + if (xxsize-1) { + SS(x+1, y); + if (y>0) SS(x+1, y-1); + if (yysize-1) SS(x+1, y+1); + } + if (y>0) SS(x, y-1); + if (yysize-1) SS(x, y+1); + } + } + } + } +} +#undef SS + +static void gtk_minefield_set_shown(GtkMineField *mfield, guint x, guint y) +{ + int c = x+mfield->xsize*y; + + if (mfield->mines[c].marked != 1 && mfield->mines[c].shown != 1) { + mfield->mines[c].shown = 1; + + gtk_mine_draw(mfield, mfield->cdownx, mfield->cdowny); + gtk_minefield_check_field(mfield); + if (mfield->mines[c].mined == 1) { + mfield->lose = 1; + gtk_minefield_draw(mfield); + gtk_signal_emit(GTK_OBJECT(mfield), + minefield_signals[EXPLODE_SIGNAL]); + } + } +} + +static void gtk_minefield_rightdown(GtkMineField *mfield, guint x, guint y) +{ + int c = x+mfield->xsize*y; + if (mfield->mines[c].shown == 0) { + if ((mfield->mines[c].marked = 1-mfield->mines[c].marked) == 1) { + mfield->flags++; + } else { + mfield->flags--; + } + gtk_signal_emit(GTK_OBJECT(mfield), + minefield_signals[MARKS_CHANGED_SIGNAL]); + } +} + +static gint gtk_minefield_button_press(GtkWidget *widget, GdkEventButton *event) +{ + GtkMineField *mfield; + guint x, y; + + g_return_val_if_fail(widget != NULL, 0); + g_return_val_if_fail(GTK_IS_MINEFIELD(widget), 0); + g_return_val_if_fail(event != NULL, 0); + + mfield = GTK_MINEFIELD(widget); + + if (!mfield->bdown) { + x = event->x/MINESIZE; + y = event->y/MINESIZE; + + mfield->cdownx = x; + mfield->cdowny = y; + mfield->cdown = x+y*(mfield->xsize); + mfield->bdown = event->button; + gtk_mine_draw(mfield, x, y); + } + return FALSE; +} + +static gint gtk_minefield_button_release(GtkWidget *widget, GdkEventButton *event) +{ + GtkMineField *mfield; + guint x, y; + + + g_return_val_if_fail(widget != NULL, FALSE); + g_return_val_if_fail(GTK_IS_MINEFIELD(widget), FALSE); + g_return_val_if_fail(event != NULL, FALSE); + + mfield = GTK_MINEFIELD(widget); + + if (mfield->lose) return FALSE; + + if (event->button == mfield->bdown) { + x = event->x/MINESIZE; + y = event->y/MINESIZE; + if (x+mfield->xsize*y == mfield->cdown) { + switch (event->button) { + case 1: gtk_minefield_set_shown(mfield, x, y); break; + case 3: gtk_minefield_rightdown(mfield, x, y); break; + } + } + mfield->cdown = -1; + mfield->bdown = 0; + gtk_mine_draw(mfield, mfield->cdownx, mfield->cdowny); + } + return FALSE; +} + + +static void gtk_minefield_class_init (GtkMineFieldClass *class) +{ + GtkWidgetClass *widget_class; + GtkObjectClass *object_class; + + widget_class = (GtkWidgetClass *)class; + object_class = (GtkObjectClass *)class; + + widget_class->realize = gtk_minefield_realize; + widget_class->size_allocate = gtk_minefield_size_allocate; + widget_class->size_request = gtk_minefield_size_request; + widget_class->expose_event = gtk_minefield_expose; + widget_class->button_press_event = gtk_minefield_button_press; + widget_class->button_release_event = gtk_minefield_button_release; + minefield_signals[MARKS_CHANGED_SIGNAL] = + gtk_signal_new("marks_changed", + GTK_RUN_FIRST, + object_class->type, + GTK_SIGNAL_OFFSET(GtkMineFieldClass, marks_changed), + gtk_signal_default_marshaller, + GTK_TYPE_NONE, + 0); + minefield_signals[EXPLODE_SIGNAL] = + gtk_signal_new("explode", + GTK_RUN_FIRST, + object_class->type, + GTK_SIGNAL_OFFSET(GtkMineFieldClass, explode), + gtk_signal_default_marshaller, + GTK_TYPE_NONE, + 0); + gtk_object_class_add_signals(object_class, minefield_signals, LAST_SIGNAL); + + +} + +static void gtk_minefield_init (GtkMineField *mfield) +{ + GTK_WIDGET_SET_FLAGS (mfield, GTK_BASIC); + mfield->xsize = 0; + mfield->ysize = 0; + + GTK_WIDGET (mfield)->requisition.width = MINESIZE; + GTK_WIDGET (mfield)->requisition.height = MINESIZE; +} + + +GtkWidget* gtk_minefield_new (guint xsize, guint ysize) +{ + GtkMineField *mfield; + GtkWidget *widget; + int i; + char *marked_filename; + char *mine_filename; + + marked_filename = gnome_unconditional_pixmap_file(MARKED_SIGN_FILENAME); + mine_filename = gnome_unconditional_pixmap_file(MINE_SIGN_FILENAME); + + mfield = gtk_type_new(gtk_minefield_get_type()); + widget = GTK_WIDGET(mfield); + mfield->xsize = xsize; + mfield->ysize = ysize; + mfield->mines = g_new(mine,xsize*ysize); + mfield->marked_sign_style = gtk_widget_get_style(GTK_WIDGET(mfield)); + mfield->marked_sign = gdk_pixmap_create_from_xpm(GTK_WIDGET(mfield)->window, + &mfield->marked_sign_mask, + &mfield->marked_sign_style->bg[GTK_STATE_NORMAL], + marked_filename); + + mfield->mine_sign_style = gtk_widget_get_style(GTK_WIDGET(mfield)); + mfield->mine_sign = gdk_pixmap_create_from_xpm(GTK_WIDGET(mfield)->window, + &mfield->mine_sign_mask, + &mfield->mine_sign_style->bg[GTK_STATE_NORMAL], + mine_filename); + + g_free(marked_filename); + g_free(mine_filename); + + for (i=0; i<8; i++) { + mfield->numstr[i].text[0]=i+'0'; + mfield->numstr[i].text[1]='\0'; + mfield->numstr[i].dx=(MINESIZE- + gdk_string_width(widget->style->font, + mfield->numstr[i].text))/2; + mfield->numstr[i].dy=(MINESIZE-widget->style->font->ascent)/2+10; + } + + mfield->cdown = -1; + gtk_minefield_restart(mfield); + return GTK_WIDGET(mfield); +} + +guint gtk_minefield_get_type () +{ + static guint minefield_type = 0; + + if (!minefield_type) + { + GtkTypeInfo minefield_info = + { + "GtkMineField", + sizeof (GtkMineField), + sizeof (GtkMineFieldClass), + (GtkClassInitFunc) gtk_minefield_class_init, + (GtkObjectInitFunc) gtk_minefield_init, + (GtkArgFunc) NULL, + }; + + minefield_type = gtk_type_unique (gtk_widget_get_type (), &minefield_info); + } + + return minefield_type; +} + +void gtk_minefield_set_size(GtkMineField *mfield, guint xsize, guint ysize) +{ + mfield->xsize = xsize; + mfield->ysize = ysize; +} + +void gtk_minefield_set_mines(GtkMineField *mfield, guint mcount) +{ + mfield->mcount = mcount; +} + +static gulong random_seed; + +void init_random(gulong seed) +{ + random_seed = seed; +} + +gulong get_random(gulong limit) +{ + do { + random_seed = (random_seed*1139113+10921)>>2; + } while (random_seed > ((gulong)(G_MAXLONG/limit))*limit); + return random_seed % limit; +} + +#define MM(x,y) mfield->mines[(x)+(y)*mfield->xsize].mined + +void gtk_minefield_restart(GtkMineField *mfield) +{ + guint i, j; + guint x, y; + guint tmp; + guint n; + + mfield->flags = 0; + mfield->lose = 0; + mfield->bdown = 0; + + for (i=0; imcount; i++) { + mfield->mines[i].mined = 1; + } + for (i=mfield->mcount; ixsize*mfield->ysize; i++) { + mfield->mines[i].mined = 0; + } + + for (i=0; ixsize*mfield->ysize; i++) { + mfield->mines[i].marked = 0; + mfield->mines[i].shown = 0; + j = (guint)get_random(mfield->xsize*mfield->ysize); + tmp = mfield->mines[i].mined; + mfield->mines[i].mined = mfield->mines[j].mined; + mfield->mines[j].mined = tmp; + } + + for (x=0; xxsize; x++) { + for (y=0; yysize; y++) { + n = 0; + if (x>0) { + n += MM(x-1, y); + if (y>0) n += MM(x-1, y-1); + if (yysize-1) n += MM(x-1, y+1); + } + if (xxsize-1) { + n += MM(x+1, y); + if (y>0) n += MM(x+1, y-1); + if (yysize-1) n += MM(x+1, y+1); + } + if (y>0) n += MM(x, y-1); + if (yysize-1) n += MM(x, y+1); + mfield->mines[x+mfield->xsize*y].neighbours = n; + } + } +} + +#undef MM + diff -uNr gnome-0.7/programs/gnomine/minefield.h gnome-0.8/programs/gnomine/minefield.h --- gnome-0.7/programs/gnomine/minefield.h Wed Dec 31 18:00:00 1969 +++ gnome-0.8/programs/gnomine/minefield.h Tue Sep 23 15:08:52 1997 @@ -0,0 +1,86 @@ + +#ifndef __GTK_MINEFIELD_H__ +#define __GTK_MINEFIELD_H__ + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + + +#define GTK_MINEFIELD(obj) GTK_CHECK_CAST(obj, gtk_minefield_get_type(), GtkMineField) +#define GTK_MINEFIELD_CLASS(klass) GTK_CHECK_CLASS_CAST(klass, gtk_minefield_get_type(), GtkMineFieldClass); +#define GTK_IS_MINEFIELD(obj) GTK_CHECK_TYPE(obj, gtk_minefield_get_type()) + +#define MARKED_SIGN_FILENAME "flag.xpm" +#define MINE_SIGN_FILENAME "mine.xpm" + +typedef struct _GtkMineField GtkMineField; +typedef struct _GtkMineFieldClass GtkMineFieldClass; + +struct _Mine { + guint mined; + guint shown; + guint marked; + guint neighbours; +}; + +typedef struct _Mine mine; + +struct _GtkMineField { + GtkWidget widget; + guint xsize, ysize; + guint mcount; + mine *mines; + guint flags; + gint cdown; + guint cdownx; + guint cdowny; + gint bdown; + gint lose; + GdkPixmap *marked_sign; + GdkBitmap *marked_sign_mask; + GtkStyle *marked_sign_style; + GdkPixmap *mine_sign; + GdkBitmap *mine_sign_mask; + GtkStyle *mine_sign_style; + struct { + char text[2]; + gint dx, dy; + } numstr[8]; +}; + +struct _GtkMineFieldClass +{ + GtkWidgetClass parent_class; + void (*marks_changed) (GtkMineField *mfield); + void (*explode) (GtkMineField *mfield); +}; + + +guint gtk_minefield_get_type (void); +GtkWidget* gtk_minefield_new (guint xsize, guint ysize); + +void gtk_minefield_set_size(GtkMineField *mfield, guint xsize, guint ysize); +void gtk_minefield_set_mines(GtkMineField *mfield, guint mcount); +void gtk_minefield_restart(GtkMineField *mfield); + +enum { + MARKS_CHANGED_SIGNAL, + EXPLODE_SIGNAL, + LAST_SIGNAL +}; + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +#endif /* __GTK_MINEFIELD_H__ */ + + + + diff -uNr gnome-0.7/programs/panel/Makefile.am gnome-0.8/programs/panel/Makefile.am --- gnome-0.7/programs/panel/Makefile.am Thu Oct 2 22:33:28 1997 +++ gnome-0.8/programs/panel/Makefile.am Wed Oct 8 16:33:52 1997 @@ -1,5 +1,5 @@ -SUBDIRS = menu mailcheck +SUBDIRS = menu mailcheck clock launcher INCLUDES = \ -I../.. \ @@ -10,6 +10,8 @@ bin_PROGRAMS = panel module_test panel_SOURCES = \ + gdkextra.c \ + gdkextra.h \ applet.c \ applet.h \ main.c \ diff -uNr gnome-0.7/programs/panel/Makefile.in gnome-0.8/programs/panel/Makefile.in --- gnome-0.7/programs/panel/Makefile.in Fri Oct 3 01:04:36 1997 +++ gnome-0.8/programs/panel/Makefile.in Fri Oct 10 00:35:47 1997 @@ -83,7 +83,7 @@ RANLIB = @RANLIB@ VERSION = @VERSION@ -SUBDIRS = menu mailcheck +SUBDIRS = menu mailcheck clock launcher INCLUDES = \ -I../.. \ @@ -94,6 +94,8 @@ bin_PROGRAMS = panel module_test panel_SOURCES = \ + gdkextra.c \ + gdkextra.h \ applet.c \ applet.h \ main.c \ @@ -123,7 +125,7 @@ X_LIBS = @X_LIBS@ X_EXTRA_LIBS = @X_EXTRA_LIBS@ X_PRE_LIBS = @X_PRE_LIBS@ -panel_OBJECTS = applet.o main.o panel.o +panel_OBJECTS = gdkextra.o applet.o main.o panel.o panel_DEPENDENCIES = $(top_builddir)/libgnomeui/libgnomeui.la \ $(top_builddir)/libgnome/libgnome.la panel_LDFLAGS = @@ -296,34 +298,42 @@ ../../libgnome/libgnome.h ../../libgnome/gnome-defs.h \ ../../libgnome/gnome-util.h ../../libgnome/gnome-hook.h \ ../../libgnome/gnome-config.h ../../libgnome/gnome-dns.h \ - ../../libgnomeui/libgnomeui.h ../../libgnomeui/gnome-colors.h \ + ../../libgnome/gnome-dentry.h ../../libgnomeui/libgnomeui.h \ + ../../libgnomeui/gnome-colors.h \ ../../libgnomeui/gnome-color-selector.h \ ../../libgnomeui/gnome-messagebox.h \ - ../../libgnomeui/gnome-pixmap.h panel.h + ../../libgnomeui/gnome-pixmap.h \ + ../../libgnomeui/gnome-toolbar.h panel.h +gdkextra.o gdkextra.lo: gdkextra.c gdkextra.h main.o main.lo: main.c applet.h ../../gnome.h ../../libgnome/libgnome.h \ ../../libgnome/gnome-defs.h ../../libgnome/gnome-util.h \ ../../libgnome/gnome-hook.h ../../libgnome/gnome-config.h \ - ../../libgnome/gnome-dns.h ../../libgnomeui/libgnomeui.h \ - ../../libgnomeui/gnome-colors.h \ + ../../libgnome/gnome-dns.h ../../libgnome/gnome-dentry.h \ + ../../libgnomeui/libgnomeui.h ../../libgnomeui/gnome-colors.h \ ../../libgnomeui/gnome-color-selector.h \ ../../libgnomeui/gnome-messagebox.h \ - ../../libgnomeui/gnome-pixmap.h panel.h + ../../libgnomeui/gnome-pixmap.h \ + ../../libgnomeui/gnome-toolbar.h panel.h module_test.o module_test.lo: module_test.c ../../gnome.h \ ../../libgnome/libgnome.h ../../libgnome/gnome-defs.h \ ../../libgnome/gnome-util.h ../../libgnome/gnome-hook.h \ ../../libgnome/gnome-config.h ../../libgnome/gnome-dns.h \ - ../../libgnomeui/libgnomeui.h ../../libgnomeui/gnome-colors.h \ + ../../libgnome/gnome-dentry.h ../../libgnomeui/libgnomeui.h \ + ../../libgnomeui/gnome-colors.h \ ../../libgnomeui/gnome-color-selector.h \ ../../libgnomeui/gnome-messagebox.h \ - ../../libgnomeui/gnome-pixmap.h + ../../libgnomeui/gnome-pixmap.h \ + ../../libgnomeui/gnome-toolbar.h panel.o panel.lo: panel.c applet.h ../../gnome.h \ ../../libgnome/libgnome.h ../../libgnome/gnome-defs.h \ ../../libgnome/gnome-util.h ../../libgnome/gnome-hook.h \ ../../libgnome/gnome-config.h ../../libgnome/gnome-dns.h \ - ../../libgnomeui/libgnomeui.h ../../libgnomeui/gnome-colors.h \ + ../../libgnome/gnome-dentry.h ../../libgnomeui/libgnomeui.h \ + ../../libgnomeui/gnome-colors.h \ ../../libgnomeui/gnome-color-selector.h \ ../../libgnomeui/gnome-messagebox.h \ - ../../libgnomeui/gnome-pixmap.h panel.h + ../../libgnomeui/gnome-pixmap.h \ + ../../libgnomeui/gnome-toolbar.h panel.h gdkextra.h info: info-recursive dvi: dvi-recursive diff -uNr gnome-0.7/programs/panel/applet.c gnome-0.8/programs/panel/applet.c --- gnome-0.7/programs/panel/applet.c Thu Oct 2 23:01:34 1997 +++ gnome-0.8/programs/panel/applet.c Thu Oct 9 14:37:57 1997 @@ -1,18 +1,13 @@ #include #include +#include #include #include #include #include "applet.h" -typedef struct { - void *dl_handle; - char *filename; -} AppletFile; - - -static GHashTable *applet_files_ht = NULL; +GHashTable *applet_files_ht = NULL; static AppletFile * @@ -117,7 +112,7 @@ if (strcmp(dir_ent->d_name + (len - 3), ".so") != 0) continue; - + filename = g_concat_dir_and_file(dirname, dir_ent->d_name); if ((stat(filename, &filestat) == 0) && @@ -149,7 +144,7 @@ void -applets_init_applet(char *name, Panel *panel, char *params, int xpos, int ypos) +applets_init_applet(char *name, char *params, int xpos, int ypos) { AppletFile *af; AppletInitFunc init; @@ -163,5 +158,5 @@ } init = get_dl_func(af->dl_handle, "init"); - (*init) (panel_command, panel, params, xpos, ypos); + (*init) (panel_command, the_panel, params, xpos, ypos); } diff -uNr gnome-0.7/programs/panel/applet.h gnome-0.8/programs/panel/applet.h --- gnome-0.7/programs/panel/applet.h Thu Oct 2 23:01:44 1997 +++ gnome-0.8/programs/panel/applet.h Thu Oct 9 13:26:10 1997 @@ -7,14 +7,21 @@ BEGIN_GNOME_DECLS +typedef struct { + void *dl_handle; + char *filename; +} AppletFile; + typedef char * (*AppletQueryFunc) (void); typedef void (*AppletInitFunc) (PanelCallback callback, Panel *panel, char *params, int xpos, int ypos); -typedef void (*AppletPropertiesFunc) (GtkWidget *applet); + + +extern GHashTable *applet_files_ht; void applets_init(void); void applets_destroy(void); -void applets_init_applet(char *name, Panel *panel, char *params, int xpos, int ypos); +void applets_init_applet(char *name, char *params, int xpos, int ypos); END_GNOME_DECLS diff -uNr gnome-0.7/programs/panel/clock/Makefile.am gnome-0.8/programs/panel/clock/Makefile.am --- gnome-0.7/programs/panel/clock/Makefile.am Wed Dec 31 18:00:00 1969 +++ gnome-0.8/programs/panel/clock/Makefile.am Mon Oct 6 19:18:36 1997 @@ -0,0 +1,10 @@ +INCLUDES = \ + -I../../.. \ + -I$(srcdir)/../../.. \ + -I$(includedir) \ + $(X_CFLAGS) + +lib_LTLIBRARIES = libpanel_clock.la + +libpanel_clock_la_SOURCES = \ + clock.c diff -uNr gnome-0.7/programs/panel/clock/Makefile.in gnome-0.8/programs/panel/clock/Makefile.in --- gnome-0.7/programs/panel/clock/Makefile.in Wed Dec 31 18:00:00 1969 +++ gnome-0.8/programs/panel/clock/Makefile.in Fri Oct 10 00:35:50 1997 @@ -0,0 +1,303 @@ +# Makefile.in generated automatically by automake 1.2 from Makefile.am + +# Copyright (C) 1994, 1995, 1996, 1997 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy, distribute and modify it. + + +SHELL = /bin/sh + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +prefix = @prefix@ +exec_prefix = @exec_prefix@ + +bindir = @bindir@ +sbindir = @sbindir@ +libexecdir = @libexecdir@ +datadir = @datadir@ +sysconfdir = @sysconfdir@ +sharedstatedir = @sharedstatedir@ +localstatedir = @localstatedir@ +libdir = @libdir@ +infodir = @infodir@ +mandir = @mandir@ +includedir = @includedir@ +oldincludedir = /usr/include + +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ + +top_builddir = ../../.. + +ACLOCAL = @ACLOCAL@ +AUTOCONF = @AUTOCONF@ +AUTOMAKE = @AUTOMAKE@ +AUTOHEADER = @AUTOHEADER@ + +INSTALL = @INSTALL@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +transform = @program_transform_name@ + +NORMAL_INSTALL = true +PRE_INSTALL = true +POST_INSTALL = true +NORMAL_UNINSTALL = true +PRE_UNINSTALL = true +POST_UNINSTALL = true +host_alias = @host_alias@ +host_triplet = @host@ +CATALOGS = @CATALOGS@ +CATOBJEXT = @CATOBJEXT@ +CC = @CC@ +CFLAGS = @CFLAGS@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +DATADIRNAME = @DATADIRNAME@ +ELCFILES = @ELCFILES@ +EMACS = @EMACS@ +GENCAT = @GENCAT@ +GMOFILES = @GMOFILES@ +GMSGFMT = @GMSGFMT@ +INSTOBJEXT = @INSTOBJEXT@ +INTLDEPS = @INTLDEPS@ +INTLLIBS = @INTLLIBS@ +INTLOBJS = @INTLOBJS@ +INTLSUB = @INTLSUB@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LEX = @LEX@ +LIBTOOL = @LIBTOOL@ +LISPDIR = @LISPDIR@ +LN_S = @LN_S@ +MAKEINFO = @MAKEINFO@ +MSGFMT = @MSGFMT@ +NM = @NM@ +PACKAGE = @PACKAGE@ +POFILES = @POFILES@ +POSUB = @POSUB@ +RANLIB = @RANLIB@ +VERSION = @VERSION@ + +INCLUDES = \ + -I../../.. \ + -I$(srcdir)/../../.. \ + -I$(includedir) \ + $(X_CFLAGS) + +lib_LTLIBRARIES = libpanel_clock.la + +libpanel_clock_la_SOURCES = \ + clock.c +mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +CONFIG_HEADER = ../../../config.h +CONFIG_CLEAN_FILES = +LTLIBRARIES = $(lib_LTLIBRARIES) + + +DEFS = @DEFS@ -I. -I$(srcdir) -I../../.. +LIBS = @LIBS@ +X_CFLAGS = @X_CFLAGS@ +X_LIBS = @X_LIBS@ +X_EXTRA_LIBS = @X_EXTRA_LIBS@ +X_PRE_LIBS = @X_PRE_LIBS@ +libpanel_clock_la_LDFLAGS = +libpanel_clock_la_LIBADD = +libpanel_clock_la_OBJECTS = clock.lo +COMPILE = $(CC) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) +LINK = $(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(LDFLAGS) -o $@ +DIST_COMMON = Makefile.am Makefile.in + + +DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) + +TAR = tar +GZIP = --best +SOURCES = $(libpanel_clock_la_SOURCES) +OBJECTS = $(libpanel_clock_la_OBJECTS) + +default: all + +.SUFFIXES: +.SUFFIXES: .c .lo .o +$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) + cd $(top_srcdir) && $(AUTOMAKE) --gnu --include-deps programs/panel/clock/Makefile + +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + cd $(top_builddir) \ + && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status + + +mostlyclean-libLTLIBRARIES: + +clean-libLTLIBRARIES: + test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES) + +distclean-libLTLIBRARIES: + +maintainer-clean-libLTLIBRARIES: + +install-libLTLIBRARIES: $(lib_LTLIBRARIES) + @$(NORMAL_INSTALL) + $(mkinstalldirs) $(libdir) + @list='$(lib_LTLIBRARIES)'; for p in $$list; do \ + if test -f $$p; then \ + echo "$(LIBTOOL) --mode=install $(INSTALL_PROGRAM) $$p $(libdir)/$$p"; \ + $(LIBTOOL) --mode=install $(INSTALL_PROGRAM) $$p $(libdir)/$$p; \ + else :; fi; \ + done + +uninstall-libLTLIBRARIES: + $(NORMAL_UNINSTALL) + list='$(lib_LTLIBRARIES)'; for p in $$list; do \ + $(LIBTOOL) --mode=uninstall rm -f $(libdir)/$$p; \ + done + +.c.o: + $(COMPILE) -c $< + +mostlyclean-compile: + rm -f *.o core + +clean-compile: + +distclean-compile: + rm -f *.tab.c + +maintainer-clean-compile: + +.c.lo: + $(LIBTOOL) --mode=compile $(COMPILE) -c $< + +mostlyclean-libtool: + rm -f *.lo + +clean-libtool: + rm -rf .libs + +distclean-libtool: + +maintainer-clean-libtool: + +libpanel_clock.la: $(libpanel_clock_la_OBJECTS) $(libpanel_clock_la_DEPENDENCIES) + $(LINK) -rpath $(libdir) $(libpanel_clock_la_LDFLAGS) $(libpanel_clock_la_OBJECTS) $(libpanel_clock_la_LIBADD) $(LIBS) + +tags: TAGS + +ID: $(HEADERS) $(SOURCES) + here=`pwd` && cd $(srcdir) && mkid -f$$here/ID $(SOURCES) $(HEADERS) + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) + tags=; \ + here=`pwd`; \ + test -z "$(ETAGS_ARGS)$(SOURCES)$(HEADERS)$$tags" \ + || (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags $(SOURCES) $(HEADERS) -o $$here/TAGS) + +mostlyclean-tags: + +clean-tags: + +distclean-tags: + rm -f TAGS ID + +maintainer-clean-tags: + +distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir) + +subdir = programs/panel/clock + +distdir: $(DISTFILES) + @for file in $(DISTFILES); do \ + d=$(srcdir); \ + test -f $(distdir)/$$file \ + || ln $$d/$$file $(distdir)/$$file 2> /dev/null \ + || cp -p $$d/$$file $(distdir)/$$file; \ + done +clock.o clock.lo: clock.c ../../../gnome.h ../../../libgnome/libgnome.h \ + ../../../libgnome/gnome-defs.h ../../../libgnome/gnome-util.h \ + ../../../libgnome/gnome-hook.h ../../../libgnome/gnome-config.h \ + ../../../libgnome/gnome-dns.h ../../../libgnome/gnome-dentry.h \ + ../../../libgnomeui/libgnomeui.h \ + ../../../libgnomeui/gnome-colors.h \ + ../../../libgnomeui/gnome-color-selector.h \ + ../../../libgnomeui/gnome-messagebox.h \ + ../../../libgnomeui/gnome-pixmap.h \ + ../../../libgnomeui/gnome-toolbar.h ../applet.h ../panel.h + +info: +dvi: +check: all + $(MAKE) +installcheck: +install-exec: install-libLTLIBRARIES + @$(NORMAL_INSTALL) + +install-data: + @$(NORMAL_INSTALL) + +install: install-exec install-data all + @: + +uninstall: uninstall-libLTLIBRARIES + +all: Makefile $(LTLIBRARIES) + +install-strip: + $(MAKE) INSTALL_PROGRAM='$(INSTALL_PROGRAM) -s' INSTALL_SCRIPT='$(INSTALL_PROGRAM)' install +installdirs: + $(mkinstalldirs) $(libdir) + + +mostlyclean-generic: + test -z "$(MOSTLYCLEANFILES)" || rm -f $(MOSTLYCLEANFILES) + +clean-generic: + test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) + +distclean-generic: + rm -f Makefile $(DISTCLEANFILES) + rm -f config.cache config.log stamp-h stamp-h[0-9]* + test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES) + test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES) +mostlyclean: mostlyclean-libLTLIBRARIES mostlyclean-compile \ + mostlyclean-libtool mostlyclean-tags \ + mostlyclean-generic + +clean: clean-libLTLIBRARIES clean-compile clean-libtool clean-tags \ + clean-generic mostlyclean + +distclean: distclean-libLTLIBRARIES distclean-compile distclean-libtool \ + distclean-tags distclean-generic clean + rm -f config.status + rm -f libtool + +maintainer-clean: maintainer-clean-libLTLIBRARIES \ + maintainer-clean-compile maintainer-clean-libtool \ + maintainer-clean-tags maintainer-clean-generic \ + distclean + @echo "This command is intended for maintainers to use;" + @echo "it deletes files that may require special tools to rebuild." + +.PHONY: default mostlyclean-libLTLIBRARIES distclean-libLTLIBRARIES \ +clean-libLTLIBRARIES maintainer-clean-libLTLIBRARIES \ +uninstall-libLTLIBRARIES install-libLTLIBRARIES mostlyclean-compile \ +distclean-compile clean-compile maintainer-clean-compile \ +mostlyclean-libtool distclean-libtool clean-libtool \ +maintainer-clean-libtool tags mostlyclean-tags distclean-tags \ +clean-tags maintainer-clean-tags distdir info dvi installcheck \ +install-exec install-data install uninstall all installdirs \ +mostlyclean-generic distclean-generic clean-generic \ +maintainer-clean-generic clean mostlyclean distclean maintainer-clean + + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff -uNr gnome-0.7/programs/panel/clock/clock.c gnome-0.8/programs/panel/clock/clock.c --- gnome-0.7/programs/panel/clock/clock.c Wed Dec 31 18:00:00 1969 +++ gnome-0.8/programs/panel/clock/clock.c Wed Oct 8 17:16:04 1997 @@ -0,0 +1,137 @@ +/* + * GNOME time/date display module. + * (C) 1997 The Free Software Foundation + * + * Author: Miguel de Icaza + * + * Feel free to implement new look and feels :-) + */ + +#include +#include +#include +#include +#include +#include +#include "gnome.h" +#include "../applet.h" +#include + +/* Computer clock widgets */ +GtkWidget *cc_vbox; +GtkWidget *cc_day; +GtkWidget *cc_hour; + +/* Main clock container */ +GtkWidget *cc; + +int clock_timeout; + +int +clock_timeout_callback (void *data) +{ + static char date [20], hour [20]; + time_t current_time; + char *strtime; + + time (¤t_time); + strtime = ctime (¤t_time); + + if (strncmp (date, strtime, 10)){ + strncpy (date, strtime, 10); + gtk_label_set (GTK_LABEL (cc_day), date); + } + strtime += 11; + if (strncmp (hour, strtime, 5)){ + strncpy (hour, strtime, 5); + gtk_label_set (GTK_LABEL (cc_hour), hour); + } + return 1; +} + +GtkWidget * +create_computer_clock_widget (GtkWidget *window) +{ + cc_vbox = gtk_vbox_new (FALSE, FALSE); + cc_day = gtk_label_new (""); + cc_hour = gtk_label_new (""); + gtk_widget_show (cc_vbox); + gtk_widget_show (cc_day); + gtk_widget_show (cc_hour); + + gtk_box_pack_start_defaults (GTK_BOX(cc_vbox), cc_day); + gtk_box_pack_start_defaults (GTK_BOX(cc_vbox), cc_hour); + + clock_timeout_callback (0); + return cc_vbox; +} + +GtkWidget * +create_analog_clock (GtkWidget *window) +{ + return 0; +} + +void +clock_destroy (GtkWidget *widget, void *data) +{ + gtk_timeout_remove (clock_timeout); +} + +GtkWidget * +create_clock_widget (GtkWidget *window) +{ + GtkWidget *widget; + GtkWidget *align; + + cc = gtk_frame_new (NULL); + gtk_frame_set_shadow_type (GTK_FRAME(cc), GTK_SHADOW_ETCHED_IN); + gtk_widget_show (cc); + + align = gtk_alignment_new (0.5, 0.5, 0.0, 0.0); + gtk_container_border_width (GTK_CONTAINER(align), 4); + gtk_widget_show (align); + + clock_timeout = gtk_timeout_add (3000, clock_timeout_callback, 0); + + /* choose style here */ + widget = create_computer_clock_widget (window); + + gtk_container_add (GTK_CONTAINER(cc), align); + gtk_container_add (GTK_CONTAINER(align), widget); + + gtk_signal_connect (GTK_OBJECT(cc), "destroy", (GtkSignalFunc) clock_destroy, 0); + return cc; +} + +char * +query (void) +{ + return "Clock"; +} + +void * +clock_callback (AppletCommand *cmd) +{ + /* nothing yet */ + return 0; +} + +void +init (PanelCallback callback, Panel *panel, char *params, int xpos, int ypos) +{ + PanelCommand cmd; + GtkWidget *clock; + + clock = create_clock_widget (panel->window); + cmd.cmd = PANEL_CMD_REGISTER_TOY; + cmd.params.register_toy.applet = clock; + cmd.params.register_toy.callback = clock_callback; + cmd.params.register_toy.id = query(); + cmd.params.register_toy.params = params; + cmd.params.register_toy.xpos = xpos; + cmd.params.register_toy.ypos = ypos; + cmd.params.register_toy.flags = APPLET_HAS_PROPERTIES; + + (*callback) (&cmd); +} diff -uNr gnome-0.7/programs/panel/gdkextra.c gnome-0.8/programs/panel/gdkextra.c --- gnome-0.7/programs/panel/gdkextra.c Wed Dec 31 18:00:00 1969 +++ gnome-0.8/programs/panel/gdkextra.c Tue Oct 7 11:22:28 1997 @@ -0,0 +1,38 @@ +#include +#include +#include "gdkextra.h" + + +void +gdk_pointer_warp(GdkWindow *src_w, + GdkWindow *dest_w, + gint src_x, + gint src_y, + guint src_width, + guint src_height, + gint dest_x, + gint dest_y) +{ + GdkWindowPrivate *src_private; + GdkWindowPrivate *dest_private; + Window xsrc_w; + Window xdest_w; + + src_private = (GdkWindowPrivate *) src_w; + dest_private = (GdkWindowPrivate *) dest_w; + + if (src_private) + xsrc_w = src_private->xwindow; + else + xsrc_w = None; + + if (dest_private) + xdest_w = dest_private->xwindow; + else + xdest_w = None; + + XWarpPointer (gdk_display, + xsrc_w, xdest_w, + src_x, src_y, src_width, src_height, + dest_x, dest_y); +} diff -uNr gnome-0.7/programs/panel/gdkextra.h gnome-0.8/programs/panel/gdkextra.h --- gnome-0.7/programs/panel/gdkextra.h Wed Dec 31 18:00:00 1969 +++ gnome-0.8/programs/panel/gdkextra.h Tue Oct 7 11:09:51 1997 @@ -0,0 +1,25 @@ +#ifndef GDKEXTRA_H +#define GDKEXTRA_H + + +#include + +#ifdef _cplusplus +extern "C" { +#endif /* _cplusplus */ + +void gdk_pointer_warp(GdkWindow *src_w, + GdkWindow *dest_w, + gint src_x, + gint src_y, + guint src_width, + guint src_height, + gint dest_x, + gint dest_y); + +#ifdef _cplusplus +} +#endif /* _cplusplus */ + + +#endif diff -uNr gnome-0.7/programs/panel/launcher/Makefile.am gnome-0.8/programs/panel/launcher/Makefile.am --- gnome-0.7/programs/panel/launcher/Makefile.am Wed Dec 31 18:00:00 1969 +++ gnome-0.8/programs/panel/launcher/Makefile.am Wed Oct 8 16:47:57 1997 @@ -0,0 +1,10 @@ +INCLUDES = \ + -I../../.. \ + -I$(srcdir)/../../.. \ + -I$(includedir) \ + $(X_CFLAGS) + +lib_LTLIBRARIES = libpanel_launcher.la + +libpanel_launcher_la_SOURCES = \ + launcher.c diff -uNr gnome-0.7/programs/panel/launcher/Makefile.in gnome-0.8/programs/panel/launcher/Makefile.in --- gnome-0.7/programs/panel/launcher/Makefile.in Wed Dec 31 18:00:00 1969 +++ gnome-0.8/programs/panel/launcher/Makefile.in Fri Oct 10 00:35:51 1997 @@ -0,0 +1,304 @@ +# Makefile.in generated automatically by automake 1.2 from Makefile.am + +# Copyright (C) 1994, 1995, 1996, 1997 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy, distribute and modify it. + + +SHELL = /bin/sh + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +prefix = @prefix@ +exec_prefix = @exec_prefix@ + +bindir = @bindir@ +sbindir = @sbindir@ +libexecdir = @libexecdir@ +datadir = @datadir@ +sysconfdir = @sysconfdir@ +sharedstatedir = @sharedstatedir@ +localstatedir = @localstatedir@ +libdir = @libdir@ +infodir = @infodir@ +mandir = @mandir@ +includedir = @includedir@ +oldincludedir = /usr/include + +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ + +top_builddir = ../../.. + +ACLOCAL = @ACLOCAL@ +AUTOCONF = @AUTOCONF@ +AUTOMAKE = @AUTOMAKE@ +AUTOHEADER = @AUTOHEADER@ + +INSTALL = @INSTALL@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +transform = @program_transform_name@ + +NORMAL_INSTALL = true +PRE_INSTALL = true +POST_INSTALL = true +NORMAL_UNINSTALL = true +PRE_UNINSTALL = true +POST_UNINSTALL = true +host_alias = @host_alias@ +host_triplet = @host@ +CATALOGS = @CATALOGS@ +CATOBJEXT = @CATOBJEXT@ +CC = @CC@ +CFLAGS = @CFLAGS@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +DATADIRNAME = @DATADIRNAME@ +ELCFILES = @ELCFILES@ +EMACS = @EMACS@ +GENCAT = @GENCAT@ +GMOFILES = @GMOFILES@ +GMSGFMT = @GMSGFMT@ +INSTOBJEXT = @INSTOBJEXT@ +INTLDEPS = @INTLDEPS@ +INTLLIBS = @INTLLIBS@ +INTLOBJS = @INTLOBJS@ +INTLSUB = @INTLSUB@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LEX = @LEX@ +LIBTOOL = @LIBTOOL@ +LISPDIR = @LISPDIR@ +LN_S = @LN_S@ +MAKEINFO = @MAKEINFO@ +MSGFMT = @MSGFMT@ +NM = @NM@ +PACKAGE = @PACKAGE@ +POFILES = @POFILES@ +POSUB = @POSUB@ +RANLIB = @RANLIB@ +VERSION = @VERSION@ + +INCLUDES = \ + -I../../.. \ + -I$(srcdir)/../../.. \ + -I$(includedir) \ + $(X_CFLAGS) + +lib_LTLIBRARIES = libpanel_launcher.la + +libpanel_launcher_la_SOURCES = \ + launcher.c +mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +CONFIG_HEADER = ../../../config.h +CONFIG_CLEAN_FILES = +LTLIBRARIES = $(lib_LTLIBRARIES) + + +DEFS = @DEFS@ -I. -I$(srcdir) -I../../.. +LIBS = @LIBS@ +X_CFLAGS = @X_CFLAGS@ +X_LIBS = @X_LIBS@ +X_EXTRA_LIBS = @X_EXTRA_LIBS@ +X_PRE_LIBS = @X_PRE_LIBS@ +libpanel_launcher_la_LDFLAGS = +libpanel_launcher_la_LIBADD = +libpanel_launcher_la_OBJECTS = launcher.lo +COMPILE = $(CC) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) +LINK = $(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(LDFLAGS) -o $@ +DIST_COMMON = Makefile.am Makefile.in + + +DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) + +TAR = tar +GZIP = --best +SOURCES = $(libpanel_launcher_la_SOURCES) +OBJECTS = $(libpanel_launcher_la_OBJECTS) + +default: all + +.SUFFIXES: +.SUFFIXES: .c .lo .o +$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) + cd $(top_srcdir) && $(AUTOMAKE) --gnu --include-deps programs/panel/launcher/Makefile + +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + cd $(top_builddir) \ + && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status + + +mostlyclean-libLTLIBRARIES: + +clean-libLTLIBRARIES: + test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES) + +distclean-libLTLIBRARIES: + +maintainer-clean-libLTLIBRARIES: + +install-libLTLIBRARIES: $(lib_LTLIBRARIES) + @$(NORMAL_INSTALL) + $(mkinstalldirs) $(libdir) + @list='$(lib_LTLIBRARIES)'; for p in $$list; do \ + if test -f $$p; then \ + echo "$(LIBTOOL) --mode=install $(INSTALL_PROGRAM) $$p $(libdir)/$$p"; \ + $(LIBTOOL) --mode=install $(INSTALL_PROGRAM) $$p $(libdir)/$$p; \ + else :; fi; \ + done + +uninstall-libLTLIBRARIES: + $(NORMAL_UNINSTALL) + list='$(lib_LTLIBRARIES)'; for p in $$list; do \ + $(LIBTOOL) --mode=uninstall rm -f $(libdir)/$$p; \ + done + +.c.o: + $(COMPILE) -c $< + +mostlyclean-compile: + rm -f *.o core + +clean-compile: + +distclean-compile: + rm -f *.tab.c + +maintainer-clean-compile: + +.c.lo: + $(LIBTOOL) --mode=compile $(COMPILE) -c $< + +mostlyclean-libtool: + rm -f *.lo + +clean-libtool: + rm -rf .libs + +distclean-libtool: + +maintainer-clean-libtool: + +libpanel_launcher.la: $(libpanel_launcher_la_OBJECTS) $(libpanel_launcher_la_DEPENDENCIES) + $(LINK) -rpath $(libdir) $(libpanel_launcher_la_LDFLAGS) $(libpanel_launcher_la_OBJECTS) $(libpanel_launcher_la_LIBADD) $(LIBS) + +tags: TAGS + +ID: $(HEADERS) $(SOURCES) + here=`pwd` && cd $(srcdir) && mkid -f$$here/ID $(SOURCES) $(HEADERS) + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) + tags=; \ + here=`pwd`; \ + test -z "$(ETAGS_ARGS)$(SOURCES)$(HEADERS)$$tags" \ + || (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags $(SOURCES) $(HEADERS) -o $$here/TAGS) + +mostlyclean-tags: + +clean-tags: + +distclean-tags: + rm -f TAGS ID + +maintainer-clean-tags: + +distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir) + +subdir = programs/panel/launcher + +distdir: $(DISTFILES) + @for file in $(DISTFILES); do \ + d=$(srcdir); \ + test -f $(distdir)/$$file \ + || ln $$d/$$file $(distdir)/$$file 2> /dev/null \ + || cp -p $$d/$$file $(distdir)/$$file; \ + done +launcher.o launcher.lo: launcher.c ../../../gnome.h \ + ../../../libgnome/libgnome.h ../../../libgnome/gnome-defs.h \ + ../../../libgnome/gnome-util.h ../../../libgnome/gnome-hook.h \ + ../../../libgnome/gnome-config.h ../../../libgnome/gnome-dns.h \ + ../../../libgnome/gnome-dentry.h \ + ../../../libgnomeui/libgnomeui.h \ + ../../../libgnomeui/gnome-colors.h \ + ../../../libgnomeui/gnome-color-selector.h \ + ../../../libgnomeui/gnome-messagebox.h \ + ../../../libgnomeui/gnome-pixmap.h \ + ../../../libgnomeui/gnome-toolbar.h ../applet.h ../panel.h + +info: +dvi: +check: all + $(MAKE) +installcheck: +install-exec: install-libLTLIBRARIES + @$(NORMAL_INSTALL) + +install-data: + @$(NORMAL_INSTALL) + +install: install-exec install-data all + @: + +uninstall: uninstall-libLTLIBRARIES + +all: Makefile $(LTLIBRARIES) + +install-strip: + $(MAKE) INSTALL_PROGRAM='$(INSTALL_PROGRAM) -s' INSTALL_SCRIPT='$(INSTALL_PROGRAM)' install +installdirs: + $(mkinstalldirs) $(libdir) + + +mostlyclean-generic: + test -z "$(MOSTLYCLEANFILES)" || rm -f $(MOSTLYCLEANFILES) + +clean-generic: + test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) + +distclean-generic: + rm -f Makefile $(DISTCLEANFILES) + rm -f config.cache config.log stamp-h stamp-h[0-9]* + test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES) + test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES) +mostlyclean: mostlyclean-libLTLIBRARIES mostlyclean-compile \ + mostlyclean-libtool mostlyclean-tags \ + mostlyclean-generic + +clean: clean-libLTLIBRARIES clean-compile clean-libtool clean-tags \ + clean-generic mostlyclean + +distclean: distclean-libLTLIBRARIES distclean-compile distclean-libtool \ + distclean-tags distclean-generic clean + rm -f config.status + rm -f libtool + +maintainer-clean: maintainer-clean-libLTLIBRARIES \ + maintainer-clean-compile maintainer-clean-libtool \ + maintainer-clean-tags maintainer-clean-generic \ + distclean + @echo "This command is intended for maintainers to use;" + @echo "it deletes files that may require special tools to rebuild." + +.PHONY: default mostlyclean-libLTLIBRARIES distclean-libLTLIBRARIES \ +clean-libLTLIBRARIES maintainer-clean-libLTLIBRARIES \ +uninstall-libLTLIBRARIES install-libLTLIBRARIES mostlyclean-compile \ +distclean-compile clean-compile maintainer-clean-compile \ +mostlyclean-libtool distclean-libtool clean-libtool \ +maintainer-clean-libtool tags mostlyclean-tags distclean-tags \ +clean-tags maintainer-clean-tags distdir info dvi installcheck \ +install-exec install-data install uninstall all installdirs \ +mostlyclean-generic distclean-generic clean-generic \ +maintainer-clean-generic clean mostlyclean distclean maintainer-clean + + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff -uNr gnome-0.7/programs/panel/launcher/launcher.c gnome-0.8/programs/panel/launcher/launcher.c --- gnome-0.7/programs/panel/launcher/launcher.c Wed Dec 31 18:00:00 1969 +++ gnome-0.8/programs/panel/launcher/launcher.c Wed Oct 8 18:06:50 1997 @@ -0,0 +1,120 @@ +/* + * GNOME panel launcher module. + * (C) 1997 The Free Software Foundation + * + * Author: Miguel de Icaza + */ +#include +#include +#include +#include +#include +#include +#include +#include "gnome.h" +#include "../applet.h" +#define _(String) gettext(String) + +PanelCallback callback; + +void +cleanup (GtkWidget *widget, void *data) +{ + struct gnome_desktop_entry *item = data; + + gnome_desktop_entry_free (item); +} + +void +launch (GtkWidget *widget, void *data) +{ + struct gnome_desktop_entry *item = data; + + gnome_desktop_entry_launch (item); +} + +GtkWidget * +create_launcher (GtkWidget *window, char *parameters) +{ + GtkWidget *pixmap, *button; + struct gnome_desktop_entry *dentry; + static char *default_app_pixmap; + + if (!default_app_pixmap) + default_app_pixmap = gnome_pixmap_file ("launcher-program.xpm"); + + if (*parameters == '/') + dentry = gnome_desktop_entry_load (parameters); + else { + char *apps_par, *entry, *extension; + + if (strstr (parameters, ".desktop")) + extension = NULL; + else + extension = ".desktop"; + + apps_par = g_copy_strings ("apps/", parameters, extension, NULL); + entry = gnome_datadir_file (apps_par); + g_free (apps_par); + + if (!entry) + return 0; + dentry = gnome_desktop_entry_load (entry); + g_free (entry); + } + if (!dentry) + return 0; + + button = gtk_button_new (); + pixmap = gnome_create_pixmap_widget (window, button, dentry->transparent_icon); + if (!pixmap){ + if (default_app_pixmap) + pixmap = gnome_create_pixmap_widget (window, button, default_app_pixmap); + else + pixmap = gtk_label_new ("App"); + } + gtk_container_add (GTK_CONTAINER(button), pixmap); + gtk_widget_show (pixmap); + gtk_widget_show (button); + + gtk_signal_connect (GTK_OBJECT(button), "clicked", (GtkSignalFunc)launch, dentry); + gtk_signal_connect (GTK_OBJECT(button), "destroy", (GtkSignalFunc)cleanup, dentry); + + return button; +} + +void * +launcher_callback (AppletCommand *cmd) +{ + return 0; +} + +char * +query (void) +{ + return "Launcher"; +} + +void +init (PanelCallback cback, Panel *panel, char *params, int xpos, int ypos) +{ + GtkWidget *launcher; + PanelCommand cmd; + + callback = cback; + launcher = create_launcher (panel->window, params); + + if (!launcher) + return; + + cmd.cmd = PANEL_CMD_REGISTER_TOY; + cmd.params.register_toy.applet = launcher; + cmd.params.register_toy.callback = launcher_callback; + cmd.params.register_toy.id = query(); + cmd.params.register_toy.params = params; + cmd.params.register_toy.xpos = xpos; + cmd.params.register_toy.ypos = ypos; + cmd.params.register_toy.flags = APPLET_HAS_PROPERTIES; + + (*callback) (&cmd); +} diff -uNr gnome-0.7/programs/panel/mailcheck/Makefile.in gnome-0.8/programs/panel/mailcheck/Makefile.in --- gnome-0.7/programs/panel/mailcheck/Makefile.in Fri Oct 3 01:04:40 1997 +++ gnome-0.8/programs/panel/mailcheck/Makefile.in Fri Oct 10 00:35:49 1997 @@ -222,11 +222,13 @@ ../../../libgnome/libgnome.h ../../../libgnome/gnome-defs.h \ ../../../libgnome/gnome-util.h ../../../libgnome/gnome-hook.h \ ../../../libgnome/gnome-config.h ../../../libgnome/gnome-dns.h \ + ../../../libgnome/gnome-dentry.h \ ../../../libgnomeui/libgnomeui.h \ ../../../libgnomeui/gnome-colors.h \ ../../../libgnomeui/gnome-color-selector.h \ ../../../libgnomeui/gnome-messagebox.h \ - ../../../libgnomeui/gnome-pixmap.h ../applet.h ../panel.h + ../../../libgnomeui/gnome-pixmap.h \ + ../../../libgnomeui/gnome-toolbar.h ../applet.h ../panel.h info: dvi: diff -uNr gnome-0.7/programs/panel/mailcheck/mailcheck.c gnome-0.8/programs/panel/mailcheck/mailcheck.c --- gnome-0.7/programs/panel/mailcheck/mailcheck.c Fri Oct 3 01:04:10 1997 +++ gnome-0.8/programs/panel/mailcheck/mailcheck.c Wed Oct 8 17:58:58 1997 @@ -33,6 +33,9 @@ /* The widget that holds the label with the mail information */ GtkWidget *label; +/* The drawing area */ +GtkWidget *da; + /* handle for the timeout */ int mail_timeout; @@ -80,26 +83,43 @@ { char *text; -#define UG "This is a test -> " check_mail_file_status (); if (anymail) - text = g_copy_strings (UG "You have ", newmail ? "new" : "", " mail", NULL); + text = g_copy_strings ("You have ", newmail ? "new" : "", " mail", NULL); else - text = g_copy_strings (UG "No mail.", NULL); + text = g_copy_strings ("No mail.", NULL); gtk_label_set (GTK_LABEL (label), text); free (text); + return 1; +} + +void +mail_destroy (GtkWidget *widget, void *data) +{ + gtk_timeout_remove (mail_timeout); } GtkWidget * create_mail_widgets (GtkWidget *window) { label = gtk_label_new (""); + da = gtk_drawing_area_new (); + gtk_drawing_area_size (da, 24, 20); + mail_check_timeout (0); gtk_widget_show (label); mail_timeout = gtk_timeout_add (10000, mail_check_timeout, 0); + gtk_signal_connect (GTK_OBJECT (label), "destroy", (GtkSignalFunc) mail_destroy, 0); return label; } +void * +mail_callback (AppletCommand *cmd) +{ + /* nothing now */ + return 0; +} + void init (PanelCallback callback, Panel *panel, char *params, int xpos, int ypos) { @@ -116,10 +136,13 @@ mailcheck = create_mail_widgets (panel->window); cmd.cmd = PANEL_CMD_REGISTER_TOY; - cmd.params.register_toy.applet = mailcheck; - cmd.params.register_toy.xpos = xpos; - cmd.params.register_toy.ypos = ypos; - cmd.params.register_toy.flags = 0; + cmd.params.register_toy.applet = mailcheck; + cmd.params.register_toy.callback = mail_callback; + cmd.params.register_toy.id = query(); + cmd.params.register_toy.params = params; + cmd.params.register_toy.xpos = xpos; + cmd.params.register_toy.ypos = ypos; + cmd.params.register_toy.flags = 0; - (*callback) (panel, &cmd); + (*callback) (&cmd); } diff -uNr gnome-0.7/programs/panel/main.c gnome-0.8/programs/panel/main.c --- gnome-0.7/programs/panel/main.c Thu Oct 2 22:26:23 1997 +++ gnome-0.8/programs/panel/main.c Thu Oct 9 20:41:08 1997 @@ -2,13 +2,12 @@ #include "applet.h" #include "panel.h" -static Panel *panel; - static void load_default_applets(void) { - applets_init_applet("Menu", panel, ".", 0, 0); - applets_init_applet("Mail check", panel, "", 550, 0); + applets_init_applet("Menu", ".", 0, 0); + applets_init_applet("Mail check", "", 550, 0); + applets_init_applet("Clock", "", 700, 0); } @@ -17,6 +16,7 @@ { void *iterator; char *key; + char *realkey; char *value; char *applet_name; char *applet_params; @@ -29,14 +29,14 @@ while (iterator) { iterator = gnome_config_iterator_next(iterator, &key, &value); - - applet_params = strchr(key, ','); /* Everything after first comma is parameters to the applet */ - if (applet_params) + realkey = strchr(key, ',') + 1; /* Skip over number-for-unique-keys hack and go to applet id */ + applet_params = strchr(realkey, ','); /* Everything after first comma is parameters to the applet */ + if (applet_params) *applet_params++ = '\0'; /* Terminate string at comma and skip over it */ else applet_params = ""; - applet_name = key; + applet_name = realkey; if (sscanf(value, "%d%d", &xpos, &ypos) != 2) { fprintf(stderr, "init_user_applets: using position (0, 0) for applet " @@ -44,7 +44,9 @@ xpos = ypos = 0; } - applets_init_applet(applet_name, panel, applet_params, xpos, ypos); + applets_init_applet(applet_name, applet_params, xpos, ypos); + g_free (key); + g_free (value); } } @@ -52,15 +54,13 @@ int main(int argc, char **argv) { - gtk_init(&argc, &argv); gnome_init(&argc, &argv); - panel = panel_new(); - + panel_init(); applets_init(); init_user_applets(); - gtk_widget_show(panel->window); + gtk_widget_show(the_panel->window); gtk_main(); return 0; diff -uNr gnome-0.7/programs/panel/menu/Makefile.in gnome-0.8/programs/panel/menu/Makefile.in --- gnome-0.7/programs/panel/menu/Makefile.in Fri Oct 3 01:04:37 1997 +++ gnome-0.8/programs/panel/menu/Makefile.in Fri Oct 10 00:35:48 1997 @@ -231,11 +231,13 @@ main.o main.lo: main.c ../../../gnome.h ../../../libgnome/libgnome.h \ ../../../libgnome/gnome-defs.h ../../../libgnome/gnome-util.h \ ../../../libgnome/gnome-hook.h ../../../libgnome/gnome-config.h \ - ../../../libgnome/gnome-dns.h ../../../libgnomeui/libgnomeui.h \ + ../../../libgnome/gnome-dns.h ../../../libgnome/gnome-dentry.h \ + ../../../libgnomeui/libgnomeui.h \ ../../../libgnomeui/gnome-colors.h \ ../../../libgnomeui/gnome-color-selector.h \ ../../../libgnomeui/gnome-messagebox.h \ - ../../../libgnomeui/gnome-pixmap.h ../applet.h ../panel.h + ../../../libgnomeui/gnome-pixmap.h \ + ../../../libgnomeui/gnome-toolbar.h ../applet.h ../panel.h info: dvi: diff -uNr gnome-0.7/programs/panel/menu/main.c gnome-0.8/programs/panel/menu/main.c --- gnome-0.7/programs/panel/menu/main.c Thu Oct 2 23:36:03 1997 +++ gnome-0.8/programs/panel/menu/main.c Thu Oct 9 14:10:20 1997 @@ -3,8 +3,6 @@ * (C) 1997 The Free Software Foundation * * Author: Miguel de Icaza - * - * Exported interfaces to the GNOME Panel */ #include @@ -18,20 +16,10 @@ #include "../applet.h" #define _(String) gettext(String) -struct item_config { - char *exec; - char *icon_base; - char *docpath; - char *info; - int terminal; - char *type; - - /* These are computed from icon_base */ - char *small_icon; - char *transparent_icon; -}; -#define free_if_empty(x) { if (x) free (x); } +#define free_if_empty(x) { if (x) g_free (x); } + +char *gnome_folder; PanelCallback callback; @@ -44,13 +32,9 @@ void activate_app_def (GtkWidget *widget, void *data) { - struct item_config *item = data; - char *command; + struct gnome_desktop_entry *item = data; - /* This is the quick hack version of this */ - command = g_copy_strings ("(true;", item->exec, ") &", NULL); - system (command); - free (command); + gnome_desktop_entry_launch (item); } void @@ -88,123 +72,57 @@ void free_app_def (GtkWidget *widget, void *data) { - struct item_config *item = data; + struct gnome_desktop_entry *item = data; - free_if_empty (item->exec); - free_if_empty (item->icon_base); - free_if_empty (item->docpath); - free_if_empty (item->info); - free_if_empty (item->type); - free_if_empty (item->small_icon); - free_if_empty (item->transparent_icon); - free (item); -} - -int -is_program_in_path (char *program) -{ - static char *path; - static char **paths; - char **p; - char *f; - - if (!path){ - char *p; - int i, pc = 1; - - path = strdup (getenv ("PATH")); - for (p = path; *p; p++) - if (*p == ':') - pc++; - - paths = (char **) g_malloc (sizeof (char *) * (pc+1)); - - for (p = path, i = 0; i < pc; i++){ - paths [i] = strtok (p, ":"); - p = NULL; - } - paths [pc] = NULL; - } - p = paths; - while (*p){ - f = g_concat_dir_and_file (*p, program); - if (g_file_exists (f)){ - free (f); - return 1; - } - free (f); - p++; - } - return 0; + gnome_desktop_entry_free (item); } - -struct item_config * -load_app_def (char *file) -{ - struct item_config *newitem; - char *prefix = g_copy_strings ("=", file, "=/Desktop Entry/", NULL); - char *exec_file, *try_file, *dot; - - gnome_config_set_prefix (prefix); - free (prefix); - - exec_file = gnome_config_get_string ("Exec"); - if (!exec_file){ - gnome_config_drop_prefix (); - return 0; - } - try_file = gnome_config_get_string ("TryExec"); - if (try_file){ - if (!is_program_in_path (try_file)){ - free (try_file); - free (exec_file); - gnome_config_drop_prefix (); - return 0; - } - } - free (try_file); - newitem = g_malloc (sizeof (struct item_config)); - newitem->exec = exec_file; - newitem->icon_base = gnome_config_get_string ("Icon"); - newitem->docpath = gnome_config_get_string ("DocPath"); - newitem->info = gnome_config_get_string ("Info"); - newitem->terminal = gnome_config_get_int ("Terminal"); - newitem->type = gnome_config_get_string ("Type"); - - if (newitem->icon_base && *newitem->icon_base){ - dot = strstr (newitem->icon_base, ".xpm"); - - if (dot){ - *dot = 0; - - newitem->small_icon = g_copy_strings (newitem->icon_base, - "-small.xpm", NULL); - newitem->transparent_icon = g_copy_strings (newitem->icon_base, - "-transparent.xpm", NULL); - *dot = '.'; - } - /* Sigh, now we need to make them local to the gnome install */ - if (*newitem->icon_base != '/'){ - char *s = newitem->small_icon; - char *t = newitem->transparent_icon; - - newitem->small_icon = gnome_pixmap_file (s); - newitem->transparent_icon = gnome_pixmap_file (t); - free (s); - free (t); - } - } else { - newitem->small_icon = newitem->transparent_icon = 0; - } - gnome_config_drop_prefix (); - return newitem; +void +add_menu_separator (GtkWidget *menu) +{ + GtkWidget *menuitem; + + menuitem = gtk_menu_item_new (); + gtk_widget_show (menuitem); + gtk_container_add (GTK_CONTAINER (menu), menuitem); +} + +void +free_string (GtkWidget *widget, void *data) +{ + g_free (data); +} + +void +add_to_panel (char *applet, char *arg) +{ + PanelCommand cmd; + + fprintf (stderr, "Asking Panel to add [%s,%s] to the panel\n", applet, arg); + cmd.cmd = PANEL_CMD_NEW_APPLET; + cmd.params.new_applet.applet = applet; + cmd.params.new_applet.params = arg; + (*callback) (&cmd); +} + +void +add_app_to_panel (GtkWidget *widget, void *data) +{ + struct gnome_desktop_entry *ii = data; + + add_to_panel ("Launcher", ii->location); +} + +void +add_dir_to_panel (GtkWidget *widget, void *data) +{ + add_to_panel (query (), data); } GtkWidget * -create_menu_at (GtkWidget *window, char *menudir) +create_menu_at (GtkWidget *window, char *menudir, int create_app_menu) { - struct item_config *item_info; + struct gnome_desktop_entry *item_info; GtkWidget *menu; struct dirent *dent; struct stat s; @@ -219,9 +137,11 @@ menu = gtk_menu_new (); while ((dent = readdir (dir)) != NULL){ - GtkWidget *menuitem, *sub, *pixmap; - char *thisfile = dent->d_name, *pixmap_name; + GtkWidget *menuitem, *sub, *pixmap; + GtkSignalFunc activate_func; + char *thisfile, *pixmap_name; + thisfile = dent->d_name; /* Skip over . and .. */ if ((thisfile [0] == '.' && thisfile [1] == 0) || (thisfile [0] == '.' && thisfile [1] == '.' && thisfile [2] == 0)) @@ -229,28 +149,57 @@ filename = g_concat_dir_and_file (menudir, thisfile); if (stat (filename, &s) == -1){ - free (filename); + g_free (filename); continue; } sub = 0; item_info = 0; if (S_ISDIR (s.st_mode)){ - sub = create_menu_at (window, filename); + sub = create_menu_at (window, filename, create_app_menu); if (!sub){ - free (filename); + g_free (filename); continue; } /* just for now */ pixmap_name = 0; + + if (create_app_menu){ + GtkWidget *pixmap = 0; + char *text; + + /* FIXME: Loading the pixmap over and over is far from efficient */ + text = g_copy_strings ("Menu: ", thisfile, NULL); + + menuitem = gtk_menu_item_new (); + gtk_menu_prepend (GTK_MENU (sub), menuitem); + gtk_widget_show (menuitem); + + menuitem = gtk_menu_item_new (); + if (gnome_folder){ + pixmap =gnome_create_pixmap_widget (window, menuitem, gnome_folder); + gtk_widget_show (pixmap); + } + setup_menuitem (menuitem, pixmap, text); + g_free (text); + text = g_strdup (filename); + gtk_menu_prepend (GTK_MENU (sub), menuitem); + gtk_signal_connect (GTK_OBJECT (menuitem), "activate", + (GtkSignalFunc) add_dir_to_panel, + text); + gtk_signal_connect (GTK_OBJECT (menuitem), "destroy", + (GtkSignalFunc) free_string, + text); + + } } else { if (strstr (filename, ".desktop") == 0){ - free (filename); + g_free (filename); continue; } - item_info = load_app_def (filename); + item_info = gnome_desktop_entry_load (filename); if (!item_info){ - free (filename); + g_free (filename); continue; } pixmap_name = item_info->small_icon; @@ -270,10 +219,14 @@ setup_menuitem (menuitem, pixmap, thisfile); gtk_menu_append (GTK_MENU (menu), menuitem); - gtk_signal_connect (GTK_OBJECT (menuitem), "destroy", (GtkSignalFunc) free_app_def, item_info); - gtk_signal_connect (GTK_OBJECT (menuitem), "activate", (GtkSignalFunc) activate_app_def, item_info); - - free (filename); + + gtk_signal_connect (GTK_OBJECT (menuitem), "destroy", + (GtkSignalFunc) free_app_def, item_info); + + activate_func = create_app_menu ? add_app_to_panel : activate_app_def; + gtk_signal_connect (GTK_OBJECT (menuitem), "activate", activate_func, item_info); + + g_free (filename); } closedir (dir); @@ -315,14 +268,103 @@ { } +static void +munge_applet_item(gpointer untrans, gpointer user_data) +{ + GList **list; + GList *node; + int pos; + + list = user_data; + + /* Insert applet id in alphabetical order */ + + node = *list; + pos = 0; + + for (pos = 0; node; node = node->next, pos++) + if (strcmp(_(untrans), _(node->data)) < 0) + break; + + *list = g_list_insert(*list, g_strdup(_(untrans)), pos); + + /* We can destroy the untranslated id now */ + + g_free(untrans); +} + +static void +append_list_item_to_menu(gpointer data, gpointer user_data) +{ + GtkMenu *menu; + GtkWidget *menuitem; + + menu = GTK_MENU(user_data); + menuitem = gtk_menu_item_new(); + setup_menuitem(menuitem, NULL, data); + /* FIXME: connect to "activate" signal */ + gtk_menu_append(menu, menuitem); + + g_free(data); /* We can now destroy the string */ +} + +static GtkWidget * +create_applets_menu(void) +{ + GtkWidget *menu; + GList *list; + GList *applets_list; + PanelCommand cmd; + + /* Get list of applet types */ + + cmd.cmd = PANEL_CMD_GET_APPLET_TYPES; + list = (*callback) (&cmd); + + /* Now translate and sort them */ + + applets_list = NULL; + g_list_foreach(list, munge_applet_item, &applets_list); + + /* Untranslated items have been destroyed by + * munge_applet_item(), now create a menu of the translated + * and sorted ones. + */ + + g_list_free(list); + + menu = gtk_menu_new(); + + g_list_foreach(applets_list, append_list_item_to_menu, menu); + + /* Translated items have been destroyed by + * append_list_item_to_menu(), now just destroy the list. + */ + + g_list_free(applets_list); + return menu; +} + GtkWidget * -create_panel_submenu (void) +create_panel_submenu (GtkWidget *app_menu) { GtkWidget *menu, *menuitem; menu = gtk_menu_new (); menuitem = gtk_menu_item_new (); + setup_menuitem (menuitem, 0, _("Add to panel")); + gtk_menu_append (GTK_MENU (menu), menuitem); + gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem), app_menu); + + menuitem = gtk_menu_item_new (); + setup_menuitem (menuitem, 0, _("Add applet")); + gtk_menu_append (GTK_MENU (menu), menuitem); + gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem), create_applets_menu()); + + add_menu_separator(menu); + + menuitem = gtk_menu_item_new (); setup_menuitem (menuitem, 0, _("Configure")); gtk_menu_append (GTK_MENU (menu), menuitem); gtk_signal_connect (GTK_OBJECT (menuitem), "activate", (GtkSignalFunc) panel_configure, 0); @@ -347,31 +389,22 @@ PanelCommand cmd; cmd.cmd = PANEL_CMD_QUIT; + (*callback) (&cmd); } void -add_menu_separator (GtkWidget *menu) -{ - GtkWidget *menuitem; - - menuitem = gtk_menu_item_new (); - gtk_widget_show (menuitem); - gtk_container_add (GTK_CONTAINER (menu), menuitem); -} - -void -add_special_entries (GtkWidget *menu) +add_special_entries (GtkWidget *menu, GtkWidget *app_menu) { GtkWidget *menuitem; /* Panel entry */ - menuitem = gtk_menu_item_new (); add_menu_separator (menu); + menuitem = gtk_menu_item_new (); setup_menuitem (menuitem, 0, _("Panel")); gtk_menu_append (GTK_MENU (menu), menuitem); - gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem), create_panel_submenu ()); + gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem), create_panel_submenu (app_menu)); add_menu_separator (menu); @@ -386,10 +419,11 @@ gtk_signal_connect (GTK_OBJECT (menuitem), "activate", (GtkSignalFunc) panel_logout, 0); } + GtkWidget * create_panel_menu (GtkWidget *window, char *menudir, int main_menu) { - GtkWidget *vbox, *button, *pixmap, *button_pixmap, *menu; + GtkWidget *vbox, *button, *pixmap, *button_pixmap, *menu, *app_menu; static char *button_pixmap_name; char *pixmap_name; @@ -418,19 +452,21 @@ gtk_widget_show (pixmap); gtk_widget_show (vbox); - menu = create_menu_at (window, menudir); - if (main_menu) - add_special_entries (menu); + menu = create_menu_at (window, menudir, 0); + if (main_menu){ + app_menu = create_menu_at (window, menudir, 1); + add_special_entries (menu, app_menu); + } gtk_signal_connect (GTK_OBJECT (button), "clicked", (GtkSignalFunc) activate_menu, menu); - free (pixmap_name); + g_free (pixmap_name); return vbox; } GtkWidget * create_menu_widget (GtkWidget *window, char *arguments, char *menudir) { - GtkWidget *menu; + GtkWidget *menu, *add_menu; int main_menu; main_menu = (strcmp (arguments, ".") == 0); @@ -438,33 +474,56 @@ return menu; } +gpointer +panel_callback (AppletCommand *cmd) +{ + return NULL; +} + void init (PanelCallback cback, Panel *panel, char *params, int xpos, int ypos) { GtkWidget *menu_component; char *menu_base = gnome_unconditional_datadir_file ("apps"); - char *this_menu = g_concat_dir_and_file (menu_base, params); + char *this_menu; PanelCommand cmd; if (!getenv ("PATH")) return; + fprintf (stderr, "Menu: %s\n", params); + + if (*params == '/') + this_menu = strdup (params); + else + this_menu = g_concat_dir_and_file (menu_base, params); + if (!g_file_exists (this_menu)){ - free (menu_base); - free (this_menu); + g_free (menu_base); + g_free (this_menu); return; } + gnome_folder = gnome_unconditional_pixmap_file ("gnome-folder-small.xpm"); + if (!g_file_exists (gnome_folder)){ + free (gnome_folder); + gnome_folder = NULL; + } + callback = cback; menu_component = create_menu_widget (panel->window, params, this_menu); + fprintf (stderr, "REGISTRANDO: %s\n", params); cmd.cmd = PANEL_CMD_REGISTER_TOY; - cmd.params.register_toy.applet = menu_component; - cmd.params.register_toy.xpos = xpos; - cmd.params.register_toy.ypos = ypos; - cmd.params.register_toy.flags = 0; + cmd.params.register_toy.applet = menu_component; + cmd.params.register_toy.callback = panel_callback; + cmd.params.register_toy.id = query(); + cmd.params.register_toy.params = params; + cmd.params.register_toy.xpos = xpos; + cmd.params.register_toy.ypos = ypos; + cmd.params.register_toy.flags = APPLET_HAS_PROPERTIES; - (*callback) (panel, &cmd); + (*callback) (&cmd); } #if 0 diff -uNr gnome-0.7/programs/panel/panel.c gnome-0.8/programs/panel/panel.c --- gnome-0.7/programs/panel/panel.c Fri Oct 3 00:17:08 1997 +++ gnome-0.8/programs/panel/panel.c Thu Oct 9 20:50:02 1997 @@ -1,7 +1,17 @@ +#include +#include #include "applet.h" +#include "gdkextra.h" +#define _(String) gettext(String) -#define DEFAULT_STEP_SIZE 4 + +#define APPLET_CALLBACK "panel_applet_callback" +#define APPLET_ID "panel_applet_id" +#define APPLET_PARAMS "panel_applet_params" +#define APPLET_FLAGS "panel_applet_flags" + +#define DEFAULT_STEP_SIZE 6 #define DEFAULT_DELAY 0 #define DEFAULT_HEIGHT 48 @@ -11,6 +21,14 @@ } Point; +static GtkWidget *applet_menu; +static GtkWidget *applet_menu_prop_separator; +static GtkWidget *applet_menu_prop_item; + + +Panel *the_panel = NULL; + + static void move_window(GtkWindow *window, int x, int y) { @@ -20,134 +38,149 @@ gdk_window_set_hints(widget->window, x, y, 0, 0, 0, 0, GDK_HINT_POS); gdk_window_move(widget->window, x, y); + gtk_widget_draw(widget, NULL); /* FIXME: this should draw only the newly exposed area! */ } static void -move_horiz(Panel *panel, int src_x, int dest_x) +move_horiz(int src_x, int dest_x) { int x; - if (panel->step_size != 0) + if (the_panel->step_size != 0) if (src_x < dest_x) - for (x = src_x; x < dest_x; x += panel->step_size) { - move_window(GTK_WINDOW(panel->window), x, 0); + for (x = src_x; x < dest_x; x += the_panel->step_size) { + move_window(GTK_WINDOW(the_panel->window), x, 0); /* FIXME: do delay */ } else - for (x = src_x; x > dest_x; x -= panel->step_size) { - move_window(GTK_WINDOW(panel->window), x, 0); + for (x = src_x; x > dest_x; x -= the_panel->step_size) { + move_window(GTK_WINDOW(the_panel->window), x, 0); /* FIXME: do delay */ } - move_window(GTK_WINDOW(panel->window), dest_x, 0); + move_window(GTK_WINDOW(the_panel->window), dest_x, 0); } static void -move_vert(Panel *panel, int src_y, int dest_y) +move_vert(int src_y, int dest_y) { int y; - if (panel->step_size != 0) + if (the_panel->step_size != 0) if (src_y < dest_y) - for (y = src_y; y < dest_y; y += panel->step_size) { - move_window(GTK_WINDOW(panel->window), 0, y); + for (y = src_y; y < dest_y; y += the_panel->step_size) { + move_window(GTK_WINDOW(the_panel->window), 0, y); /* FIXME: do delay */ } else - for (y = src_y; y > dest_y; y -= panel->step_size) { - move_window(GTK_WINDOW(panel->window), 0, y); + for (y = src_y; y > dest_y; y -= the_panel->step_size) { + move_window(GTK_WINDOW(the_panel->window), 0, y); /* FIXME: do delay */ } - move_window(GTK_WINDOW(panel->window), 0, dest_y); + move_window(GTK_WINDOW(the_panel->window), 0, dest_y); } static void -pop_up(Panel *panel) +pop_up(void) { int width, height; int swidth, sheight; - if (panel->state == PANEL_SHOWN) + if (the_panel->state == PANEL_SHOWN) return; - width = panel->window->allocation.width; - height = panel->window->allocation.height; + width = the_panel->window->allocation.width; + height = the_panel->window->allocation.height; swidth = gdk_screen_width(); sheight = gdk_screen_height(); - switch (panel->pos) { + switch (the_panel->pos) { case PANEL_POS_TOP: - move_vert(panel, -height + 1, 0); + move_vert(-height + 1, 0); break; case PANEL_POS_BOTTOM: - move_vert(panel, sheight - 1, sheight - height); + move_vert(sheight - 1, sheight - height); break; case PANEL_POS_LEFT: - move_horiz(panel, -width + 1, 0); + move_horiz(-width + 1, 0); break; case PANEL_POS_RIGHT: - move_horiz(panel, swidth - 1, swidth - width); + move_horiz(swidth - 1, swidth - width); break; } - panel->state = PANEL_SHOWN; + the_panel->state = PANEL_SHOWN; } static void -pop_down(Panel *panel) +pop_down(void) { int width, height; int swidth, sheight; - if (panel->state == PANEL_HIDDEN) + if (the_panel->state == PANEL_HIDDEN) return; - width = panel->window->allocation.width; - height = panel->window->allocation.height; + width = the_panel->window->allocation.width; + height = the_panel->window->allocation.height; swidth = gdk_screen_width(); sheight = gdk_screen_height(); - switch (panel->pos) { + switch (the_panel->pos) { case PANEL_POS_TOP: - move_vert(panel, 0, -height + 1); + move_vert(0, -height + 1); break; case PANEL_POS_BOTTOM: - move_vert(panel, sheight - height, sheight - 1); + move_vert(sheight - height, sheight - 1); break; case PANEL_POS_LEFT: - move_horiz(panel, 0, -width + 1); + move_horiz(0, -width + 1); break; case PANEL_POS_RIGHT: - move_horiz(panel, swidth - width, swidth - 1); + move_horiz(swidth - width, swidth - 1); break; } - panel->state = PANEL_HIDDEN; + the_panel->state = PANEL_HIDDEN; } -static gint -panel_enter_notify(GtkWidget *widget, GdkEventCrossing *event, gpointer data) +static void +panel_block_signals(void) { - Panel *panel; + gtk_signal_handler_block(GTK_OBJECT(the_panel->window), the_panel->enter_notify_id); + gtk_signal_handler_block(GTK_OBJECT(the_panel->window), the_panel->leave_notify_id); +} - panel = data; - if ((panel->mode == PANEL_STAYS_PUT) || +static void +panel_unblock_signals(void) +{ + gtk_signal_handler_unblock(GTK_OBJECT(the_panel->window), the_panel->leave_notify_id); + gtk_signal_handler_unblock(GTK_OBJECT(the_panel->window), the_panel->enter_notify_id); +} + + +static gint +panel_enter_notify(GtkWidget *widget, GdkEventCrossing *event, gpointer data) +{ + if ((the_panel->mode == PANEL_STAYS_PUT) || (event->detail == GDK_NOTIFY_INFERIOR)) return FALSE; - pop_up(panel); - + panel_block_signals(); + pop_up(); + panel_unblock_signals(); + return FALSE; } @@ -155,15 +188,13 @@ static gint panel_leave_notify(GtkWidget *widget, GdkEventCrossing *event, gpointer data) { - Panel *panel; - - panel = data; - - if ((panel->mode == PANEL_STAYS_PUT) || + if ((the_panel->mode == PANEL_STAYS_PUT) || (event->detail == GDK_NOTIFY_INFERIOR)) return FALSE; - pop_down(panel); + panel_block_signals(); + pop_down(); + panel_unblock_signals(); return FALSE; } @@ -181,18 +212,22 @@ static void -get_applet_placement(Panel *panel, int *x, int *y) +find_applet_placement(int *x, int *y) { Point point; point.x = 0; point.y = 0; + + *x = 0; + *y = 0; + return; /* FIXME: this is for now; fix to calculate appropriate position */ - gtk_container_foreach(GTK_CONTAINER(panel->fixed), + gtk_container_foreach(GTK_CONTAINER(the_panel->fixed), (GtkCallback) max_pos, &point); - switch (panel->pos) { + switch (the_panel->pos) { case PANEL_POS_TOP: case PANEL_POS_BOTTOM: *x = point.x; @@ -222,115 +257,539 @@ static void realize_change_cursor(GtkWidget *widget, gpointer data) { - change_window_cursor(widget->window, GDK_ARROW); /* XXX: I don't like this arrow */ + change_window_cursor(widget->window, GDK_ARROW); +} + + +static AppletCallback +get_applet_callback(GtkWidget *applet) +{ + return gtk_object_get_data(GTK_OBJECT(applet), APPLET_CALLBACK); +} + + +static char * +get_applet_id(GtkWidget *applet) +{ + return gtk_object_get_data(GTK_OBJECT(applet), APPLET_ID); +} + + +static char * +get_applet_params(GtkWidget *applet) +{ + return gtk_object_get_data(GTK_OBJECT(applet), APPLET_PARAMS); +} + + +static long +get_applet_flags(GtkWidget *applet) +{ + return (long) gtk_object_get_data(GTK_OBJECT(applet), APPLET_FLAGS); } static void -save_applet_configuration(GtkWidget *widget, gpointer data) +get_applet_geometry(GtkWidget *applet, int *x, int *y, int *width, int *height) +{ + if (x) + *x = applet->allocation.x; + + if (y) + *y = applet->allocation.y; + + if (width) + *width = applet->allocation.width; + + if (height) + *height = applet->allocation.height; +} + + +static gpointer +call_applet(GtkWidget *applet, AppletCommand *cmd) { + AppletCallback callback; + + cmd->panel = the_panel; + cmd->applet = GTK_BIN(applet)->child; + + callback = get_applet_callback(applet); + + if (callback) + return (*callback) (cmd); + else + return NULL; } static void -panel_quit(Panel *panel) +save_applet_configuration(GtkWidget *widget, gpointer data) { - g_assert(panel != NULL); + static int num = 0; + + int xpos, ypos; + char *id; + char *params; + char *path; + char buf[256]; + + id = get_applet_id(widget); + params = get_applet_params(widget); + get_applet_geometry(widget, &xpos, &ypos, NULL, NULL); + + /* XXX: The increasing number is sort of a hack to guarantee unique keys */ + + sprintf(buf, "%d,", num++); + path = g_copy_strings("/panel/Applets/", buf, id, ",", params, NULL); + sprintf(buf, "%d %d", xpos, ypos); + gnome_config_set_string(path, buf); + g_free(path); +} - gtk_container_foreach(GTK_CONTAINER(panel->fixed), save_applet_configuration, panel); - gtk_widget_destroy(panel->window); + +static void +panel_quit(void) +{ + gnome_config_clean_section("/panel/Applets"); + gtk_container_foreach(GTK_CONTAINER(the_panel->fixed), save_applet_configuration, NULL); + gnome_config_sync(); + gtk_widget_destroy(the_panel->window); applets_destroy(); } -Panel * -panel_new(void) +static void +applet_drag_start(GtkWidget *applet, int warp) { - Panel *panel; + the_panel->applet_being_dragged = applet; - panel = g_new(Panel, 1); + if (warp) + gdk_pointer_warp(NULL, applet->window, + 0, 0, 0, 0, + applet->allocation.width / 2, + applet->allocation.height / 2); + + gtk_widget_get_pointer(the_panel->window, + &the_panel->applet_drag_click_x, + &the_panel->applet_drag_click_y); + get_applet_geometry(applet, + &the_panel->applet_drag_orig_x, + &the_panel->applet_drag_orig_y, + NULL, + NULL); - panel->window = gtk_window_new(GTK_WINDOW_POPUP); + gtk_grab_add(applet); +} - panel->fixed = gtk_fixed_new(); - gtk_container_add(GTK_CONTAINER(panel->window), panel->fixed); - gtk_widget_show(panel->fixed); - panel->pos = PANEL_POS_BOTTOM; - panel->state = PANEL_SHOWN; - panel->mode = PANEL_GETS_HIDDEN; - gtk_widget_set_usize(panel->window, gdk_screen_width(), DEFAULT_HEIGHT); - gtk_widget_set_uposition(panel->window, 0, gdk_screen_height() - DEFAULT_HEIGHT); +static void +applet_drag_end(GtkWidget *applet) +{ + the_panel->applet_being_dragged = NULL; + gtk_grab_remove(applet); +} + + +static void +move_applet_callback(GtkWidget *widget, gpointer data) +{ + GtkWidget *applet; + + /* FIXME: when the mouse moves outside of the applet, no + * motion events are sent to it, even when the applet has a + * gtk_grab to it. However, when the drag was started by the + * mouse instead of the menu, it works. I don't know why this + * happens. + */ + + applet = gtk_object_get_user_data(GTK_OBJECT(applet_menu)); + applet_drag_start(applet, TRUE); +} + + +static void +remove_applet_callback(GtkWidget *widget, gpointer data) +{ + GtkWidget *applet; + + applet = gtk_object_get_user_data(GTK_OBJECT(applet_menu)); + gtk_widget_destroy(applet); +} + + +static void +applet_properties_callback(GtkWidget *widget, gpointer data) +{ + GtkWidget *applet; + AppletCommand cmd; + + applet = gtk_object_get_user_data(GTK_OBJECT(applet_menu)); + + cmd.cmd = APPLET_CMD_PROPERTIES; + + call_applet(applet, &cmd); +} + + +static void +create_applet_menu(void) +{ + GtkWidget *menuitem; + + applet_menu = gtk_menu_new(); + + menuitem = gtk_menu_item_new_with_label(_("Move applet")); + gtk_signal_connect(GTK_OBJECT(menuitem), "activate", + (GtkSignalFunc) move_applet_callback, + NULL); + gtk_menu_append(GTK_MENU(applet_menu), menuitem); + gtk_widget_show(menuitem); + + menuitem = gtk_menu_item_new_with_label(_("Remove from panel")); + gtk_signal_connect(GTK_OBJECT(menuitem), "activate", + (GtkSignalFunc) remove_applet_callback, + NULL); + gtk_menu_append(GTK_MENU(applet_menu), menuitem); + gtk_widget_show(menuitem); + + menuitem = gtk_menu_item_new(); + gtk_menu_append(GTK_MENU(applet_menu), menuitem); + gtk_widget_show(menuitem); + applet_menu_prop_separator = menuitem; + + menuitem = gtk_menu_item_new_with_label(_("Applet properties...")); + gtk_signal_connect(GTK_OBJECT(menuitem), "activate", + (GtkSignalFunc) applet_properties_callback, + NULL); + gtk_menu_append(GTK_MENU(applet_menu), menuitem); + gtk_widget_show(menuitem); + applet_menu_prop_item = menuitem; + + gtk_signal_connect_after(GTK_OBJECT(applet_menu), "deactivate", + (GtkSignalFunc) panel_unblock_signals, + NULL); +} + + +static void +show_applet_menu(GtkWidget *applet) +{ + long flags; + + flags = get_applet_flags(applet); + + if (flags & APPLET_HAS_PROPERTIES) { + gtk_widget_show(applet_menu_prop_separator); + gtk_widget_show(applet_menu_prop_item); + } else { + gtk_widget_hide(applet_menu_prop_separator); + gtk_widget_hide(applet_menu_prop_item); + } + + gtk_object_set_user_data(GTK_OBJECT(applet_menu), applet); + + panel_block_signals(); + gtk_menu_popup(GTK_MENU(applet_menu), NULL, NULL, NULL, NULL, 3, 0); +} + + +static gint +panel_applet_event(GtkWidget *widget, GdkEvent *event, gpointer data) +{ + GdkEventButton *bevent; + gint x, y; + int x1, y1, x2, y2; + int dx, dy; + int xpos, ypos; + int width, height; + + get_applet_geometry(widget, &xpos, &ypos, &width, &height); + + switch (event->type) { + case GDK_BUTTON_PRESS: + bevent = (GdkEventButton *) event; + + if (the_panel->applet_being_dragged) + return TRUE; + + switch (bevent->button) { + case 2: /* Start drag */ + if (the_panel->applet_being_dragged) + break; + + applet_drag_start(widget, FALSE); + return TRUE; + + case 3: /* Applet menu */ + show_applet_menu(widget); + return TRUE; + } + + break; + + case GDK_BUTTON_RELEASE: + bevent = (GdkEventButton *) event; + + if (the_panel->applet_being_dragged == widget) { + applet_drag_end(widget); + return TRUE; + } + + break; + + case GDK_MOTION_NOTIFY: + if (the_panel->applet_being_dragged == widget) { + gtk_widget_get_pointer(the_panel->window, &x, &y); + + dx = x - the_panel->applet_drag_click_x; + dy = y - the_panel->applet_drag_click_y; + + x1 = the_panel->applet_drag_orig_x + dx; + y1 = the_panel->applet_drag_orig_y + dy; + x2 = x1 + width; + y2 = y1 + height; + + if (x2 > the_panel->window->allocation.width) + x1 = the_panel->window->allocation.width - width; + + if (y2 > the_panel->window->allocation.height) + y1 = the_panel->window->allocation.height - height; + + if (x1 < 0) + x1 = 0; + + if (y1 < 0) + y1 = 0; + + if ((x1 != xpos) || (y1 != ypos)) + gtk_fixed_move(GTK_FIXED(the_panel->fixed), widget, x1, y1); + + return TRUE; + } + + break; + + default: + break; + } + + return FALSE; +} + +static GtkWidget * +listening_parent(GtkWidget *widget) +{ + if (GTK_WIDGET_NO_WINDOW(widget)) + return listening_parent(widget->parent); + + return widget; +} + + +static gint +panel_sub_event_handler (GtkWidget *widget, GdkEvent *event, gpointer data) +{ + GdkEventButton *bevent; + + switch (event->type) { + case GDK_BUTTON_PRESS: + bevent = (GdkEventButton *) event; + + switch (bevent->button) { + case 2: + case 3: + return gtk_widget_event(listening_parent(widget->parent), event); + } + + break; + + case GDK_BUTTON_RELEASE: + bevent = (GdkEventButton *) event; + + if (the_panel->applet_being_dragged) + return gtk_widget_event(listening_parent(widget->parent), event); + break; + + case GDK_MOTION_NOTIFY: + if (the_panel->applet_being_dragged) + return gtk_widget_event(listening_parent(widget->parent), event); + break; + + default: + break; + } + + return FALSE; +} + + +static void +get_applet_type(gpointer key, gpointer value, gpointer user_data) +{ + GList **list = user_data; + + *list = g_list_prepend(*list, g_strdup(key)); +} + + +GList * +get_applet_types(void) +{ + GList *list = NULL; + + g_hash_table_foreach(applet_files_ht, get_applet_type, &list); + return list; +} + + +void +panel_init(void) +{ + the_panel = g_new(Panel, 1); + + the_panel->window = gtk_window_new(GTK_WINDOW_POPUP); + + the_panel->fixed = gtk_fixed_new(); + gtk_container_add(GTK_CONTAINER(the_panel->window), the_panel->fixed); + gtk_widget_show(the_panel->fixed); + + the_panel->pos = PANEL_POS_BOTTOM; + the_panel->state = PANEL_SHOWN; + the_panel->mode = PANEL_GETS_HIDDEN; + gtk_widget_set_usize(the_panel->window, gdk_screen_width(), DEFAULT_HEIGHT); + gtk_widget_set_uposition(the_panel->window, 0, gdk_screen_height() - DEFAULT_HEIGHT); #if 0 - panel->pos = PANEL_POS_TOP; - panel->state = PANEL_SHOWN; - panel->mode = PANEL_GETS_HIDDEN; - gtk_widget_set_usize(panel->window, gdk_screen_width(), DEFAULT_HEIGHT); - gtk_widget_set_uposition(panel->window, 0, 0); + the_panel->pos = PANEL_POS_TOP; + the_panel->state = PANEL_SHOWN; + the_panel->mode = PANEL_GETS_HIDDEN; + gtk_widget_set_usize(the_panel->window, gdk_screen_width(), DEFAULT_HEIGHT); + gtk_widget_set_uposition(the_panel->window, 0, 0); #endif #if 0 - panel->pos = PANEL_POS_RIGHT; - panel->state = PANEL_SHOWN; - panel->mode = PANEL_GETS_HIDDEN; - gtk_widget_set_usize(panel->window, DEFAULT_HEIGHT, gdk_screen_height()); - gtk_widget_set_uposition(panel->window, gdk_screen_width() - DEFAULT_HEIGHT, 0); + the_panel->pos = PANEL_POS_RIGHT; + the_panel->state = PANEL_SHOWN; + the_panel->mode = PANEL_GETS_HIDDEN; + gtk_widget_set_usize(the_panel->window, DEFAULT_HEIGHT, gdk_screen_height()); + gtk_widget_set_uposition(the_panel->window, gdk_screen_width() - DEFAULT_HEIGHT, 0); #endif #if 0 - panel->pos = PANEL_POS_LEFT; - panel->state = PANEL_SHOWN; - panel->mode = PANEL_GETS_HIDDEN; - gtk_widget_set_usize(panel->window, DEFAULT_HEIGHT, gdk_screen_height()); - gtk_widget_set_uposition(panel->window, 0, 0); + the_panel->pos = PANEL_POS_LEFT; + the_panel->state = PANEL_SHOWN; + the_panel->mode = PANEL_GETS_HIDDEN; + gtk_widget_set_usize(the_panel->window, DEFAULT_HEIGHT, gdk_screen_height()); + gtk_widget_set_uposition(the_panel->window, 0, 0); #endif - panel->step_size = DEFAULT_STEP_SIZE; - panel->delay = DEFAULT_DELAY; - - gtk_signal_connect(GTK_OBJECT(panel->window), "enter_notify_event", - (GtkSignalFunc) panel_enter_notify, - panel); - gtk_signal_connect(GTK_OBJECT(panel->window), "leave_notify_event", - (GtkSignalFunc) panel_leave_notify, - panel); - gtk_signal_connect_after(GTK_OBJECT(panel->window), "realize", + the_panel->step_size = DEFAULT_STEP_SIZE; + the_panel->delay = DEFAULT_DELAY; + the_panel->applet_being_dragged = NULL; + + the_panel->enter_notify_id = gtk_signal_connect(GTK_OBJECT(the_panel->window), "enter_notify_event", + (GtkSignalFunc) panel_enter_notify, + the_panel); + the_panel->leave_notify_id = gtk_signal_connect(GTK_OBJECT(the_panel->window), "leave_notify_event", + (GtkSignalFunc) panel_leave_notify, + the_panel); + gtk_signal_connect_after(GTK_OBJECT(the_panel->window), "realize", (GtkSignalFunc) realize_change_cursor, NULL); - return panel; + create_applet_menu(); +} + + +void +panel_bind_events (GtkWidget *widget, void *data) +{ + gint events; + + if (!GTK_WIDGET_NO_WINDOW (widget)) { + events = (gtk_widget_get_events(widget) | + GDK_BUTTON_PRESS_MASK | + GDK_BUTTON_RELEASE_MASK | + GDK_POINTER_MOTION_MASK | + GDK_POINTER_MOTION_HINT_MASK); + + gtk_widget_set_events(widget, events); + + gtk_signal_connect(GTK_OBJECT(widget), "event", + (GtkSignalFunc) panel_sub_event_handler, the_panel); + } + + if (GTK_IS_CONTAINER (widget)) + gtk_container_foreach (GTK_CONTAINER (widget), panel_bind_events, 0); } void -panel_register_toy(Panel *panel, GtkWidget *applet, int xpos, int ypos, int flags) +panel_register_toy(GtkWidget *applet, char *id, char *params, int xpos, int ypos, long flags) { - g_assert(panel != NULL); + GtkWidget *eventbox; + gint events; + g_assert(applet != NULL); - gtk_fixed_put(GTK_FIXED(panel->fixed), applet, xpos, ypos); + /* We wrap the applet in a GtkEventBox so that we can capture events over it */ + + eventbox = gtk_event_box_new(); + gtk_container_add(GTK_CONTAINER(eventbox), applet); + + events = (gtk_widget_get_events(eventbox) | + GDK_BUTTON_PRESS_MASK | + GDK_BUTTON_RELEASE_MASK | + GDK_POINTER_MOTION_MASK | + GDK_POINTER_MOTION_HINT_MASK); + + gtk_widget_set_events(eventbox, events); + + gtk_signal_connect(GTK_OBJECT(eventbox), "event", (GtkSignalFunc) panel_applet_event, the_panel); + panel_bind_events (applet, 0); + + /* Attach our private data to the applet */ + + gtk_object_set_data(GTK_OBJECT(eventbox), APPLET_ID, id); + gtk_object_set_data(GTK_OBJECT(eventbox), APPLET_PARAMS, params); + gtk_object_set_data(GTK_OBJECT(eventbox), APPLET_FLAGS, (gpointer) flags); + + gtk_fixed_put(GTK_FIXED(the_panel->fixed), eventbox, xpos, ypos); + gtk_widget_show(eventbox); gtk_widget_show(applet); } -int -panel_command(Panel *panel, PanelCommand *cmd) +gpointer +panel_command(PanelCommand *cmd) { - g_assert(panel != NULL); + int xpos, ypos; + g_assert(cmd != NULL); switch (cmd->cmd) { case PANEL_CMD_REGISTER_TOY: - panel_register_toy(panel, - cmd->params.register_toy.applet, + panel_register_toy(cmd->params.register_toy.applet, + cmd->params.register_toy.id, + cmd->params.register_toy.params, cmd->params.register_toy.xpos, cmd->params.register_toy.ypos, cmd->params.register_toy.flags); - return 0; + return NULL; case PANEL_CMD_QUIT: - panel_quit(panel); + panel_quit(); gtk_main_quit(); - return 0; + return NULL; + + case PANEL_CMD_NEW_APPLET: + find_applet_placement(&xpos, &ypos); + applets_init_applet(cmd->params.new_applet.applet, + cmd->params.new_applet.params, + xpos, ypos); + return NULL; + + case PANEL_CMD_GET_APPLET_TYPES: + return get_applet_types(); } - return -1; + return NULL; } diff -uNr gnome-0.7/programs/panel/panel.h gnome-0.8/programs/panel/panel.h --- gnome-0.7/programs/panel/panel.h Thu Oct 2 22:55:28 1997 +++ gnome-0.8/programs/panel/panel.h Wed Oct 8 19:16:17 1997 @@ -6,6 +6,8 @@ BEGIN_GNOME_DECLS +/* Panel types */ + typedef enum { PANEL_POS_TOP, PANEL_POS_BOTTOM, @@ -23,10 +25,6 @@ PANEL_GETS_HIDDEN } PanelMode; -typedef enum { - APPLET_HAS_PROPERTIES = 1 << 0 -} AppletFlags; - typedef struct { GtkWidget *window; GtkWidget *fixed; @@ -35,11 +33,51 @@ PanelMode mode; int step_size; int delay; + gint enter_notify_id; + gint leave_notify_id; + GtkWidget *applet_being_dragged; + gint applet_drag_click_x; + gint applet_drag_click_y; + gint applet_drag_orig_x; + gint applet_drag_orig_y; } Panel; + +/* Applet types */ + +typedef enum { + APPLET_HAS_PROPERTIES = 1L << 0 +} AppletFlags; + + +/* Applet command types */ + +typedef enum { + APPLET_CMD_PROPERTIES, + APPLET_CMD_TOOLTIPS +} AppletCommandType; + +typedef struct { + AppletCommandType cmd; + + Panel *panel; + GtkWidget *applet; + + union { + int tool_tips; + } params; +} AppletCommand; + +typedef gpointer (*AppletCallback) (AppletCommand *cmd); + + +/* Panel command types */ + typedef enum { PANEL_CMD_REGISTER_TOY, - PANEL_CMD_QUIT + PANEL_CMD_QUIT, + PANEL_CMD_NEW_APPLET, + PANEL_CMD_GET_APPLET_TYPES } PanelCommandType; typedef struct { @@ -48,19 +86,32 @@ union { /* Register toy parameters */ struct { - GtkWidget *applet; - int xpos; - int ypos; - int flags; + GtkWidget *applet; + AppletCallback callback; + char *id; + char *params; + int xpos; + int ypos; + long flags; } register_toy; + + /* New Applet parameters: applet name, arguments to applet */ + struct { + char *applet; + char *params; + } new_applet; } params; } PanelCommand; -typedef int (*PanelCallback) (Panel *panel, PanelCommand *cmd); +typedef gpointer (*PanelCallback) (PanelCommand *cmd); + + +extern Panel *the_panel; + -Panel *panel_new(void); +void panel_init(void); -int panel_command (Panel *panel, PanelCommand *cmd); +gpointer panel_command (PanelCommand *cmd); END_GNOME_DECLS