static void reload_style(struct rtb_element *self) { const struct rtb_style_property_definition *prop; int need_reflow = 0; /* layout-related properties trigger a reflow if they change, so * we'll handle them first. */ #define ASSIGN_LAYOUT_FLOAT(pname, dest) do { \ prop = rtb_style_query_prop(self, \ pname, RTB_STYLE_PROP_FLOAT, 0); \ if (!prop) \ break; \ if (self->dest != prop->flt \ && self->window->state != RTB_STATE_UNATTACHED) { \ self->dest = prop->flt; \ need_reflow = 1; \ } else \ self->dest = prop->flt; \ } while (0) ASSIGN_LAYOUT_FLOAT("min-width", min_size.w); ASSIGN_LAYOUT_FLOAT("min-height", min_size.h); #undef ASSIGN_LAYOUT_FLOAT #define LOAD_PROP(name, type, member, load_func) \ if ((prop = rtb_style_query_prop(self, name, type, 0)) \ && !load_func(&self->stylequad, &prop->member)) \ #define LOAD_COLOR(name, load_func) \ LOAD_PROP(name, RTB_STYLE_PROP_COLOR, color, load_func) { \ rtb_elem_mark_dirty(self); \ } #define LOAD_TEXTURE(name, load_func) \ LOAD_PROP(name, RTB_STYLE_PROP_TEXTURE, texture, load_func) { \ rtb_elem_mark_dirty(self); \ } LOAD_COLOR("background-color", rtb_stylequad_set_background_color); LOAD_COLOR("border-color", rtb_stylequad_set_border_color); LOAD_TEXTURE("border-image", rtb_stylequad_set_border_image); LOAD_TEXTURE("background-image", rtb_stylequad_set_background_image); #undef LOAD_TEXTURE #undef LOAD_COLOR #undef LOAD_PROP if (need_reflow) rtb_elem_reflow_rootward(self); }
// 加载配置信息 // @pConfigs: 配置信息 gboolean Lyric_LoadConfigs(OUT Configs* pConfigs) { int iTmp = 0; // 加载配置信息 ConfigDb *cfgfile = aud_cfg_db_open(); gchar *lpszTmp= NULL; if (aud_cfg_db_get_string(cfgfile, PLUGIN_NAME, "LyricPath", &lpszTmp)) { strncpy(pConfigs->szLyricPath, lpszTmp, MAX_PATH); g_free(lpszTmp); lpszTmp = NULL; } if (aud_cfg_db_get_int(cfgfile, PLUGIN_NAME, "SearchAppIndex", &iTmp)) pConfigs->nSearchAppIndex = iTmp; #define LOAD_COLOR(name, to) if(aud_cfg_db_get_string(cfgfile, PLUGIN_NAME, name, &lpszTmp)) {\ gdk_color_parse(lpszTmp, &to);\ } LOAD_COLOR("BackgroundColor", pConfigs->colors.background); LOAD_COLOR("NormalColor", pConfigs->colors.normal); LOAD_COLOR("CurrColor", pConfigs->colors.current); LOAD_COLOR("DragColor", pConfigs->colors.drag); LOAD_COLOR("MsgColor", pConfigs->colors.msg); LOAD_COLOR("ErrorColor", pConfigs->colors.error); gboolean bTmp = FALSE; if (aud_cfg_db_get_bool(cfgfile, PLUGIN_NAME, "ShowWindowLyric", &bTmp)) pConfigs->bShowWindowLyric = bTmp; if (aud_cfg_db_get_bool(cfgfile, PLUGIN_NAME, "SmartShowWin", &bTmp)) pConfigs->bSmartShowWin = bTmp; if (aud_cfg_db_get_bool(cfgfile, PLUGIN_NAME, "SmartDownLoad", &bTmp)) pConfigs->bSmartDownLoad = bTmp; if (aud_cfg_db_get_bool(cfgfile, PLUGIN_NAME, "ShowBroad", &bTmp)) pConfigs->bShowBroad = bTmp; if (aud_cfg_db_get_bool(cfgfile, PLUGIN_NAME, "SaveLyricToSongFolder", &bTmp)) pConfigs->bSaveLyricToSongFolder = bTmp; if (aud_cfg_db_get_bool(cfgfile, PLUGIN_NAME, "SaveLyricAsFileName", &bTmp)) { pConfigs->bSaveLyricAsFileName = bTmp; } if (aud_cfg_db_get_int(cfgfile, PLUGIN_NAME, "Opacity", &iTmp)) pConfigs->iOpacity = iTmp; if (aud_cfg_db_get_int(cfgfile, PLUGIN_NAME, "Pos_iX", &iTmp)) pConfigs->pos.iX = iTmp; if (aud_cfg_db_get_int(cfgfile, PLUGIN_NAME, "Pos_iY", &iTmp)) pConfigs->pos.iY = iTmp; if (aud_cfg_db_get_string(cfgfile, PLUGIN_NAME, "LyricFontName", &lpszTmp)) { strncpy(pConfigs->szLyricFontName, lpszTmp, MAX_PATH); g_free(lpszTmp); lpszTmp = NULL; } if (aud_cfg_db_get_string(cfgfile, PLUGIN_NAME, "LyricEncode", &lpszTmp)) { strncpy(pConfigs->szLyricEncode, lpszTmp, MAX_PATH); g_free(lpszTmp); lpszTmp = NULL; } if (aud_cfg_db_get_bool(cfgfile, PLUGIN_NAME, "ShowOSDLyric", &bTmp)) pConfigs->bShowOSDLyric = bTmp; if (aud_cfg_db_get_bool(cfgfile, PLUGIN_NAME, "IsKaLaOK", &bTmp)) pConfigs->bIsKaLaOK = bTmp; if (aud_cfg_db_get_string(cfgfile, PLUGIN_NAME, "OSD_fake_translucent_bg", &lpszTmp)) { strncpy(pConfigs->OSD.fake_translucent_bg, lpszTmp, MAX_PATH); g_free(lpszTmp); lpszTmp = NULL; } if (aud_cfg_db_get_string(cfgfile, PLUGIN_NAME, "OSD_vposition", &lpszTmp)) { strncpy(pConfigs->OSD.vposition, lpszTmp, MAX_PATH); g_free(lpszTmp); lpszTmp = NULL; } if (aud_cfg_db_get_string(cfgfile, PLUGIN_NAME, "OSD_halignment", &lpszTmp)) { strncpy(pConfigs->OSD.halignment, lpszTmp, MAX_PATH); g_free(lpszTmp); lpszTmp = NULL; } if (aud_cfg_db_get_string(cfgfile, PLUGIN_NAME, "OSD_animations", &lpszTmp)) { strncpy(pConfigs->OSD.animations, lpszTmp, MAX_PATH); g_free(lpszTmp); lpszTmp = NULL; } if (aud_cfg_db_get_string(cfgfile, PLUGIN_NAME, "OSD_font", &lpszTmp)) { strncpy(pConfigs->OSD.szFontName, lpszTmp, MAX_PATH); g_free(lpszTmp); lpszTmp = NULL; } aud_cfg_db_close(cfgfile); return TRUE; }