Re: gnome_score dialog - default on OK
- From: Simon Kagedal <simon sdf se>
- To: Havoc Pennington <rhpennin midway uchicago edu>
- Cc: horape compendium com ar, gnome-list gnome org
- Subject: Re: gnome_score dialog - default on OK
- Date: Sat, 25 Jul 1998 03:07:44 +0200
On Fri, Jul 24, 1998 at 05:18:27PM -0500, Havoc Pennington wrote:
>
> The correct solution here is to change the score dialog so its parent is
> GnomeDialog instead of GtkWindow. Then all the key shortcuts and etc.
> will be handled automatically. Also it will cut down on the code size of
> gnome-score.c and reduce bloat a few trivial K.
>
> Unfortunately this is a little more ambitious than you might have wanted,
> but it shouldn't be too hard if you want to give it a go. ;-)
Ok. Was kinda thinking of this, but hoped there would be an easy
way...:)
Anyway, here's the patch. I've tested this on the gnome-games that
uses gnome-score, and it works alright AFAICS. I haven't tested the
features that no current app uses.
(should i be sending patches like this to the list? or should someone
give me a cvs account? :) )
Index: gnome-scores.c
===================================================================
RCS file: /cvs/gnome/gnome-libs/libgnomeui/gnome-scores.c,v
retrieving revision 1.14
diff -u -r1.14 gnome-scores.c
--- gnome-scores.c 1998/06/28 14:52:04 1.14
+++ gnome-scores.c 1998/07/25 00:49:36
@@ -39,7 +39,8 @@
(GtkArgGetFunc) NULL,
};
- scores_type = gtk_type_unique (gtk_window_get_type (), &scores_info);
+ scores_type = gtk_type_unique (gnome_dialog_get_type (),
+ &scores_info);
}
return scores_type;
@@ -69,8 +70,6 @@
gchar *tmp2;
int i;
- gtk_window_set_policy (GTK_WINDOW(gs), FALSE, FALSE, TRUE);
-
gs->logo = 0;
gs->but_clear = 0;
gs->n_scores = n_scores;
@@ -111,36 +110,26 @@
}
gtk_widget_show (GTK_WIDGET(table));
- button1 = gnome_stock_button(GNOME_STOCK_BUTTON_OK);
- gtk_signal_connect_object (GTK_OBJECT (button1), "clicked",
- GTK_SIGNAL_FUNC (gtk_widget_destroy),
- GTK_OBJECT (gs));
- gtk_widget_show (button1);
- hor_table = gtk_table_new (1, clear?5:3, TRUE);
- gtk_table_attach_defaults ( GTK_TABLE(hor_table), button1, 1, 2, 0, 1);
- gtk_widget_show (hor_table);
-
+ /*
if(clear) {
- gs->but_clear = gtk_button_new_with_label ( _("Clear") );
- gtk_widget_show (gs->but_clear);
- gtk_table_attach_defaults ( GTK_TABLE(hor_table), gs->but_clear, 3, 4, 0, 1);
+ gs->but_clear = gtk_button_new_with_label ( _("Clear") );
+ gtk_widget_show (gs->but_clear);
+ gtk_table_attach_defaults ( GTK_TABLE(hor_table), gs->but_clear, 3, 4, 0, 1);
}
+ */
- gs->vbox = gtk_vbox_new (FALSE, 5);
- gtk_widget_show (gs->vbox);
- gtk_box_pack_end (GTK_BOX(gs->vbox), hor_table, TRUE, TRUE, 0);
- hSep = gtk_hseparator_new ();
- gtk_widget_show (hSep);
- gtk_box_pack_end (GTK_BOX(gs->vbox), hSep, TRUE, TRUE, 0);
- gtk_box_pack_end (GTK_BOX(gs->vbox), GTK_WIDGET(table), TRUE, TRUE, 0);
- hSep = gtk_hseparator_new ();
- gtk_widget_show (hSep);
- gtk_box_pack_end (GTK_BOX(gs->vbox), hSep, TRUE, TRUE, 0);
+ gtk_box_pack_end (GTK_BOX(GNOME_DIALOG(gs)->vbox),
+ GTK_WIDGET(table),
+ TRUE, TRUE, 0);
- gtk_container_add( GTK_CONTAINER(gs), gs->vbox);
gtk_window_set_title (GTK_WINDOW (gs), _("Top Ten") );
gtk_container_border_width (GTK_CONTAINER (gs), 5);
+ gnome_dialog_append_button (GNOME_DIALOG (gs),
+ GNOME_STOCK_BUTTON_OK);
+
+ gnome_dialog_set_close (GNOME_DIALOG (gs), TRUE);
+
return retval;
}
@@ -196,7 +185,7 @@
gs->logo = gtk_label_new(txt);
gtk_widget_set_name(GTK_WIDGET(gs->logo), "Logo");
- gtk_box_pack_end (GTK_BOX(gs->vbox), gs->logo, TRUE, TRUE, 0);
+ gtk_box_pack_end (GTK_BOX(GNOME_DIALOG(gs)->vbox), gs->logo, TRUE, TRUE, 0);
gtk_widget_show (gs->logo);
}
@@ -228,7 +217,7 @@
gs->logo = gtk_label_new(txt);
gtk_widget_set_style(GTK_WIDGET(gs->logo), s);
gtk_style_unref(s);
- gtk_box_pack_end (GTK_BOX(gs->vbox), gs->logo, TRUE, TRUE, 0);
+ gtk_box_pack_end (GTK_BOX(GNOME_DIALOG(gs)->vbox), gs->logo, TRUE, TRUE, 0);
gtk_widget_show (gs->logo);
}
@@ -241,7 +230,7 @@
}
gs->logo = w;
- gtk_box_pack_end (GTK_BOX(gs->vbox), gs->logo, TRUE, TRUE, 0);
+ gtk_box_pack_end (GTK_BOX(GNOME_DIALOG(gs)->vbox), gs->logo, TRUE, TRUE, 0);
}
void gnome_scores_set_logo_pixmap (GnomeScores *gs, gchar *pix_name)
@@ -262,7 +251,7 @@
pix_name);
gs->logo = gtk_pixmap_new (pixmap, mask);
- gtk_box_pack_end (GTK_BOX(gs->vbox), gs->logo, TRUE, TRUE, 0);
+ gtk_box_pack_end (GTK_BOX(GNOME_DIALOG(gs)->vbox), gs->logo, TRUE, TRUE, 0);
gtk_widget_show (gs->logo);
}
Index: gnome-scores.h
===================================================================
RCS file: /cvs/gnome/gnome-libs/libgnomeui/gnome-scores.h,v
retrieving revision 1.5
diff -u -r1.5 gnome-scores.h
--- gnome-scores.h 1998/02/17 14:54:38 1.5
+++ gnome-scores.h 1998/07/25 00:49:36
@@ -20,9 +20,10 @@
#ifndef GNOME_SCORES_H
#define GNOME_SCORES_H
-#include <gtk/gtkwindow.h>
-#include <libgnome/gnome-defs.h>
+
#include <time.h>
+#include "gnome-dialog.h"
+#include "libgnome/gnome-defs.h"
BEGIN_GNOME_DECLS
@@ -35,13 +36,12 @@
struct _GnomeScores
{
- GtkWindow window;
+ GnomeDialog dialog;
GtkWidget *but_clear;
guint n_scores;
GtkWidget *logo;
- GtkWidget *vbox;
GtkWidget **label_names;
GtkWidget **label_scores;
GtkWidget **label_times;
@@ -49,7 +49,7 @@
struct _GnomeScoresClass
{
- GtkWindowClass parent_class;
+ GnomeDialogClass parent_class;
};
guint gnome_scores_get_type (void);
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/gnome-libs/libgnomeui/ChangeLog,v
retrieving revision 1.339
diff -u -r1.339 ChangeLog
--- ChangeLog 1998/07/24 06:50:54 1.339
+++ ChangeLog 1998/07/25 00:49:40
@@ -1,3 +1,9 @@
+Sat Jul 25 02:51:12 1998 Simon Kagedal <simon@sdf.se>
+
+ * gnome-scores.[ch]:
+ made the GnomeScore dialog inherit from GnomeDialog
+ instead of GtkWindow
+
Fri Jul 24 02:34:31 1998 John Ellis <johne@bellatlantic.net>
* gnome-dentry-edit.c:
--
Simon Kågedal <simon@sdf.se> - Homepage: http://www.sdf.se/~simon/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]