Yasumichi Akahoshi
yasum****@users*****
2005年 4月 10日 (日) 04:11:49 JST
Index: libcxp/src/Makefile.am diff -u libcxp/src/Makefile.am:1.7 libcxp/src/Makefile.am:1.8 --- libcxp/src/Makefile.am:1.7 Thu Mar 31 01:04:44 2005 +++ libcxp/src/Makefile.am Sun Apr 10 04:11:49 2005 @@ -9,5 +9,6 @@ libcxp_la_SOURCES = cxp-profile.c \ cxp-handler.c \ cxp-utils.c \ + cxp-about-dialog.c \ cxp-entry-dialog.c Index: libcxp/src/Makefile.in diff -u libcxp/src/Makefile.in:1.8 libcxp/src/Makefile.in:1.9 --- libcxp/src/Makefile.in:1.8 Thu Mar 31 02:57:00 2005 +++ libcxp/src/Makefile.in Sun Apr 10 04:11:49 2005 @@ -52,12 +52,13 @@ am__DEPENDENCIES_1 = libcxp_la_DEPENDENCIES = $(am__DEPENDENCIES_1) am_libcxp_la_OBJECTS = cxp-profile.lo cxp-handler.lo cxp-utils.lo \ - cxp-entry-dialog.lo + cxp-about-dialog.lo cxp-entry-dialog.lo libcxp_la_OBJECTS = $(am_libcxp_la_OBJECTS) DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles - @ AMDEP_TRUE@DEP_FILES = ./$(DEPDIR)/cxp-entry-dialog.Plo \ + @ AMDEP_TRUE@DEP_FILES = ./$(DEPDIR)/cxp-about-dialog.Plo \ + @ AMDEP_TRUE@ ./$(DEPDIR)/cxp-entry-dialog.Plo \ @AMDEP_TRUE@ ./$(DEPDIR)/cxp-handler.Plo \ @AMDEP_TRUE@ ./$(DEPDIR)/cxp-profile.Plo \ @AMDEP_TRUE@ ./$(DEPDIR)/cxp-utils.Plo @@ -220,6 +221,7 @@ libcxp_la_SOURCES = cxp-profile.c \ cxp-handler.c \ cxp-utils.c \ + cxp-about-dialog.c \ cxp-entry-dialog.c all: all-am @@ -291,6 +293,7 @@ distclean-compile: -rm -f *.tab.c + @ AMDEP_TRUE@@am__include@ @am__quote @ ./$(DEPDIR)/cxp-about-dialog.Plo @ am__quote@ @AMDEP_TRUE@@am__include@ @am__quote @ ./$(DEPDIR)/cxp-entry-dialog.Plo @ am__quote@ @AMDEP_TRUE@@am__include@ @am__quote @ ./$(DEPDIR)/cxp-handler.Plo @ am__quote@ @AMDEP_TRUE@@am__include@ @am__quote @ ./$(DEPDIR)/cxp-profile.Plo @ am__quote@ Index: libcxp/src/cxp-about-dialog.c diff -u /dev/null libcxp/src/cxp-about-dialog.c:1.1 --- /dev/null Sun Apr 10 04:11:49 2005 +++ libcxp/src/cxp-about-dialog.c Sun Apr 10 04:11:49 2005 @@ -0,0 +1,317 @@ +/*************************************************************************** + * cxp-about-dialog.c + * + * Sun Feb 13 23:50:30 2005 + * Copyright 2005 Yasumichi Akahoshi + * yasum****@users***** + ****************************************************************************/ + +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Library General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + + +#include "cxp-about-dialog.h" + +/* If you use Pimpls, include the private structure + * definition here. Some people create a cxp-property_dialog-private.h header + * which is included by the cxp-property_dialog.c file and which contains the + * definition for this private structure. + */ + +typedef struct +{ + gchar *title; + gchar *version; + gchar *url; + gchar *copyright; + gchar *image_file; + gboolean dispose_has_run; +} CxpAboutDialogPrivate; + +#define CXP_ABOUT_DIALOG_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), CXP_TYPE_ABOUT_DIALOG, CxpAboutDialogPrivate)) + +static GObjectClass *parent_class = NULL; + +enum +{ + CXP_ABOUT_DIALOG_APPNAME = 1, + CXP_ABOUT_DIALOG_VERSION, + CXP_ABOUT_DIALOG_URL, + CXP_ABOUT_DIALOG_COPYRIGHT, + CXP_ABOUT_DIALOG_IMAGE_FILE, +}; + +static void cxp_about_dialog_class_init (gpointer g_class, + gpointer g_class_data); +static GObject * cxp_about_dialog_constructor (GType type, guint n_construct_properties, GObjectConstructParam *construct_properties); +static void cxp_about_dialog_instance_init (GTypeInstance * instance, + gpointer g_class); +static void cxp_about_dialog_dispose (GObject * obj); +static void cxp_about_dialog_finalize (GObject * obj); +static void cxp_about_dialog_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec); +static void cxp_about_dialog_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec); + +static void cxp_about_dialog_class_init (gpointer g_class, + gpointer g_class_data) +{ + GObjectClass *gobject_class = G_OBJECT_CLASS (g_class); + CxpAboutDialogClass *dialog_class = CXP_ABOUT_DIALOG_CLASS(g_class); + GParamSpec *pspec; + + parent_class = g_type_class_peek_parent (g_class); + + gobject_class->constructor = cxp_about_dialog_constructor; + gobject_class->dispose = cxp_about_dialog_dispose; + gobject_class->finalize = cxp_about_dialog_finalize; + gobject_class->set_property = cxp_about_dialog_set_property; + gobject_class->get_property = cxp_about_dialog_get_property; + + /* install properties. */ + pspec = g_param_spec_string ("title", + "Application name", + "Set application name", + NULL, + G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE); + g_object_class_install_property (gobject_class, + CXP_ABOUT_DIALOG_APPNAME, pspec); + + pspec = g_param_spec_string ("version", + "application version", + "Set application version", + NULL, + G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE); + g_object_class_install_property (gobject_class, + CXP_ABOUT_DIALOG_VERSION, pspec); + + pspec = g_param_spec_string ("url", + "url of project page", + "Set url of project page", + NULL, + G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE); + g_object_class_install_property (gobject_class, + CXP_ABOUT_DIALOG_URL, pspec); + + pspec = g_param_spec_string ("copyright", + "copyleft", + "Set copyright", + NULL, + G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE); + g_object_class_install_property (gobject_class, + CXP_ABOUT_DIALOG_COPYRIGHT, pspec); + + pspec = g_param_spec_string ("image_file", + "fullpath of image file", + "Set fullpath of image file", + NULL, + G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE); + g_object_class_install_property (gobject_class, + CXP_ABOUT_DIALOG_IMAGE_FILE, pspec); + + g_type_class_add_private (dialog_class, sizeof (CxpAboutDialogPrivate)); +} + +static GObject * cxp_about_dialog_constructor (GType type, guint n_construct_properties, GObjectConstructParam *construct_properties) +{ + GObject *obj; + CxpAboutDialogClass *klass; + + klass = CXP_ABOUT_DIALOG_CLASS (g_type_class_peek (CXP_TYPE_ABOUT_DIALOG)); + obj = parent_class->constructor (type, + n_construct_properties, + construct_properties); + + cxp_about_dialog_instance_init(obj, klass); + + return obj; +} + +static void cxp_about_dialog_instance_init (GTypeInstance * instance, + gpointer g_class) +{ + CxpAboutDialog *self = CXP_ABOUT_DIALOG (instance); + CxpAboutDialogPrivate *private = CXP_ABOUT_DIALOG_GET_PRIVATE(instance); + GtkWidget *image; + GtkWidget *version_label; + GtkWidget *url_label; + GtkWidget *copyright_label; + GtkWidget *close_button; + + 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_CLOSE); + gtk_window_set_title (GTK_WINDOW(self), private->title); + + version_label = gtk_label_new (private->version); + gtk_box_pack_start (GTK_BOX(GTK_DIALOG(self)->vbox), version_label, TRUE, TRUE, 0); + gtk_label_set_justify (GTK_LABEL (version_label), GTK_JUSTIFY_LEFT); + gtk_widget_show (version_label); + gtk_widget_show (GTK_DIALOG(self)->vbox); + + + /* + URLLabel = gtk_label_new (_("http://cxplorer.sourceforge.jp/")); + gtk_box_pack_start (GTK_BOX (vbox2), URLLabel, TRUE, FALSE, 0); + gtk_label_set_justify (GTK_LABEL (URLLabel), GTK_JUSTIFY_LEFT); + gtk_widget_show (URLLabel); + label4 = gtk_label_new (_("Copyright 2003-2004 Cxplorer Project")); + gtk_box_pack_start (GTK_BOX (vbox2), label4, TRUE, FALSE, 0); + gtk_label_set_justify (GTK_LABEL (label4), GTK_JUSTIFY_LEFT); + gtk_widget_show (label4); + */ + + close_button = gtk_button_new_from_stock("gtk-close"); + gtk_dialog_add_action_widget (GTK_DIALOG (self), close_button, GTK_RESPONSE_CLOSE); + gtk_widget_show (close_button); +} + +static void cxp_about_dialog_dispose (GObject * obj) +{ + CxpAboutDialogPrivate *private = CXP_ABOUT_DIALOG_GET_PRIVATE(obj); + + if (private->dispose_has_run) + { + /* If dispose did already run, return. */ + return; + } + /* Make sure dispose does not run twice. */ + private->dispose_has_run = TRUE; + + /* + * In dispose, you are supposed to free all types referenced from this + * object which might themselves hold a reference to self. Generally, + * the most simple solution is to unref all members on which you own a + * reference. + */ + + /* Chain up to the parent class */ + G_OBJECT_CLASS (parent_class)->dispose (obj); +} + +static void cxp_about_dialog_finalize (GObject * obj) +{ + CxpAboutDialogPrivate *private = CXP_ABOUT_DIALOG_GET_PRIVATE(obj); + + g_free (private->title); + g_free (private->version); + g_free (private->url); + g_free (private->copyright); + g_free (private->image_file); + + /* Chain up to the parent class */ + G_OBJECT_CLASS (parent_class)->finalize (obj); +} + +GType cxp_about_dialog_get_type (void) +{ + static GType type = 0; + + if (type == 0) + { + static const GTypeInfo info = { + sizeof (CxpAboutDialogClass), + NULL, /* base_init */ + NULL, /* base_finalize */ + cxp_about_dialog_class_init, /* class_init */ + NULL, /* class_finalize */ + NULL, /* class_data */ + sizeof (CxpAboutDialog), + 0, /* n_preallocs */ + //cxp_about_dialog_instance_init /* instance_init */ + NULL /* instance_init */ + }; + type = g_type_register_static (GTK_TYPE_DIALOG, + "CxpAboutDialogType", + &info, 0); + } + return type; +} + +GtkWidget *cxp_about_dialog_new(const gchar *title, const gchar *version, const gchar *url, const gchar *copyright, const gchar *image_file) +{ + return GTK_WIDGET(g_object_new(CXP_TYPE_ABOUT_DIALOG, "title", title, "version", version, "url", url, "copyright", copyright, "image_file", image_file, NULL)); +} + +/* + + */ +static void cxp_about_dialog_set_property (GObject * object, + guint property_id, + const GValue * value, + GParamSpec * pspec) +{ + CxpAboutDialogPrivate *priv = CXP_ABOUT_DIALOG_GET_PRIVATE(object); + + switch (property_id) + { + case CXP_ABOUT_DIALOG_APPNAME: + g_free (priv->title); + priv->title = g_value_dup_string (value); + break; + case CXP_ABOUT_DIALOG_VERSION: + g_free (priv->version); + priv->version = g_value_dup_string (value); + break; + case CXP_ABOUT_DIALOG_URL: + g_free (priv->url); + priv->url = g_value_dup_string (value); + break; + case CXP_ABOUT_DIALOG_COPYRIGHT: + g_free (priv->copyright); + priv->copyright = g_value_dup_string (value); + break; + case CXP_ABOUT_DIALOG_IMAGE_FILE: + g_free (priv->image_file); + priv->image_file = g_value_dup_string (value); + break; + default: + /* We don't have any other property... */ + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + break; + } +} + +static void cxp_about_dialog_get_property (GObject * object, + guint property_id, + GValue * value, GParamSpec * pspec) +{ + CxpAboutDialogPrivate *priv = CXP_ABOUT_DIALOG_GET_PRIVATE(object); + + switch (property_id) + { + case CXP_ABOUT_DIALOG_APPNAME: + g_value_set_string (value, priv->title); + break; + case CXP_ABOUT_DIALOG_VERSION: + g_value_set_string (value, priv->version); + break; + case CXP_ABOUT_DIALOG_URL: + g_value_set_string (value, priv->url); + break; + case CXP_ABOUT_DIALOG_COPYRIGHT: + g_value_set_string (value, priv->copyright); + break; + case CXP_ABOUT_DIALOG_IMAGE_FILE: + g_value_set_string (value, priv->image_file); + break; + default: + /* We don't have any other property... */ + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + break; + } +} + +