~ayatana-scrollbar-team/gtk/ubuntu

« back to all changes in this revision

Viewing changes to debian/patches/020_immodules-files-d.patch

  • Committer: robert.ancell at gmail
  • Date: 2009-08-27 05:54:01 UTC
  • Revision ID: robert.ancell@gmail.com-20090827055401-lhs8w2vpbr9mvfx5
initalĀ gtkĀ import

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
Index: gtk+2.0-2.17.3/gtk/gtkimmodule.c
 
2
===================================================================
 
3
--- gtk+2.0-2.17.3.orig/gtk/gtkimmodule.c       2009-06-04 21:18:04.000000000 +0200
 
4
+++ gtk+2.0-2.17.3/gtk/gtkimmodule.c    2009-07-09 17:41:30.000000000 +0200
 
5
@@ -70,6 +70,9 @@
 
6
 #define GTK_IM_MODULE(im_module)    (G_TYPE_CHECK_INSTANCE_CAST ((im_module), GTK_TYPE_IM_MODULE, GtkIMModule))
 
7
 #define GTK_IS_IM_MODULE(im_module) (G_TYPE_CHECK_INSTANCE_TYPE ((im_module), GTK_TYPE_IM_MODULE))
 
8
 
 
9
+#define IMMODULEFILEEXT ".immodules"
 
10
+#define IMMODULEFILEEXT_LEN ((int) strlen (IMMODULEFILEEXT))
 
11
+
 
12
 struct _GtkIMModule
 
13
 {
 
14
   GTypeModule parent_instance;
 
15
@@ -310,19 +313,15 @@
 
16
 }
 
17
 
 
18
 static void
 
19
-gtk_im_module_initialize (void)
 
20
+process_module_file (const gchar *filename, FILE *file)
 
21
 {
 
22
   GString *line_buf = g_string_new (NULL);
 
23
   GString *tmp_buf = g_string_new (NULL);
 
24
-  gchar *filename = gtk_rc_get_im_module_file();
 
25
-  FILE *file;
 
26
   gboolean have_error = FALSE;
 
27
 
 
28
   GtkIMModule *module = NULL;
 
29
   GSList *infos = NULL;
 
30
 
 
31
-  contexts_hash = g_hash_table_new (g_str_hash, g_str_equal);
 
32
-
 
33
 #define do_builtin(m)                                                  \
 
34
   {                                                                    \
 
35
     const GtkIMContextInfo **contexts;                                 \
 
36
@@ -380,18 +379,6 @@
 
37
 
 
38
 #undef do_builtin
 
39
 
 
40
-  file = g_fopen (filename, "r");
 
41
-  if (!file)
 
42
-    {
 
43
-      /* In case someone wants only the default input method,
 
44
-       * we allow no file at all.
 
45
-       */
 
46
-      g_string_free (line_buf, TRUE);
 
47
-      g_string_free (tmp_buf, TRUE);
 
48
-      g_free (filename);
 
49
-      return;
 
50
-    }
 
51
-
 
52
   while (!have_error && pango_read_line (file, line_buf))
 
53
     {
 
54
       const char *p;
 
55
@@ -489,10 +476,76 @@
 
56
   else if (module)
 
57
     add_module (module, infos);
 
58
 
 
59
-  fclose (file);
 
60
   g_string_free (line_buf, TRUE);
 
61
   g_string_free (tmp_buf, TRUE);
 
62
-  g_free (filename);
 
63
+}
 
64
+
 
65
+static void
 
66
+gtk_im_module_initialize (void)
 
67
+{
 
68
+  gchar *im_module_file_str = gtk_rc_get_im_module_file();
 
69
+  gchar *im_module_files_d_str = g_build_filename (GTK_LIBDIR,
 
70
+                                                  "gtk-2.0",
 
71
+                                                  GTK_BINARY_VERSION,
 
72
+                                                  "immodule-files.d",
 
73
+                                                  NULL);
 
74
+  FILE *file;
 
75
+  gchar *list_str;
 
76
+  char **files;
 
77
+  int n;
 
78
+
 
79
+  list_str = g_strjoin (G_SEARCHPATH_SEPARATOR_S,
 
80
+                       im_module_files_d_str,
 
81
+                       im_module_file_str,
 
82
+                       NULL);
 
83
+
 
84
+  files = pango_split_file_list (list_str);
 
85
+
 
86
+  contexts_hash = g_hash_table_new (g_str_hash, g_str_equal);
 
87
+
 
88
+  n = 0;
 
89
+  while (files[n])
 
90
+    n++;
 
91
+
 
92
+  while (n-- > 0)
 
93
+    {
 
94
+      GDir *dir = g_dir_open (files[n], 0, NULL);
 
95
+      if (dir)
 
96
+       {
 
97
+         const char *dent;
 
98
+
 
99
+         while ((dent = g_dir_read_name (dir)))
 
100
+           {
 
101
+             int len = strlen (dent);
 
102
+             if (len > IMMODULEFILEEXT_LEN && strcmp (dent + len - IMMODULEFILEEXT_LEN, IMMODULEFILEEXT) == 0)
 
103
+               {
 
104
+                 gchar *pathname = g_build_filename (files[n], dent, NULL);
 
105
+                 file = g_fopen (pathname, "r");
 
106
+                 if (file)
 
107
+                   {
 
108
+                     process_module_file(pathname, file);
 
109
+                     fclose(file);
 
110
+                   }
 
111
+                 g_free (pathname);
 
112
+               }
 
113
+           }
 
114
+         g_dir_close (dir);
 
115
+       }
 
116
+      else
 
117
+       {
 
118
+         file = g_fopen (files[n], "r");
 
119
+         if (file)
 
120
+           {
 
121
+             process_module_file(files[n], file);
 
122
+             fclose (file);
 
123
+           }
 
124
+       }
 
125
+    }
 
126
+
 
127
+  g_strfreev (files);
 
128
+  g_free (list_str);
 
129
+  g_free (im_module_files_d_str);
 
130
+  g_free (im_module_file_str);
 
131
 }
 
132
 
 
133
 static gint