void ghb_load_icons() { #if GTK_CHECK_VERSION(3, 14, 0) ghb_icons_register_resource(); gtk_icon_theme_add_resource_path(gtk_icon_theme_get_default(), "/fr/handbrake/ghb/icons"); #else ghb_icons_register_resource(); GResource *icon_res = ghb_icons_get_resource(); char ** children = g_resource_enumerate_children(icon_res, "/fr/handbrake/ghb/icons/scalable/apps", 0, NULL); if (children == NULL) { g_warning("No icons in resources!"); return; } int ii; for (ii = 0; children[ii] != NULL; ii++) { char * path; path = g_strdup_printf("/fr/handbrake/ghb/icons/scalable/apps/%s", children[ii]); GBytes *gbytes = g_resource_lookup_data(icon_res, path, 0, NULL); gsize data_size; gconstpointer data = g_bytes_get_data(gbytes, &data_size); g_free(path); char *pos; char *name = g_strdup(children[ii]); pos = g_strstr_len(name, -1, "."); if (pos != NULL) *pos = '\0'; int jj; int sizes[] = {16, 22, 24, 32, 48, 64, 128, 256, 0}; for (jj = 0; sizes[jj]; jj++) { GdkPixbuf *pb; GInputStream *gis; int size; gis = g_memory_input_stream_new_from_data(data, data_size, NULL); pb = gdk_pixbuf_new_from_stream_at_scale(gis, sizes[jj], sizes[jj], TRUE, NULL, NULL); g_input_stream_close(gis, NULL, NULL); size = gdk_pixbuf_get_height(pb); gtk_icon_theme_add_builtin_icon(name, size, pb); g_object_unref(pb); } g_bytes_unref(gbytes); } g_strfreev(children); #endif }
void gnm_init (void) { static gboolean inited = FALSE; if (inited) return; inited = TRUE; libgoffice_init (); _gnm_register_resource (); if (gdk_screen_get_default ()) { /* Only when we have a gui. */ gtk_icon_theme_add_resource_path (gtk_icon_theme_get_default (), "/org/gnumeric/gnumeric/icons"); } gnm_register_ui_files (); go_plugin_service_define ("function_group", &gnm_plugin_service_function_group_get_type); go_plugin_service_define ("ui", &gnm_plugin_service_ui_get_type); go_plugin_service_define ("solver", &gnm_plugin_service_solver_get_type); go_plugin_loader_module_register_version ("gnumeric", GNM_VERSION_FULL); g_object_new (GNM_APP_TYPE, NULL); mathfunc_init (); gnm_style_init (); gnm_conf_init (); gnm_color_init (); gnm_font_init (); /* requires config */ value_init (); parse_util_init (); _gnm_expr_init (); gnm_sheet_cell_init (); clipboard_init (); dependent_types_init (); gnm_rendered_value_init (); functions_init (); print_init (); gnm_autofill_init (); sheet_objects_init (); _gnm_hlink_init (); /* The statically linked in file formats */ gnm_xml_sax_read_init (); gnm_xml_sax_write_init (); stf_init (); /* Make sure that images will be displayed with the correct resolution, see #628472 */ go_image_set_default_dpi (gnm_app_display_dpi_get (TRUE), gnm_app_display_dpi_get (FALSE)); }