1 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
4 * Copyright (C) 2002 Paolo Maggi
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 * Boston, MA 02110-1301, USA.
23 * Modified by the gedit Team, 2002. See the gedit AUTHORS file for a
24 * list of people on the gedit Team.
25 * See the gedit ChangeLog files for a list of changes.
27 /* Stolen from gedit - Naba */
30 * SECTION:anjuta-encodings
31 * @title: AnjutaEncoding
32 * @short_description: Text encoding and decoding
34 * @stability: Unstable
35 * @include: libanjuta/anjuta-encodings.h
43 #include <gtk/gtktreeview.h>
44 #include <gtk/gtkliststore.h>
47 #include <libanjuta/anjuta-encodings.h>
48 #include <libanjuta/anjuta-utils.h>
49 #include <libanjuta/anjuta-debug.h>
51 struct _AnjutaEncoding
59 * The original versions of the following tables are taken from profterm
61 * Copyright (C) 2002 Red Hat, Inc.
67 ANJUTA_ENCODING_ISO_8859_1
,
68 ANJUTA_ENCODING_ISO_8859_2
,
69 ANJUTA_ENCODING_ISO_8859_3
,
70 ANJUTA_ENCODING_ISO_8859_4
,
71 ANJUTA_ENCODING_ISO_8859_5
,
72 ANJUTA_ENCODING_ISO_8859_6
,
73 ANJUTA_ENCODING_ISO_8859_7
,
74 ANJUTA_ENCODING_ISO_8859_8
,
75 ANJUTA_ENCODING_ISO_8859_8_I
,
76 ANJUTA_ENCODING_ISO_8859_9
,
77 ANJUTA_ENCODING_ISO_8859_10
,
78 ANJUTA_ENCODING_ISO_8859_13
,
79 ANJUTA_ENCODING_ISO_8859_14
,
80 ANJUTA_ENCODING_ISO_8859_15
,
81 ANJUTA_ENCODING_ISO_8859_16
,
83 ANJUTA_ENCODING_UTF_7
,
84 ANJUTA_ENCODING_UTF_16
,
85 ANJUTA_ENCODING_UCS_2
,
86 ANJUTA_ENCODING_UCS_4
,
88 ANJUTA_ENCODING_ARMSCII_8
,
90 ANJUTA_ENCODING_BIG5_HKSCS
,
91 ANJUTA_ENCODING_CP_866
,
93 ANJUTA_ENCODING_EUC_JP
,
94 ANJUTA_ENCODING_EUC_KR
,
95 ANJUTA_ENCODING_EUC_TW
,
97 ANJUTA_ENCODING_GB18030
,
98 ANJUTA_ENCODING_GB2312
,
100 ANJUTA_ENCODING_GEOSTD8
,
103 ANJUTA_ENCODING_IBM_850
,
104 ANJUTA_ENCODING_IBM_852
,
105 ANJUTA_ENCODING_IBM_855
,
106 ANJUTA_ENCODING_IBM_857
,
107 ANJUTA_ENCODING_IBM_862
,
108 ANJUTA_ENCODING_IBM_864
,
110 ANJUTA_ENCODING_ISO_2022_JP
,
111 ANJUTA_ENCODING_ISO_2022_KR
,
112 ANJUTA_ENCODING_ISO_IR_111
,
113 ANJUTA_ENCODING_JOHAB
,
114 ANJUTA_ENCODING_KOI8_R
,
115 ANJUTA_ENCODING_KOI8_U
,
117 ANJUTA_ENCODING_SHIFT_JIS
,
118 ANJUTA_ENCODING_TCVN
,
119 ANJUTA_ENCODING_TIS_620
,
121 ANJUTA_ENCODING_VISCII
,
123 ANJUTA_ENCODING_WINDOWS_1250
,
124 ANJUTA_ENCODING_WINDOWS_1251
,
125 ANJUTA_ENCODING_WINDOWS_1252
,
126 ANJUTA_ENCODING_WINDOWS_1253
,
127 ANJUTA_ENCODING_WINDOWS_1254
,
128 ANJUTA_ENCODING_WINDOWS_1255
,
129 ANJUTA_ENCODING_WINDOWS_1256
,
130 ANJUTA_ENCODING_WINDOWS_1257
,
131 ANJUTA_ENCODING_WINDOWS_1258
,
135 } AnjutaEncodingIndex
;
137 static AnjutaEncoding encodings
[] = {
139 { ANJUTA_ENCODING_ISO_8859_1
,
140 "ISO-8859-1", N_("Western") },
141 { ANJUTA_ENCODING_ISO_8859_2
,
142 "ISO-8859-2", N_("Central European") },
143 { ANJUTA_ENCODING_ISO_8859_3
,
144 "ISO-8859-3", N_("South European") },
145 { ANJUTA_ENCODING_ISO_8859_4
,
146 "ISO-8859-4", N_("Baltic") },
147 { ANJUTA_ENCODING_ISO_8859_5
,
148 "ISO-8859-5", N_("Cyrillic") },
149 { ANJUTA_ENCODING_ISO_8859_6
,
150 "ISO-8859-6", N_("Arabic") },
151 { ANJUTA_ENCODING_ISO_8859_7
,
152 "ISO-8859-7", N_("Greek") },
153 { ANJUTA_ENCODING_ISO_8859_8
,
154 "ISO-8859-8", N_("Hebrew Visual") },
155 { ANJUTA_ENCODING_ISO_8859_8_I
,
156 "ISO-8859-8-I", N_("Hebrew") },
157 { ANJUTA_ENCODING_ISO_8859_9
,
158 "ISO-8859-9", N_("Turkish") },
159 { ANJUTA_ENCODING_ISO_8859_10
,
160 "ISO-8859-10", N_("Nordic") },
161 { ANJUTA_ENCODING_ISO_8859_13
,
162 "ISO-8859-13", N_("Baltic") },
163 { ANJUTA_ENCODING_ISO_8859_14
,
164 "ISO-8859-14", N_("Celtic") },
165 { ANJUTA_ENCODING_ISO_8859_15
,
166 "ISO-8859-15", N_("Western") },
167 { ANJUTA_ENCODING_ISO_8859_16
,
168 "ISO-8859-16", N_("Romanian") },
170 { ANJUTA_ENCODING_UTF_7
,
171 "UTF-7", N_("Unicode") },
172 { ANJUTA_ENCODING_UTF_16
,
173 "UTF-16", N_("Unicode") },
174 { ANJUTA_ENCODING_UCS_2
,
175 "UCS-2", N_("Unicode") },
176 { ANJUTA_ENCODING_UCS_4
,
177 "UCS-4", N_("Unicode") },
179 { ANJUTA_ENCODING_ARMSCII_8
,
180 "ARMSCII-8", N_("Armenian") },
181 { ANJUTA_ENCODING_BIG5
,
182 "BIG5", N_("Chinese Traditional") },
183 { ANJUTA_ENCODING_BIG5_HKSCS
,
184 "BIG5-HKSCS", N_("Chinese Traditional") },
185 { ANJUTA_ENCODING_CP_866
,
186 "CP866", N_("Cyrillic/Russian") },
188 { ANJUTA_ENCODING_EUC_JP
,
189 "EUC-JP", N_("Japanese") },
190 { ANJUTA_ENCODING_EUC_KR
,
191 "EUC-KR", N_("Korean") },
192 { ANJUTA_ENCODING_EUC_TW
,
193 "EUC-TW", N_("Chinese Traditional") },
195 { ANJUTA_ENCODING_GB18030
,
196 "GB18030", N_("Chinese Simplified") },
197 { ANJUTA_ENCODING_GB2312
,
198 "GB2312", N_("Chinese Simplified") },
199 { ANJUTA_ENCODING_GBK
,
200 "GBK", N_("Chinese Simplified") },
201 { ANJUTA_ENCODING_GEOSTD8
,
202 "GEORGIAN-ACADEMY", N_("Georgian") }, /* FIXME GEOSTD8 ? */
203 { ANJUTA_ENCODING_HZ
,
204 "HZ", N_("Chinese Simplified") },
206 { ANJUTA_ENCODING_IBM_850
,
207 "IBM850", N_("Western") },
208 { ANJUTA_ENCODING_IBM_852
,
209 "IBM852", N_("Central European") },
210 { ANJUTA_ENCODING_IBM_855
,
211 "IBM855", N_("Cyrillic") },
212 { ANJUTA_ENCODING_IBM_857
,
213 "IBM857", N_("Turkish") },
214 { ANJUTA_ENCODING_IBM_862
,
215 "IBM862", N_("Hebrew") },
216 { ANJUTA_ENCODING_IBM_864
,
217 "IBM864", N_("Arabic") },
219 { ANJUTA_ENCODING_ISO_2022_JP
,
220 "ISO-2022-JP", N_("Japanese") },
221 { ANJUTA_ENCODING_ISO_2022_KR
,
222 "ISO-2022-KR", N_("Korean") },
223 { ANJUTA_ENCODING_ISO_IR_111
,
224 "ISO-IR-111", N_("Cyrillic") },
225 { ANJUTA_ENCODING_JOHAB
,
226 "JOHAB", N_("Korean") },
227 { ANJUTA_ENCODING_KOI8_R
,
228 "KOI8R", N_("Cyrillic") },
229 { ANJUTA_ENCODING_KOI8_U
,
230 "KOI8U", N_("Cyrillic/Ukrainian") },
232 { ANJUTA_ENCODING_SHIFT_JIS
,
233 "SHIFT_JIS", N_("Japanese") },
234 { ANJUTA_ENCODING_TCVN
,
235 "TCVN", N_("Vietnamese") },
236 { ANJUTA_ENCODING_TIS_620
,
237 "TIS-620", N_("Thai") },
238 { ANJUTA_ENCODING_UHC
,
239 "UHC", N_("Korean") },
240 { ANJUTA_ENCODING_VISCII
,
241 "VISCII", N_("Vietnamese") },
243 { ANJUTA_ENCODING_WINDOWS_1250
,
244 "WINDOWS-1250", N_("Central European") },
245 { ANJUTA_ENCODING_WINDOWS_1251
,
246 "WINDOWS-1251", N_("Cyrillic") },
247 { ANJUTA_ENCODING_WINDOWS_1252
,
248 "WINDOWS-1252", N_("Western") },
249 { ANJUTA_ENCODING_WINDOWS_1253
,
250 "WINDOWS-1253", N_("Greek") },
251 { ANJUTA_ENCODING_WINDOWS_1254
,
252 "WINDOWS-1254", N_("Turkish") },
253 { ANJUTA_ENCODING_WINDOWS_1255
,
254 "WINDOWS-1255", N_("Hebrew") },
255 { ANJUTA_ENCODING_WINDOWS_1256
,
256 "WINDOWS-1256", N_("Arabic") },
257 { ANJUTA_ENCODING_WINDOWS_1257
,
258 "WINDOWS-1257", N_("Baltic") },
259 { ANJUTA_ENCODING_WINDOWS_1258
,
260 "WINDOWS-1258", N_("Vietnamese") }
263 static void save_property (void);
266 anjuta_encoding_lazy_init (void)
269 static gboolean initialized
= FALSE
;
275 g_return_if_fail (G_N_ELEMENTS (encodings
) == ANJUTA_ENCODING_LAST
);
278 while (i
< ANJUTA_ENCODING_LAST
)
280 g_return_if_fail (encodings
[i
].idx
== i
);
282 /* Translate the names */
283 encodings
[i
].name
= _(encodings
[i
].name
);
292 * anjuta_encoding_get_from_charset:
293 * @charset: Character set for the encoding.
295 * Gets #AnjutaEncoding object corresponding to the given character set
297 * Returns: #AnjutaEncoding object for the given charset
299 const AnjutaEncoding
*
300 anjuta_encoding_get_from_charset (const gchar
*charset
)
304 anjuta_encoding_lazy_init ();
307 while (i
< ANJUTA_ENCODING_LAST
)
309 if (strcmp (charset
, encodings
[i
].charset
) == 0)
310 return &encodings
[i
];
319 * anjuta_encoding_get_from_index:
320 * @idx: Index of the encoding object
322 * Retrieves #AnjutaEncoding object at the given index.
324 * Returns: #AnjutaEncoding object at the index @idx.
326 const AnjutaEncoding
*
327 anjuta_encoding_get_from_index (gint idx
)
329 g_return_val_if_fail (idx
>= 0, NULL
);
331 if (idx
>= ANJUTA_ENCODING_LAST
)
334 anjuta_encoding_lazy_init ();
336 return &encodings
[idx
];
340 * anjuta_encoding_to_string:
341 * @enc: an #AnjutaEncoding object
343 * Returns the string form of the given encoding.
345 * Returns: string name of the encoding.
348 anjuta_encoding_to_string (const AnjutaEncoding
* enc
)
350 g_return_val_if_fail (enc
!= NULL
, NULL
);
351 g_return_val_if_fail (enc
->name
!= NULL
, NULL
);
352 g_return_val_if_fail (enc
->charset
!= NULL
, NULL
);
354 anjuta_encoding_lazy_init ();
356 return g_strdup_printf ("%s (%s)", enc
->name
, enc
->charset
);
360 * anjuta_encoding_get_charset:
361 * @enc: an #AnjutaEncoding object
363 * Gets the character set for the given encoding.
365 * Returns: Character set
368 anjuta_encoding_get_charset (const AnjutaEncoding
* enc
)
370 g_return_val_if_fail (enc
!= NULL
, NULL
);
371 g_return_val_if_fail (enc
->charset
!= NULL
, NULL
);
373 anjuta_encoding_lazy_init ();
379 * anjuta_encoding_get_encodings:
380 * @encodings_strings: List of encoding names.
382 * Returns list of encoding objects for the given names.
384 * Returns: list of #AnjutaEncoding objects
387 anjuta_encoding_get_encodings (GList
*encoding_strings
)
391 if (encoding_strings
!= NULL
)
394 const AnjutaEncoding
*enc
;
396 tmp
= encoding_strings
;
400 const char *charset
= tmp
->data
;
402 if (strcmp (charset
, "current") == 0)
403 g_get_charset (&charset
);
405 g_return_val_if_fail (charset
!= NULL
, NULL
);
406 enc
= anjuta_encoding_get_from_charset (charset
);
409 res
= g_list_append (res
, (gpointer
)enc
);
411 tmp
= g_list_next (tmp
);
419 AnjutaPreferences
*pref
;
420 GtkWidget
*add_button
;
421 GtkWidget
*remove_button
;
422 GtkWidget
*up_button
;
423 GtkWidget
*down_button
;
424 GtkWidget
*supported_treeview
;
425 GtkWidget
*stock_treeview
;
426 } AnjutaEncodingsDialog
;
428 static AnjutaEncodingsDialog
*anjuta_encodings_dialog
= NULL
;
432 COLUMN_ENCODING_NAME
= 0,
433 COLUMN_ENCODING_INDEX
,
439 COLUMN_SUPPORTED_ENCODING_NAME
= 0,
440 COLUMN_SUPPORTED_ENCODING
,
441 SUPPORTED_ENCODING_NUM_COLS
445 create_encodings_treeview_model (void)
450 const AnjutaEncoding
* enc
;
452 /* create list store */
453 store
= gtk_list_store_new (ENCODING_NUM_COLS
, G_TYPE_STRING
, G_TYPE_INT
);
456 while ((enc
= anjuta_encoding_get_from_index (i
)) != NULL
)
459 enc
= anjuta_encoding_get_from_index (i
);
460 name
= anjuta_encoding_to_string (enc
);
461 gtk_list_store_append (store
, &iter
);
462 gtk_list_store_set (store
, &iter
, COLUMN_ENCODING_NAME
, name
,
463 COLUMN_ENCODING_INDEX
, i
, -1);
467 return GTK_TREE_MODEL (store
);
471 on_add_encodings (GtkButton
*button
)
473 GValue value
= {0, };
474 const AnjutaEncoding
* enc
;
478 GtkTreeSelection
*selection
;
483 gtk_tree_view_get_selection (GTK_TREE_VIEW
484 (anjuta_encodings_dialog
->stock_treeview
));
485 g_return_if_fail (selection
!= NULL
);
487 model
= gtk_tree_view_get_model (GTK_TREE_VIEW
488 (anjuta_encodings_dialog
->stock_treeview
));
489 if (!gtk_tree_model_get_iter_first (model
, &iter
))
492 if (gtk_tree_selection_iter_is_selected (selection
, &iter
))
494 gtk_tree_model_get_value (model
, &iter
,
495 COLUMN_ENCODING_INDEX
, &value
);
496 enc
= anjuta_encoding_get_from_index (g_value_get_int (&value
));
497 g_return_if_fail (enc
!= NULL
);
498 encs
= g_slist_prepend (encs
, (gpointer
)enc
);
500 g_value_unset (&value
);
503 while (gtk_tree_model_iter_next (model
, &iter
))
505 if (gtk_tree_selection_iter_is_selected (selection
, &iter
))
507 gtk_tree_model_get_value (model
, &iter
,
508 COLUMN_ENCODING_INDEX
, &value
);
510 enc
= anjuta_encoding_get_from_index (g_value_get_int (&value
));
511 g_return_if_fail (enc
!= NULL
);
513 encs
= g_slist_prepend (encs
, (gpointer
)enc
);
515 g_value_unset (&value
);
522 model
= gtk_tree_view_get_model (GTK_TREE_VIEW
523 (anjuta_encodings_dialog
->supported_treeview
));
524 encs
= g_slist_reverse (encs
);
528 const AnjutaEncoding
*enc
;
531 enc
= (const AnjutaEncoding
*) node
->data
;
533 name
= anjuta_encoding_to_string (enc
);
535 gtk_list_store_append (GTK_LIST_STORE (model
), &iter
);
536 gtk_list_store_set (GTK_LIST_STORE (model
), &iter
,
537 COLUMN_SUPPORTED_ENCODING_NAME
, name
,
538 COLUMN_SUPPORTED_ENCODING
, enc
,
542 node
= g_slist_next (node
);
550 on_remove_encodings (GtkButton
*button
)
552 GtkTreeSelection
*selection
;
555 GtkTreeView
*treeview
;
557 treeview
= GTK_TREE_VIEW (anjuta_encodings_dialog
->supported_treeview
);
558 selection
= gtk_tree_view_get_selection (treeview
);
560 gtk_tree_selection_get_selected (selection
, &model
, &iter
))
562 gtk_list_store_remove (GTK_LIST_STORE (model
), &iter
);
568 on_up_encoding (GtkButton
*button
)
570 GtkTreeSelection
*selection
;
573 GtkTreeView
*treeview
;
575 treeview
= GTK_TREE_VIEW (anjuta_encodings_dialog
->supported_treeview
);
576 selection
= gtk_tree_view_get_selection (treeview
);
578 gtk_tree_selection_get_selected (selection
, &model
, &iter
))
582 path
= gtk_tree_model_get_path (model
, &iter
);
583 if (gtk_tree_path_prev (path
))
585 GtkTreeIter prev_iter
;
586 gtk_tree_model_get_iter (model
, &prev_iter
, path
);
587 gtk_list_store_swap (GTK_LIST_STORE (model
), &prev_iter
, &iter
);
589 gtk_tree_path_free (path
);
595 on_down_encoding (GtkButton
*button
)
597 GtkTreeSelection
*selection
;
600 GtkTreeView
*treeview
;
602 treeview
= GTK_TREE_VIEW (anjuta_encodings_dialog
->supported_treeview
);
603 selection
= gtk_tree_view_get_selection (treeview
);
605 gtk_tree_selection_get_selected (selection
, &model
, &iter
))
607 GtkTreeIter next_iter
= iter
;
608 if (gtk_tree_model_iter_next (model
, &next_iter
))
610 gtk_list_store_swap (GTK_LIST_STORE (model
), &iter
, &next_iter
);
617 on_stock_selection_changed (GtkTreeSelection
*selection
)
619 g_return_if_fail(anjuta_encodings_dialog
!= NULL
);
620 if (gtk_tree_selection_count_selected_rows (selection
) > 0)
621 gtk_widget_set_sensitive (anjuta_encodings_dialog
->add_button
, TRUE
);
623 gtk_widget_set_sensitive (anjuta_encodings_dialog
->add_button
, FALSE
);
627 on_supported_selection_changed (GtkTreeSelection
*selection
)
632 g_return_if_fail(anjuta_encodings_dialog
!= NULL
);
634 if (gtk_tree_selection_get_selected (selection
, &model
, &iter
) > 0)
637 gtk_widget_set_sensitive (anjuta_encodings_dialog
->remove_button
, TRUE
);
638 path
= gtk_tree_model_get_path (model
, &iter
);
639 if (gtk_tree_path_prev (path
))
640 gtk_widget_set_sensitive (anjuta_encodings_dialog
->up_button
, TRUE
);
642 gtk_widget_set_sensitive (anjuta_encodings_dialog
->up_button
, FALSE
);
643 gtk_tree_path_free (path
);
645 if (gtk_tree_model_iter_next (model
, &iter
))
646 gtk_widget_set_sensitive (anjuta_encodings_dialog
->down_button
, TRUE
);
648 gtk_widget_set_sensitive (anjuta_encodings_dialog
->down_button
, FALSE
);
652 gtk_widget_set_sensitive (anjuta_encodings_dialog
->remove_button
, FALSE
);
653 gtk_widget_set_sensitive (anjuta_encodings_dialog
->up_button
, FALSE
);
654 gtk_widget_set_sensitive (anjuta_encodings_dialog
->down_button
, FALSE
);
659 get_current_value (GtkWidget
*tree_view
)
661 GtkTreeView
*treeview
;
668 treeview
= GTK_TREE_VIEW (tree_view
);
670 str
= g_string_new ("");
672 model
= gtk_tree_view_get_model (GTK_TREE_VIEW (treeview
));
673 valid
= gtk_tree_model_get_iter_first (model
, &iter
);
677 gtk_tree_model_get (model
, &iter
, COLUMN_SUPPORTED_ENCODING
, &enc
, -1);
678 g_assert (enc
!= NULL
);
679 g_assert (enc
->charset
!= NULL
);
680 str
= g_string_append (str
, enc
->charset
);
681 str
= g_string_append (str
, " ");
682 valid
= gtk_tree_model_iter_next (model
, &iter
);
684 value
= g_string_free (str
, FALSE
);
689 get_property (AnjutaProperty
*prop
)
691 return get_current_value (anjuta_property_get_widget (prop
));
695 set_property (AnjutaProperty
*prop
, const gchar
*value
)
697 GtkTreeView
*treeview
;
701 treeview
= GTK_TREE_VIEW (anjuta_property_get_widget (prop
));
702 model
= gtk_tree_view_get_model (treeview
);
703 gtk_list_store_clear (GTK_LIST_STORE (model
));
705 if (!value
|| strlen (value
) <= 0)
709 list
= anjuta_util_glist_from_string (value
);
713 const AnjutaEncoding
*enc
;
717 enc
= anjuta_encoding_get_from_charset ((gchar
*) node
->data
);
718 name
= anjuta_encoding_to_string (enc
);
720 gtk_list_store_append (GTK_LIST_STORE (model
), &iter
);
721 gtk_list_store_set (GTK_LIST_STORE (model
), &iter
,
722 COLUMN_SUPPORTED_ENCODING_NAME
, name
,
723 COLUMN_SUPPORTED_ENCODING
, enc
,
727 node
= g_list_next (node
);
729 anjuta_util_glist_strings_free (list
);
735 gchar
*value
= get_current_value (anjuta_encodings_dialog
->supported_treeview
);
736 anjuta_preferences_set (anjuta_encodings_dialog
->pref
,
743 * anjuta_encodings_init:
744 * @pref: an #AnjutaPreferences object.
745 * @gxml: an #GladeXML object holding encodings dialog.
747 * Initializes the encodings system.
750 anjuta_encodings_init (AnjutaPreferences
*pref
, GladeXML
*gxml
)
752 GtkWidget
*add_button
;
753 GtkWidget
*remove_button
;
754 GtkWidget
*up_button
;
755 GtkWidget
*down_button
;
756 GtkWidget
*supported_treeview
;
757 GtkWidget
*stock_treeview
;
759 GtkCellRenderer
*cell
;
760 GtkTreeViewColumn
*column
;
761 GtkTreeSelection
*selection
;
763 supported_treeview
= glade_xml_get_widget (gxml
, "supported_treeview");
764 stock_treeview
= glade_xml_get_widget (gxml
, "stock_treeview");
765 add_button
= glade_xml_get_widget (gxml
, "add_button");
766 remove_button
= glade_xml_get_widget (gxml
, "remove_button");
767 up_button
= glade_xml_get_widget (gxml
, "up_button");
768 down_button
= glade_xml_get_widget (gxml
, "down_button");
770 /* Add the encoding column for stock treeview*/
771 cell
= gtk_cell_renderer_text_new ();
772 column
= gtk_tree_view_column_new_with_attributes (_("Stock Encodings"),
774 COLUMN_ENCODING_NAME
,
776 gtk_tree_view_append_column (GTK_TREE_VIEW (stock_treeview
), column
);
777 gtk_tree_view_set_search_column (GTK_TREE_VIEW (stock_treeview
),
778 COLUMN_ENCODING_NAME
);
779 selection
= gtk_tree_view_get_selection (GTK_TREE_VIEW (stock_treeview
));
780 g_return_if_fail (selection
!= NULL
);
781 gtk_tree_selection_set_mode (selection
, GTK_SELECTION_MULTIPLE
);
783 model
= create_encodings_treeview_model ();
784 gtk_tree_view_set_model (GTK_TREE_VIEW (stock_treeview
), model
);
785 g_signal_connect (G_OBJECT (selection
), "changed",
786 G_CALLBACK (on_stock_selection_changed
), NULL
);
787 g_object_unref (model
);
789 /* Add the encoding column for supported treeview*/
790 cell
= gtk_cell_renderer_text_new ();
791 column
= gtk_tree_view_column_new_with_attributes (_("Supported Encodings"),
793 COLUMN_ENCODING_NAME
,
795 gtk_tree_view_append_column (GTK_TREE_VIEW (supported_treeview
), column
);
796 gtk_tree_view_set_search_column (GTK_TREE_VIEW (supported_treeview
),
797 COLUMN_ENCODING_NAME
);
798 selection
= gtk_tree_view_get_selection (GTK_TREE_VIEW (supported_treeview
));
799 g_return_if_fail (selection
!= NULL
);
800 gtk_tree_selection_set_mode (selection
, GTK_SELECTION_BROWSE
);
802 /* create list store */
803 model
= GTK_TREE_MODEL (gtk_list_store_new (SUPPORTED_ENCODING_NUM_COLS
,
804 G_TYPE_STRING
, G_TYPE_POINTER
));
805 gtk_tree_view_set_model (GTK_TREE_VIEW (supported_treeview
), model
);
806 g_signal_connect (G_OBJECT (selection
), "changed",
807 G_CALLBACK (on_supported_selection_changed
), NULL
);
808 g_object_unref (model
);
810 anjuta_preferences_register_property_custom (pref
, supported_treeview
,
813 ANJUTA_PROPERTY_DATA_TYPE_TEXT
,
818 g_signal_connect (G_OBJECT (add_button
), "clicked",
819 G_CALLBACK (on_add_encodings
), NULL
);
820 g_signal_connect (G_OBJECT (remove_button
), "clicked",
821 G_CALLBACK (on_remove_encodings
), NULL
);
822 g_signal_connect (G_OBJECT (up_button
), "clicked",
823 G_CALLBACK (on_up_encoding
), NULL
);
824 g_signal_connect (G_OBJECT (down_button
), "clicked",
825 G_CALLBACK (on_down_encoding
), NULL
);
827 gtk_widget_set_sensitive (add_button
, FALSE
);
828 gtk_widget_set_sensitive (remove_button
, FALSE
);
829 gtk_widget_set_sensitive (up_button
, FALSE
);
830 gtk_widget_set_sensitive (down_button
, FALSE
);
832 anjuta_encodings_dialog
= g_new0 (AnjutaEncodingsDialog
, 1);
833 anjuta_encodings_dialog
->pref
= pref
;
834 anjuta_encodings_dialog
->add_button
= add_button
;
835 anjuta_encodings_dialog
->remove_button
= remove_button
;
836 anjuta_encodings_dialog
->up_button
= up_button
;
837 anjuta_encodings_dialog
->down_button
= down_button
;
838 anjuta_encodings_dialog
->supported_treeview
= supported_treeview
;
839 anjuta_encodings_dialog
->stock_treeview
= stock_treeview
;