[Cxplorer-cvs 00979] CVS update: libcxp/src

Back to archive index

Yasumichi Akahoshi yasum****@users*****
2005年 4月 8日 (金) 19:06:04 JST


Index: libcxp/src/cxp-entry-dialog.c
diff -u libcxp/src/cxp-entry-dialog.c:1.2 libcxp/src/cxp-entry-dialog.c:1.3
--- libcxp/src/cxp-entry-dialog.c:1.2	Sun Feb 13 23:51:02 2005
+++ libcxp/src/cxp-entry-dialog.c	Fri Apr  8 19:06:04 2005
@@ -31,12 +31,14 @@
  * definition for this private structure.
  */
 
-struct _CxpEntryDialogPrivate
+typedef struct
 {
 	GtkWidget *msg_label;
 	GtkWidget *entry;
 	gboolean dispose_has_run;
-};
+} CxpEntryDialogPrivate;
+
+#define CXP_ENTRY_DIALOG_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), CXP_TYPE_ENTRY_DIALOG, CxpEntryDialogPrivate))
 
 static GObjectClass *parent_class = NULL;
 
@@ -57,14 +59,14 @@
 					    gpointer g_class_data)
 {
 	GObjectClass *gobject_class = G_OBJECT_CLASS (g_class);
-	CxpEntryDialogClass *klass = CXP_ENTRY_DIALOG_CLASS (g_class);
 	GParamSpec *pspec;
 
 	gobject_class->dispose = cxp_entry_dialog_dispose;
 	gobject_class->finalize = cxp_entry_dialog_finalize;
 
-	parent_class = g_type_class_peek_parent (klass);
+	g_type_class_add_private (g_class, sizeof (CxpEntryDialogPrivate));
 
+	parent_class = g_type_class_peek_parent (g_class);
 }
 
 static void cxp_entry_dialog_instance_init (GTypeInstance * instance,
@@ -73,22 +75,22 @@
 	CxpEntryDialog *self = CXP_ENTRY_DIALOG (instance);
 	GtkWidget *ok_button;
 	GtkWidget *cancel_button;
+	CxpEntryDialogPrivate *private = CXP_ENTRY_DIALOG_GET_PRIVATE(instance);
 
-	self->private = g_new (CxpEntryDialogPrivate, 1);
-	self->private->dispose_has_run = FALSE;
+	private->dispose_has_run = FALSE;
 
 	gtk_window_set_destroy_with_parent(GTK_WINDOW(self), TRUE);
 	gtk_dialog_set_default_response (GTK_DIALOG (self), GTK_RESPONSE_OK);
 
-	self->private->msg_label = gtk_label_new("Message");
-	gtk_misc_set_alignment (GTK_MISC(self->private->msg_label), 0, 0);
-	gtk_label_set_line_wrap (GTK_LABEL(self->private->msg_label), TRUE);
-	gtk_box_pack_start (GTK_BOX(GTK_DIALOG(self)->vbox), self->private->msg_label, TRUE, TRUE, 2);
-	gtk_widget_show(self->private->msg_label);
-
-	self->private->entry = gtk_entry_new();
-	gtk_box_pack_start (GTK_BOX(GTK_DIALOG(self)->vbox), self->private->entry, TRUE, TRUE, 2);
-	gtk_widget_show(self->private->entry);
+	private->msg_label = gtk_label_new("Message");
+	gtk_misc_set_alignment (GTK_MISC(private->msg_label), 0, 0);
+	gtk_label_set_line_wrap (GTK_LABEL(private->msg_label), TRUE);
+	gtk_box_pack_start (GTK_BOX(GTK_DIALOG(self)->vbox), private->msg_label, TRUE, TRUE, 2);
+	gtk_widget_show(private->msg_label);
+
+	private->entry = gtk_entry_new();
+	gtk_box_pack_start (GTK_BOX(GTK_DIALOG(self)->vbox), private->entry, TRUE, TRUE, 2);
+	gtk_widget_show(private->entry);
 
 	ok_button = gtk_button_new_from_stock("gtk-ok");
 	gtk_dialog_add_action_widget (GTK_DIALOG (self), ok_button, GTK_RESPONSE_OK);
@@ -102,15 +104,15 @@
 
 static void cxp_entry_dialog_dispose (GObject * obj)
 {
-	CxpEntryDialog *self = CXP_ENTRY_DIALOG (obj);
+	CxpEntryDialogPrivate *private = CXP_ENTRY_DIALOG_GET_PRIVATE(obj);
 
-	if (self->private->dispose_has_run)
+	if (private->dispose_has_run)
 	{
 		/* If dispose did already run, return. */
 		return;
 	}
 	/* Make sure dispose does not run twice. */
-	self->private->dispose_has_run = TRUE;
+	private->dispose_has_run = TRUE;
 
 	/* 
 	 * In dispose, you are supposed to free all types referenced from this
@@ -125,15 +127,6 @@
 
 static void cxp_entry_dialog_finalize (GObject * obj)
 {
-	CxpEntryDialog *self = CXP_ENTRY_DIALOG (obj);
-
-	/*
-	 * Here, complete object destruction.
-	 * You might not need to do much...
-	 */
-
-	g_free (self->private);
-
 	/* Chain up to the parent class */
 	G_OBJECT_CLASS (parent_class)->finalize (obj);
 }
@@ -165,16 +158,20 @@
 GtkWidget *cxp_entry_dialog_new(const gchar *title, const gchar *message, const gchar *entry_text)
 {
 	CxpEntryDialog *dialog;
+	CxpEntryDialogPrivate *private;
 
 	dialog = g_object_new(CXP_TYPE_ENTRY_DIALOG, NULL);
+	private = CXP_ENTRY_DIALOG_GET_PRIVATE(dialog);
 	gtk_window_set_title(GTK_WINDOW(dialog), title);
-	gtk_label_set_text(GTK_LABEL(dialog->private->msg_label), message);
-	gtk_entry_set_text(GTK_ENTRY(dialog->private->entry), entry_text);
+	gtk_label_set_text(GTK_LABEL(private->msg_label), message);
+	gtk_entry_set_text(GTK_ENTRY(private->entry), entry_text);
 
 	return	GTK_WIDGET(dialog);
 }
 
 gchar *cxp_entry_dialog_get_entry_text(CxpEntryDialog *dialog)
 {
-	return	g_strdup(gtk_entry_get_text(GTK_ENTRY(dialog->private->entry)));
+	CxpEntryDialogPrivate *private = CXP_ENTRY_DIALOG_GET_PRIVATE(dialog);
+
+	return	g_strdup(gtk_entry_get_text(GTK_ENTRY(private->entry)));
 }


Cxplorer-cvs メーリングリストの案内
Back to archive index