Yasumichi Akahoshi
yasum****@users*****
2005年 8月 11日 (木) 00:59:23 JST
Index: libcxp/src/Makefile.am diff -u libcxp/src/Makefile.am:1.11 libcxp/src/Makefile.am:1.12 --- libcxp/src/Makefile.am:1.11 Thu Aug 11 00:05:12 2005 +++ libcxp/src/Makefile.am Thu Aug 11 00:59:23 2005 @@ -6,8 +6,7 @@ libcxp_la_LIBADD = $(GTK_LIBS) $(GCONF_LIBS) libcxp_la_LDFLAGS = -libcxp_la_SOURCES = cxp-profile.c \ - cxp-handler.c \ +libcxp_la_SOURCES = 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.12 libcxp/src/Makefile.in:1.13 --- libcxp/src/Makefile.in:1.12 Thu Aug 11 00:05:12 2005 +++ libcxp/src/Makefile.in Thu Aug 11 00:59:23 2005 @@ -51,11 +51,10 @@ LTLIBRARIES = $(lib_LTLIBRARIES) am__DEPENDENCIES_1 = libcxp_la_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) -am_libcxp_la_OBJECTS = cxp-profile.lo cxp-handler.lo cxp-utils.lo \ - cxp-about-dialog.lo cxp-entry-dialog.lo \ - cxp-gconf-pair-editor.lo xdgmime.lo xdgmimealias.lo \ - xdgmimecache.lo xdgmimeglob.lo xdgmimeint.lo xdgmimemagic.lo \ - xdgmimeparent.lo +am_libcxp_la_OBJECTS = cxp-handler.lo cxp-utils.lo cxp-about-dialog.lo \ + cxp-entry-dialog.lo cxp-gconf-pair-editor.lo xdgmime.lo \ + xdgmimealias.lo xdgmimecache.lo xdgmimeglob.lo xdgmimeint.lo \ + xdgmimemagic.lo xdgmimeparent.lo libcxp_la_OBJECTS = $(am_libcxp_la_OBJECTS) DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/depcomp @@ -64,7 +63,6 @@ @AMDEP_TRUE@ ./$(DEPDIR)/cxp-entry-dialog.Plo \ @AMDEP_TRUE@ ./$(DEPDIR)/cxp-gconf-pair-editor.Plo \ @AMDEP_TRUE@ ./$(DEPDIR)/cxp-handler.Plo \ - @ AMDEP_TRUE@ ./$(DEPDIR)/cxp-profile.Plo \ @AMDEP_TRUE@ ./$(DEPDIR)/cxp-utils.Plo ./$(DEPDIR)/xdgmime.Plo \ @AMDEP_TRUE@ ./$(DEPDIR)/xdgmimealias.Plo \ @AMDEP_TRUE@ ./$(DEPDIR)/xdgmimecache.Plo \ @@ -230,8 +228,7 @@ lib_LTLIBRARIES = libcxp.la libcxp_la_LIBADD = $(GTK_LIBS) $(GCONF_LIBS) libcxp_la_LDFLAGS = -libcxp_la_SOURCES = cxp-profile.c \ - cxp-handler.c \ +libcxp_la_SOURCES = cxp-handler.c \ cxp-utils.c \ cxp-about-dialog.c \ cxp-entry-dialog.c \ @@ -324,7 +321,6 @@ @AMDEP_TRUE@@am__include@ @am__quote @ ./$(DEPDIR)/cxp-entry-dialog.Plo @ am__quote@ @AMDEP_TRUE@@am__include@ @am__quote @ ./$(DEPDIR)/cxp-gconf-pair-editor.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@ @AMDEP_TRUE@@am__include@ @am__quote @ ./$(DEPDIR)/cxp-utils.Plo @ am__quote@ @AMDEP_TRUE@@am__include@ @am__quote @ ./$(DEPDIR)/xdgmime.Plo @ am__quote@ @AMDEP_TRUE@@am__include@ @am__quote @ ./$(DEPDIR)/xdgmimealias.Plo @ am__quote@ Index: libcxp/src/cxp-handler.c diff -u libcxp/src/cxp-handler.c:1.13 libcxp/src/cxp-handler.c:1.14 --- libcxp/src/cxp-handler.c:1.13 Fri Apr 22 01:16:47 2005 +++ libcxp/src/cxp-handler.c Thu Aug 11 00:59:23 2005 @@ -1,4 +1,4 @@ -/* $Id: cxp-handler.c,v 1.13 2005/04/21 16:16:47 yasumichi Exp $ */ +/* $Id: cxp-handler.c,v 1.14 2005/08/10 15:59:23 yasumichi Exp $ */ /** * \if japanese * @file @@ -6,7 +6,7 @@ * * @author 赤星 柔充 * @date Tue Mar 29 2005 - * $Revision: 1.13 $ + * $Revision: 1.14 $ * \endif * \if english * @file @@ -14,7 +14,7 @@ * * @author Yasumichi Akahoshi * @date Tue Mar 29 2005 - * $Revision: 1.13 $ + * $Revision: 1.14 $ * \endif */ @@ -40,8 +40,8 @@ #include <glib/gi18n-lib.h> #include <string.h> +#include <gconf/gconf-client.h> #include "cxp-utils.h" -#include "cxp-profile.h" #include "cxp-handler.h" #include "cxp-entry-dialog.h" @@ -51,7 +51,7 @@ */ typedef struct { - CxpProfile *profile; + GConfClient *client; gboolean dispose_has_run; /**< Is dispose funciton executed */ } CxpHandlerPrivate; @@ -120,7 +120,7 @@ bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); - priv->profile = cxp_profile_new ("common", "handler"); + priv->client = gconf_client_get_default (); priv->dispose_has_run = FALSE; } @@ -152,7 +152,7 @@ } priv->dispose_has_run = TRUE; - g_object_unref (priv->profile); + g_object_unref (priv->client); G_OBJECT_CLASS (parent_class)->dispose (obj); } @@ -251,8 +251,8 @@ void cxp_handler_launch (CxpHandler * handler, const gchar * fullpath) { CxpHandlerPrivate *priv = CXP_HANDLER_GET_PRIVATE(handler); - gchar *filename; - gchar *suffix = NULL; + gchar *gconf_dir; + gchar *mime_type; gchar *cmd = NULL; gchar *fullcmd; gchar *message; @@ -261,48 +261,31 @@ g_return_if_fail (fullpath != NULL); - filename = cxp_path_get_basename_of_utf8 (fullpath); - if ((suffix = g_strrstr (filename, ".")) != NULL) - { - cmd = cxp_profile_get_string (priv->profile, suffix); - if (cmd == NULL) - { - message = - g_strdup_printf (_ - ("Please input the command that opens the file whose extension is %s"), - suffix); - dialog = cxp_entry_dialog_new (_("Undefined extension"), - message, ""); - if (gtk_dialog_run (GTK_DIALOG (dialog)) == - GTK_RESPONSE_OK) - { - cmd = cxp_entry_dialog_get_entry_text - (CXP_ENTRY_DIALOG (dialog)); - if ((cmd != NULL) && (strlen (cmd) > 0)) - { - cxp_profile_set_string (priv-> profile, suffix, cmd); - } - } - gtk_widget_destroy (dialog); - g_free (message); - } - } - else + mime_type = cxp_get_mime_type_for_file (fullpath); + gconf_dir = g_strdup_printf ("/apps/cxp/mime-types/%s/open", mime_type); + cmd = gconf_client_get_string (priv->client, gconf_dir, NULL); + if (cmd == NULL) { message = g_strdup_printf (_ - ("Please input the command that opens file %s"), - filename); - dialog = cxp_entry_dialog_new (_("File without extension"), - message, ""); - if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_OK) + ("Please input the command that opens the file whose type is %s"), + mime_type); + dialog = cxp_entry_dialog_new (_("Undefined extension"), + message, ""); + if (gtk_dialog_run (GTK_DIALOG (dialog)) == + GTK_RESPONSE_OK) { - cmd = cxp_entry_dialog_get_entry_text (CXP_ENTRY_DIALOG - (dialog)); + cmd = cxp_entry_dialog_get_entry_text + (CXP_ENTRY_DIALOG (dialog)); + if ((cmd != NULL) && (strlen (cmd) > 0)) + { + gconf_client_set_string (priv->client, gconf_dir, cmd, NULL); + } } gtk_widget_destroy (dialog); g_free (message); } + g_free (mime_type); if ((cmd != NULL) && (strlen (cmd) > 0)) { @@ -312,5 +295,4 @@ g_free (fullcmd); } - g_free (filename); }