| File: | charpick/charpick.c |
| Warning: | line 657, column 19 Value stored to 'applet' during its initialization is never read |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
| 1 | /* charpick.c This is a cafe panel applet that allow users to select |
| 2 | * accented (and other) characters to be pasted into other apps. |
| 3 | */ |
| 4 | |
| 5 | #include <cdk/cdkx.h> |
| 6 | #include <config.h> |
| 7 | #include <string.h> |
| 8 | #include <cafe-panel-applet.h> |
| 9 | #include <cafe-panel-applet-gsettings.h> |
| 10 | #ifdef HAVE_GUCHARMAP1 |
| 11 | #include <gucharmap/gucharmap.h> |
| 12 | #endif |
| 13 | #include "charpick.h" |
| 14 | |
| 15 | /* The comment for each char list has the html entity names of the chars */ |
| 16 | /* All gunicar codes should end in 0 */ |
| 17 | |
| 18 | |
| 19 | /* This is the default list used when starting charpick the first time */ |
| 20 | /* aacute, agrave, eacute, iacute, oacute, frac12, copy*/ |
| 21 | /* static const gchar *def_list = "áàéíñóœ©"; */ |
| 22 | static const gunichar def_code[] = {225, 224, 233, 237, 241, 243, 189, 169, 1579, 8364, 0}; |
| 23 | |
| 24 | /* aacute, agrave, acirc, atilde, auml. aring, aelig, ordf */ |
| 25 | /* static const gchar *a_list = "áàâãäåæª"; */ |
| 26 | static const gunichar a_code[] = {225, 224, 226, 227, 228, 229, 230, 170, 0}; |
| 27 | /* static const gchar *cap_a_list = "ÁÀÂÃÄÅÆª"; */ |
| 28 | static const gunichar cap_a_code[] = {192, 193, 194, 195, 196, 197, 198, 170, 0}; |
| 29 | /* ccedil, cent, copy */ |
| 30 | /* static const gchar *c_list = "çÇ¢©"; */ |
| 31 | static const gunichar c_code[] = {231, 199, 162, 169, 0}; |
| 32 | /* eacute, egrave, ecirc, euml, aelig */ |
| 33 | /* static const gchar *e_list = "éèêëæ"; */ |
| 34 | static const gunichar e_code[] = {232, 233, 234, 235, 230, 0}; |
| 35 | /* static const gchar *cap_e_list = "ÉÈÊËÆ"; */ |
| 36 | static const gunichar cap_e_code[] = {200, 201, 202, 203, 198, 0}; |
| 37 | /* iacute, igrave, icirc, iuml */ |
| 38 | /* static const gchar *i_list = "íìîï"; */ |
| 39 | static const gunichar i_code[] = {236, 237, 238, 239, 0}; |
| 40 | /* static const gchar *cap_i_list = "ÍÌÎÏ"; */ |
| 41 | static const gunichar cap_i_code[] = {204, 205, 206, 207, 0}; |
| 42 | /* ntilde (this is the most important line in this program.) */ |
| 43 | /* static const gchar *n_list = "ñ, Ñ"; */ |
| 44 | static const gunichar n_code[] = {241, 209, 0}; |
| 45 | /* oacute, ograve, ocirc, otilde, ouml, oslash, ordm */ |
| 46 | /* static const gchar *o_list = "óòôõöøº"; */ |
| 47 | static const gunichar o_code[] = {242, 243, 244, 245, 246, 248, 176, 0}; |
| 48 | /* static const gchar *cap_o_list = "ÓÒÔÕÖØº"; */ |
| 49 | static const gunichar cap_o_code[] = {210, 211, 212, 213, 214, 216, 176, 0}; |
| 50 | /* szlig, sect, dollar */ |
| 51 | /* static const gchar *s_list = "ß§$"; */ |
| 52 | static const gunichar s_code[] = {223, 167, 36, 0}; |
| 53 | /* eth, thorn */ |
| 54 | /* static const gchar *t_list = "ðÐþÞ"; */ |
| 55 | static const gunichar t_code[] = {240, 208, 254, 222, 0}; |
| 56 | /* uacute, ugrave, ucirc, uuml */ |
| 57 | /* static const gchar *u_list = "úùûü"; */ |
| 58 | static const gunichar u_code[] = {249, 250, 251, 252, 0}; |
| 59 | /* static const gchar *cap_u_list = "ÚÙÛÜ"; */ |
| 60 | static const gunichar cap_u_code[] = {217, 218, 219, 220, 0}; |
| 61 | /* yacute, yuml, yen Yes, there is no capital yuml in iso 8859-1.*/ |
| 62 | /* static const gchar *y_list = "ýÝÿ¥"; */ |
| 63 | static const gunichar y_code[] = {253, 221, 255, 165, 0}; |
| 64 | |
| 65 | /* extra characters unrelated to the latin alphabet. All characters in |
| 66 | ISO-8859-1 should now be accounted for.*/ |
| 67 | /* not shy macr plusmn */ |
| 68 | /* static const gchar *dash_list = "¬¯±"; */ |
| 69 | static const gunichar dash_code[] = {172, 173, 175, 177, 0}; |
| 70 | /* laquo raquo uml */ |
| 71 | /* static const gchar *quote_list = "«»š·×"; */ |
| 72 | static const gunichar quote_code[] = {171, 187, 168, 183, 215, 0}; |
| 73 | /* curren, pound, yen, cent, dollar */ |
| 74 | /* static const gchar *currency_list = "€£¥¢$"; */ |
| 75 | static const gunichar currency_code[] = {164, 163, 165, 162, 36, 8364, 0}; |
| 76 | /* sup1 frac12 */ |
| 77 | /* static const gchar *one_list = "¹œŒ"; */ |
| 78 | static const gunichar one_code[] = {185, 178, 179, 188, 189, 190, 0}; |
| 79 | /* µ ¶ ® ¿ ¡ | */ |
| 80 | static const gunichar misc_code[] = {181, 182, 174, 191, 161, 124, 0}; |
| 81 | |
| 82 | /* language/region specific character groups */ |
| 83 | /* South Africa: Venda, Tswana and Northern Sotho */ |
| 84 | /* static const gchar *ZA_list = "ḓḽṋṱḒḼṊṰṅṄšŠ"; */ |
| 85 | static const gunichar ZA_code[] = {7699, 7741, 7755, 7793, 7698, 7740, 7754, 7792, 7749, 7748, 353, 352, 0}; |
| 86 | /* South Africa: Afrikaans */ |
| 87 | /* static const gchar *af_ZA_list = "áéíóúýêîôûèäëïöüÁÉÍÓÚÝÊÎÔÛÈÄËÏÖÜ"; */ |
| 88 | static const gunichar af_ZA_code[] = {225, 233, 237, 243, 250, 253, 234, 238, 244, 251, 232, 228, 235, 239, 246, 252, 193, 201, 205, 211, 218, 221, 202, 206, 212, 219, 200, 196, 203, 207, 214, 220, 0}; |
| 89 | |
| 90 | |
| 91 | static const gunichar * const chartable[] = { |
| 92 | def_code, |
| 93 | a_code, |
| 94 | cap_a_code, |
| 95 | c_code, |
| 96 | e_code, |
| 97 | cap_e_code, |
| 98 | i_code, |
| 99 | cap_i_code, |
| 100 | n_code, |
| 101 | o_code, |
| 102 | cap_o_code, |
| 103 | s_code, |
| 104 | t_code, |
| 105 | u_code, |
| 106 | cap_u_code, |
| 107 | y_code, |
| 108 | dash_code, |
| 109 | quote_code, |
| 110 | currency_code, |
| 111 | one_code, |
| 112 | misc_code, |
| 113 | ZA_code, |
| 114 | af_ZA_code |
| 115 | }; |
| 116 | |
| 117 | /* sets the picked character as the selection when it gets a request */ |
| 118 | static void |
| 119 | charpick_selection_handler(CtkWidget *widget G_GNUC_UNUSED__attribute__ ((__unused__)), |
| 120 | CtkSelectionData *selection_data, |
| 121 | guint info G_GNUC_UNUSED__attribute__ ((__unused__)), |
| 122 | guint time G_GNUC_UNUSED__attribute__ ((__unused__)), |
| 123 | gpointer data) |
| 124 | { |
| 125 | charpick_data *p_curr_data = data; |
| 126 | gint num; |
| 127 | gchar tmp[7]; |
| 128 | num = g_unichar_to_utf8 (p_curr_data->selected_unichar, tmp); |
| 129 | tmp[num] = '\0'; |
| 130 | |
| 131 | ctk_selection_data_set_text (selection_data, tmp, -1); |
| 132 | |
| 133 | return; |
| 134 | } |
| 135 | |
| 136 | /* untoggles the active toggle_button when we lose the selection */ |
| 137 | static gint |
| 138 | selection_clear_cb (CtkWidget *widget G_GNUC_UNUSED__attribute__ ((__unused__)), |
| 139 | CdkEventSelection *event G_GNUC_UNUSED__attribute__ ((__unused__)), |
| 140 | gpointer data) |
| 141 | { |
| 142 | charpick_data *curr_data = data; |
| 143 | |
| 144 | if (curr_data->last_toggle_button) |
| 145 | ctk_toggle_button_set_active (curr_data->last_toggle_button, FALSE(0)); |
| 146 | |
| 147 | curr_data->last_toggle_button = NULL((void*)0); |
| 148 | return TRUE(!(0)); |
| 149 | } |
| 150 | |
| 151 | |
| 152 | static gint |
| 153 | toggle_button_toggled_cb(CtkToggleButton *button, gpointer data) |
| 154 | { |
| 155 | charpick_data *curr_data = data; |
| 156 | gint button_index; |
| 157 | gboolean toggled; |
| 158 | |
| 159 | button_index = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (button), "index"))((gint) (glong) (g_object_get_data (((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((button)), (((GType) ((20) << (2))) ))))), "index"))); |
| 160 | toggled = ctk_toggle_button_get_active (button); |
| 161 | |
| 162 | if (toggled) |
| 163 | { |
| 164 | gunichar unichar; |
| 165 | if (curr_data->last_toggle_button && (button != curr_data->last_toggle_button)) |
| 166 | ctk_toggle_button_set_active (curr_data->last_toggle_button, |
| 167 | FALSE(0)); |
| 168 | |
| 169 | curr_data->last_toggle_button = button; |
| 170 | ctk_widget_grab_focus(curr_data->applet); |
| 171 | unichar = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (button), "unichar"))((gint) (glong) (g_object_get_data (((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((button)), (((GType) ((20) << (2))) ))))), "unichar"))); |
| 172 | curr_data->selected_unichar = unichar; |
| 173 | /* set this? widget as the selection owner */ |
| 174 | ctk_selection_owner_set (curr_data->applet, |
| 175 | CDK_SELECTION_PRIMARY((CdkAtom)((gpointer) (gulong) (1))), |
| 176 | CDK_CURRENT_TIME0L); |
| 177 | ctk_selection_owner_set (curr_data->applet, |
| 178 | CDK_SELECTION_CLIPBOARD((CdkAtom)((gpointer) (gulong) (69))), |
| 179 | CDK_CURRENT_TIME0L); |
| 180 | curr_data->last_index = button_index; |
| 181 | } |
| 182 | |
| 183 | return TRUE(!(0)); |
| 184 | } |
| 185 | |
| 186 | /* This is a hack around the fact that ctk+ doesn't |
| 187 | * propogate button presses on button2/3. |
| 188 | */ |
| 189 | static gboolean |
| 190 | button_press_hack (CtkWidget *widget G_GNUC_UNUSED__attribute__ ((__unused__)), |
| 191 | CdkEventButton *event, |
| 192 | CtkWidget *applet) |
| 193 | { |
| 194 | if (event->button == 3 || event->button == 2) { |
| 195 | ctk_propagate_event (applet, (CdkEvent *) event); |
| 196 | |
| 197 | return TRUE(!(0)); |
| 198 | } |
| 199 | |
| 200 | return FALSE(0); |
| 201 | } |
| 202 | |
| 203 | static gint |
| 204 | key_press_event (CtkWidget *widget G_GNUC_UNUSED__attribute__ ((__unused__)), |
| 205 | CdkEventKey *event G_GNUC_UNUSED__attribute__ ((__unused__)), |
| 206 | gpointer data G_GNUC_UNUSED__attribute__ ((__unused__))) |
| 207 | { |
| 208 | #if 0 |
| 209 | charpick_data *p_curr_data = data; |
| 210 | const gunichar *code = NULL((void*)0); |
| 211 | gchar inputchar = event->keyval; |
| 212 | |
| 213 | switch (inputchar) |
| 214 | { |
| 215 | case 'a' : code = a_code; |
| 216 | break; |
| 217 | case 'A' : code = cap_a_code; |
| 218 | break; |
| 219 | case 'c' : |
| 220 | case 'C' : code = c_code; |
| 221 | break; |
| 222 | case 'e' : code = e_code; |
| 223 | break; |
| 224 | case 'E' : code = cap_e_code; |
| 225 | break; |
| 226 | case 'i' : code = i_code; |
| 227 | break; |
| 228 | case 'I' : code = cap_i_code; |
| 229 | break; |
| 230 | case 'n' : |
| 231 | case 'N' : code = n_code; |
| 232 | break; |
| 233 | case 'o' : code = o_code; |
| 234 | break; |
| 235 | case 'O' : code = cap_o_code; |
| 236 | break; |
| 237 | case 's' : code = s_code; |
| 238 | break; |
| 239 | case 't' : |
| 240 | case 'T' : code = t_code; |
| 241 | break; |
| 242 | case 'u' : code = u_code; |
| 243 | break; |
| 244 | case 'U' : code = cap_u_code; |
| 245 | break; |
| 246 | case 'y' : |
| 247 | case 'Y' : code = y_code; |
| 248 | break; |
| 249 | case '-' : code = dash_code; |
| 250 | break; |
| 251 | case '\"' : code = quote_code; |
| 252 | break; |
| 253 | case '$' : code = currency_code; |
| 254 | break; |
| 255 | case '1' : |
| 256 | case '2' : |
| 257 | case '3' : code = one_code; |
| 258 | break; |
| 259 | case 'd' : code = NULL((void*)0); |
| 260 | break; |
| 261 | default : |
| 262 | return FALSE(0); |
| 263 | } |
| 264 | /* FIXME: what's wrong here ? */ |
| 265 | if (code) |
| 266 | p_curr_data->charlist = g_ucs4_to_utf8 (code, -1, NULL((void*)0), NULL((void*)0), NULL((void*)0)); |
| 267 | else |
| 268 | p_curr_data->charlist = "hello"; |
| 269 | p_curr_data->last_index = NO_LAST_INDEX-1; |
| 270 | p_curr_data->last_toggle_button = NULL((void*)0); |
| 271 | build_table(p_curr_data); |
| 272 | #endif |
| 273 | return FALSE(0); |
| 274 | } |
| 275 | |
| 276 | static void |
| 277 | menuitem_activated (CtkMenuItem *menuitem, charpick_data *curr_data) |
| 278 | { |
| 279 | gchar *string; |
| 280 | CafePanelApplet *applet = CAFE_PANEL_APPLET (curr_data->applet)((((CafePanelApplet*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((curr_data->applet)), ((cafe_panel_applet_get_type ()) ))))); |
| 281 | |
| 282 | string = g_object_get_data (G_OBJECT (menuitem)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((menuitem)), (((GType) ((20) << (2)))))))), "string"); |
| 283 | if (g_ascii_strcasecmp (curr_data->charlist, string) == 0) |
| 284 | return; |
| 285 | |
| 286 | curr_data->charlist = string; |
| 287 | build_table (curr_data); |
| 288 | if (g_settings_is_writable (curr_data->settings, "current-list")) |
| 289 | g_settings_set_string (curr_data->settings, "current-list", curr_data->charlist); |
| 290 | } |
| 291 | |
| 292 | void |
| 293 | populate_menu (charpick_data *curr_data) |
| 294 | { |
| 295 | GList *list = curr_data->chartable; |
| 296 | GSList *group = NULL((void*)0); |
| 297 | CtkMenu *menu; |
| 298 | CtkWidget *menuitem; |
| 299 | |
| 300 | if (curr_data->menu) |
| 301 | ctk_widget_destroy (curr_data->menu); |
| 302 | |
| 303 | curr_data->menu = ctk_menu_new (); |
| 304 | menu = CTK_MENU (curr_data->menu)((((CtkMenu*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((curr_data->menu)), ((ctk_menu_get_type ())))))); |
| 305 | |
| 306 | while (list) { |
| 307 | gchar *string = list->data; |
| 308 | menuitem = ctk_radio_menu_item_new_with_label (group, string); |
| 309 | group = ctk_radio_menu_item_get_group (CTK_RADIO_MENU_ITEM (menuitem)((((CtkRadioMenuItem*) (void *) g_type_check_instance_cast (( GTypeInstance*) ((menuitem)), ((ctk_radio_menu_item_get_type ( )))))))); |
| 310 | ctk_widget_show (menuitem); |
| 311 | g_object_set_data (G_OBJECT (menuitem)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((menuitem)), (((GType) ((20) << (2)))))))), "string", string); |
| 312 | g_signal_connect (G_OBJECT (menuitem), "activate",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((menuitem)), (((GType) ((20) << (2) )))))))), ("activate"), (((GCallback) (menuitem_activated))), (curr_data), ((void*)0), (GConnectFlags) 0) |
| 313 | G_CALLBACK (menuitem_activated), curr_data)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((menuitem)), (((GType) ((20) << (2) )))))))), ("activate"), (((GCallback) (menuitem_activated))), (curr_data), ((void*)0), (GConnectFlags) 0); |
| 314 | ctk_menu_shell_append (CTK_MENU_SHELL (menu)((((CtkMenuShell*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((menu)), ((ctk_menu_shell_get_type ())))))), menuitem); |
| 315 | if (g_ascii_strcasecmp (curr_data->charlist, string) == 0) |
| 316 | ctk_check_menu_item_set_active (CTK_CHECK_MENU_ITEM (menuitem)((((CtkCheckMenuItem*) (void *) g_type_check_instance_cast (( GTypeInstance*) ((menuitem)), ((ctk_check_menu_item_get_type ( ))))))), TRUE(!(0))); |
| 317 | list = g_list_next (list)((list) ? (((GList *)(list))->next) : ((void*)0)); |
| 318 | } |
| 319 | build_table(curr_data); |
| 320 | |
| 321 | /*Set up custom theme and transparency support*/ |
| 322 | CtkWidget *toplevel = ctk_widget_get_toplevel (CTK_WIDGET (menu)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((menu)), ((ctk_widget_get_type ()))))))); |
| 323 | /* Fix any failures of compiz/other wm's to communicate with ctk for transparency */ |
| 324 | CdkScreen *screen = ctk_widget_get_screen(CTK_WIDGET(toplevel)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((toplevel)), ((ctk_widget_get_type ()))))))); |
| 325 | CdkVisual *visual = cdk_screen_get_rgba_visual(screen); |
| 326 | ctk_widget_set_visual(CTK_WIDGET(toplevel)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((toplevel)), ((ctk_widget_get_type ())))))), visual); |
| 327 | /* Set menu and it's toplevel window to follow panel theme */ |
| 328 | CtkStyleContext *context; |
| 329 | context = ctk_widget_get_style_context (CTK_WIDGET(toplevel)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((toplevel)), ((ctk_widget_get_type ()))))))); |
| 330 | ctk_style_context_add_class(context,"gnome-panel-menu-bar"); |
| 331 | ctk_style_context_add_class(context,"cafe-panel-menu-bar"); |
| 332 | } |
| 333 | |
| 334 | static void |
| 335 | chooser_button_clicked (CtkButton *button, charpick_data *curr_data) |
| 336 | { |
| 337 | if (ctk_widget_get_visible (curr_data->menu)) |
| 338 | ctk_menu_popdown (CTK_MENU (curr_data->menu)((((CtkMenu*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((curr_data->menu)), ((ctk_menu_get_type ()))))))); |
| 339 | else { |
| 340 | ctk_menu_set_screen (CTK_MENU (curr_data->menu)((((CtkMenu*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((curr_data->menu)), ((ctk_menu_get_type ())))))), |
| 341 | ctk_widget_get_screen (CTK_WIDGET (curr_data->applet)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((curr_data->applet)), ((ctk_widget_get_type ())))))))); |
| 342 | |
| 343 | ctk_menu_popup_at_widget (CTK_MENU (curr_data->menu)((((CtkMenu*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((curr_data->menu)), ((ctk_menu_get_type ())))))), |
| 344 | CTK_WIDGET (button)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((button)), ((ctk_widget_get_type ())))))), |
| 345 | CDK_GRAVITY_SOUTH_WEST, |
| 346 | CDK_GRAVITY_NORTH_WEST, |
| 347 | NULL((void*)0)); |
| 348 | } |
| 349 | } |
| 350 | |
| 351 | /* Force the button not to have any focus padding and let the focus |
| 352 | indication be drawn on the label itself when space is tight. Taken from the clock applet. |
| 353 | FIXME : This is an Evil Hack and should be fixed when the focus padding can be overridden at the ctk+ level */ |
| 354 | |
| 355 | static inline void force_no_button_padding (CtkWidget *widget) |
| 356 | { |
| 357 | CtkCssProvider *provider; |
| 358 | |
| 359 | provider = ctk_css_provider_new (); |
| 360 | |
| 361 | ctk_css_provider_load_from_data (provider, |
| 362 | "#charpick-applet-button {\n" |
| 363 | "border-width: 0px;\n" |
| 364 | "padding: 0px;\n" |
| 365 | "margin: 0px;\n" |
| 366 | "}", |
| 367 | -1, |
| 368 | NULL((void*)0)); |
| 369 | ctk_style_context_add_provider (ctk_widget_get_style_context (widget), |
| 370 | CTK_STYLE_PROVIDER (provider)((((CtkStyleProvider*) (void *) g_type_check_instance_cast (( GTypeInstance*) ((provider)), ((ctk_style_provider_get_type ( ))))))), |
| 371 | CTK_STYLE_PROVIDER_PRIORITY_APPLICATION600); |
| 372 | |
| 373 | g_object_unref (provider); |
| 374 | |
| 375 | ctk_widget_set_name (widget, "charpick-applet-button"); |
| 376 | } |
| 377 | |
| 378 | /* creates table of buttons, sets up their callbacks, and packs the table in |
| 379 | the event box */ |
| 380 | |
| 381 | void |
| 382 | build_table(charpick_data *p_curr_data) |
| 383 | { |
| 384 | CtkWidget *box, *button_box, **row_box; |
| 385 | CtkWidget *button, *arrow; |
| 386 | gint i = 0, len = g_utf8_strlen (p_curr_data->charlist, -1); |
| 387 | CtkWidget **toggle_button; |
| 388 | gchar *charlist; |
| 389 | gint max_width=1, max_height=1; |
| 390 | gint size_ratio; |
| 391 | |
| 392 | toggle_button = g_new (CtkWidget *, len)((CtkWidget * *) g_malloc_n ((len), sizeof (CtkWidget *))); |
| 393 | |
| 394 | if (p_curr_data->box) |
| 395 | ctk_widget_destroy(p_curr_data->box); |
| 396 | |
| 397 | if (p_curr_data->panel_vertical) |
| 398 | box = ctk_box_new (CTK_ORIENTATION_VERTICAL, 0); |
| 399 | else |
| 400 | box = ctk_box_new (CTK_ORIENTATION_HORIZONTAL, 0); |
| 401 | ctk_widget_show (box); |
| 402 | p_curr_data->box = box; |
| 403 | |
| 404 | button = ctk_button_new (); |
| 405 | if (g_list_length (p_curr_data->chartable) != 1) |
| 406 | { |
| 407 | ctk_widget_set_tooltip_text (button, _("Available palettes")gettext ("Available palettes")); |
| 408 | |
| 409 | switch (cafe_panel_applet_get_orient (CAFE_PANEL_APPLET (p_curr_data->applet)((((CafePanelApplet*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((p_curr_data->applet)), ((cafe_panel_applet_get_type ( ))))))))) { |
| 410 | case CAFE_PANEL_APPLET_ORIENT_DOWN: |
| 411 | arrow = ctk_image_new_from_icon_name ("pan-down-symbolic", CTK_ICON_SIZE_MENU); |
| 412 | break; |
| 413 | case CAFE_PANEL_APPLET_ORIENT_UP: |
| 414 | arrow = ctk_image_new_from_icon_name ("pan-up-symbolic", CTK_ICON_SIZE_MENU); |
| 415 | break; |
| 416 | case CAFE_PANEL_APPLET_ORIENT_LEFT: |
| 417 | arrow = ctk_image_new_from_icon_name ("pan-start-symbolic", CTK_ICON_SIZE_MENU); |
| 418 | break; |
| 419 | case CAFE_PANEL_APPLET_ORIENT_RIGHT: |
| 420 | arrow = ctk_image_new_from_icon_name ("pan-end-symbolic", CTK_ICON_SIZE_MENU); |
| 421 | break; |
| 422 | default: |
| 423 | g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "charpick.c", 423 , ((const char*) (__func__)), ((void*)0)); } while (0); |
| 424 | } |
| 425 | ctk_container_add (CTK_CONTAINER (button)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((button)), ((ctk_container_get_type ())))))), arrow); |
| 426 | ctk_button_set_relief(CTK_BUTTON(button)((((CtkButton*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((button)), ((ctk_button_get_type ())))))), CTK_RELIEF_NONE); |
| 427 | |
| 428 | /* FIXME : evil hack (see force_no_button_padding) */ |
| 429 | force_no_button_padding (button); |
| 430 | |
| 431 | ctk_box_pack_start (CTK_BOX (box)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((box)), ((ctk_box_get_type ())))))), button, TRUE(!(0)), TRUE(!(0)), 0); |
| 432 | g_signal_connect (G_OBJECT (button), "clicked",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((button)), (((GType) ((20) << (2))) )))))), ("clicked"), (((GCallback) (chooser_button_clicked))) , (p_curr_data), ((void*)0), (GConnectFlags) 0) |
| 433 | G_CALLBACK (chooser_button_clicked),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((button)), (((GType) ((20) << (2))) )))))), ("clicked"), (((GCallback) (chooser_button_clicked))) , (p_curr_data), ((void*)0), (GConnectFlags) 0) |
| 434 | p_curr_data)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((button)), (((GType) ((20) << (2))) )))))), ("clicked"), (((GCallback) (chooser_button_clicked))) , (p_curr_data), ((void*)0), (GConnectFlags) 0); |
| 435 | g_signal_connect (G_OBJECT (button), "button_press_event",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((button)), (((GType) ((20) << (2))) )))))), ("button_press_event"), (((GCallback) (button_press_hack ))), (p_curr_data->applet), ((void*)0), (GConnectFlags) 0) |
| 436 | G_CALLBACK (button_press_hack),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((button)), (((GType) ((20) << (2))) )))))), ("button_press_event"), (((GCallback) (button_press_hack ))), (p_curr_data->applet), ((void*)0), (GConnectFlags) 0) |
| 437 | p_curr_data->applet)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((button)), (((GType) ((20) << (2))) )))))), ("button_press_event"), (((GCallback) (button_press_hack ))), (p_curr_data->applet), ((void*)0), (GConnectFlags) 0); |
| 438 | |
| 439 | } |
| 440 | |
| 441 | charlist = g_strdup (p_curr_data->charlist)g_strdup_inline (p_curr_data->charlist); |
| 442 | for (i = 0; i < len; i++) { |
| 443 | gchar label[7]; |
| 444 | CtkRequisition req; |
| 445 | gchar *atk_desc; |
| 446 | gchar *name; |
| 447 | |
| 448 | g_utf8_strncpy (label, charlist, 1); |
| 449 | charlist = g_utf8_next_char (charlist)((charlist) + g_utf8_skip[*(const guchar *)(charlist)]); |
| 450 | |
| 451 | #ifdef HAVE_GUCHARMAP1 |
| 452 | /* TRANSLATOR: This sentance reads something like 'Insert "PILCROW SIGN"' |
| 453 | * hopefully, the name of the unicode character has already |
| 454 | * been translated. |
| 455 | */ |
| 456 | name = g_strdup_printf (_("Insert \"%s\"")gettext ("Insert \"%s\""), |
| 457 | gucharmap_get_unicode_name (g_utf8_get_char (label))); |
| 458 | #else |
| 459 | name = g_strdup (_("Insert special character"))g_strdup_inline (gettext ("Insert special character")); |
| 460 | #endif |
| 461 | |
| 462 | toggle_button[i] = ctk_toggle_button_new_with_label (label); |
| 463 | atk_desc = g_strdup_printf (_("insert special character %s")gettext ("insert special character %s"), label); |
| 464 | set_atk_name_description (toggle_button[i], NULL((void*)0), atk_desc); |
| 465 | g_free (atk_desc); |
| 466 | ctk_widget_show (toggle_button[i]); |
| 467 | ctk_button_set_relief(CTK_BUTTON(toggle_button[i])((((CtkButton*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((toggle_button[i])), ((ctk_button_get_type ())))))), CTK_RELIEF_NONE); |
| 468 | |
| 469 | /* FIXME : evil hack (see force_no_button_padding) */ |
| 470 | force_no_button_padding (toggle_button[i]); |
| 471 | |
| 472 | ctk_widget_set_tooltip_text (toggle_button[i], name); |
| 473 | g_free (name); |
| 474 | |
| 475 | ctk_widget_get_preferred_size (toggle_button[i], NULL((void*)0), &req); |
| 476 | |
| 477 | max_width = MAX (max_width, req.width)(((max_width) > (req.width)) ? (max_width) : (req.width)); |
| 478 | max_height = MAX (max_height, req.height-2)(((max_height) > (req.height-2)) ? (max_height) : (req.height -2)); |
| 479 | |
| 480 | g_object_set_data (G_OBJECT (toggle_button[i])((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((toggle_button[i])), (((GType) ((20) << (2)))))))), "unichar", |
| 481 | GINT_TO_POINTER(g_utf8_get_char (label))((gpointer) (glong) (g_utf8_get_char (label)))); |
| 482 | g_signal_connect (G_OBJECT (toggle_button[i]), "toggled",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((toggle_button[i])), (((GType) ((20) << (2))))))))), ("toggled"), (((GCallback) (toggle_button_toggled_cb ))), (p_curr_data), ((void*)0), (GConnectFlags) 0) |
| 483 | G_CALLBACK (toggle_button_toggled_cb),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((toggle_button[i])), (((GType) ((20) << (2))))))))), ("toggled"), (((GCallback) (toggle_button_toggled_cb ))), (p_curr_data), ((void*)0), (GConnectFlags) 0) |
| 484 | p_curr_data)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((toggle_button[i])), (((GType) ((20) << (2))))))))), ("toggled"), (((GCallback) (toggle_button_toggled_cb ))), (p_curr_data), ((void*)0), (GConnectFlags) 0); |
| 485 | g_signal_connect (G_OBJECT (toggle_button[i]), "button_press_event",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((toggle_button[i])), (((GType) ((20) << (2))))))))), ("button_press_event"), (((GCallback) (button_press_hack ))), (p_curr_data->applet), ((void*)0), (GConnectFlags) 0) |
| 486 | G_CALLBACK (button_press_hack), p_curr_data->applet)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((toggle_button[i])), (((GType) ((20) << (2))))))))), ("button_press_event"), (((GCallback) (button_press_hack ))), (p_curr_data->applet), ((void*)0), (GConnectFlags) 0); |
| 487 | } |
| 488 | |
| 489 | if (p_curr_data->panel_vertical) { |
| 490 | size_ratio = p_curr_data->panel_size / max_width; |
| 491 | button_box = ctk_box_new (CTK_ORIENTATION_HORIZONTAL, 0); |
| 492 | } else { |
| 493 | size_ratio = p_curr_data->panel_size / max_height; |
| 494 | button_box = ctk_box_new (CTK_ORIENTATION_VERTICAL, 0); |
| 495 | } |
| 496 | |
| 497 | ctk_box_set_homogeneous (CTK_BOX (button_box)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((button_box)), ((ctk_box_get_type ())))))), TRUE(!(0))); |
| 498 | ctk_box_pack_start (CTK_BOX (box)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((box)), ((ctk_box_get_type ())))))), button_box, TRUE(!(0)), TRUE(!(0)), 0); |
| 499 | |
| 500 | size_ratio = MAX (size_ratio, 1)(((size_ratio) > (1)) ? (size_ratio) : (1)); |
| 501 | row_box = g_new0 (CtkWidget *, size_ratio)((CtkWidget * *) g_malloc0_n ((size_ratio), sizeof (CtkWidget *))); |
| 502 | for (i=0; i < size_ratio; i++) { |
| 503 | if (!p_curr_data->panel_vertical) row_box[i] = ctk_box_new (CTK_ORIENTATION_HORIZONTAL, 0); |
| 504 | else row_box[i] = ctk_box_new (CTK_ORIENTATION_VERTICAL, 0); |
| 505 | ctk_box_set_homogeneous (CTK_BOX (row_box[i])((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((row_box[i])), ((ctk_box_get_type ())))))), TRUE(!(0))); |
| 506 | ctk_box_pack_start (CTK_BOX (button_box)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((button_box)), ((ctk_box_get_type ())))))), row_box[i], TRUE(!(0)), TRUE(!(0)), 0); |
| 507 | } |
| 508 | |
| 509 | for (i = 0; i <len; i++) { |
| 510 | int delta = len/size_ratio; |
| 511 | int index; |
| 512 | |
| 513 | if (delta > 0) |
| 514 | index = i / delta; |
| 515 | else |
| 516 | index = i; |
| 517 | |
| 518 | index = CLAMP (index, 0, size_ratio-1)(((index) > (size_ratio-1)) ? (size_ratio-1) : (((index) < (0)) ? (0) : (index))); |
| 519 | ctk_box_pack_start (CTK_BOX (row_box[index])((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((row_box[index])), ((ctk_box_get_type ())))))), toggle_button[i], TRUE(!(0)), TRUE(!(0)), 0); |
| 520 | } |
| 521 | |
| 522 | g_free (toggle_button); |
| 523 | g_free (row_box); |
| 524 | |
| 525 | ctk_container_add (CTK_CONTAINER(p_curr_data->applet)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((p_curr_data->applet)), ((ctk_container_get_type ()))) ))), box); |
| 526 | ctk_widget_show_all (p_curr_data->box); |
| 527 | |
| 528 | p_curr_data->last_index = NO_LAST_INDEX-1; |
| 529 | p_curr_data->last_toggle_button = NULL((void*)0); |
| 530 | |
| 531 | } |
| 532 | |
| 533 | static void applet_size_allocate (CafePanelApplet *applet G_GNUC_UNUSED__attribute__ ((__unused__)), |
| 534 | CtkAllocation *allocation, |
| 535 | gpointer data) |
| 536 | { |
| 537 | charpick_data *curr_data = data; |
| 538 | if (curr_data->panel_vertical) { |
| 539 | if (curr_data->panel_size == allocation->width) |
| 540 | return; |
| 541 | curr_data->panel_size = allocation->width; |
| 542 | } else { |
| 543 | if (curr_data->panel_size == allocation->height) |
| 544 | return; |
| 545 | curr_data->panel_size = allocation->height; |
| 546 | } |
| 547 | |
| 548 | build_table (curr_data); |
| 549 | return; |
| 550 | } |
| 551 | |
| 552 | static void applet_change_orient (CafePanelApplet *applet G_GNUC_UNUSED__attribute__ ((__unused__)), |
| 553 | CafePanelAppletOrient o, |
| 554 | gpointer data) |
| 555 | { |
| 556 | charpick_data *curr_data = data; |
| 557 | if (o == CAFE_PANEL_APPLET_ORIENT_UP || |
| 558 | o == CAFE_PANEL_APPLET_ORIENT_DOWN) |
| 559 | curr_data->panel_vertical = FALSE(0); |
| 560 | else |
| 561 | curr_data->panel_vertical = TRUE(!(0)); |
| 562 | build_table (curr_data); |
| 563 | return; |
| 564 | } |
| 565 | |
| 566 | |
| 567 | static void |
| 568 | about (CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)), |
| 569 | charpick_data *curr_data G_GNUC_UNUSED__attribute__ ((__unused__))) |
| 570 | { |
| 571 | static const char * const authors[] = { |
| 572 | "Alexandre Muñiz <munizao@xprt.net>", |
| 573 | "Kevin Vandersloot", |
| 574 | "Pablo Barciela <scow@riseup.net>", |
| 575 | NULL((void*)0) |
| 576 | }; |
| 577 | |
| 578 | static const gchar* documenters[] = { |
| 579 | "Dan Mueth <d-mueth@uchicago.edu>", |
| 580 | N_("Sun GNOME Documentation Team <gdocteam@sun.com>")("Sun GNOME Documentation Team <gdocteam@sun.com>"), |
| 581 | N_("MATE Documentation Team")("MATE Documentation Team"), |
| 582 | N_("CAFE Documentation Team")("CAFE Documentation Team"), |
| 583 | NULL((void*)0) |
| 584 | }; |
| 585 | |
| 586 | #ifdef ENABLE_NLS1 |
| 587 | const char **p; |
| 588 | for (p = documenters; *p; ++p) |
| 589 | *p = _(*p)gettext (*p); |
| 590 | #endif |
| 591 | |
| 592 | ctk_show_about_dialog (NULL((void*)0), |
| 593 | "title", _("About Character Palette")gettext ("About Character Palette"), |
| 594 | "version", VERSION"1.25.0", |
| 595 | "copyright", _("Copyright \xc2\xa9 1998, 2004-2005 GNOME Applets Maintainers and others\n"gettext ("Copyright \xc2\xa9 1998, 2004-2005 GNOME Applets Maintainers and others\n" "Copyright \xc2\xa9 2012-2020 MATE developers\n" "Copyright \xc2\xa9 2023-2024 Pablo Barciela" ) |
| 596 | "Copyright \xc2\xa9 2012-2020 MATE developers\n"gettext ("Copyright \xc2\xa9 1998, 2004-2005 GNOME Applets Maintainers and others\n" "Copyright \xc2\xa9 2012-2020 MATE developers\n" "Copyright \xc2\xa9 2023-2024 Pablo Barciela" ) |
| 597 | "Copyright \xc2\xa9 2023-2024 Pablo Barciela")gettext ("Copyright \xc2\xa9 1998, 2004-2005 GNOME Applets Maintainers and others\n" "Copyright \xc2\xa9 2012-2020 MATE developers\n" "Copyright \xc2\xa9 2023-2024 Pablo Barciela" ), |
| 598 | "comments", _("Cafe Panel applet for selecting strange "gettext ("Cafe Panel applet for selecting strange " "characters that are not on my keyboard. " "Released under GNU General Public Licence.") |
| 599 | "characters that are not on my keyboard. "gettext ("Cafe Panel applet for selecting strange " "characters that are not on my keyboard. " "Released under GNU General Public Licence.") |
| 600 | "Released under GNU General Public Licence.")gettext ("Cafe Panel applet for selecting strange " "characters that are not on my keyboard. " "Released under GNU General Public Licence."), |
| 601 | "authors", authors, |
| 602 | "documenters", documenters, |
| 603 | "translator-credits", _("translator-credits")gettext ("translator-credits"), |
| 604 | "logo-icon-name", "accessories-character-map", |
| 605 | NULL((void*)0)); |
| 606 | } |
| 607 | |
| 608 | |
| 609 | static void |
| 610 | help_cb (CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)), |
| 611 | charpick_data *curr_data G_GNUC_UNUSED__attribute__ ((__unused__))) |
| 612 | { |
| 613 | GError *error = NULL((void*)0); |
| 614 | |
| 615 | ctk_show_uri_on_window (NULL((void*)0), |
| 616 | "help:cafe-char-palette", |
| 617 | ctk_get_current_event_time (), |
| 618 | &error); |
| 619 | |
| 620 | if (error) { /* FIXME: the user needs to see this */ |
| 621 | g_warning ("help error: %s\n", error->message); |
| 622 | g_error_free (error); |
| 623 | error = NULL((void*)0); |
| 624 | } |
| 625 | } |
| 626 | |
| 627 | static void |
| 628 | applet_destroy (CtkWidget *widget G_GNUC_UNUSED__attribute__ ((__unused__)), |
| 629 | gpointer data) |
| 630 | { |
| 631 | charpick_data *curr_data = data; |
| 632 | |
| 633 | g_return_if_fail (curr_data)do { if ((curr_data)) { } else { g_return_if_fail_warning ((( gchar*) 0), ((const char*) (__func__)), "curr_data"); return; } } while (0); |
| 634 | |
| 635 | if (curr_data->about_dialog) |
| 636 | ctk_widget_destroy (curr_data->about_dialog); |
| 637 | if (curr_data->propwindow) |
| 638 | ctk_widget_destroy (curr_data->propwindow); |
| 639 | if (curr_data->box) |
| 640 | ctk_widget_destroy (curr_data->box); |
| 641 | if (curr_data->menu) |
| 642 | ctk_widget_destroy (curr_data->menu); |
| 643 | g_free (curr_data); |
| 644 | |
| 645 | } |
| 646 | |
| 647 | void |
| 648 | save_chartable (charpick_data *curr_data) |
| 649 | { |
| 650 | cafe_panel_applet_settings_set_glist (curr_data->settings, |
| 651 | "chartable", curr_data->chartable); |
| 652 | } |
| 653 | |
| 654 | static void |
| 655 | get_chartable (charpick_data *curr_data) |
| 656 | { |
| 657 | CafePanelApplet *applet = CAFE_PANEL_APPLET (curr_data->applet)((((CafePanelApplet*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((curr_data->applet)), ((cafe_panel_applet_get_type ()) ))))); |
Value stored to 'applet' during its initialization is never read | |
| 658 | gint i, n; |
| 659 | GList *value = NULL((void*)0); |
| 660 | |
| 661 | value = cafe_panel_applet_settings_get_glist (curr_data->settings, "chartable"); |
| 662 | if (value) { |
| 663 | curr_data->chartable = value; |
| 664 | } |
| 665 | else { |
| 666 | n = G_N_ELEMENTS (chartable)(sizeof (chartable) / sizeof ((chartable)[0])); |
| 667 | for (i=0; i<n; i++) { |
| 668 | gchar *string; |
| 669 | |
| 670 | string = g_ucs4_to_utf8 (chartable[i], -1, NULL((void*)0), NULL((void*)0), NULL((void*)0)); |
| 671 | curr_data->chartable = g_list_append (curr_data->chartable, string); |
| 672 | |
| 673 | } |
| 674 | if ( ! g_settings_is_writable (curr_data->settings, "chartable")) |
| 675 | save_chartable (curr_data); |
| 676 | } |
| 677 | |
| 678 | |
| 679 | } |
| 680 | |
| 681 | static const CtkActionEntry charpick_applet_menu_actions [] = { |
| 682 | { "Preferences", "document-properties", N_("_Preferences")("_Preferences"), |
| 683 | NULL((void*)0), NULL((void*)0), |
| 684 | G_CALLBACK (show_preferences_dialog)((GCallback) (show_preferences_dialog)) }, |
| 685 | { "Help", "help-browser", N_("_Help")("_Help"), |
| 686 | NULL((void*)0), NULL((void*)0), |
| 687 | G_CALLBACK (help_cb)((GCallback) (help_cb)) }, |
| 688 | { "About", "help-about", N_("_About")("_About"), |
| 689 | NULL((void*)0), NULL((void*)0), |
| 690 | G_CALLBACK (about)((GCallback) (about)) } |
| 691 | }; |
| 692 | |
| 693 | void |
| 694 | set_atk_name_description (CtkWidget *widget, const gchar *name, |
| 695 | const gchar *description) |
| 696 | { |
| 697 | AtkObject *aobj; |
| 698 | aobj = ctk_widget_get_accessible (widget); |
| 699 | /* return if gail is not loaded */ |
| 700 | if (CTK_IS_ACCESSIBLE (aobj)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) ( (aobj)); GType __t = ((ctk_accessible_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))) == FALSE(0)) |
| 701 | return; |
| 702 | if (name) |
| 703 | atk_object_set_name (aobj, name); |
| 704 | if (description) |
| 705 | atk_object_set_description (aobj, description); |
| 706 | } |
| 707 | |
| 708 | static void |
| 709 | make_applet_accessible (CtkWidget *applet) |
| 710 | { |
| 711 | set_atk_name_description (applet, _("Character Palette")gettext ("Character Palette"), _("Insert characters")gettext ("Insert characters")); |
| 712 | } |
| 713 | |
| 714 | static gboolean |
| 715 | charpicker_applet_fill (CafePanelApplet *applet) |
| 716 | { |
| 717 | CafePanelAppletOrient orientation; |
| 718 | charpick_data *curr_data; |
| 719 | CdkAtom utf8_atom; |
| 720 | GList *list; |
| 721 | gchar *string; |
| 722 | CtkActionGroup *action_group; |
| 723 | gchar *ui_path; |
| 724 | |
| 725 | g_set_application_name (_("Character Palette")gettext ("Character Palette")); |
| 726 | |
| 727 | ctk_window_set_default_icon_name ("accessories-character-map"); |
| 728 | |
| 729 | g_object_set (ctk_settings_get_default (), "ctk-menu-images", TRUE(!(0)), NULL((void*)0)); |
| 730 | g_object_set (ctk_settings_get_default (), "ctk-button-images", TRUE(!(0)), NULL((void*)0)); |
| 731 | |
| 732 | cafe_panel_applet_set_background_widget (applet, CTK_WIDGET (applet)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((applet)), ((ctk_widget_get_type ()))))))); |
| 733 | |
| 734 | cafe_panel_applet_set_flags (applet, CAFE_PANEL_APPLET_EXPAND_MINOR); |
| 735 | |
| 736 | curr_data = g_new0 (charpick_data, 1)((charpick_data *) g_malloc0_n ((1), sizeof (charpick_data))); |
| 737 | curr_data->last_index = NO_LAST_INDEX-1; |
| 738 | curr_data->applet = CTK_WIDGET (applet)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((applet)), ((ctk_widget_get_type ())))))); |
| 739 | curr_data->about_dialog = NULL((void*)0); |
| 740 | curr_data->add_edit_dialog = NULL((void*)0); |
| 741 | curr_data->settings = cafe_panel_applet_settings_new (applet, "org.cafe.panel.applet.charpick"); |
| 742 | |
| 743 | get_chartable (curr_data); |
| 744 | |
| 745 | string = g_settings_get_string (curr_data->settings, "current-list"); |
| 746 | if (string) { |
| 747 | list = curr_data->chartable; |
| 748 | while (list) { |
| 749 | if (g_ascii_strcasecmp (list->data, string) == 0) |
| 750 | curr_data->charlist = list->data; |
| 751 | list = g_list_next (list)((list) ? (((GList *)(list))->next) : ((void*)0)); |
| 752 | } |
| 753 | /* FIXME: yeah leak, but this code is full of leaks and evil |
| 754 | point shuffling. This should really be rewritten |
| 755 | -George */ |
| 756 | if (curr_data->charlist == NULL((void*)0)) |
| 757 | curr_data->charlist = string; |
| 758 | else |
| 759 | g_free (string); |
| 760 | } else { |
| 761 | curr_data->charlist = curr_data->chartable->data; |
| 762 | } |
| 763 | |
| 764 | curr_data->panel_size = cafe_panel_applet_get_size (applet); |
| 765 | |
| 766 | orientation = cafe_panel_applet_get_orient (applet); |
| 767 | curr_data->panel_vertical = (orientation == CAFE_PANEL_APPLET_ORIENT_LEFT) |
| 768 | || (orientation == CAFE_PANEL_APPLET_ORIENT_RIGHT); |
| 769 | build_table (curr_data); |
| 770 | |
| 771 | g_signal_connect (G_OBJECT (curr_data->applet), "key_press_event",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((curr_data->applet)), (((GType) ((20) << (2))))))))), ("key_press_event"), (((GCallback) (key_press_event ))), (curr_data), ((void*)0), (GConnectFlags) 0) |
| 772 | G_CALLBACK (key_press_event), curr_data)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((curr_data->applet)), (((GType) ((20) << (2))))))))), ("key_press_event"), (((GCallback) (key_press_event ))), (curr_data), ((void*)0), (GConnectFlags) 0); |
| 773 | |
| 774 | utf8_atom = cdk_atom_intern ("UTF8_STRING", FALSE(0)); |
| 775 | ctk_selection_add_target (curr_data->applet, |
| 776 | CDK_SELECTION_PRIMARY((CdkAtom)((gpointer) (gulong) (1))), |
| 777 | utf8_atom, |
| 778 | 0); |
| 779 | ctk_selection_add_target (curr_data->applet, |
| 780 | CDK_SELECTION_CLIPBOARD((CdkAtom)((gpointer) (gulong) (69))), |
| 781 | utf8_atom, |
| 782 | 0); |
| 783 | g_signal_connect (G_OBJECT (curr_data->applet), "selection_get",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((curr_data->applet)), (((GType) ((20) << (2))))))))), ("selection_get"), (((GCallback) (charpick_selection_handler ))), (curr_data), ((void*)0), (GConnectFlags) 0) |
| 784 | G_CALLBACK (charpick_selection_handler),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((curr_data->applet)), (((GType) ((20) << (2))))))))), ("selection_get"), (((GCallback) (charpick_selection_handler ))), (curr_data), ((void*)0), (GConnectFlags) 0) |
| 785 | curr_data)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((curr_data->applet)), (((GType) ((20) << (2))))))))), ("selection_get"), (((GCallback) (charpick_selection_handler ))), (curr_data), ((void*)0), (GConnectFlags) 0); |
| 786 | g_signal_connect (G_OBJECT (curr_data->applet), "selection_clear_event",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((curr_data->applet)), (((GType) ((20) << (2))))))))), ("selection_clear_event"), (((GCallback) (selection_clear_cb ))), (curr_data), ((void*)0), (GConnectFlags) 0) |
| 787 | G_CALLBACK (selection_clear_cb),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((curr_data->applet)), (((GType) ((20) << (2))))))))), ("selection_clear_event"), (((GCallback) (selection_clear_cb ))), (curr_data), ((void*)0), (GConnectFlags) 0) |
| 788 | curr_data)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((curr_data->applet)), (((GType) ((20) << (2))))))))), ("selection_clear_event"), (((GCallback) (selection_clear_cb ))), (curr_data), ((void*)0), (GConnectFlags) 0); |
| 789 | |
| 790 | make_applet_accessible (CTK_WIDGET (applet)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((applet)), ((ctk_widget_get_type ()))))))); |
| 791 | |
| 792 | /* session save signal */ |
| 793 | g_signal_connect (G_OBJECT (applet), "change_orient",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((applet)), (((GType) ((20) << (2))) )))))), ("change_orient"), (((GCallback) (applet_change_orient ))), (curr_data), ((void*)0), (GConnectFlags) 0) |
| 794 | G_CALLBACK (applet_change_orient), curr_data)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((applet)), (((GType) ((20) << (2))) )))))), ("change_orient"), (((GCallback) (applet_change_orient ))), (curr_data), ((void*)0), (GConnectFlags) 0); |
| 795 | |
| 796 | g_signal_connect (G_OBJECT (applet), "size_allocate",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((applet)), (((GType) ((20) << (2))) )))))), ("size_allocate"), (((GCallback) (applet_size_allocate ))), (curr_data), ((void*)0), (GConnectFlags) 0) |
| 797 | G_CALLBACK (applet_size_allocate), curr_data)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((applet)), (((GType) ((20) << (2))) )))))), ("size_allocate"), (((GCallback) (applet_size_allocate ))), (curr_data), ((void*)0), (GConnectFlags) 0); |
| 798 | |
| 799 | g_signal_connect (G_OBJECT (applet), "destroy",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((applet)), (((GType) ((20) << (2))) )))))), ("destroy"), (((GCallback) (applet_destroy))), (curr_data ), ((void*)0), (GConnectFlags) 0) |
| 800 | G_CALLBACK (applet_destroy), curr_data)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((applet)), (((GType) ((20) << (2))) )))))), ("destroy"), (((GCallback) (applet_destroy))), (curr_data ), ((void*)0), (GConnectFlags) 0); |
| 801 | |
| 802 | ctk_widget_show_all (CTK_WIDGET (applet)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((applet)), ((ctk_widget_get_type ()))))))); |
| 803 | |
| 804 | action_group = ctk_action_group_new ("Charpicker Applet Actions"); |
| 805 | ctk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE"cafe-applets"); |
| 806 | ctk_action_group_add_actions (action_group, |
| 807 | charpick_applet_menu_actions, |
| 808 | G_N_ELEMENTS (charpick_applet_menu_actions)(sizeof (charpick_applet_menu_actions) / sizeof ((charpick_applet_menu_actions )[0])), |
| 809 | curr_data); |
| 810 | ui_path = g_build_filename (CHARPICK_MENU_UI_DIR"/usr/share/cafe/ui", "charpick-applet-menu.xml", NULL((void*)0)); |
| 811 | cafe_panel_applet_setup_menu_from_file (CAFE_PANEL_APPLET (applet)((((CafePanelApplet*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((applet)), ((cafe_panel_applet_get_type ())))))), |
| 812 | ui_path, action_group); |
| 813 | g_free (ui_path); |
| 814 | |
| 815 | if (cafe_panel_applet_get_locked_down (CAFE_PANEL_APPLET (applet)((((CafePanelApplet*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((applet)), ((cafe_panel_applet_get_type ())))))))) { |
| 816 | CtkAction *action; |
| 817 | |
| 818 | action = ctk_action_group_get_action (action_group, "Preferences"); |
| 819 | ctk_action_set_visible (action, FALSE(0)); |
| 820 | } |
| 821 | g_object_unref (action_group); |
| 822 | |
| 823 | register_stock_for_edit (); |
| 824 | populate_menu (curr_data); |
| 825 | |
| 826 | return TRUE(!(0)); |
| 827 | } |
| 828 | |
| 829 | static gboolean |
| 830 | charpicker_applet_factory (CafePanelApplet *applet, |
| 831 | const gchar *iid, |
| 832 | gpointer data G_GNUC_UNUSED__attribute__ ((__unused__))) |
| 833 | { |
| 834 | gboolean retval = FALSE(0); |
| 835 | |
| 836 | if (!strcmp (iid, "CharpickerApplet")) |
| 837 | retval = charpicker_applet_fill (applet); |
| 838 | |
| 839 | return retval; |
| 840 | } |
| 841 | |
| 842 | CAFE_PANEL_APPLET_OUT_PROCESS_FACTORY ("CharpickerAppletFactory",int main(int argc, char* argv[]) { GOptionContext* context; GError * error; int retval; do { bindtextdomain ("cafe-applets", "/usr/share/locale" ); bind_textdomain_codeset ("cafe-applets", "UTF-8"); if ((!( 0))) textdomain ("cafe-applets"); } while (0); context = g_option_context_new (""); g_option_context_add_group (context, ctk_get_option_group ((!(0)))); error = ((void*)0); if (!g_option_context_parse (context , &argc, &argv, &error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n", error->message); g_error_free (error); } else { g_printerr ("Cannot parse arguments.\n"); } g_option_context_free (context); return 1; } ctk_init (& argc, &argv); retval = cafe_panel_applet_factory_main ("CharpickerAppletFactory" ,(!(0)), (cafe_panel_applet_get_type ()), charpicker_applet_factory , ((void*)0)); g_option_context_free (context); return retval ; } |
| 843 | PANEL_TYPE_APPLET,int main(int argc, char* argv[]) { GOptionContext* context; GError * error; int retval; do { bindtextdomain ("cafe-applets", "/usr/share/locale" ); bind_textdomain_codeset ("cafe-applets", "UTF-8"); if ((!( 0))) textdomain ("cafe-applets"); } while (0); context = g_option_context_new (""); g_option_context_add_group (context, ctk_get_option_group ((!(0)))); error = ((void*)0); if (!g_option_context_parse (context , &argc, &argv, &error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n", error->message); g_error_free (error); } else { g_printerr ("Cannot parse arguments.\n"); } g_option_context_free (context); return 1; } ctk_init (& argc, &argv); retval = cafe_panel_applet_factory_main ("CharpickerAppletFactory" ,(!(0)), (cafe_panel_applet_get_type ()), charpicker_applet_factory , ((void*)0)); g_option_context_free (context); return retval ; } |
| 844 | "char-palette",int main(int argc, char* argv[]) { GOptionContext* context; GError * error; int retval; do { bindtextdomain ("cafe-applets", "/usr/share/locale" ); bind_textdomain_codeset ("cafe-applets", "UTF-8"); if ((!( 0))) textdomain ("cafe-applets"); } while (0); context = g_option_context_new (""); g_option_context_add_group (context, ctk_get_option_group ((!(0)))); error = ((void*)0); if (!g_option_context_parse (context , &argc, &argv, &error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n", error->message); g_error_free (error); } else { g_printerr ("Cannot parse arguments.\n"); } g_option_context_free (context); return 1; } ctk_init (& argc, &argv); retval = cafe_panel_applet_factory_main ("CharpickerAppletFactory" ,(!(0)), (cafe_panel_applet_get_type ()), charpicker_applet_factory , ((void*)0)); g_option_context_free (context); return retval ; } |
| 845 | charpicker_applet_factory,int main(int argc, char* argv[]) { GOptionContext* context; GError * error; int retval; do { bindtextdomain ("cafe-applets", "/usr/share/locale" ); bind_textdomain_codeset ("cafe-applets", "UTF-8"); if ((!( 0))) textdomain ("cafe-applets"); } while (0); context = g_option_context_new (""); g_option_context_add_group (context, ctk_get_option_group ((!(0)))); error = ((void*)0); if (!g_option_context_parse (context , &argc, &argv, &error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n", error->message); g_error_free (error); } else { g_printerr ("Cannot parse arguments.\n"); } g_option_context_free (context); return 1; } ctk_init (& argc, &argv); retval = cafe_panel_applet_factory_main ("CharpickerAppletFactory" ,(!(0)), (cafe_panel_applet_get_type ()), charpicker_applet_factory , ((void*)0)); g_option_context_free (context); return retval ; } |
| 846 | NULL)int main(int argc, char* argv[]) { GOptionContext* context; GError * error; int retval; do { bindtextdomain ("cafe-applets", "/usr/share/locale" ); bind_textdomain_codeset ("cafe-applets", "UTF-8"); if ((!( 0))) textdomain ("cafe-applets"); } while (0); context = g_option_context_new (""); g_option_context_add_group (context, ctk_get_option_group ((!(0)))); error = ((void*)0); if (!g_option_context_parse (context , &argc, &argv, &error)) { if (error) { g_printerr ("Cannot parse arguments: %s.\n", error->message); g_error_free (error); } else { g_printerr ("Cannot parse arguments.\n"); } g_option_context_free (context); return 1; } ctk_init (& argc, &argv); retval = cafe_panel_applet_factory_main ("CharpickerAppletFactory" ,(!(0)), (cafe_panel_applet_get_type ()), charpicker_applet_factory , ((void*)0)); g_option_context_free (context); return retval ; } |
| 847 |