• R/O
  • SSH
  • HTTPS

tmaid: Commit


Commit MetaInfo

Revisión210 (tree)
Tiempo2013-05-29 04:05:20
Autoriwm

Log Message

(empty log message)

Cambiar Resumen

Diferencia incremental

--- tmaid/trunk/src/tmaid.c (revision 209)
+++ tmaid/trunk/src/tmaid.c (revision 210)
@@ -1,6 +1,6 @@
11 /*
22 Text maid
3- copyright (c) 1998-2011 Kazuki Iwamoto http://www.maid.org/ iwm@maid.org
3+ copyright (c) 1998-2013 Kazuki Iwamoto http://www.maid.org/ iwm@maid.org
44
55 This program is free software: you can redistribute it and/or modify
66 it under the terms of the GNU General Public License as published by
@@ -96,7 +96,7 @@
9696 char *argv[])
9797 {
9898 gboolean *arg_files, success[12];
99- const gchar *file;
99+ gchar *file;
100100 gint i, count = 0, init_line = 0;
101101 GList *glist;
102102 GObject *accel, *winmenu;
@@ -129,11 +129,13 @@
129129 SetErrorMode (SetErrorMode (0) | SEM_FAILCRITICALERRORS);
130130 #endif /* G_OS_WIN32 */
131131 setlocale (LC_ALL, "");
132-#if ! GTK_CHECK_VERSION(3,0,0)
132+#if ! GTK_CHECK_VERSION(2,24,0)
133133 gtk_set_locale ();
134-#endif /* not GTK_CHECK_VERSION(3,0,0) */
134+#endif /* not GTK_CHECK_VERSION(2,24,0) */
135135 gtk_init (&argc, &argv);
136- bindtextdomain (PACKAGE, misc_spec_locale (argv[0]));
136+ file = misc_spec_locale (argv[0]);
137+ bindtextdomain (PACKAGE, file);
138+ g_free (file);
137139 bind_textdomain_codeset (PACKAGE, "UTF-8");
138140 textdomain (PACKAGE);
139141
@@ -200,7 +202,10 @@
200202 newfile = arg_n.flag;
201203 /* ja:レジストリ */
202204 if (!arg_p.flag)
203- file = NULL;
205+ {
206+ g_free (file);
207+ file = NULL;
208+ }
204209 /* ja:ウインドウサイズ */
205210 def_width = array[0];
206211 def_height = array[1];
@@ -394,6 +399,7 @@
394399
395400 /* ja:キーファイルに書き込む */
396401 keyfile_write (file);
402+ g_free (file);
397403
398404 pango_font_description_free (system_font);
399405 g_free (clipboard_text);
--- tmaid/trunk/ChangeLog (revision 209)
+++ tmaid/trunk/ChangeLog (revision 210)
@@ -1,3 +1,7 @@
1+2013-05-29 Kazuki Iwamoto <iwm@maid.org>
2+
3+ * version 2.7.5
4+
15 2012-12-29 Kazuki Iwamoto <iwm@maid.org>
26
37 * version 2.7.4
--- tmaid/trunk/misc/gcommon.c (revision 209)
+++ tmaid/trunk/misc/gcommon.c (revision 210)
@@ -1,6 +1,6 @@
11 /*
22 gcommon
3- copyright (c) 1998-2012 Kazuki Iwamoto http://www.maid.org/ iwm@maid.org
3+ copyright (c) 1998-2013 Kazuki Iwamoto http://www.maid.org/ iwm@maid.org
44
55 This program is free software: you can redistribute it and/or modify
66 it under the terms of the GNU General Public License as published by
@@ -935,7 +935,7 @@
935935 const gchar *delimiter,
936936 gint max_tokens)
937937 {
938- GList *glist = NULL, *gl;
938+ GList *glist = NULL;
939939 gchar **ret, *s;
940940 guint n = 0;
941941 const gchar *remainder;
@@ -971,9 +971,11 @@
971971 ret = g_malloc ((n + 1) * sizeof (gchar *));
972972 ret[n] = NULL;
973973 n = 0;
974- for (gl = g_list_first (glist); gl; gl = g_list_next (gl))
975- ret[n++] = gl->data;
976- g_list_free (glist);
974+ while (glist)
975+ {
976+ ret[n++] = glist->data;
977+ glist = g_list_delete_link (glist, glist);
978+ }
977979
978980 return ret;
979981 }
@@ -2843,8 +2845,7 @@
28432845 }
28442846 }
28452847 str[j] = NULL;
2846- leng += g_strv_length (args) * len + 1;
2847- path = g_malloc (leng * sizeof (gchar));
2848+ path = g_malloc ((leng + j * len + 1) * sizeof (gchar));
28482849 path[0] = '\0';
28492850 for (i = 0; str[i]; i++)
28502851 {
@@ -2960,35 +2961,132 @@
29602961 # endif /* not G_OS_WIN32 */
29612962 }
29622963 #endif /* USE_GTK_EMULATE */
2964+
2965+
2966+#if ! GLIB_CHECK_VERSION(2,26,0)
2967+gchar *
2968+g_mkdtemp (gchar *tmpl)
2969+{
2970+ return g_mkdtemp_full (tmpl, 0700);
2971+}
2972+
2973+
2974+gchar *
2975+g_mkdtemp_full (gchar *tmpl,
2976+ gint mode)
2977+{
2978+ gchar *xxxxxx;
2979+ gint i;
2980+
2981+ if (!tmpl)
2982+ return NULL;
2983+ xxxxxx = g_strrstr (tmpl, "XXXXXX");
2984+ if (!xxxxxx)
2985+ {
2986+ errno = EINVAL;
2987+ return NULL;
2988+ }
2989+ for (i = 0; i < 1000000; i++)
2990+ {
2991+ gchar *p;
2992+ gint j, n;
2993+
2994+ p = xxxxxx + 5;
2995+ n = i;
2996+ for (j = 0; j < 6; j++)
2997+ {
2998+ *p = n % 10 + '0';
2999+ p--;
3000+ n /= 10;
3001+ }
3002+ if (g_mkdir (tmpl, mode) == 0)
3003+ return tmpl;
3004+ else if (errno != EEXIST)
3005+ return NULL;
3006+ }
3007+ errno = EEXIST;
3008+ return NULL;
3009+}
3010+#endif /* not GLIB_CHECK_VERSION(2,26,0) */
3011+
3012+
3013+#if ! GLIB_CHECK_VERSION(2,30,0)
3014+gchar *
3015+g_dir_make_tmp (const gchar *tmpl,
3016+ GError **error)
3017+{
3018+ gchar *tmplate;
3019+ const gchar *tmp;
3020+
3021+ if (tmpl)
3022+ {
3023+ if (g_strchr (tmpl, G_DIR_SEPARATOR)
3024+# ifdef G_OS_WIN32
3025+ || g_strchr (tmpl, '/')
3026+# endif /* G_OS_WIN32 */
3027+ || !g_strstr (tmpl, "XXXXXX"))
3028+ return NULL;
3029+ tmp = tmpl;
3030+ }
3031+ else
3032+ {
3033+ tmp = ".XXXXXX";
3034+ }
3035+ tmplate = g_build_filename (g_get_tmp_dir (), tmp, NULL);
3036+ if (!g_mkdtemp (tmplate))
3037+ {
3038+ g_free (tmplate);
3039+ return NULL;
3040+ }
3041+ return tmplate;
3042+}
3043+#endif /* not GLIB_CHECK_VERSION(2,30,0) */
3044+
3045+
29633046 #if ! GLIB_CHECK_VERSION(2,6,0) && defined (G_OS_WIN32)
29643047 gint
29653048 g_mkdir (const gchar *filename,
29663049 gint mode)
29673050 {
3051+ int err;
3052+ gint ret;
3053+ LPTSTR lpszFile;
29683054 # ifdef UNICODE
29693055 gchar *utf8str;
2970- gint ret;
2971- LPWSTR lpszFile;
3056+# endif /* UNICODE */
29723057
3058+# ifdef UNICODE
29733059 utf8str = g_filename_to_utf8 (filename, -1, NULL, NULL, NULL);
3060+ if (!utf8str)
3061+ {
3062+ errno = EINVAL;
3063+ return -1;
3064+ }
29743065 lpszFile = g_utf8_to_utf16 (utf8str, -1, NULL, NULL, NULL);
29753066 g_free (utf8str);
2976- ret = CreateDirectoryW (lpszFile, NULL);
3067+# else /* not UNICODE */
3068+ lpszFile = g_win32_locale_filename_from_utf8 (filename);
3069+# endif /* not UNICODE */
3070+ if (!lpszFile)
3071+ {
3072+ errno = EINVAL;
3073+ return -1;
3074+ }
3075+ ret = _tmkdir (lpszFile, mode);
3076+ err = errno;
29773077 g_free (lpszFile);
2978- return ret ? 0 : -1;
2979-# else /* UNICODE */
2980- return CreateDirectoryA (filename, NULL) ? 0 : -1;
2981-# endif /* UNICODE */
3078+ errno = err;
3079+ return ret;
29823080 }
29833081 #endif /* ! GLIB_CHECK_VERSION(2,6,0) && defined (G_OS_WIN32) */
29843082
29853083
2986-#if ! GLIB_CHECK_VERSION(2,8,0)
3084+#if ! GLIB_CHECK_VERSION(2,8,0) && defined (G_OS_WIN32)
29873085 gint
29883086 g_chmod (const gchar *filename,
29893087 gint mode)
29903088 {
2991-#ifdef G_OS_WIN32
3089+ int err;
29923090 gint ret;
29933091 LPTSTR lpszFile;
29943092 # ifdef UNICODE
@@ -3013,11 +3111,10 @@
30133111 return -1;
30143112 }
30153113 ret = _tchmod (lpszFile, mode);
3114+ err = errno;
30163115 g_free (lpszFile);
3116+ errno = err;
30173117 return ret;
3018-#else /* not G_OS_WIN32 */
3019- return chmod (filename, mode);
3020-#endif /* not G_OS_WIN32 */
30213118 }
30223119
30233120
@@ -3025,7 +3122,7 @@
30253122 g_access (const gchar *filename,
30263123 gint mode)
30273124 {
3028-#ifdef G_OS_WIN32
3125+ int err;
30293126 gint ret;
30303127 LPTSTR lpszFile;
30313128 # ifdef UNICODE
@@ -3050,11 +3147,10 @@
30503147 return -1;
30513148 }
30523149 ret = _taccess (lpszFile, mode);
3150+ err = errno;
30533151 g_free (lpszFile);
3152+ errno = err;
30543153 return ret;
3055-#else /* not G_OS_WIN32 */
3056- return access (filename, mode);
3057-#endif /* not G_OS_WIN32 */
30583154 }
30593155
30603156
@@ -3061,7 +3157,7 @@
30613157 gint g_creat (const gchar *filename,
30623158 gint mode)
30633159 {
3064-#ifdef G_OS_WIN32
3160+ int err;
30653161 gint ret;
30663162 LPTSTR lpszFile;
30673163 # ifdef UNICODE
@@ -3086,11 +3182,10 @@
30863182 return -1;
30873183 }
30883184 ret = _tcreat (lpszFile, mode);
3185+ err = errno;
30893186 g_free (lpszFile);
3187+ errno = err;
30903188 return ret;
3091-#else /* not G_OS_WIN32 */
3092- return creat (filename, mode);
3093-#endif /* not G_OS_WIN32 */
30943189 }
30953190
30963191
@@ -3097,7 +3192,7 @@
30973192 gint
30983193 g_chdir (const gchar *path)
30993194 {
3100-#ifdef G_OS_WIN32
3195+ int err;
31013196 gint ret;
31023197 LPTSTR lpszPath;
31033198 # ifdef UNICODE
@@ -3122,13 +3217,12 @@
31223217 return -1;
31233218 }
31243219 ret = _tchdir (lpszPath);
3220+ err = errno;
31253221 g_free (lpszPath);
3222+ errno = err;
31263223 return ret;
3127-#else /* not G_OS_WIN32 */
3128- return chdir (path);
3129-#endif /* not G_OS_WIN32 */
31303224 }
3131-#endif /* not GLIB_CHECK_VERSION(2,8,0) */
3225+#endif /* ! GLIB_CHECK_VERSION(2,8,0) && defined (G_OS_WIN32) */
31323226
31333227
31343228 #if ! GLIB_CHECK_VERSION(2,18,0)
@@ -3623,6 +3717,7 @@
36233717 glist = g_list_last (glist);
36243718 glist->next = gl;
36253719 gl->prev = glist;
3720+ gl = g_list_first (glist);
36263721 }
36273722 else
36283723 {
@@ -3656,6 +3751,46 @@
36563751
36573752
36583753 GList *
3754+g_list_insert (GList *glist,
3755+ gpointer data,
3756+ gint position)
3757+{
3758+ GList *gl;
3759+
3760+ if (position < 0 || !(gl = g_list_nth (glist, position)))
3761+ return g_list_append (glist, data);
3762+ glist = g_malloc (sizeof (GList));
3763+ glist->data = data;
3764+ glist->prev = gl->prev;
3765+ glist->next = gl;
3766+ if (gl->prev)
3767+ gl->prev->next = glist;
3768+ gl->prev = glist;
3769+ return g_list_first (glist);
3770+}
3771+
3772+
3773+GList *
3774+g_list_insert_before (GList *glist,
3775+ GList *sibling,
3776+ gpointer data)
3777+{
3778+ if (sibling)
3779+ {
3780+ glist = g_malloc (sizeof (GList));
3781+ glist->data = data;
3782+ glist->prev = sibling->prev;
3783+ glist->next = sibling;
3784+ if (sibling->prev)
3785+ sibling->prev->next = glist;
3786+ sibling->prev = glist;
3787+ return g_list_first (glist);
3788+ }
3789+ return g_list_append (glist, data);
3790+}
3791+
3792+
3793+GList *
36593794 g_list_insert_sorted (GList *glist,
36603795 gpointer data,
36613796 GCompareFunc compare)
@@ -3677,6 +3812,7 @@
36773812 if (glist->next)
36783813 glist->next->prev = gl;
36793814 glist->next = gl;
3815+ glist = g_list_first (glist);
36803816 }
36813817 else
36823818 {
@@ -3693,7 +3829,8 @@
36933829 {
36943830 GList *gl;
36953831
3696- for (gl = g_list_first (glist); gl; gl = g_list_next (gl))
3832+ glist = g_list_first (glist);
3833+ for (gl = glist; gl; gl = g_list_next (gl))
36973834 if (gl->data == data)
36983835 return g_list_delete_link (glist, gl);
36993836 return glist;
@@ -3704,8 +3841,6 @@
37043841 g_list_remove_link (GList *glist,
37053842 GList *glink)
37063843 {
3707- GList *gl = NULL;
3708-
37093844 if (glink)
37103845 {
37113846 if (glink->prev)
@@ -3712,10 +3847,10 @@
37123847 glink->prev->next = glink->next;
37133848 if (glink->next)
37143849 glink->next->prev = glink->prev;
3715- gl = glink->prev ? glink->prev : glink->next;
3850+ glist = glink->prev ? glink->prev : glink->next;
37163851 glink->prev = glink->next = NULL;
37173852 }
3718- return glist == glink ? gl : glist;
3853+ return g_list_first (glist);
37193854 }
37203855
37213856
@@ -3723,11 +3858,30 @@
37233858 g_list_delete_link (GList *glist,
37243859 GList *glink)
37253860 {
3861+ glist = g_list_remove_link (glist, glink);
3862+ g_free (glink);
3863+ return glist;
3864+}
3865+
3866+
3867+GList *
3868+g_list_remove_all (GList *glist,
3869+ gconstpointer data)
3870+{
37263871 GList *gl;
37273872
3728- gl = g_list_remove_link (glist, glink);
3729- g_free (glink);
3730- return gl;
3873+ gl = glist = g_list_first (glist);
3874+ while (gl)
3875+ {
3876+ GList *next;
3877+
3878+ next = g_list_next (gl);
3879+ if (gl->data == data)
3880+ glist = g_list_delete_link (glist, gl);
3881+ gl = next;
3882+ }
3883+ return glist;
3884+
37313885 }
37323886
37333887
@@ -3737,8 +3891,34 @@
37373891 while (glist)
37383892 glist = g_list_delete_link (glist, glist);
37393893 }
3894+#endif /* USE_GTK_EMULATE */
37403895
37413896
3897+#if ! GLIB_CHECK_VERSION(2,28,0)
3898+void g_list_free_full (GList *glist,
3899+ GDestroyNotify destroy)
3900+{
3901+ g_list_foreach (glist, (GFunc)destroy, NULL);
3902+ g_list_free (glist);
3903+}
3904+#endif /* not GLIB_CHECK_VERSION(2,28,0) */
3905+
3906+
3907+#ifdef USE_GTK_EMULATE
3908+GList *
3909+g_list_alloc (void)
3910+{
3911+ return g_malloc0 (sizeof (GList));
3912+}
3913+
3914+
3915+void
3916+g_list_free_1 (GList *glist)
3917+{
3918+ g_free (glist);
3919+}
3920+
3921+
37423922 guint
37433923 g_list_length (GList *glist)
37443924 {
@@ -3751,6 +3931,163 @@
37513931
37523932
37533933 GList *
3934+g_list_copy (GList *glist)
3935+{
3936+ GList *gl = NULL;
3937+
3938+ for (glist = g_list_first (glist); glist; glist = g_list_next (glist))
3939+ gl = g_list_append (gl, glist->data);
3940+ return gl;
3941+}
3942+#endif /* USE_GTK_EMULATE */
3943+
3944+
3945+#if ! GLIB_CHECK_VERSION(2,34,0)
3946+GList *
3947+g_list_copy_deep (GList *glist,
3948+ GCopyFunc func,
3949+ gpointer user_data)
3950+{
3951+ if (func)
3952+ {
3953+ GList *gl = NULL;
3954+
3955+ for (glist = g_list_first (glist); glist; glist = g_list_next (glist))
3956+ gl = g_list_append (gl, func (glist->data, user_data));
3957+ return gl;
3958+ }
3959+ return g_list_copy (glist);
3960+}
3961+#endif /* not GLIB_CHECK_VERSION(2,34,0) */
3962+
3963+
3964+#ifdef USE_GTK_EMULATE
3965+GList *
3966+g_list_reverse (GList *glist)
3967+{
3968+ GList *gl = NULL;
3969+
3970+ while (glist)
3971+ {
3972+ gl = glist;
3973+ glist = glist->next;
3974+ gl->next = gl->prev;
3975+ gl->prev = glist;
3976+ }
3977+ return gl;
3978+}
3979+
3980+
3981+GList *
3982+g_list_sort (GList *glist,
3983+ GCompareFunc compare_func)
3984+{
3985+ if (glist && compare_func)
3986+ {
3987+ glist = g_list_first (glist);
3988+ while (glist->next)
3989+ {
3990+ GList *gl, *glist_small;
3991+
3992+ gl = glist_small = glist;
3993+ while ((gl = g_list_next (gl)))
3994+ if (compare_func (gl->data, glist_small->data) < 0)
3995+ glist_small = gl;
3996+ if (glist != glist_small)
3997+ {
3998+ GList *prev, *next;
3999+
4000+ prev = glist->prev;
4001+ next = glist->next;
4002+ glist->prev = glist_small->prev;
4003+ glist->next = glist_small->next;
4004+ glist_small->prev = prev;
4005+ glist_small->next = next;
4006+ glist = glist_small;
4007+ }
4008+ glist = glist->next;
4009+ }
4010+ glist = g_list_first (glist);
4011+ }
4012+ return glist;
4013+}
4014+#endif /* USE_GTK_EMULATE */
4015+
4016+
4017+#if ! GLIB_CHECK_VERSION(2,10,0)
4018+GList *
4019+g_list_insert_sorted_with_data (GList *glist,
4020+ gpointer data,
4021+ GCompareDataFunc func,
4022+ gpointer user_data)
4023+{
4024+ if (func)
4025+ {
4026+ GList *gl;
4027+
4028+ for (gl = g_list_last (glist); gl; gl = g_list_previous (gl))
4029+ if (func (gl->data, data, user_data) <= 0)
4030+ break;
4031+ if (gl)
4032+ {
4033+ glist = gl;
4034+ gl = g_malloc (sizeof (GList));
4035+ gl->data = data;
4036+ gl->prev = glist;
4037+ gl->next = glist->next;
4038+ if (glist->next)
4039+ glist->next->prev = gl;
4040+ glist->next = gl;
4041+ glist = g_list_first (glist);
4042+ }
4043+ else
4044+ {
4045+ glist = g_list_prepend (glist, data);
4046+ }
4047+ }
4048+ return glist;
4049+}
4050+#endif /* not GLIB_CHECK_VERSION(2,10,0) */
4051+
4052+
4053+#ifdef USE_GTK_EMULATE
4054+GList *
4055+g_list_sort_with_data (GList *glist,
4056+ GCompareDataFunc compare_func,
4057+ gpointer user_data)
4058+{
4059+ if (glist && compare_func)
4060+ {
4061+ glist = g_list_first (glist);
4062+ while (glist->next)
4063+ {
4064+ GList *gl, *glist_small;
4065+
4066+ gl = glist_small = glist;
4067+ while ((gl = g_list_next (gl)))
4068+ if (compare_func (gl->data, glist_small->data, user_data) < 0)
4069+ glist_small = gl;
4070+ if (glist != glist_small)
4071+ {
4072+ GList *prev, *next;
4073+
4074+ prev = glist->prev;
4075+ next = glist->next;
4076+ glist->prev = glist_small->prev;
4077+ glist->next = glist_small->next;
4078+ glist_small->prev = prev;
4079+ glist_small->next = next;
4080+ glist = glist_small;
4081+ }
4082+ glist = glist->next;
4083+ }
4084+ glist = g_list_first (glist);
4085+ }
4086+ return glist;
4087+}
4088+
4089+
4090+GList *
37544091 g_list_concat (GList *glist1,
37554092 GList *glist2)
37564093 {
@@ -3761,10 +4098,30 @@
37614098 glist1->next = glist2;
37624099 glist2->prev = glist1;
37634100 }
3764- return glist1 ? glist1 : glist2;
4101+ return g_list_first (glist1 ? glist1 : glist2);
37654102 }
37664103
37674104
4105+void
4106+g_list_foreach (GList *glist,
4107+ GFunc func,
4108+ gpointer user_data)
4109+{
4110+ if (func)
4111+ {
4112+ glist = g_list_first (glist);
4113+ while (glist)
4114+ {
4115+ gpointer data;
4116+
4117+ data = glist->data;
4118+ glist = g_list_next (glist);
4119+ func (data, user_data);
4120+ }
4121+ }
4122+}
4123+
4124+
37684125 GList *
37694126 g_list_first (GList *glist)
37704127 {
@@ -3785,16 +4142,32 @@
37854142 }
37864143
37874144
4145+GList *
4146+g_list_nth (GList *glist,
4147+ guint n)
4148+{
4149+ while (glist && n-- > 0)
4150+ glist = g_list_next (glist);
4151+ return glist;
4152+}
4153+
4154+
37884155 gpointer
37894156 g_list_nth_data (GList *glist,
37904157 guint n)
37914158 {
3792- guint i;
3793- GList *gl;
4159+ glist = g_list_nth (glist, n);
4160+ return glist ? glist->data : NULL;
4161+}
37944162
3795- for (i = 0, gl = g_list_first (glist);
3796- i < n && gl; i++, gl = g_list_next (gl));
3797- return gl ? gl->data : NULL;
4163+
4164+GList *
4165+g_list_nth_prev (GList *glist,
4166+ guint n)
4167+{
4168+ while (glist && n-- > 0)
4169+ glist = g_list_previous (glist);
4170+ return glist;
37984171 }
37994172
38004173
@@ -3802,11 +4175,12 @@
38024175 g_list_find (GList *glist,
38034176 gconstpointer data)
38044177 {
3805- GList *gl;
3806-
3807- for (gl = g_list_first (glist); gl; gl = g_list_next (gl))
3808- if (gl->data == data)
3809- return gl;
4178+ while (glist)
4179+ {
4180+ if (glist->data == data)
4181+ return glist;
4182+ glist = g_list_next (glist);
4183+ }
38104184 return NULL;
38114185 }
38124186
@@ -3817,16 +4191,48 @@
38174191 GCompareFunc compare)
38184192 {
38194193 if (compare)
4194+ while (glist)
4195+ {
4196+ if (compare (glist->data, data) == 0)
4197+ return glist;
4198+ glist = g_list_next (glist);
4199+ }
4200+ return NULL;
4201+}
4202+
4203+
4204+gint
4205+g_list_position (GList *glist,
4206+ GList *llink)
4207+{
4208+ gint n = 0;
4209+
4210+ while (glist)
38204211 {
3821- while (glist)
3822- {
3823- if (compare (glist->data, data) == 0)
3824- return glist;
3825- glist = g_list_next (glist);
3826- }
4212+ if (glist == llink)
4213+ return n;
4214+ n++;
4215+ glist = g_list_next (glist);
38274216 }
3828- return NULL;
4217+ return -1;
38294218 }
4219+
4220+
4221+gint
4222+g_list_index (GList *glist,
4223+ gconstpointer data)
4224+{
4225+ gint n = 0;
4226+
4227+ while (glist)
4228+ {
4229+ if (glist->data == data)
4230+ return n;
4231+ n++;
4232+ glist = g_list_next (glist);
4233+ }
4234+ return -1;
4235+}
38304236 #endif /* USE_GTK_EMULATE */
38314237
38324238
@@ -3890,8 +4296,7 @@
38904296 GList *glist;
38914297
38924298 hash = hash_table->hash_func (key) & HASH_TABLE_MASK;
3893- for (glist = g_list_first (hash_table->glist[hash]);
3894- glist; glist = g_list_next (glist))
4299+ for (glist = hash_table->glist[hash]; glist; glist = g_list_next (glist))
38954300 {
38964301 GHashNode *node;
38974302
@@ -3983,7 +4388,7 @@
39834388 {
39844389 GList *glist;
39854390
3986- for (glist = g_list_first (hash_table->glist[i]);
4391+ for (glist = hash_table->glist[i];
39874392 glist; glist = g_list_next (glist))
39884393 {
39894394 GHashNode *node;
@@ -4006,8 +4411,7 @@
40064411 GList *glist;
40074412
40084413 hash = hash_table->hash_func (key) & HASH_TABLE_MASK;
4009- for (glist = g_list_first (hash_table->glist[hash]);
4010- glist; glist = g_list_next (glist))
4414+ for (glist = hash_table->glist[hash]; glist; glist = g_list_next (glist))
40114415 {
40124416 GHashNode *node;
40134417
@@ -4044,7 +4448,7 @@
40444448 {
40454449 GList *glist;
40464450
4047- glist = g_list_first (hash_table->glist[i]);
4451+ glist = hash_table->glist[i];
40484452 while (glist)
40494453 {
40504454 GList *gl;
@@ -4774,7 +5178,7 @@
47745178 g_strcspn (const gchar *s,
47755179 const gchar *reject)
47765180 {
4777- return s && reject ? strcspn (s, reject) : 0;
5181+ return !s ? 0 : !reject ? g_strlen (s) : strcspn (s, reject);
47785182 }
47795183
47805184
--- tmaid/trunk/misc/misc.h (revision 209)
+++ tmaid/trunk/misc/misc.h (revision 210)
@@ -1,6 +1,6 @@
11 /*
22 misc
3- copyright (c) 1998-2012 Kazuki Iwamoto http://www.maid.org/ iwm@maid.org
3+ copyright (c) 1998-2013 Kazuki Iwamoto http://www.maid.org/ iwm@maid.org
44
55 This program is free software: you can redistribute it and/or modify
66 it under the terms of the GNU General Public License as published by
@@ -25,177 +25,8 @@
2525 G_BEGIN_DECLS
2626
2727
28-#define MISC_CREATE_MENU_BAR 1
29-#define MISC_CREATE_MENU_SHELL 2
30-#define MISC_CREATE_MENU_SEPARATOR 3
31-#define MISC_CREATE_MENU_STOCK 4
32-#define MISC_CREATE_MENU_ITEM 5
33-#define MISC_CREATE_MENU_CHECK 6
34-#define MISC_CREATE_MENU_RADIO 7
35-#define MISC_CREATE_MENU_TERMINAL 0
36-#define MISC_CREATE_MENU_ELLIPSIS 8
37-#define MISC_CREATE_MENU_NOIMAGE 16
38-#define MISC_CREATE_MENU_DISABLE 32
39-#define MISC_CREATE_MENU_MASK 7
40-
41-
42-typedef struct _MiscCreateMenuEntry
43-{
44- gchar *path;
45- gchar *name;
46- gchar *accel;
47- const gchar **xpm;
48- guint menu_type;
49- void (*func) (GtkWidget *widget, gpointer user_data);
50- gpointer user_data;
51- GtkWidget *widget;
52-} MiscCreateMenuEntry;
53-typedef struct _MiscCreateToolbarEntry
54-{
55- gchar *path;
56- gchar *name;
57- const gchar **xpm;
58- void (*func) (GtkWidget *widget, gpointer user_data);
59- gpointer user_data;
60- GtkToolItem *tool_item;
61-} MiscCreateToolbarEntry;
62-
63-
6428 /******************************************************************************
6529 * *
66-* ja:メニュー/ツールバー関数群 *
67-* *
68-******************************************************************************/
69-/* ja:メニューを作成する
70- entries,メニュー構造体
71- accel_group,アクセルグループ */
72-void
73-misc_create_menu (MiscCreateMenuEntry *entries,
74- GtkAccelGroup *accel_group);
75-
76-
77-/* ja:メニューを検索する
78- entries,メニュー構造体
79- path,パス
80- RET,メニューアイテム */
81-GtkWidget *
82-misc_find_menu (MiscCreateMenuEntry *entries,
83- const gchar *path);
84-
85-
86-/* ja:ツールバーを作成する
87- entries,ツールバー構造体
88- RET,ツールバー */
89-GtkWidget *
90-misc_create_toolbar (MiscCreateToolbarEntry *entries);
91-
92-
93-/* ja:ツールバーを検索する
94- entries,ツールバー構造体
95- path,パス
96- RET,ツールアイテム */
97-GtkToolItem *
98-misc_find_toolbar (MiscCreateToolbarEntry *entries,
99- const gchar *path);
100-
101-
102-/******************************************************************************
103-* *
104-* ja:特定ファイル関数群 *
105-* *
106-******************************************************************************/
107-/* ja:ユーザ設定ファイルを取得する
108- group,グループ
109- name,アプリケーション名
110- file,ファイル名
111- RET,ユーザ設定ファイル */
112-const gchar *
113-misc_spec_config (const gchar *group,
114- const gchar *name,
115- const gchar *file);
116-
117-
118-/* ja:ロケールのディレクトリを取得する
119- prgname,プログラム
120- RET,ロケールのディレクトリ */
121-const gchar *
122-misc_spec_locale (const gchar *prgname);
123-
124-
125-/******************************************************************************
126-* *
127-* ja:クローズボタン関数群 *
128-* *
129-******************************************************************************/
130-/* ja:クローズボタンのイメージを取得する
131- RET,イメージ,NULL:エラー */
132-GtkWidget *
133-misc_close_image (void);
134-
135-
136-/* ja:クローズボタンを取得する
137- RET,ボタン,NULL:エラー */
138-GtkWidget *
139-misc_close_button (void);
140-
141-
142-/******************************************************************************
143-* *
144-* ja:低レベル関数群 *
145-* *
146-******************************************************************************/
147-/* ja:mnemonicをテキストに変換する
148- mnemonic,mnemonic
149- RET,テキスト */
150-gchar *
151-misc_mnemonic_to_text (const gchar *mnemonic);
152-
153-
154-/* ja:スクロールバーを設定する
155- scroll,スクロールウイジット
156- func,シグナル関数
157- func_data,データ
158- min,最小値
159- max,最大値
160- page,ページ
161- pos,位置 */
162-void
163-misc_set_scroll_bar (GtkWidget *scroll,
164- GCallback func,
165- gpointer func_data,
166- const gint min,
167- const gint max,
168- const gint page,
169- const gint pos);
170-
171-
172-/* ja:Windowの内容をスクロールする
173- widget,ウイジット
174- dx,X軸方向の移動
175- dy,Y軸方向の移動
176- x,スクロールする範囲の右上X座標
177- y,スクロールする範囲の右上Y座標
178- width,スクロールする範囲の幅
179- height,スクロールする範囲の高さ */
180-void
181-misc_scroll_window (GtkWidget *widget,
182- const gint dx,
183- const gint dy,
184- const gint x,
185- const gint y,
186- const gint width,
187- const gint height);
188-
189-
190-/* ja:ESCが押されたとき */
191-gboolean
192-misc_dialog_key_press (GtkWidget *widget,
193- GdkEventKey *event,
194- gpointer user_data);
195-
196-
197-/******************************************************************************
198-* *
19930 * ja:数値文字列関数群 *
20031 * *
20132 ******************************************************************************/
@@ -279,6 +110,29 @@
279110
280111 /******************************************************************************
281112 * *
113+* ja:特定ファイル関数群 *
114+* *
115+******************************************************************************/
116+/* ja:ユーザ設定ファイルを取得する
117+ group,グループ
118+ name,アプリケーション名
119+ file,ファイル名
120+ RET,ユーザ設定ファイル */
121+gchar *
122+misc_spec_config (const gchar *group,
123+ const gchar *name,
124+ const gchar *file);
125+
126+
127+/* ja:ロケールのディレクトリを取得する
128+ prgname,プログラム
129+ RET,ロケールのディレクトリ */
130+gchar *
131+misc_spec_locale (const gchar *prgname);
132+
133+
134+/******************************************************************************
135+* *
282136 * ja:日時文字列関数群 *
283137 * *
284138 ******************************************************************************/
@@ -354,6 +208,154 @@
354208 const gchar sign);
355209
356210
211+#ifndef USE_GTK_EMULATE
212+/******************************************************************************
213+* *
214+* ja:メニュー/ツールバー関数群 *
215+* *
216+******************************************************************************/
217+#define MISC_CREATE_MENU_BAR 1
218+#define MISC_CREATE_MENU_SHELL 2
219+#define MISC_CREATE_MENU_SEPARATOR 3
220+#define MISC_CREATE_MENU_STOCK 4
221+#define MISC_CREATE_MENU_ITEM 5
222+#define MISC_CREATE_MENU_CHECK 6
223+#define MISC_CREATE_MENU_RADIO 7
224+#define MISC_CREATE_MENU_TERMINAL 0
225+#define MISC_CREATE_MENU_ELLIPSIS 8
226+#define MISC_CREATE_MENU_NOIMAGE 16
227+#define MISC_CREATE_MENU_DISABLE 32
228+#define MISC_CREATE_MENU_MASK 7
229+
230+
231+typedef struct _MiscCreateMenuEntry
232+{
233+ gchar *path;
234+ gchar *name;
235+ gchar *accel;
236+ const gchar **xpm;
237+ guint menu_type;
238+ void (*func) (GtkWidget *widget, gpointer user_data);
239+ gpointer user_data;
240+ GtkWidget *widget;
241+} MiscCreateMenuEntry;
242+typedef struct _MiscCreateToolbarEntry
243+{
244+ gchar *path;
245+ gchar *name;
246+ const gchar **xpm;
247+ void (*func) (GtkWidget *widget, gpointer user_data);
248+ gpointer user_data;
249+ GtkToolItem *tool_item;
250+} MiscCreateToolbarEntry;
251+
252+
253+/* ja:メニューを作成する
254+ entries,メニュー構造体
255+ accel_group,アクセルグループ */
256+void
257+misc_create_menu (MiscCreateMenuEntry *entries,
258+ GtkAccelGroup *accel_group);
259+
260+
261+/* ja:メニューを検索する
262+ entries,メニュー構造体
263+ path,パス
264+ RET,メニューアイテム */
265+GtkWidget *
266+misc_find_menu (MiscCreateMenuEntry *entries,
267+ const gchar *path);
268+
269+
270+/* ja:ツールバーを作成する
271+ entries,ツールバー構造体
272+ RET,ツールバー */
273+GtkWidget *
274+misc_create_toolbar (MiscCreateToolbarEntry *entries);
275+
276+
277+/* ja:ツールバーを検索する
278+ entries,ツールバー構造体
279+ path,パス
280+ RET,ツールアイテム */
281+GtkToolItem *
282+misc_find_toolbar (MiscCreateToolbarEntry *entries,
283+ const gchar *path);
284+
285+
286+/******************************************************************************
287+* *
288+* ja:クローズボタン関数群 *
289+* *
290+******************************************************************************/
291+/* ja:クローズボタンのイメージを取得する
292+ RET,イメージ,NULL:エラー */
293+GtkWidget *
294+misc_close_image (void);
295+
296+
297+/* ja:クローズボタンを取得する
298+ RET,ボタン,NULL:エラー */
299+GtkWidget *
300+misc_close_button (void);
301+
302+
303+/******************************************************************************
304+* *
305+* ja:低レベル関数群 *
306+* *
307+******************************************************************************/
308+/* ja:mnemonicをテキストに変換する
309+ mnemonic,mnemonic
310+ RET,テキスト */
311+gchar *
312+misc_mnemonic_to_text (const gchar *mnemonic);
313+
314+
315+/* ja:スクロールバーを設定する
316+ scroll,スクロールウイジット
317+ func,シグナル関数
318+ func_data,データ
319+ min,最小値
320+ max,最大値
321+ page,ページ
322+ pos,位置 */
323+void
324+misc_set_scroll_bar (GtkWidget *scroll,
325+ GCallback func,
326+ gpointer func_data,
327+ const gint min,
328+ const gint max,
329+ const gint page,
330+ const gint pos);
331+
332+
333+/* ja:Windowの内容をスクロールする
334+ widget,ウイジット
335+ dx,X軸方向の移動
336+ dy,Y軸方向の移動
337+ x,スクロールする範囲の右上X座標
338+ y,スクロールする範囲の右上Y座標
339+ width,スクロールする範囲の幅
340+ height,スクロールする範囲の高さ */
341+void
342+misc_scroll_window (GtkWidget *widget,
343+ const gint dx,
344+ const gint dy,
345+ const gint x,
346+ const gint y,
347+ const gint width,
348+ const gint height);
349+
350+
351+/* ja:ESCが押されたとき */
352+gboolean
353+misc_dialog_key_press (GtkWidget *widget,
354+ GdkEventKey *event,
355+ gpointer user_data);
356+#endif /* not USE_GTK_EMULATE */
357+
358+
357359 G_END_DECLS
358360
359361
--- tmaid/trunk/misc/gcommon.h (revision 209)
+++ tmaid/trunk/misc/gcommon.h (revision 210)
@@ -1,6 +1,6 @@
11 /*
22 gcommon
3- copyright (c) 1998-2012 Kazuki Iwamoto http://www.maid.org/ iwm@maid.org
3+ copyright (c) 1998-2013 Kazuki Iwamoto http://www.maid.org/ iwm@maid.org
44
55 This program is free software: you can redistribute it and/or modify
66 it under the terms of the GNU General Public License as published by
@@ -1474,6 +1474,13 @@
14741474 #endif /* not GLIB_CHECK_VERSION(2,26,0) */
14751475
14761476
1477+#if ! GLIB_CHECK_VERSION(2,26,0)
1478+gchar *g_mkdtemp (gchar *tmpl);
1479+gchar *g_mkdtemp_full (gchar *tmpl, gint mode);
1480+#endif /* not GLIB_CHECK_VERSION(2,26,0) */
1481+#if ! GLIB_CHECK_VERSION(2,30,0)
1482+gchar *g_dir_make_tmp (const gchar *tmpl, GError **error);
1483+#endif /* not GLIB_CHECK_VERSION(2,30,0) */
14771484 #if ! GLIB_CHECK_VERSION(2,22,0)
14781485 # define g_mapped_file_unref(file) g_mapped_file_free(file)
14791486 #endif /* not GLIB_CHECK_VERSION(2,22,0) */
@@ -1498,10 +1505,17 @@
14981505 # define g_freopen freopen
14991506 #endif /* not GLIB_CHECK_VERSION(2,6,0) */
15001507 #if ! GLIB_CHECK_VERSION(2,8,0)
1508+# ifdef G_OS_WIN32
15011509 gint g_chmod (const gchar *filename, gint mode);
15021510 gint g_access (const gchar *filename, gint mode);
15031511 gint g_creat (const gchar *filename, gint mode);
15041512 gint g_chdir (const gchar *path);
1513+# else /* not G_OS_WIN32 */
1514+# define g_chmod chmod
1515+# define g_access access
1516+# define g_creat creat
1517+# define g_chdir chdir
1518+# endif /* not G_OS_WIN32 */
15051519 #endif /* not GLIB_CHECK_VERSION(2,8,0) */
15061520 #if ! GLIB_CHECK_VERSION(2,18,0)
15071521 # ifdef G_OS_WIN32
@@ -1583,25 +1597,63 @@
15831597 struct _GList *prev;
15841598 struct _GList *next;
15851599 } GList;
1600+typedef gint (*GCompareDataFunc) (gconstpointer a, gconstpointer b, gpointer user_data);
15861601 typedef gint (*GCompareFunc) (gconstpointer a, gconstpointer b);
1602+#endif /* USE_GTK_EMULATE */
1603+#if ! GLIB_CHECK_VERSION(2,4,0)
1604+typedef gpointer (*GCopyFunc) (gconstpointer src, gpointer data);
1605+#endif /* not GLIB_CHECK_VERSION(2,4,0) */
1606+#ifdef USE_GTK_EMULATE
1607+typedef void (*GDestroyNotify) (gpointer data);
1608+typedef void (*GFunc) (gpointer data, gpointer user_data);
15871609
15881610
15891611 GList *g_list_append (GList *list, gpointer data);
15901612 GList *g_list_prepend (GList *glist, gpointer data);
1613+GList *g_list_insert (GList *glist, gpointer data, gint position);
1614+GList *g_list_insert_before (GList *glist, GList *sibling, gpointer data);
15911615 GList *g_list_insert_sorted (GList *glist, gpointer data, GCompareFunc compare);
15921616 GList *g_list_remove (GList *glist, gconstpointer data);
15931617 GList *g_list_remove_link (GList *glist, GList *glink);
15941618 GList *g_list_delete_link (GList *glist, GList *glink);
1619+GList *g_list_remove_all (GList *glist, gconstpointer data);
15951620 void g_list_free (GList *glist);
1621+#endif /* USE_GTK_EMULATE */
1622+#if ! GLIB_CHECK_VERSION(2,28,0)
1623+void g_list_free_full (GList *glist, GDestroyNotify destroy);
1624+#endif /* not GLIB_CHECK_VERSION(2,28,0) */
1625+#ifdef USE_GTK_EMULATE
1626+GList *g_list_alloc (void);
1627+void g_list_free_1 (GList *glist);
1628+# define g_list_free1 g_list_free_1
15961629 guint g_list_length (GList *glist);
1630+GList *g_list_copy (GList *glist);
1631+#endif /* USE_GTK_EMULATE */
1632+#if ! GLIB_CHECK_VERSION(2,34,0)
1633+GList *g_list_copy_deep (GList *glist, GCopyFunc func, gpointer user_data);
1634+#endif /* not GLIB_CHECK_VERSION(2,34,0) */
1635+#ifdef USE_GTK_EMULATE
1636+GList *g_list_reverse (GList *glist);
1637+GList *g_list_sort (GList *glist, GCompareFunc compare_func);
1638+#endif /* USE_GTK_EMULATE */
1639+#if ! GLIB_CHECK_VERSION(2,10,0)
1640+GList *g_list_insert_sorted_with_data (GList *glist, gpointer data, GCompareDataFunc func, gpointer user_data);
1641+#endif /* not GLIB_CHECK_VERSION(2,10,0) */
1642+#ifdef USE_GTK_EMULATE
1643+GList *g_list_sort_with_data (GList *glist, GCompareDataFunc compare_func, gpointer user_data);
15971644 GList *g_list_concat (GList *glist1, GList *glist2);
1645+void g_list_foreach (GList *glist, GFunc func, gpointer user_data);
15981646 GList *g_list_first (GList *glist);
15991647 GList *g_list_last (GList *glist);
16001648 # define g_list_previous(glist) ((glist)?((GList *)(glist))->prev:NULL)
16011649 # define g_list_next(glist) ((glist)?((GList *)(glist))->next:NULL)
1650+GList *g_list_nth (GList *glist, guint n);
16021651 gpointer g_list_nth_data (GList *glist, guint n);
1652+GList *g_list_nth_prev (GList *glist, guint n);
16031653 GList *g_list_find (GList *glist, gconstpointer data);
16041654 GList *g_list_find_custom (GList *glist, gconstpointer data, GCompareFunc compare);
1655+gint g_list_position (GList *glist, GList *llink);
1656+gint g_list_index (GList *glist, gconstpointer data);
16051657 #endif /* USE_GTK_EMULATE */
16061658
16071659
@@ -1614,7 +1666,6 @@
16141666 typedef gboolean (*GEqualFunc) (gconstpointer a, gconstpointer b);
16151667 typedef void (*GHFunc) (gpointer key, gpointer value, gpointer user_data);
16161668 typedef gboolean (*GHRFunc) (gpointer key, gpointer value, gpointer user_data);
1617-typedef void (*GDestroyNotify) (gpointer data);
16181669
16191670
16201671 GHashTable *g_hash_table_new (GHashFunc hash_func, GEqualFunc key_equal_func);
--- tmaid/trunk/misc/misc.c (revision 209)
+++ tmaid/trunk/misc/misc.c (revision 210)
@@ -1,6 +1,6 @@
11 /*
22 misc
3- copyright (c) 1998-2012 Kazuki Iwamoto http://www.maid.org/ iwm@maid.org
3+ copyright (c) 1998-2013 Kazuki Iwamoto http://www.maid.org/ iwm@maid.org
44
55 This program is free software: you can redistribute it and/or modify
66 it under the terms of the GNU General Public License as published by
@@ -26,749 +26,6 @@
2626
2727 /******************************************************************************
2828 * *
29-* ja:メニュー/ツールバー関数群 *
30-* *
31-******************************************************************************/
32-/* ja:メニューを作成する
33- entries,メニュー構造体
34- accel_group,アクセルグループ */
35-void
36-misc_create_menu (MiscCreateMenuEntry *entries,
37- GtkAccelGroup *accel_group)
38-{
39- gint i;
40-
41- for (i = 0; (entries[i].menu_type & MISC_CREATE_MENU_MASK)
42- != MISC_CREATE_MENU_TERMINAL; i++)
43- switch (entries[i].menu_type & MISC_CREATE_MENU_MASK)
44- {
45- case MISC_CREATE_MENU_BAR:
46- entries[i].widget = gtk_menu_bar_new ();
47- break;
48- case MISC_CREATE_MENU_SHELL:
49- {
50- gchar *path, *p;
51- gint j;
52-
53- entries[i].widget = gtk_menu_new ();
54- path = g_strdup (entries[i].path);
55- p = g_strrchr (path, '/');
56- *p = '\0';
57- for (j = 0; j < i; j++)
58- if (g_strcmp (entries[j].path, path) == 0)
59- {
60- gtk_menu_item_set_submenu (GTK_MENU_ITEM (entries[j].widget),
61- entries[i].widget);
62- break;
63- }
64- g_free (path);
65- }
66- break;
67- default:
68- {
69- gchar *path, *p;
70- gint j;
71-
72- switch (entries[i].menu_type & MISC_CREATE_MENU_MASK)
73- {
74- case MISC_CREATE_MENU_STOCK:
75- if (entries[i].menu_type & MISC_CREATE_MENU_NOIMAGE)
76- {
77- GtkStockItem stock_item;
78-
79- gtk_stock_lookup (entries[i].name, &stock_item);
80- entries[i].widget = gtk_image_menu_item_new_with_mnemonic
81- (stock_item.label);
82- }
83- else
84- {
85- entries[i].widget = gtk_image_menu_item_new_from_stock
86- (entries[i].name,
87- entries[i].accel ? NULL : accel_group);
88- }
89- break;
90- case MISC_CREATE_MENU_ITEM:
91- if (entries[i].xpm
92- && !(entries[i].menu_type & MISC_CREATE_MENU_NOIMAGE))
93- {
94- GdkPixbuf *pixbuf;
95-
96- entries[i].widget = gtk_image_menu_item_new_with_mnemonic
97- (_(entries[i].name));
98- pixbuf = gdk_pixbuf_new_from_xpm_data (entries[i].xpm);
99- gtk_image_menu_item_set_image
100- (GTK_IMAGE_MENU_ITEM (entries[i].widget),
101- gtk_image_new_from_pixbuf (pixbuf));
102- g_object_unref (pixbuf);
103- }
104- else
105- {
106- entries[i].widget = gtk_menu_item_new_with_mnemonic
107- (_(entries[i].name));
108- }
109- break;
110- case MISC_CREATE_MENU_CHECK:
111- entries[i].widget = gtk_check_menu_item_new_with_mnemonic
112- (_(entries[i].name));
113- break;
114- case MISC_CREATE_MENU_RADIO:
115- entries[i].widget = gtk_radio_menu_item_new_with_mnemonic
116- (i > 0
117- && (entries[i - 1].menu_type & MISC_CREATE_MENU_MASK)
118- == MISC_CREATE_MENU_RADIO
119- ? gtk_radio_menu_item_get_group
120- (GTK_RADIO_MENU_ITEM (entries[i - 1].widget))
121- : NULL, _(entries[i].name));
122- break;
123- default:
124- entries[i].widget = gtk_separator_menu_item_new ();
125- }
126- if (entries[i].menu_type & MISC_CREATE_MENU_ELLIPSIS)
127- {
128- gchar *mnemonic;
129- GtkWidget *label;
130-
131- label = gtk_bin_get_child (GTK_BIN (entries[i].widget));
132- mnemonic = g_strconcat
133- (gtk_label_get_label (GTK_LABEL (label)), "...", NULL);
134- gtk_label_set_text_with_mnemonic (GTK_LABEL (label), mnemonic);
135- g_free (mnemonic);
136- }
137- path = g_strdup (entries[i].path);
138- p = g_strrchr (path, '/') + 1 ;
139- *p = '\0';
140- for (j = 0; j < i; j++)
141- if (g_strcmp (entries[j].path, path) == 0)
142- {
143- gtk_menu_shell_append (GTK_MENU_SHELL (entries[j].widget),
144- entries[i].widget);
145- break;
146- }
147- g_free (path);
148- if (accel_group && entries[i].accel && entries[i].accel[0] != '\0')
149- {
150- guint key;
151- GdkModifierType mods;
152-
153- gtk_accelerator_parse (entries[i].accel, &key, &mods);
154- gtk_widget_add_accelerator (entries[i].widget, "activate",
155- accel_group, key, mods,
156- GTK_ACCEL_VISIBLE | GTK_ACCEL_LOCKED);
157- }
158- if (entries[i].func)
159- g_signal_connect (G_OBJECT (entries[i].widget),
160- (entries[i].menu_type & MISC_CREATE_MENU_MASK)
161- == MISC_CREATE_MENU_CHECK
162- || (entries[i].menu_type & MISC_CREATE_MENU_MASK)
163- == MISC_CREATE_MENU_RADIO
164- ? "toggled" : "activate",
165- G_CALLBACK (entries[i].func), entries[i].user_data);
166- if (entries[i].menu_type & MISC_CREATE_MENU_DISABLE)
167- gtk_widget_set_sensitive (entries[i].widget, FALSE);
168- }
169- }
170-}
171-
172-
173-/* ja:メニューを検索する
174- entries,メニュー構造体
175- path,パス
176- RET,メニューアイテム */
177-GtkWidget *
178-misc_find_menu (MiscCreateMenuEntry *entries,
179- const gchar *path)
180-{
181- gint i;
182-
183- for (i = 0; entries[i].menu_type != MISC_CREATE_MENU_TERMINAL; i++)
184- if (g_strcmp (entries[i].path, path) == 0)
185- return entries[i].widget;
186- return NULL;
187-}
188-
189-
190-/* ja:ツールバーを作成する
191- entries,ツールバー構造体
192- RET,ツールバー */
193-GtkWidget *
194-misc_create_toolbar (MiscCreateToolbarEntry *entries)
195-{
196- gint i;
197-#if ! GTK_CHECK_VERSION(2,12,0)
198- GtkTooltips *tooltips;
199-#endif /* not GTK_CHECK_VERSION(2,12,0) */
200- GtkWidget *toolbar;
201-
202- toolbar = gtk_toolbar_new ();
203-#if GTK_CHECK_VERSION(2,16,0)
204- gtk_orientable_set_orientation (GTK_ORIENTABLE (toolbar),
205- GTK_ORIENTATION_HORIZONTAL);
206-#else /* not GTK_CHECK_VERSION(2,16,0) */
207- gtk_toolbar_set_orientation (GTK_TOOLBAR (toolbar),
208- GTK_ORIENTATION_HORIZONTAL);
209-#endif /* not GTK_CHECK_VERSION(2,16,0) */
210- gtk_toolbar_set_style (GTK_TOOLBAR (toolbar), GTK_TOOLBAR_ICONS);
211-#if ! GTK_CHECK_VERSION(2,14,0)
212- gtk_toolbar_set_tooltips (GTK_TOOLBAR (toolbar), TRUE);
213-#endif /* not GTK_CHECK_VERSION(2,14,0) */
214-#if GTK_CHECK_VERSION(2,4,0)
215- gtk_toolbar_set_show_arrow (GTK_TOOLBAR (toolbar), FALSE);
216-#endif /* GTK_CHECK_VERSION(2,4,0) */
217-#if ! GTK_CHECK_VERSION(2,12,0)
218- tooltips = gtk_tooltips_new ();
219-#endif /* not GTK_CHECK_VERSION(2,12,0) */
220- for (i = 0; entries[i].path; i++)
221- {
222- if (entries[i].name)
223- {
224- if (entries[i].xpm)
225- {
226- GdkPixbuf *pixbuf;
227-
228- pixbuf = gdk_pixbuf_new_from_xpm_data (entries[i].xpm);
229-#if GTK_CHECK_VERSION(2,4,0)
230- entries[i].tool_item = gtk_tool_button_new
231- (gtk_image_new_from_pixbuf (pixbuf), _(entries[i].name));
232-# if GTK_CHECK_VERSION(2,12,0)
233- gtk_tool_item_set_tooltip_text (entries[i].tool_item,
234- _(entries[i].name));
235-# else /* not GTK_CHECK_VERSION(2,12,0) */
236- gtk_tool_item_set_tooltip (entries[i].tool_item, tooltips,
237- _(entries[i].name), _(entries[i].name));
238-# endif /* not GTK_CHECK_VERSION(2,12,0) */
239-#else /* not GTK_CHECK_VERSION(2,4,0) */
240- entries[i].tool_item = gtk_toolbar_append_item
241- (GTK_TOOLBAR (toolbar),
242- _(entries[i].name),
243- _(entries[i].name),
244- _(entries[i].name),
245- gtk_image_new_from_pixbuf (pixbuf),
246- G_CALLBACK (entries[i].func),
247- NULL);
248-#endif /* not GTK_CHECK_VERSION(2,4,0) */
249- g_object_unref (pixbuf);
250- }
251- else
252- {
253- gchar *text;
254- GtkStockItem stock_item;
255-
256- gtk_stock_lookup (entries[i].name, &stock_item);
257- text = misc_mnemonic_to_text (stock_item.label);
258-#if GTK_CHECK_VERSION(2,4,0)
259- entries[i].tool_item = gtk_tool_button_new_from_stock
260- (entries[i].name);
261-# if GTK_CHECK_VERSION(2,12,0)
262- gtk_tool_item_set_tooltip_text (entries[i].tool_item, text);
263-# else /* not GTK_CHECK_VERSION(2,12,0) */
264- gtk_tool_item_set_tooltip (entries[i].tool_item, tooltips,
265- text, text);
266-# endif /* not GTK_CHECK_VERSION(2,12,0) */
267-#else /* not GTK_CHECK_VERSION(2,4,0) */
268- entries[i].tool_item = gtk_toolbar_insert_stock
269- (GTK_TOOLBAR (toolbar),
270- entries[i].name,
271- text,
272- text,
273- G_CALLBACK (entries[i].func),
274- NULL,
275- -1);
276-#endif /* not GTK_CHECK_VERSION(2,4,0) */
277- g_free (text);
278- }
279-#if GTK_CHECK_VERSION(2,4,0)
280- if (entries[i].func)
281- g_signal_connect (G_OBJECT (entries[i].tool_item), "clicked",
282- G_CALLBACK (entries[i].func), entries[i].user_data);
283-#endif /* GTK_CHECK_VERSION(2,4,0) */
284- }
285- else
286- {
287-#if GTK_CHECK_VERSION(2,4,0)
288- entries[i].tool_item = gtk_separator_tool_item_new ();
289-#else /* not GTK_CHECK_VERSION(2,4,0) */
290- gtk_toolbar_append_space (GTK_TOOLBAR (toolbar));
291-#endif /* not GTK_CHECK_VERSION(2,4,0) */
292- }
293-#if GTK_CHECK_VERSION(2,4,0)
294- gtk_toolbar_insert (GTK_TOOLBAR (toolbar), entries[i].tool_item, i);
295-#endif /* GTK_CHECK_VERSION(2,4,0) */
296- }
297- return toolbar;
298-}
299-
300-
301-/* ja:ツールバーを検索する
302- entries,ツールバー構造体
303- path,パス
304- RET,ツールアイテム */
305-GtkToolItem *
306-misc_find_toolbar (MiscCreateToolbarEntry *entries,
307- const gchar *path)
308-{
309- gint i;
310-
311- for (i = 0; entries[i].path; i++)
312- if (g_strcmp (entries[i].path, path) == 0)
313- return entries[i].tool_item;
314- return NULL;
315-}
316-
317-
318-/******************************************************************************
319-* *
320-* ja:特定ファイル関数群 *
321-* *
322-******************************************************************************/
323-/* ja:ユーザ設定ファイルを取得する
324- group,グループ
325- name,アプリケーション名
326- file,ファイル名
327- RET,ユーザ設定ファイル */
328-const gchar *
329-misc_spec_config (const gchar *group,
330- const gchar *name,
331- const gchar *file)
332-{
333- const static gchar *config = NULL;
334- gchar *filename;
335-#if ! GLIB_CHECK_VERSION(2,6,0) && defined (G_OS_WIN32)
336- LPITEMIDLIST pidl = NULL;
337-#endif /* ! GLIB_CHECK_VERSION(2,6,0) && defined (G_OS_WIN32) */
338-
339- if (config)
340- return config;
341-#ifdef G_OS_WIN32
342- filename = g_strconcat (file, ".ini", NULL);
343-# if GLIB_CHECK_VERSION(2,6,0)
344- config = g_build_filename (g_get_user_config_dir (),
345- group, name, filename, NULL);
346- if (!config)
347- {
348- LPITEMIDLIST pidl = NULL;
349-# endif /* GLIB_CHECK_VERSION(2,6,0) */
350- if (SHGetSpecialFolderLocation (NULL, CSIDL_APPDATA, &pidl) == S_OK)
351- {
352-# if ! GLIB_CHECK_VERSION(2,6,0)
353- TCHAR szPath[MAX_PATH + 1];
354-# endif /* not GLIB_CHECK_VERSION(2,6,0) */
355-
356-# if GLIB_CHECK_VERSION(2,6,0)
357- if (G_WIN32_HAVE_WIDECHAR_API ())
358- {
359- WCHAR szPath[MAX_PATH + 1];
360-# endif /* GLIB_CHECK_VERSION(2,6,0) */
361-# if GLIB_CHECK_VERSION(2,6,0) || defined (UNICODE)
362- if (SHGetPathFromIDListW (pidl, szPath))
363- {
364- gchar *utf8str;
365-
366- utf8str = g_utf16_to_utf8 (szPath, -1, NULL, NULL, NULL);
367- if (utf8str)
368- {
369- gchar *dir;
370-
371- dir = g_filename_from_utf8
372- (utf8str, -1, NULL, NULL, NULL);
373- g_free (utf8str);
374- if (dir)
375- {
376- config = g_build_filename
377- (dir, group, name, filename, NULL);
378- g_free (dir);
379- }
380- }
381- }
382-# endif /* GLIB_CHECK_VERSION(2,6,0) || defined (UNICODE) */
383-# if GLIB_CHECK_VERSION(2,6,0)
384- }
385- else
386- {
387- CHAR szPath[MAX_PATH + 1];
388-# endif /* GLIB_CHECK_VERSION(2,6,0) */
389-# if GLIB_CHECK_VERSION(2,6,0) || ! defined (UNICODE)
390- if (SHGetPathFromIDListA (pidl, szPath))
391-# if GLIB_CHECK_VERSION(2,6,0)
392- {
393- gchar *utf8str;
394-
395- utf8str = g_locale_to_utf8 (szPath, -1, NULL, NULL, NULL);
396- if (utf8str)
397- {
398- gchar *path;
399-
400- path = g_filename_from_utf8
401- (utf8str, -1, NULL, NULL, NULL);
402- if (path)
403- {
404- config = g_build_filename
405- (path, group, name, filename, NULL);
406- g_free (path);
407- }
408- g_free (utf8str);
409- }
410- }
411-# else /* not GLIB_CHECK_VERSION(2,6,0) */
412- config = g_build_filename
413- (szPath, group, name, filename, NULL);
414-# endif /* not GLIB_CHECK_VERSION(2,6,0) */
415-# endif /* GLIB_CHECK_VERSION(2,6,0) || ! defined (UNICODE) */
416-# if GLIB_CHECK_VERSION(2,6,0)
417- }
418-# endif /* GLIB_CHECK_VERSION(2,6,0) */
419- CoTaskMemFree (pidl);
420- }
421-# if GLIB_CHECK_VERSION(2,6,0)
422- }
423-# else /* not GLIB_CHECK_VERSION(2,6,0) */
424- else
425- {
426- config = NULL;
427- }
428-# endif /* not GLIB_CHECK_VERSION(2,6,0) */
429- if (!config)
430- config = g_build_filename (g_get_home_dir (), group, name, filename, NULL);
431-#else /* not G_OS_WIN32 */
432- gchar *dir;
433-
434- dir = g_strconcat (".", group, NULL);
435- filename = g_strconcat (file, ".conf", NULL);
436- config = g_build_filename (g_get_home_dir (), dir, name, filename, NULL);
437- g_free (dir);
438-#endif /* not G_OS_WIN32 */
439- g_free (filename);
440- return config;
441-}
442-
443-
444-/* ja:ロケールのディレクトリを取得する
445- prgname,プログラム
446- RET,ロケールのディレクトリ */
447-const gchar *
448-misc_spec_locale (const gchar *prgname)
449-{
450-#ifdef LOCALEDIR
451- return LOCALEDIR;
452-#else /* not LOCALEDIR */
453- static gchar *locale = NULL;
454- gchar *dirname, *path;
455-# ifdef G_OS_WIN32
456- gchar *tmp;
457-# endif /* G_OS_WIN32 */
458-
459- if (locale)
460- return locale;
461- path = fileio_get_full_path (prgname);
462- dirname = g_path_get_dirname (path);
463- g_free (path);
464- locale = g_build_filename (dirname, "locale", NULL);
465- g_free (dirname);
466-# ifdef G_OS_WIN32
467- if (!g_file_test (locale, G_FILE_TEST_EXISTS))
468- {
469- g_free (locale);
470-# if GLIB_CHECK_VERSION(2,16,0)
471- dirname = g_win32_get_package_installation_directory_of_module (NULL);
472- locale = g_build_filename (dirname, "share", "locale", NULL);
473- g_free (dirname);
474-# else /* not GLIB_CHECK_VERSION(2,16,0) */
475- locale = g_win32_get_package_installation_subdirectory
476- (NULL, prgname, "share" G_DIR_SEPARATOR_S "locale");
477-# endif /* not GLIB_CHECK_VERSION(2,16,0) */
478- }
479- tmp = g_win32_locale_filename_from_utf8 (locale);
480- g_free (locale);
481- locale = tmp;
482-# endif /* G_OS_WIN32 */
483- return locale;
484-#endif /* not LOCALEDIR */
485-}
486-
487-
488-/******************************************************************************
489-* *
490-* ja:クローズボタン関数群 *
491-* *
492-******************************************************************************/
493-/* ja:クローズボタンのイメージを取得する
494- RET,イメージ,NULL:エラー */
495-GtkWidget *
496-misc_close_image (void)
497-{
498- GtkIconSet *icon_set;
499- GtkWidget *image = NULL;
500-
501- icon_set = gtk_icon_factory_lookup_default (GTK_STOCK_CLOSE);
502- if (icon_set)
503- {
504- GdkPixbuf *pixbuf;
505-
506- pixbuf = gtk_icon_set_render_icon (icon_set,
507- gtk_widget_get_default_style (),
508- GTK_TEXT_DIR_NONE,
509- GTK_STATE_NORMAL,
510- GTK_ICON_SIZE_MENU,
511- NULL, NULL);
512- if (pixbuf)
513- {
514- if (gdk_pixbuf_get_colorspace (pixbuf) == GDK_COLORSPACE_RGB
515- && gdk_pixbuf_get_n_channels (pixbuf) == 4
516- && gdk_pixbuf_get_has_alpha (pixbuf)
517- && gdk_pixbuf_get_bits_per_sample (pixbuf) == 8)
518- {
519- int width, height, rowstride;
520- gint x, y, left, top, right, bottom;
521- guchar *pixels;
522-
523- pixels = gdk_pixbuf_get_pixels (pixbuf);
524- width = gdk_pixbuf_get_width (pixbuf);
525- height = gdk_pixbuf_get_height (pixbuf);
526- rowstride = gdk_pixbuf_get_rowstride (pixbuf);
527- for (x = 0; x < width; x++)
528- for (y = 0; y < height; y++)
529- if (pixels[y * rowstride + x * 4 + 3] > 0)
530- goto loop_left;
531- loop_left: left = x;
532- for (y = 0; y < height; y++)
533- for (x = 0; x < width; x++)
534- if (pixels[y * rowstride + x * 4 + 3] > 0)
535- goto loop_top;
536- loop_top: top = y;
537- for (x = width - 1; x >= 0; x--)
538- for (y = 0; y < height; y++)
539- if (pixels[y * rowstride + x * 4 + 3] > 0)
540- goto loop_right;
541- loop_right: right = x;
542- for (y = height - 1; y >= 0; y--)
543- for (x = 0; x < width; x++)
544- if (pixels[y * rowstride + x * 4 + 3] > 0)
545- goto loop_bottom;
546- loop_bottom: bottom = y;
547- if (left <= right && top <= bottom)
548- {
549- int w, h, r;
550- guchar *p;
551- gint i;
552- GdkPixbuf *b;
553-
554- w = right - left + 1;
555- h = bottom - top + 1;
556- b = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, w, h);
557- p = gdk_pixbuf_get_pixels (b);
558- r = gdk_pixbuf_get_rowstride (b);
559- for (x = 0; x < w; x++)
560- for (y = 0; y < h; y++)
561- for (i = 0; i < 4; i++)
562- p[y * r + x * 4 + i]
563- = pixels[(y + top) * rowstride + (x + left) * 4 + i];
564- image = gtk_image_new_from_pixbuf (b);
565- g_object_unref (b);
566- }
567- }
568- g_object_unref (pixbuf);
569- }
570- }
571- if (!image)
572- image = gtk_image_new_from_stock (GTK_STOCK_CLOSE, GTK_ICON_SIZE_MENU);
573- if (!image)
574- {
575- GdkPixbuf *pixbuf;
576- const static gchar *xpm[] = {
577-"12 13 4 1",
578-" c None",
579-"X c #000000",
580-"+ c #808080",
581-". c #FFFFFF",
582-"+++++++++++.",
583-"+.........+.",
584-"+. +.",
585-"+.XX XX+.",
586-"+. XX XX +.",
587-"+. XXXX +.",
588-"+. XX +.",
589-"+. XXXX +.",
590-"+. XX XX +.",
591-"+.XX XX+.",
592-"+. +.",
593-"+++++++++++.",
594-"............"};
595-
596- pixbuf = gdk_pixbuf_new_from_xpm_data (xpm);
597- image = gtk_image_new_from_pixbuf (pixbuf);
598- g_object_unref (pixbuf);
599- }
600- return image;
601-}
602-
603-
604-/* ja:クローズボタンを取得する
605- RET,ボタン,NULL:エラー */
606-GtkWidget *
607-misc_close_button (void)
608-{
609- GtkWidget *button = NULL, *image;
610-
611- image = misc_close_image ();
612- if (image)
613- {
614- button = gtk_button_new ();
615- gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE);
616- gtk_container_add (GTK_CONTAINER (button), image);
617- gtk_widget_show (image);
618- }
619- return button;
620-}
621-
622-
623-/******************************************************************************
624-* *
625-* ja:低レベル関数群 *
626-* *
627-******************************************************************************/
628-/* ja:mnemonicをテキストに変換する
629- mnemonic,mnemonic
630- RET,テキスト */
631-gchar *
632-misc_mnemonic_to_text (const gchar *mnemonic)
633-{
634- gchar *text;
635- gint i;
636-
637- if (!mnemonic)
638- return NULL;
639- text = g_strdup (mnemonic);
640- for (i = 0; text[i] != '\0'; i++)
641- if (text[i] == '(' && text[i + 1] == '_'
642- && g_ascii_isalpha (text[i + 2]) && text[i + 3] == ')')
643- {
644- g_memmove (text + i, text + i + 4, g_strlen (text + i) - 3);
645- break;
646- }
647- else if (text[i] == '_' && g_ascii_isalpha (text[i + 1]))
648- {
649- g_memmove (text + i, text + i + 2, g_strlen (text + i) - 1);
650- break;
651- }
652- return text;
653-}
654-
655-
656-/* ja:スクロールバーを設定する
657- scroll,スクロールウイジット
658- func,シグナル関数
659- func_data,データ
660- min,最小値
661- max,最大値
662- page,ページ
663- pos,位置 */
664-void
665-misc_set_scroll_bar (GtkWidget *scroll,
666- GCallback func,
667- gpointer func_data,
668- const gint min,
669- const gint max,
670- const gint page,
671- const gint pos)
672-{
673- GtkAdjustment *adjust;
674-
675- adjust = GTK_ADJUSTMENT (gtk_adjustment_new (pos, min, max, 1, page, page));
676- gtk_range_set_adjustment (GTK_RANGE (scroll), adjust);
677- if (func)
678- g_signal_connect (G_OBJECT (adjust), "value-changed", func, func_data);
679-}
680-
681-
682-/* ja:Windowの内容をスクロールする
683- widget,ウイジット
684- dx,X軸方向の移動
685- dy,Y軸方向の移動
686- x,スクロールする範囲の右上X座標
687- y,スクロールする範囲の右上Y座標
688- width,スクロールする範囲の幅
689- height,スクロールする範囲の高さ */
690-void
691-misc_scroll_window (GtkWidget *widget,
692- const gint dx,
693- const gint dy,
694- const gint x,
695- const gint y,
696- const gint width,
697- const gint height)
698-{
699- if (ABS (dx) > width || ABS (dy) > height)
700- {
701- gtk_widget_queue_draw_area (widget, x, y, width, height);
702- }
703- else if (dx != 0 || dy != 0)
704- {
705-#if GTK_CHECK_VERSION(2,24,0)
706- cairo_t *cr;
707- gint w, h, xx, yy;
708- GdkPixbuf *pixbuf;
709- GdkWindow *window;
710-
711- window = gtk_widget_get_window (widget);
712- cr = gdk_cairo_create (window);
713- w = width - ABS (dx);
714- h = height - ABS (dy);
715-# if GTK_CHECK_VERSION(3,0,0)
716- pixbuf = gdk_pixbuf_get_from_window (window,
717- dx > 0 ? x : x - dx, dy > 0 ? y : y - dy, w, h);
718-# else /* not GTK_CHECK_VERSION(3,0,0) */
719- pixbuf = gdk_pixbuf_get_from_drawable (NULL, window,
720- gdk_colormap_get_system (),
721- dx > 0 ? x : x - dx, dy > 0 ? y : y - dy,
722- 0, 0, w, h);
723-# endif /* not GTK_CHECK_VERSION(3,0,0) */
724- xx = dx > 0 ? x + dx : x;
725- yy = dy > 0 ? y + dy : y;
726- gdk_cairo_set_source_pixbuf (cr, pixbuf, xx, yy);
727- g_object_unref (pixbuf);
728- cairo_rectangle (cr, xx, yy, w, h);
729- cairo_fill (cr);
730- cairo_destroy (cr);
731-#else /* not GTK_CHECK_VERSION(2,24,0) */
732- GdkGC *gc;
733-
734- gc = gdk_gc_new (gtk_widget_get_window (widget));
735- gdk_gc_set_exposures (gc, TRUE);
736- gdk_draw_drawable (gtk_widget_get_window (widget),
737- gc,
738- gtk_widget_get_window (widget),
739- dx > 0 ? x : x - dx,
740- dy > 0 ? y : y - dy,
741- dx > 0 ? x + dx : x,
742- dy > 0 ? y + dy : y,
743- width - ABS (dx),
744- height - ABS (dy));
745- g_object_unref (gc);
746-#endif /* not GTK_CHECK_VERSION(2,24,0) */
747- if (dx != 0)
748- gtk_widget_queue_draw_area (widget, dx > 0 ? x : x + width + dx, y,
749- ABS (dx), height);
750- if (dy != 0)
751- gtk_widget_queue_draw_area (widget, x, dy > 0 ? y : y + height + dy,
752- width, ABS (dy));
753- }
754- gdk_window_process_updates (gtk_widget_get_window (widget), TRUE);
755-}
756-
757-
758-/* ja:ESCが押されたとき */
759-gboolean
760-misc_dialog_key_press (GtkWidget *widget,
761- GdkEventKey *event,
762- gpointer user_data)
763-{
764- if (event->keyval == GDK_KEY_Escape)
765- gtk_dialog_response (GTK_DIALOG (widget), GTK_RESPONSE_NONE);
766- return FALSE;
767-}
768-
769-
770-/******************************************************************************
771-* *
77229 * ja:数値文字列関数群 *
77330 * *
77431 ******************************************************************************/
@@ -1196,6 +453,81 @@
1196453
1197454 /******************************************************************************
1198455 * *
456+* ja:特定ファイル関数群 *
457+* *
458+******************************************************************************/
459+/* ja:ユーザ設定ファイルを取得する
460+ group,グループ
461+ name,アプリケーション名
462+ file,ファイル名
463+ RET,ユーザ設定ファイル */
464+gchar *
465+misc_spec_config (const gchar *group,
466+ const gchar *name,
467+ const gchar *file)
468+{
469+ gchar *config, *filename;
470+
471+#ifdef G_OS_WIN32
472+ filename = g_strconcat (file, ".ini", NULL);
473+ config = g_build_filename (g_get_user_config_dir (),
474+ group, name, filename, NULL);
475+#else /* not G_OS_WIN32 */
476+ gchar *dir;
477+
478+ dir = g_strconcat (".", group, NULL);
479+ filename = g_strconcat (file, ".conf", NULL);
480+ config = g_build_filename (g_get_home_dir (), dir, name, filename, NULL);
481+ g_free (dir);
482+#endif /* not G_OS_WIN32 */
483+ g_free (filename);
484+ return config;
485+}
486+
487+
488+/* ja:ロケールのディレクトリを取得する
489+ prgname,プログラム
490+ RET,ロケールのディレクトリ */
491+gchar *
492+misc_spec_locale (const gchar *prgname)
493+{
494+#ifdef LOCALEDIR
495+ return g_strdup (LOCALEDIR);
496+#else /* not LOCALEDIR */
497+ gchar *locale, *dirname, *path;
498+# ifdef G_OS_WIN32
499+ gchar *tmp;
500+# endif /* G_OS_WIN32 */
501+
502+ path = fileio_get_full_path (prgname);
503+ dirname = g_path_get_dirname (path);
504+ g_free (path);
505+ locale = g_build_filename (dirname, "locale", NULL);
506+ g_free (dirname);
507+# ifdef G_OS_WIN32
508+ if (!g_file_test (locale, G_FILE_TEST_EXISTS))
509+ {
510+ g_free (locale);
511+# if GLIB_CHECK_VERSION(2,16,0)
512+ dirname = g_win32_get_package_installation_directory_of_module (NULL);
513+ locale = g_build_filename (dirname, "share", "locale", NULL);
514+ g_free (dirname);
515+# else /* not GLIB_CHECK_VERSION(2,16,0) */
516+ locale = g_win32_get_package_installation_subdirectory
517+ (NULL, prgname, "share" G_DIR_SEPARATOR_S "locale");
518+# endif /* not GLIB_CHECK_VERSION(2,16,0) */
519+ }
520+ tmp = g_win32_locale_filename_from_utf8 (locale);
521+ g_free (locale);
522+ locale = tmp;
523+# endif /* G_OS_WIN32 */
524+ return locale;
525+#endif /* not LOCALEDIR */
526+}
527+
528+
529+/******************************************************************************
530+* *
1199531 * ja:日時文字列関数群 *
1200532 * *
1201533 ******************************************************************************/
@@ -1304,9 +636,8 @@
1304636 glong value;
1305637
1306638 value = g_strtol (cymdhms, &endptr, 0);
1307- if (g_strcasecmp (endptr, "u") == 0)
639+ if (g_ascii_strcasecmp (endptr, "u") == 0)
1308640 dt0 = g_date_time_new_from_unix_utc (value);
1309-
1310641 }
1311642 else
1312643 {
@@ -1321,7 +652,7 @@
1321652 gdouble value;
1322653
1323654 value = g_strtod (tmp, &endptr);
1324- if (g_strcasecmp (endptr, "s") == 0)
655+ if (g_ascii_strcasecmp (endptr, "s") == 0)
1325656 dt0 = g_date_time_add_seconds (dt1, value);
1326657 }
1327658 else
@@ -1330,15 +661,15 @@
1330661 glong value;
1331662
1332663 value = g_strtol (tmp, &endptr, 0);
1333- if (g_strcasecmp (endptr, "y") == 0)
664+ if (g_ascii_strcasecmp (endptr, "y") == 0)
1334665 dt0 = g_date_time_add_years (dt1, value);
1335666 else if (g_strcmp (endptr, "M") == 0)
1336667 dt0 = g_date_time_add_months (dt1, value);
1337- else if (g_strcasecmp (endptr, "w") == 0)
668+ else if (g_ascii_strcasecmp (endptr, "w") == 0)
1338669 dt0 = g_date_time_add_weeks (dt1, value);
1339- else if (g_strcasecmp (endptr, "d") == 0)
670+ else if (g_ascii_strcasecmp (endptr, "d") == 0)
1340671 dt0 = g_date_time_add_days (dt1, value);
1341- else if (g_strcasecmp (endptr, "h") == 0)
672+ else if (g_ascii_strcasecmp (endptr, "h") == 0)
1342673 dt0 = g_date_time_add_hours (dt1, value);
1343674 else if (g_strcmp (endptr, "m") == 0)
1344675 dt0 = g_date_time_add_minutes (dt1, value);
@@ -1446,3 +777,578 @@
1446777 }
1447778 return epoch;
1448779 }
780+
781+
782+#ifndef USE_GTK_EMULATE
783+/******************************************************************************
784+* *
785+* ja:メニュー/ツールバー関数群 *
786+* *
787+******************************************************************************/
788+/* ja:メニューを作成する
789+ entries,メニュー構造体
790+ accel_group,アクセルグループ */
791+void
792+misc_create_menu (MiscCreateMenuEntry *entries,
793+ GtkAccelGroup *accel_group)
794+{
795+ gint i;
796+
797+ for (i = 0; (entries[i].menu_type & MISC_CREATE_MENU_MASK)
798+ != MISC_CREATE_MENU_TERMINAL; i++)
799+ switch (entries[i].menu_type & MISC_CREATE_MENU_MASK)
800+ {
801+ case MISC_CREATE_MENU_BAR:
802+ entries[i].widget = gtk_menu_bar_new ();
803+ break;
804+ case MISC_CREATE_MENU_SHELL:
805+ {
806+ gchar *path, *p;
807+ gint j;
808+
809+ entries[i].widget = gtk_menu_new ();
810+ path = g_strdup (entries[i].path);
811+ p = g_strrchr (path, '/');
812+ *p = '\0';
813+ for (j = 0; j < i; j++)
814+ if (g_strcmp (entries[j].path, path) == 0)
815+ {
816+ gtk_menu_item_set_submenu (GTK_MENU_ITEM (entries[j].widget),
817+ entries[i].widget);
818+ break;
819+ }
820+ g_free (path);
821+ }
822+ break;
823+ default:
824+ {
825+ gchar *path, *p;
826+ gint j;
827+
828+ switch (entries[i].menu_type & MISC_CREATE_MENU_MASK)
829+ {
830+ case MISC_CREATE_MENU_STOCK:
831+ if (entries[i].menu_type & MISC_CREATE_MENU_NOIMAGE)
832+ {
833+ GtkStockItem stock_item;
834+
835+ gtk_stock_lookup (entries[i].name, &stock_item);
836+ entries[i].widget = gtk_image_menu_item_new_with_mnemonic
837+ (stock_item.label);
838+ }
839+ else
840+ {
841+ entries[i].widget = gtk_image_menu_item_new_from_stock
842+ (entries[i].name,
843+ entries[i].accel ? NULL : accel_group);
844+ }
845+ break;
846+ case MISC_CREATE_MENU_ITEM:
847+ if (entries[i].xpm
848+ && !(entries[i].menu_type & MISC_CREATE_MENU_NOIMAGE))
849+ {
850+ GdkPixbuf *pixbuf;
851+
852+ entries[i].widget = gtk_image_menu_item_new_with_mnemonic
853+ (_(entries[i].name));
854+ pixbuf = gdk_pixbuf_new_from_xpm_data (entries[i].xpm);
855+ gtk_image_menu_item_set_image
856+ (GTK_IMAGE_MENU_ITEM (entries[i].widget),
857+ gtk_image_new_from_pixbuf (pixbuf));
858+ g_object_unref (pixbuf);
859+ }
860+ else
861+ {
862+ entries[i].widget = gtk_menu_item_new_with_mnemonic
863+ (_(entries[i].name));
864+ }
865+ break;
866+ case MISC_CREATE_MENU_CHECK:
867+ entries[i].widget = gtk_check_menu_item_new_with_mnemonic
868+ (_(entries[i].name));
869+ break;
870+ case MISC_CREATE_MENU_RADIO:
871+ entries[i].widget = gtk_radio_menu_item_new_with_mnemonic
872+ (i > 0
873+ && (entries[i - 1].menu_type & MISC_CREATE_MENU_MASK)
874+ == MISC_CREATE_MENU_RADIO
875+ ? gtk_radio_menu_item_get_group
876+ (GTK_RADIO_MENU_ITEM (entries[i - 1].widget))
877+ : NULL, _(entries[i].name));
878+ break;
879+ default:
880+ entries[i].widget = gtk_separator_menu_item_new ();
881+ }
882+ if (entries[i].menu_type & MISC_CREATE_MENU_ELLIPSIS)
883+ {
884+ gchar *mnemonic;
885+ GtkWidget *label;
886+
887+ label = gtk_bin_get_child (GTK_BIN (entries[i].widget));
888+ mnemonic = g_strconcat
889+ (gtk_label_get_label (GTK_LABEL (label)), "...", NULL);
890+ gtk_label_set_text_with_mnemonic (GTK_LABEL (label), mnemonic);
891+ g_free (mnemonic);
892+ }
893+ path = g_strdup (entries[i].path);
894+ p = g_strrchr (path, '/') + 1 ;
895+ *p = '\0';
896+ for (j = 0; j < i; j++)
897+ if (g_strcmp (entries[j].path, path) == 0)
898+ {
899+ gtk_menu_shell_append (GTK_MENU_SHELL (entries[j].widget),
900+ entries[i].widget);
901+ break;
902+ }
903+ g_free (path);
904+ if (accel_group && entries[i].accel && entries[i].accel[0] != '\0')
905+ {
906+ guint key;
907+ GdkModifierType mods;
908+
909+ gtk_accelerator_parse (entries[i].accel, &key, &mods);
910+ gtk_widget_add_accelerator (entries[i].widget, "activate",
911+ accel_group, key, mods,
912+ GTK_ACCEL_VISIBLE | GTK_ACCEL_LOCKED);
913+ }
914+ if (entries[i].func)
915+ g_signal_connect (G_OBJECT (entries[i].widget),
916+ (entries[i].menu_type & MISC_CREATE_MENU_MASK)
917+ == MISC_CREATE_MENU_CHECK
918+ || (entries[i].menu_type & MISC_CREATE_MENU_MASK)
919+ == MISC_CREATE_MENU_RADIO
920+ ? "toggled" : "activate",
921+ G_CALLBACK (entries[i].func), entries[i].user_data);
922+ if (entries[i].menu_type & MISC_CREATE_MENU_DISABLE)
923+ gtk_widget_set_sensitive (entries[i].widget, FALSE);
924+ }
925+ }
926+}
927+
928+
929+/* ja:メニューを検索する
930+ entries,メニュー構造体
931+ path,パス
932+ RET,メニューアイテム */
933+GtkWidget *
934+misc_find_menu (MiscCreateMenuEntry *entries,
935+ const gchar *path)
936+{
937+ gint i;
938+
939+ for (i = 0; entries[i].menu_type != MISC_CREATE_MENU_TERMINAL; i++)
940+ if (g_strcmp (entries[i].path, path) == 0)
941+ return entries[i].widget;
942+ return NULL;
943+}
944+
945+
946+/* ja:ツールバーを作成する
947+ entries,ツールバー構造体
948+ RET,ツールバー */
949+GtkWidget *
950+misc_create_toolbar (MiscCreateToolbarEntry *entries)
951+{
952+ gint i;
953+#if ! GTK_CHECK_VERSION(2,12,0)
954+ GtkTooltips *tooltips;
955+#endif /* not GTK_CHECK_VERSION(2,12,0) */
956+ GtkWidget *toolbar;
957+
958+ toolbar = gtk_toolbar_new ();
959+#if GTK_CHECK_VERSION(2,16,0)
960+ gtk_orientable_set_orientation (GTK_ORIENTABLE (toolbar),
961+ GTK_ORIENTATION_HORIZONTAL);
962+#else /* not GTK_CHECK_VERSION(2,16,0) */
963+ gtk_toolbar_set_orientation (GTK_TOOLBAR (toolbar),
964+ GTK_ORIENTATION_HORIZONTAL);
965+#endif /* not GTK_CHECK_VERSION(2,16,0) */
966+ gtk_toolbar_set_style (GTK_TOOLBAR (toolbar), GTK_TOOLBAR_ICONS);
967+#if ! GTK_CHECK_VERSION(2,14,0)
968+ gtk_toolbar_set_tooltips (GTK_TOOLBAR (toolbar), TRUE);
969+#endif /* not GTK_CHECK_VERSION(2,14,0) */
970+#if GTK_CHECK_VERSION(2,4,0)
971+ gtk_toolbar_set_show_arrow (GTK_TOOLBAR (toolbar), FALSE);
972+#endif /* GTK_CHECK_VERSION(2,4,0) */
973+#if ! GTK_CHECK_VERSION(2,12,0)
974+ tooltips = gtk_tooltips_new ();
975+#endif /* not GTK_CHECK_VERSION(2,12,0) */
976+ for (i = 0; entries[i].path; i++)
977+ {
978+ if (entries[i].name)
979+ {
980+ if (entries[i].xpm)
981+ {
982+ GdkPixbuf *pixbuf;
983+
984+ pixbuf = gdk_pixbuf_new_from_xpm_data (entries[i].xpm);
985+#if GTK_CHECK_VERSION(2,4,0)
986+ entries[i].tool_item = gtk_tool_button_new
987+ (gtk_image_new_from_pixbuf (pixbuf), _(entries[i].name));
988+# if GTK_CHECK_VERSION(2,12,0)
989+ gtk_tool_item_set_tooltip_text (entries[i].tool_item,
990+ _(entries[i].name));
991+# else /* not GTK_CHECK_VERSION(2,12,0) */
992+ gtk_tool_item_set_tooltip (entries[i].tool_item, tooltips,
993+ _(entries[i].name), _(entries[i].name));
994+# endif /* not GTK_CHECK_VERSION(2,12,0) */
995+#else /* not GTK_CHECK_VERSION(2,4,0) */
996+ entries[i].tool_item = gtk_toolbar_append_item
997+ (GTK_TOOLBAR (toolbar),
998+ _(entries[i].name),
999+ _(entries[i].name),
1000+ _(entries[i].name),
1001+ gtk_image_new_from_pixbuf (pixbuf),
1002+ G_CALLBACK (entries[i].func),
1003+ NULL);
1004+#endif /* not GTK_CHECK_VERSION(2,4,0) */
1005+ g_object_unref (pixbuf);
1006+ }
1007+ else
1008+ {
1009+ gchar *text;
1010+ GtkStockItem stock_item;
1011+
1012+ gtk_stock_lookup (entries[i].name, &stock_item);
1013+ text = misc_mnemonic_to_text (stock_item.label);
1014+#if GTK_CHECK_VERSION(2,4,0)
1015+ entries[i].tool_item = gtk_tool_button_new_from_stock
1016+ (entries[i].name);
1017+# if GTK_CHECK_VERSION(2,12,0)
1018+ gtk_tool_item_set_tooltip_text (entries[i].tool_item, text);
1019+# else /* not GTK_CHECK_VERSION(2,12,0) */
1020+ gtk_tool_item_set_tooltip (entries[i].tool_item, tooltips,
1021+ text, text);
1022+# endif /* not GTK_CHECK_VERSION(2,12,0) */
1023+#else /* not GTK_CHECK_VERSION(2,4,0) */
1024+ entries[i].tool_item = gtk_toolbar_insert_stock
1025+ (GTK_TOOLBAR (toolbar),
1026+ entries[i].name,
1027+ text,
1028+ text,
1029+ G_CALLBACK (entries[i].func),
1030+ NULL,
1031+ -1);
1032+#endif /* not GTK_CHECK_VERSION(2,4,0) */
1033+ g_free (text);
1034+ }
1035+#if GTK_CHECK_VERSION(2,4,0)
1036+ if (entries[i].func)
1037+ g_signal_connect (G_OBJECT (entries[i].tool_item), "clicked",
1038+ G_CALLBACK (entries[i].func), entries[i].user_data);
1039+#endif /* GTK_CHECK_VERSION(2,4,0) */
1040+ }
1041+ else
1042+ {
1043+#if GTK_CHECK_VERSION(2,4,0)
1044+ entries[i].tool_item = gtk_separator_tool_item_new ();
1045+#else /* not GTK_CHECK_VERSION(2,4,0) */
1046+ gtk_toolbar_append_space (GTK_TOOLBAR (toolbar));
1047+#endif /* not GTK_CHECK_VERSION(2,4,0) */
1048+ }
1049+#if GTK_CHECK_VERSION(2,4,0)
1050+ gtk_toolbar_insert (GTK_TOOLBAR (toolbar), entries[i].tool_item, i);
1051+#endif /* GTK_CHECK_VERSION(2,4,0) */
1052+ }
1053+ return toolbar;
1054+}
1055+
1056+
1057+/* ja:ツールバーを検索する
1058+ entries,ツールバー構造体
1059+ path,パス
1060+ RET,ツールアイテム */
1061+GtkToolItem *
1062+misc_find_toolbar (MiscCreateToolbarEntry *entries,
1063+ const gchar *path)
1064+{
1065+ gint i;
1066+
1067+ for (i = 0; entries[i].path; i++)
1068+ if (g_strcmp (entries[i].path, path) == 0)
1069+ return entries[i].tool_item;
1070+ return NULL;
1071+}
1072+
1073+
1074+/******************************************************************************
1075+* *
1076+* ja:クローズボタン関数群 *
1077+* *
1078+******************************************************************************/
1079+/* ja:クローズボタンのイメージを取得する
1080+ RET,イメージ,NULL:エラー */
1081+GtkWidget *
1082+misc_close_image (void)
1083+{
1084+ GtkIconSet *icon_set;
1085+ GtkWidget *image = NULL;
1086+
1087+ icon_set = gtk_icon_factory_lookup_default (GTK_STOCK_CLOSE);
1088+ if (icon_set)
1089+ {
1090+ GdkPixbuf *pixbuf;
1091+
1092+ pixbuf = gtk_icon_set_render_icon (icon_set,
1093+ gtk_widget_get_default_style (),
1094+ GTK_TEXT_DIR_NONE,
1095+ GTK_STATE_NORMAL,
1096+ GTK_ICON_SIZE_MENU,
1097+ NULL, NULL);
1098+ if (pixbuf)
1099+ {
1100+ if (gdk_pixbuf_get_colorspace (pixbuf) == GDK_COLORSPACE_RGB
1101+ && gdk_pixbuf_get_n_channels (pixbuf) == 4
1102+ && gdk_pixbuf_get_has_alpha (pixbuf)
1103+ && gdk_pixbuf_get_bits_per_sample (pixbuf) == 8)
1104+ {
1105+ int width, height, rowstride;
1106+ gint x, y, left, top, right, bottom;
1107+ guchar *pixels;
1108+
1109+ pixels = gdk_pixbuf_get_pixels (pixbuf);
1110+ width = gdk_pixbuf_get_width (pixbuf);
1111+ height = gdk_pixbuf_get_height (pixbuf);
1112+ rowstride = gdk_pixbuf_get_rowstride (pixbuf);
1113+ for (x = 0; x < width; x++)
1114+ for (y = 0; y < height; y++)
1115+ if (pixels[y * rowstride + x * 4 + 3] > 0)
1116+ goto loop_left;
1117+ loop_left: left = x;
1118+ for (y = 0; y < height; y++)
1119+ for (x = 0; x < width; x++)
1120+ if (pixels[y * rowstride + x * 4 + 3] > 0)
1121+ goto loop_top;
1122+ loop_top: top = y;
1123+ for (x = width - 1; x >= 0; x--)
1124+ for (y = 0; y < height; y++)
1125+ if (pixels[y * rowstride + x * 4 + 3] > 0)
1126+ goto loop_right;
1127+ loop_right: right = x;
1128+ for (y = height - 1; y >= 0; y--)
1129+ for (x = 0; x < width; x++)
1130+ if (pixels[y * rowstride + x * 4 + 3] > 0)
1131+ goto loop_bottom;
1132+ loop_bottom: bottom = y;
1133+ if (left <= right && top <= bottom)
1134+ {
1135+ int w, h, r;
1136+ guchar *p;
1137+ gint i;
1138+ GdkPixbuf *b;
1139+
1140+ w = right - left + 1;
1141+ h = bottom - top + 1;
1142+ b = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, w, h);
1143+ p = gdk_pixbuf_get_pixels (b);
1144+ r = gdk_pixbuf_get_rowstride (b);
1145+ for (x = 0; x < w; x++)
1146+ for (y = 0; y < h; y++)
1147+ for (i = 0; i < 4; i++)
1148+ p[y * r + x * 4 + i]
1149+ = pixels[(y + top) * rowstride + (x + left) * 4 + i];
1150+ image = gtk_image_new_from_pixbuf (b);
1151+ g_object_unref (b);
1152+ }
1153+ }
1154+ g_object_unref (pixbuf);
1155+ }
1156+ }
1157+ if (!image)
1158+ image = gtk_image_new_from_stock (GTK_STOCK_CLOSE, GTK_ICON_SIZE_MENU);
1159+ if (!image)
1160+ {
1161+ GdkPixbuf *pixbuf;
1162+ const static gchar *xpm[] = {
1163+"12 13 4 1",
1164+" c None",
1165+"X c #000000",
1166+"+ c #808080",
1167+". c #FFFFFF",
1168+"+++++++++++.",
1169+"+.........+.",
1170+"+. +.",
1171+"+.XX XX+.",
1172+"+. XX XX +.",
1173+"+. XXXX +.",
1174+"+. XX +.",
1175+"+. XXXX +.",
1176+"+. XX XX +.",
1177+"+.XX XX+.",
1178+"+. +.",
1179+"+++++++++++.",
1180+"............"};
1181+
1182+ pixbuf = gdk_pixbuf_new_from_xpm_data (xpm);
1183+ image = gtk_image_new_from_pixbuf (pixbuf);
1184+ g_object_unref (pixbuf);
1185+ }
1186+ return image;
1187+}
1188+
1189+
1190+/* ja:クローズボタンを取得する
1191+ RET,ボタン,NULL:エラー */
1192+GtkWidget *
1193+misc_close_button (void)
1194+{
1195+ GtkWidget *button = NULL, *image;
1196+
1197+ image = misc_close_image ();
1198+ if (image)
1199+ {
1200+ button = gtk_button_new ();
1201+ gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE);
1202+ gtk_container_add (GTK_CONTAINER (button), image);
1203+ gtk_widget_show (image);
1204+ }
1205+ return button;
1206+}
1207+
1208+
1209+/******************************************************************************
1210+* *
1211+* ja:低レベル関数群 *
1212+* *
1213+******************************************************************************/
1214+/* ja:mnemonicをテキストに変換する
1215+ mnemonic,mnemonic
1216+ RET,テキスト */
1217+gchar *
1218+misc_mnemonic_to_text (const gchar *mnemonic)
1219+{
1220+ gchar *text;
1221+ gint i;
1222+
1223+ if (!mnemonic)
1224+ return NULL;
1225+ text = g_strdup (mnemonic);
1226+ for (i = 0; text[i] != '\0'; i++)
1227+ if (text[i] == '(' && text[i + 1] == '_'
1228+ && g_ascii_isalpha (text[i + 2]) && text[i + 3] == ')')
1229+ {
1230+ g_memmove (text + i, text + i + 4, g_strlen (text + i) - 3);
1231+ break;
1232+ }
1233+ else if (text[i] == '_' && g_ascii_isalpha (text[i + 1]))
1234+ {
1235+ g_memmove (text + i, text + i + 2, g_strlen (text + i) - 1);
1236+ break;
1237+ }
1238+ return text;
1239+}
1240+
1241+
1242+/* ja:スクロールバーを設定する
1243+ scroll,スクロールウイジット
1244+ func,シグナル関数
1245+ func_data,データ
1246+ min,最小値
1247+ max,最大値
1248+ page,ページ
1249+ pos,位置 */
1250+void
1251+misc_set_scroll_bar (GtkWidget *scroll,
1252+ GCallback func,
1253+ gpointer func_data,
1254+ const gint min,
1255+ const gint max,
1256+ const gint page,
1257+ const gint pos)
1258+{
1259+ GtkAdjustment *adjust;
1260+
1261+ adjust = GTK_ADJUSTMENT (gtk_adjustment_new (pos, min, max, 1, page, page));
1262+ gtk_range_set_adjustment (GTK_RANGE (scroll), adjust);
1263+ if (func)
1264+ g_signal_connect (G_OBJECT (adjust), "value-changed", func, func_data);
1265+}
1266+
1267+
1268+/* ja:Windowの内容をスクロールする
1269+ widget,ウイジット
1270+ dx,X軸方向の移動
1271+ dy,Y軸方向の移動
1272+ x,スクロールする範囲の右上X座標
1273+ y,スクロールする範囲の右上Y座標
1274+ width,スクロールする範囲の幅
1275+ height,スクロールする範囲の高さ */
1276+void
1277+misc_scroll_window (GtkWidget *widget,
1278+ const gint dx,
1279+ const gint dy,
1280+ const gint x,
1281+ const gint y,
1282+ const gint width,
1283+ const gint height)
1284+{
1285+ if (ABS (dx) > width || ABS (dy) > height)
1286+ {
1287+ gtk_widget_queue_draw_area (widget, x, y, width, height);
1288+ }
1289+ else if (dx != 0 || dy != 0)
1290+ {
1291+#if GTK_CHECK_VERSION(2,24,0)
1292+ cairo_t *cr;
1293+ gint w, h, xx, yy;
1294+ GdkPixbuf *pixbuf;
1295+ GdkWindow *window;
1296+
1297+ window = gtk_widget_get_window (widget);
1298+ cr = gdk_cairo_create (window);
1299+ w = width - ABS (dx);
1300+ h = height - ABS (dy);
1301+# if GTK_CHECK_VERSION(3,0,0)
1302+ pixbuf = gdk_pixbuf_get_from_window (window,
1303+ dx > 0 ? x : x - dx, dy > 0 ? y : y - dy, w, h);
1304+# else /* not GTK_CHECK_VERSION(3,0,0) */
1305+ pixbuf = gdk_pixbuf_get_from_drawable (NULL, window,
1306+ gdk_colormap_get_system (),
1307+ dx > 0 ? x : x - dx, dy > 0 ? y : y - dy,
1308+ 0, 0, w, h);
1309+# endif /* not GTK_CHECK_VERSION(3,0,0) */
1310+ xx = dx > 0 ? x + dx : x;
1311+ yy = dy > 0 ? y + dy : y;
1312+ gdk_cairo_set_source_pixbuf (cr, pixbuf, xx, yy);
1313+ g_object_unref (pixbuf);
1314+ cairo_rectangle (cr, xx, yy, w, h);
1315+ cairo_fill (cr);
1316+ cairo_destroy (cr);
1317+#else /* not GTK_CHECK_VERSION(2,24,0) */
1318+ GdkGC *gc;
1319+
1320+ gc = gdk_gc_new (gtk_widget_get_window (widget));
1321+ gdk_gc_set_exposures (gc, TRUE);
1322+ gdk_draw_drawable (gtk_widget_get_window (widget),
1323+ gc,
1324+ gtk_widget_get_window (widget),
1325+ dx > 0 ? x : x - dx,
1326+ dy > 0 ? y : y - dy,
1327+ dx > 0 ? x + dx : x,
1328+ dy > 0 ? y + dy : y,
1329+ width - ABS (dx),
1330+ height - ABS (dy));
1331+ g_object_unref (gc);
1332+#endif /* not GTK_CHECK_VERSION(2,24,0) */
1333+ if (dx != 0)
1334+ gtk_widget_queue_draw_area (widget, dx > 0 ? x : x + width + dx, y,
1335+ ABS (dx), height);
1336+ if (dy != 0)
1337+ gtk_widget_queue_draw_area (widget, x, dy > 0 ? y : y + height + dy,
1338+ width, ABS (dy));
1339+ }
1340+ gdk_window_process_updates (gtk_widget_get_window (widget), TRUE);
1341+}
1342+
1343+
1344+/* ja:ESCが押されたとき */
1345+gboolean
1346+misc_dialog_key_press (GtkWidget *widget,
1347+ GdkEventKey *event,
1348+ gpointer user_data)
1349+{
1350+ if (event->keyval == GDK_KEY_Escape)
1351+ gtk_dialog_response (GTK_DIALOG (widget), GTK_RESPONSE_NONE);
1352+ return FALSE;
1353+}
1354+#endif /* not USE_GTK_EMULATE */
--- tmaid/trunk/Makefile.msc.in (revision 209)
+++ tmaid/trunk/Makefile.msc.in (revision 210)
@@ -238,6 +238,7 @@
238238 iwmcrt\maincrtstartup.obj \
239239 iwmcrt\onexit.obj \
240240 iwmcrt\security.obj \
241+ iwmcrt\set_invalid_parameter_handler.obj \
241242 iwmcrt\stat32.obj \
242243 iwmcrt\stat32i64.obj \
243244 iwmcrt\stat64i32.obj \
@@ -329,6 +330,9 @@
329330 iwmcrt\security.obj: $(TOP)\$*.c
330331 $(CC) $(CLFLAGS) $**
331332
333+iwmcrt\set_invalid_parameter_handler.obj: $(TOP)\$*.c
334+ $(CC) $(CLFLAGS) $**
335+
332336 iwmcrt\stat32.obj: $(TOP)\$*.c
333337 $(CC) $(CLFLAGS) $**
334338
--- tmaid/trunk/configure.ac (revision 209)
+++ tmaid/trunk/configure.ac (revision 210)
@@ -5,7 +5,7 @@
55 dnl version number
66 MAJOR_VERSION=2
77 MINOR_VERSION=7
8-MICRO_VERSION=4
8+MICRO_VERSION=5
99 EXTRA_VERSION=
1010 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION
1111
@@ -112,15 +112,22 @@
112112 AC_CHECK_HEADERS(arpa/inet.h arpa/nameser.h complex.h dirent.h fcntl.h netdb.h netinet/in.h resolv.h stdint.h sys/file.h sys/mman.h sys/param.h sys/select.h sys/socket.h sys/stat.h sys/time.h sys/timeb.h sys/types.h unistd.h utime.h)
113113
114114 dnl **************************************************************
115-dnl Checks for typedefs, structures, and compiler characteristics.
115+dnl Checks for typedefs and structures.
116116 dnl **************************************************************
117117 AC_C_CONST
118118 AC_C_VOLATILE
119119 AC_STRUCT_TM
120120 AC_TYPE_SIZE_T
121-if test "$CC" = 'gcc'; then
121+
122+dnl **************************************************************
123+dnl Checks for compiler characteristics.
124+dnl **************************************************************
125+if test "$GCC" = 'yes'; then
122126 CFLAGS="$CFLAGS -Wall"
123127 fi
128+if $LD --help 2> /dev/null | grep as-needed > /dev/null; then
129+ LDFLAGS="$LDFLAGS -Wl,--no-as-needed"
130+fi
124131
125132 dnl **************************************************************
126133 dnl Checks for library functions.
--- tmaid/trunk/iwmcrt/set_invalid_parameter_handler.c (nonexistent)
+++ tmaid/trunk/iwmcrt/set_invalid_parameter_handler.c (revision 210)
@@ -0,0 +1,42 @@
1+/*
2+copyright (c) 2012-2013 Kazuki Iwamoto http://www.maid.org/ iwm@maid.org
3+
4+Permission is hereby granted, free of charge, to any person obtaining
5+a copy of this software and associated documentation files (the
6+"Software"), to deal in the Software without restriction, including
7+without limitation the rights to use, copy, modify, merge, publish,
8+distribute, sublicense, and/or sell copies of the Software, and to
9+permit persons to whom the Software is furnished to do so, subject to
10+the following conditions:
11+
12+The above copyright notice and this permission notice shall be included
13+in all copies or substantial portions of the Software.
14+
15+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18+IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
19+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
20+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
21+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22+*/
23+#if _MSC_VER >= 1400
24+#include <stdlib.h>
25+
26+
27+typedef void (__cdecl *_set_invalid_parameter_handler_t)(_invalid_parameter_handler);
28+
29+
30+static _invalid_parameter_handler __cdecl x_set_invalid_parameter_handler (_invalid_parameter_handler pNew)
31+{
32+ static _invalid_parameter_handler pInvalidArgHandler = NULL;
33+ _invalid_parameter_handler pOld;
34+
35+ pOld = pInvalidArgHandler;
36+ pInvalidArgHandler = pNew;
37+ return pOld;
38+}
39+
40+
41+_set_invalid_parameter_handler_t _imp___set_invalid_parameter_handler = x_set_invalid_parameter_handler;
42+#endif /* _MSC_VER >= 1400 */
--- tmaid/trunk/iwmcrt/iwmcrt.c (revision 209)
+++ tmaid/trunk/iwmcrt/iwmcrt.c (revision 210)
@@ -28,6 +28,6 @@
2828 _PVFV *__onexitend = NULL;
2929 _PVFV __xc_a[] = {NULL};
3030 _PVFV __xc_z[] = {NULL};
31-_PVFV __xi_a[] = {NULL};
32-_PVFV __xi_z[] = {NULL};
31+_PIFV __xi_a[] = {NULL};
32+_PIFV __xi_z[] = {NULL};
3333 int _fltused = 0x9875;
--- tmaid/trunk/iwmcrt/iwmcrt.h (revision 209)
+++ tmaid/trunk/iwmcrt/iwmcrt.h (revision 210)
@@ -29,6 +29,7 @@
2929 #endif /* __cplusplus */
3030
3131
32+typedef int (__cdecl *_PIFV)(void);
3233 typedef void (__cdecl *_PVFV)(void);
3334
3435
@@ -37,12 +38,17 @@
3738
3839 extern _PVFV *__onexitbegin;
3940 extern _PVFV *__onexitend;
40-extern _PVFV __xc_a[];
41-extern _PVFV __xc_z[];
42-extern _PVFV __xi_a[];
43-extern _PVFV __xi_z[];
4441
42+#pragma section (".CRT$XCA", long, read)
43+#pragma section (".CRT$XCZ", long, read)
44+#pragma section (".CRT$XIA", long, read)
45+#pragma section (".CRT$XIZ", long, read)
46+extern __declspec (allocate (".CRT$XCA")) _PVFV __xc_a[];
47+extern __declspec (allocate (".CRT$XCZ")) _PVFV __xc_z[];
48+extern __declspec (allocate (".CRT$XIA")) _PIFV __xi_a[];
49+extern __declspec (allocate (".CRT$XIZ")) _PIFV __xi_z[];
4550
51+
4652 #ifdef __cplusplus
4753 }
4854 #endif /* __cplusplus */
--- tmaid/trunk/iwmcrt/Makefile.am (revision 209)
+++ tmaid/trunk/iwmcrt/Makefile.am (revision 210)
@@ -25,6 +25,7 @@
2525 maincrtstartup.c \
2626 onexit.c \
2727 security.c \
28+ set_invalid_parameter_handler.c \
2829 stat32.c \
2930 stat32i64.c \
3031 stat64i32.c \
--- tmaid/trunk/po/ja.po (revision 209)
+++ tmaid/trunk/po/ja.po (revision 210)
@@ -1,12 +1,12 @@
11 # Text maid ja.po
2-# Copyright (C) 1998-2012 Kazuki Iwamoto
3-# Kazuki Iwamoto <iwm@maid.org>, 1998-2012.
2+# Copyright (C) 1998-2013 Kazuki Iwamoto
3+# Kazuki Iwamoto <iwm@maid.org>, 1998-2013.
44 #
55 msgid ""
66 msgstr ""
7-"Project-Id-Version: tmaid 2.7.4\n"
7+"Project-Id-Version: tmaid 2.7.5\n"
88 "Report-Msgid-Bugs-To: http://www.maid.org/\n"
9-"POT-Creation-Date: 2012-08-29 22:47+0900\n"
9+"POT-Creation-Date: 2013-05-29 03:59+0900\n"
1010 "PO-Revision-Date: 2002-08-11 18:10+0900\n"
1111 "Last-Translator: Kazuki Iwamoto <iwm@maid.org>\n"
1212 "Language-Team: Kazuki Iwamoto <iwm@maid.org>\n"
@@ -160,20 +160,20 @@
160160 msgid "Conversion from character encoding '%s' to 'UTF-8' is not supported"
161161 msgstr "'%s'から'UTF-8'への文字符号化方式の変換に対応していません"
162162
163-#: src/file.c:616
163+#: src/file.c:644
164164 #, c-format
165165 msgid "Conversion from character encoding 'UTF-8' to '%s' is not supported"
166166 msgstr "'UTF-8'から'%s'への文字符号化方式の変換に対応していません"
167167
168-#: src/file.c:652
168+#: src/file.c:680
169169 msgid "Invalid byte sequence in conversion input"
170170 msgstr "変換入力の不正なバイト列"
171171
172-#: src/file.c:687 src/print.c:204
172+#: src/file.c:715 src/print.c:204
173173 msgid "Can not open file"
174174 msgstr "ファイルが開けません"
175175
176-#: src/file.c:713
176+#: src/file.c:741
177177 msgid "Can not write"
178178 msgstr "ファイルに書き込みできません"
179179
Show on old repository browser