diff options
author | Sergey V. Udaltsov <svu@src.gnome.org> | 2008-10-27 14:52:02 +0000 |
---|---|---|
committer | Sergey V. Udaltsov <svu@src.gnome.org> | 2008-10-27 14:52:02 +0000 |
commit | 46e6aac158a2ee1d9da7011db88d582eb48aee5d (patch) | |
tree | 504404c84707e0df1f32b6f82cb88f4c026ef3b4 /libgnomekbd | |
parent | 45f731ff86574e3b82192f91d0f3a9f27da941eb (diff) | |
download | libgnomekbd-46e6aac158a2ee1d9da7011db88d582eb48aee5d.tar.gz |
fix crash in broken X env, b.g.o#553915
svn path=/trunk/; revision=354
Diffstat (limited to 'libgnomekbd')
-rw-r--r-- | libgnomekbd/gkbd-indicator.c | 115 |
1 files changed, 60 insertions, 55 deletions
diff --git a/libgnomekbd/gkbd-indicator.c b/libgnomekbd/gkbd-indicator.c index f3ded9c..462e5ed 100644 --- a/libgnomekbd/gkbd-indicator.c +++ b/libgnomekbd/gkbd-indicator.c @@ -135,7 +135,12 @@ gkbd_indicator_fill (GkbdIndicator * gki) GtkNotebook *notebook = GTK_NOTEBOOK (gki); for (grp = 0; grp < total_groups; grp++) { - GtkWidget *page, *decorated_page; + GtkWidget *page, *decorated_page = NULL; + gchar *full_group_name = + (grp < + g_strv_length (globals. + full_group_names)) ? + globals.full_group_names[grp] : "?"; page = gkbd_indicator_prepare_drawing (gki, grp); if (page == NULL) @@ -144,7 +149,7 @@ gkbd_indicator_fill (GkbdIndicator * gki) decorated_page = gkbd_indicator_plugin_manager_decorate_widget (&globals.plugin_manager, page, grp, - globals.full_group_names[grp], &globals.kbd_cfg); + full_group_name, &globals.kbd_cfg); page = decorated_page == NULL ? page : decorated_page; @@ -257,39 +262,46 @@ gkbd_indicator_prepare_drawing (GkbdIndicator * gki, int group) g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL); - if (xkl_engine_get_features (globals.engine) & - XKLF_MULTIPLE_LAYOUTS_SUPPORTED) { - char *full_layout_name = - (char *) g_slist_nth_data (globals.kbd_cfg. - layouts_variants, - group); - char *variant_name; - if (!gkbd_keyboard_config_split_items - (full_layout_name, &layout_name, - &variant_name)) - /* just in case */ - layout_name = full_layout_name; - - /* make it freeable */ - layout_name = g_strdup (layout_name); - - if (globals.short_group_names != NULL) { - char *short_group_name = - globals.short_group_names[group]; - if (short_group_name != NULL - && *short_group_name != '\0') { - /* drop the long name */ - g_free (layout_name); - layout_name = - g_strdup (short_group_name); + + if (group < g_strv_length (globals.short_group_names)) { + if (xkl_engine_get_features (globals.engine) & + XKLF_MULTIPLE_LAYOUTS_SUPPORTED) { + char *full_layout_name = (char *) + g_slist_nth_data (globals.kbd_cfg. + layouts_variants, + group); + char *variant_name; + if (!gkbd_keyboard_config_split_items + (full_layout_name, &layout_name, + &variant_name)) + /* just in case */ + layout_name = full_layout_name; + + /* make it freeable */ + layout_name = g_strdup (layout_name); + + if (globals.short_group_names != NULL) { + char *short_group_name = + globals.short_group_names + [group]; + if (short_group_name != NULL + && *short_group_name != '\0') { + /* drop the long name */ + g_free (layout_name); + layout_name = + g_strdup + (short_group_name); + } } + } else { + layout_name = + g_strdup (globals.full_group_names + [group]); } - } else - layout_name = - g_strdup (globals.full_group_names[group]); + } if (layout_name == NULL) - layout_name = g_strdup ("?"); + layout_name = g_strdup ("??"); /* Process layouts with repeating description */ ppln = &prev_layout_name; @@ -347,7 +359,8 @@ gkbd_indicator_update_tooltips (GkbdIndicator * gki) { XklState *state = xkl_engine_get_current_state (globals.engine); gchar *buf; - if (state == NULL || state->group < 0) + if (state == NULL || state->group < 0 + || state->group >= g_strv_length (globals.full_group_names)) return; buf = g_strdup_printf (globals.tooltips_format, @@ -401,12 +414,9 @@ gkbd_indicator_ind_cfg_changed (GConfClient * client, &globals.kbd_cfg); gkbd_indicator_config_activate (&globals.ind_cfg); - gkbd_indicator_plugin_manager_toggle_plugins (&globals. - plugin_manager, - &globals. - plugin_container, - globals.ind_cfg. - enabled_plugins); + gkbd_indicator_plugin_manager_toggle_plugins + (&globals.plugin_manager, &globals.plugin_container, + globals.ind_cfg.enabled_plugins); ForAllIndicators () { gkbd_indicator_reinit_ui (gki); @@ -465,8 +475,8 @@ gkbd_indicator_kbd_cfg_callback (GkbdIndicator * gki) } gkbd_indicator_load_group_names ((const gchar **) xklrec->layouts, - (const gchar **) xklrec-> - variants); + (const gchar **) + xklrec->variants); ForAllIndicators () { gkbd_indicator_reinit_ui (gki); @@ -664,8 +674,8 @@ gkbd_indicator_global_term (void) gkbd_desktop_config_stop_listen (&globals.cfg); gkbd_indicator_config_stop_listen (&globals.ind_cfg); - gkbd_indicator_plugin_manager_term_initialized_plugins (&globals. - plugin_manager); + gkbd_indicator_plugin_manager_term_initialized_plugins + (&globals.plugin_manager); gkbd_indicator_plugin_manager_term (&globals.plugin_manager); gkbd_indicator_config_term (&globals.ind_cfg); @@ -756,18 +766,14 @@ gkbd_indicator_global_init (void) gkbd_indicator_config_activate (&globals.ind_cfg); gkbd_indicator_load_group_names ((const gchar **) xklrec->layouts, - (const gchar **) xklrec-> - variants); + (const gchar **) + xklrec->variants); g_object_unref (G_OBJECT (xklrec)); gkbd_indicator_plugin_manager_init (&globals.plugin_manager); - gkbd_indicator_plugin_manager_init_enabled_plugins (&globals. - plugin_manager, - &globals. - plugin_container, - globals. - ind_cfg. - enabled_plugins); + gkbd_indicator_plugin_manager_init_enabled_plugins + (&globals.plugin_manager, &globals.plugin_container, + globals.ind_cfg.enabled_plugins); gkbd_desktop_config_start_listen (&globals.cfg, (GConfClientNotifyFunc) gkbd_indicator_cfg_changed, @@ -821,10 +827,9 @@ gkbd_indicator_get_image_filename (guint group) { if (!globals.ind_cfg.show_flags) return NULL; - return gkbd_indicator_config_get_images_file (&globals. - ind_cfg, - &globals. - kbd_cfg, group); + return gkbd_indicator_config_get_images_file (&globals.ind_cfg, + &globals.kbd_cfg, + group); } gdouble |