-int
-ThemeManager::load (string path)
-{
- ifstream in (path.c_str());
-
- if (!in) {
- error << string_compose (_("cannot open color definition file %1: %2"), path, strerror(errno)) << endmsg;
- return -1;
- }
-
- cerr << "Loading color definition file " << path << endl;
-
- while (in) {
- string name;
- double r, g, b, a;
-
- in >> name; if (!in) break;
- in >> r; if (!in) break;
- in >> g; if (!in) break;
- in >> b; if (!in) break;
- in >> a; if (!in) break;
-
- for (uint32_t i = 0; i < sizeof (color_id_strs)/sizeof(color_id_strs[0]); ++i) {
- if (name == color_id_strs[i]) {
-
- /* set color map */
-
- int ir,ig,ib,ia;
- int rgba;
-
- ir = (int) floor (r * 255.0);
- ig = (int) floor (g * 255.0);
- ib = (int) floor (b * 255.0);
- ia = (int) floor (a * 255.0);
- rgba = RGBA_TO_UINT (ir, ig, ib, ia);
-
- color_map[(ColorID)i] = rgba;
-
- /* set up list entry */
-
- Gdk::Color col;
- col.set_rgb_p (r,g,b);
-
- TreeModel::Row row = *(color_list->append());
-
- /* all the color names are prefixed by 'c' to avoid
- naming collisions when used as enums. trim
- this leading character from the displayed
- value.
- */
-
- row[columns.name] = name.substr (1);
- row[columns.color] = "";
- row[columns.id] = (ColorID) i;
- row[columns.gdkcolor] = col;
- row[columns.rgba] = rgba;
-
- break;
- }
- }
- }
-
- ColorsChanged(); /* emit signal */
-
- return 0;
-}
-