📄 config.c
字号:
{ style->margin.left = atoi(value) * _GK.theme_scale / 100; style->margin.right = style->margin.left; } else if (entry_flag == GKRELLMSTYLE_TOP_MARGIN) { style->margin.top = atoi(value) * _GK.theme_scale / 100; _GK.use_top_bottom_margins = TRUE; /* Allow themes to adapt. */ } else if (entry_flag == GKRELLMSTYLE_BOTTOM_MARGIN) { style->margin.bottom = atoi(value) * _GK.theme_scale / 100; _GK.use_top_bottom_margins = TRUE; /* Allow themes to adapt. */ } else if (entry_flag == GKRELLMSTYLE_LEFT_MARGIN) style->margin.left = atoi(value) * _GK.theme_scale / 100; else if (entry_flag == GKRELLMSTYLE_RIGHT_MARGIN) style->margin.right = atoi(value) * _GK.theme_scale / 100; else if (entry_flag == GKRELLMSTYLE_TRANSPARENCY) style->transparency = atoi(value); else if (entry_flag == GKRELLMSTYLE_SCROLL_TEXT_CACHE_OFF) style->scroll_text_cache_off = parse_boolean(value); else if (entry_flag == GKRELLMSTYLE_TEXTCOLOR_A) assign_textcolor(style, value, GKRELLMSTYLE_TEXTCOLOR_A); else if (entry_flag == GKRELLMSTYLE_TEXTCOLOR_B) assign_textcolor(style, value, GKRELLMSTYLE_TEXTCOLOR_B); else if (entry_flag == GKRELLMSTYLE_TEXTFONT_A) assign_font(style, value, GKRELLMSTYLE_TEXTFONT_A); else if (entry_flag == GKRELLMSTYLE_TEXTFONT_B) assign_font(style, value, GKRELLMSTYLE_TEXTFONT_B); else if (entry_flag == GKRELLMSTYLE_BORDER) set_border(&style->border, value); else if (entry_flag == SET_ALL_MARGINS) set_margins(style, value); }static voidset_themed(GkrellmStyle *s, gint flag) { if (flag == OLD_SET_MARGIN) flag = (GKRELLMSTYLE_LEFT_MARGIN | GKRELLMSTYLE_RIGHT_MARGIN); else if (flag == SET_ALL_MARGINS) flag = ( GKRELLMSTYLE_LEFT_MARGIN | GKRELLMSTYLE_RIGHT_MARGIN | GKRELLMSTYLE_TOP_MARGIN | GKRELLMSTYLE_BOTTOM_MARGIN); s->themed |= flag; }static voidassign_style(gchar *debug_name, GList *style_list, gint index, gchar *arg, gint entry_flag, gint override) { GkrellmStyle *style; GList *list; style = (GkrellmStyle *) g_list_nth_data(style_list, index); if (!style) return; /* If this is not an override assignment and this entry has already had | an override assignment, then we do not assign. */ if (! override && (style->override & entry_flag)) return; if (override) style->override |= entry_flag; assign_style_entry(style, arg, entry_flag); if (index > 0) /* Theme has custom setting for this style */ set_themed(style, entry_flag); if (index++ == 0) /* style == style_list */ { if (override) printf("Bad override on DEFAULT: %s %s %d\n", debug_name, arg, entry_flag); for (list = style_list->next; list; list = list->next, ++index) { style = (GkrellmStyle *) list->data; if (style && !(style->override & entry_flag)) assign_style_entry(style, arg, entry_flag); } } }#if 0static voidassign_chart_style(gint index, gchar *arg, gint entry_flag, gint override) { assign_style("StyleChart", _GK.chart_style_list, index, arg, entry_flag, override); }static voidassign_panel_style(gint index, gchar *arg, gint entry_flag, gint override) { assign_style("StylePanel", _GK.panel_style_list, index, arg, entry_flag, override); }#endifstatic voidassign_meter_style(gint index, gchar *arg, gint entry_flag, gint override) { assign_style("StyleMeter", _GK.meter_style_list, index, arg, entry_flag, override); }static voidassign_custom_style(gchar *debug_name, GList *style_list, gint index, gchar *arg, gint entry_flag, gchar *custom_name) { GkrellmStyle *style, *custom_style; gint i; if ((i = gkrellm_string_position_in_list(_GK.custom_name_list, custom_name)) < 0) { style = (GkrellmStyle *) g_list_nth_data(style_list, index); if (!style) return; custom_style = gkrellm_copy_style(style); _GK.custom_name_list = g_list_append(_GK.custom_name_list, g_strdup(custom_name)); _GK.custom_style_list = g_list_append(_GK.custom_style_list, custom_style); } else custom_style = (GkrellmStyle *) g_list_nth_data(_GK.custom_style_list, i);//printf("assign_custom_style(%s, %s, %d, %s) %d\n",//debug_name, custom_name, entry_flag, arg, i); assign_style_entry(custom_style, arg, entry_flag); set_themed(custom_style, entry_flag); }static struct string_map { gchar *string; gint flag; } entry_map[] = { { "krell_yoff", GKRELLMSTYLE_KRELL_YOFF }, { "krell_yoff_not_scalable",GKRELLMSTYLE_KRELL_YOFF_NOT_SCALABLE }, { "krell_expand", GKRELLMSTYLE_KRELL_EXPAND }, { "krell_x_hot", GKRELLMSTYLE_KRELL_X_HOT }, { "krell_ema_period", GKRELLMSTYLE_KRELL_EMA_PERIOD }, { "krell_depth", GKRELLMSTYLE_KRELL_DEPTH }, { "krell_left_margin", GKRELLMSTYLE_KRELL_LEFT_MARGIN }, { "krell_right_margin", GKRELLMSTYLE_KRELL_RIGHT_MARGIN }, { "label_position", GKRELLMSTYLE_LABEL_POSITION }, { "label_yoff", GKRELLMSTYLE_LABEL_YOFF }, { "margins", SET_ALL_MARGINS }, { "left_margin", GKRELLMSTYLE_LEFT_MARGIN }, { "right_margin", GKRELLMSTYLE_RIGHT_MARGIN }, { "top_margin", GKRELLMSTYLE_TOP_MARGIN }, { "bottom_margin", GKRELLMSTYLE_BOTTOM_MARGIN }, { "textcolor", GKRELLMSTYLE_TEXTCOLOR_A }, { "alt_textcolor", GKRELLMSTYLE_TEXTCOLOR_B }, { "font", GKRELLMSTYLE_TEXTFONT_A }, { "alt_font", GKRELLMSTYLE_TEXTFONT_B }, { "border", GKRELLMSTYLE_BORDER }, { "transparency", GKRELLMSTYLE_TRANSPARENCY }, { "scroll_text_cache_off", GKRELLMSTYLE_SCROLL_TEXT_CACHE_OFF }, { "margin", OLD_SET_MARGIN }, /* deprecated */ };static gintget_entry_flag(gchar *entry) { struct string_map *sm; for (sm = &entry_map[0]; sm < &entry_map[sizeof(entry_map) / sizeof(struct string_map)]; ++sm) if (!strcmp(entry, sm->string)) return sm->flag; return -1; }static voidassign_gkrellmrc_style(gchar *source_line, gchar *area, gchar *string) { GList *style_list = NULL, *name_list = NULL; gchar *s; gchar *arg = NULL, *mon_name = NULL, *custom_name = NULL, *entry = NULL; gint index, entry_flag, override; /* string starts out in format "*.yyy arg" or "foo.yyy arg" */ mon_name = strtok(string, " \t=:"); /* "*.yyy" or "foo.yyy" */ if (mon_name && (arg = strtok(NULL, "\n")) != NULL) /* arg is "arg" part */ { while (*arg == ' ' || *arg == '\t' || *arg == '=' || *arg == ':') ++arg; entry = strrchr(mon_name, '.'); if (entry) *entry++ = '\0'; if ((s = strchr(mon_name, '.')) != NULL) { custom_name = g_strdup(mon_name); *s = '\0'; } } if (!mon_name || !entry || !*entry || !arg) { printf("StyleXXX ?: %s\n", source_line); g_free(custom_name); return; } override = TRUE; entry_flag = get_entry_flag(entry); if (!strcmp(area, "StyleChart")) { name_list = _GK.chart_name_list; style_list = _GK.chart_style_list; } else if (!strcmp(area, "StylePanel")) { name_list = _GK.chart_name_list; style_list = _GK.panel_style_list; } else if (!strcmp(area, "StyleMeter")) { name_list = _GK.meter_name_list; style_list = _GK.meter_style_list; } else { printf("StyleXXX ?: %s\n", source_line); g_free(custom_name); return; } index = gkrellm_string_position_in_list(name_list, mon_name); if (index == DEFAULT_STYLE_ID) override = FALSE; if (entry_flag >= 0 && index >= 0) { if (custom_name) assign_custom_style(area, style_list, index, arg, entry_flag, custom_name); else assign_style(area, style_list, index, arg, entry_flag, override); } g_free(custom_name); }gintgkrellm_add_chart_style(GkrellmMonitor *mon, gchar *name) { GkrellmStyle *panel_style, *chart_style; gint id; static gint style_id; if (!name) return 0; id = style_id++; chart_style = gkrellm_style_new0(); panel_style = gkrellm_style_new0(); if (mon) { if (mon->privat == NULL) mon->privat = g_new0(GkrellmMonprivate, 1); mon->privat->panel_style = panel_style; mon->privat->chart_style = chart_style; mon->privat->style_name = name; mon->privat->style_type = CHART_PANEL_TYPE; mon->privat->style_id = id; } _GK.chart_name_list = g_list_append(_GK.chart_name_list, (gchar *) name); _GK.chart_style_list = g_list_append(_GK.chart_style_list, chart_style); _GK.panel_style_list = g_list_append(_GK.panel_style_list, panel_style); _GK.bg_chart_piximage_list = g_list_append(_GK.bg_chart_piximage_list, NULL); _GK.bg_grid_piximage_list = g_list_append(_GK.bg_grid_piximage_list, NULL); _GK.bg_panel_piximage_list = g_list_append(_GK.bg_panel_piximage_list, NULL); _GK.krell_panel_piximage_list = g_list_append(_GK.krell_panel_piximage_list, NULL); return id; }gintgkrellm_add_meter_style(GkrellmMonitor *mon, gchar *name) { GkrellmStyle *style; gint id; static gint style_id; if (!name) return 0; id = style_id++; style = gkrellm_style_new0(); if (mon) { if (mon->privat == NULL) mon->privat = g_new0(GkrellmMonprivate, 1); mon->privat->panel_style = style; mon->privat->style_name = name; mon->privat->style_type = METER_PANEL_TYPE; mon->privat->style_id = id; } _GK.meter_name_list = g_list_append(_GK.meter_name_list, (gchar *) name); _GK.meter_style_list = g_list_append(_GK.meter_style_list, style); _GK.bg_meter_piximage_list = g_list_append(_GK.bg_meter_piximage_list, NULL); _GK.krell_meter_piximage_list = g_list_append(_GK.krell_meter_piximage_list, NULL); return id; }static voidset_piximage_borders_in_list(GList *st_list, GList *im_list, GList *nm_list) { GkrellmStyle *style; GkrellmPiximage *image; for ( ; st_list && im_list && nm_list; st_list = st_list->next, im_list = im_list->next, nm_list = nm_list->next) { style = (GkrellmStyle *) st_list->data; image = (GkrellmPiximage *) im_list->data; if (style && image) gkrellm_set_piximage_border(image, &style->border); } }static voidsetup_piximages(void) { GList *list; GkrellmMonitor *mon; GkrellmMonprivate *mp; gint h; gkrellm_set_piximage_border(_GK.frame_top_piximage, &_GK.frame_top_border); gkrellm_set_piximage_border(_GK.frame_bottom_piximage, &_GK.frame_bottom_border); if (_GK.frame_left_width == 0) _GK.frame_left_width = gdk_pixbuf_get_width(_GK.frame_left_piximage->pixbuf);// _GK.frame_left_width = _GK.frame_left_width * _GK.theme_scale / 100; gkrellm_set_piximage_border(_GK.frame_left_piximage, &_GK.frame_left_border); if (_GK.frame_right_width == 0) _GK.frame_right_width = gdk_pixbuf_get_width(_GK.frame_right_piximage->pixbuf);// _GK.frame_right_width = _GK.frame_right_width * _GK.theme_scale / 100; gkrellm_set_piximage_border(_GK.frame_right_piximage, &_GK.frame_right_border); gkrellm_set_piximage_border(_GK.button_panel_out_piximage, &_GK.button_panel_border); gkrellm_set_piximage_border(_GK.button_panel_in_piximage, &_GK.button_panel_border); gkrellm_set_piximage_border(_GK.button_meter_out_piximage, &_GK.button_meter_border); gkrellm_set_piximage_border(_GK.button_meter_in_piximage, &_GK.button_meter_border); set_piximage_borders_in_list(_GK.chart_style_list, _GK.bg_chart_piximage_list, _GK.chart_name_list); set_piximage_borders_in_list(_GK.panel_style_list, _GK.bg_panel_piximage_list, _GK.chart_name_list); set_piximage_borders_in_list(_GK.meter_style_list, _GK.bg_meter_piximage_list, _GK.meter_name_list); h = gdk_pixbuf_get_height(_GK.decal_misc_piximage->pixbuf) / N_MISC_DECALS * _GK.theme_scale / 100; gkrellm_scale_piximage_to_pixmap(_GK.decal_misc_piximage, &_GK.decal_misc_pixmap, &_GK.decal_misc_mask, -1, h * N_MISC_DECALS); if (!_GK.spacer_top_chart_piximage) _GK.spacer_top_chart_piximage = gkrellm_clone_piximage(_GK.spacer_top_piximage); if (!_GK.spacer_bottom_chart_piximage) _GK.spacer_bottom_chart_piximage = gkrellm_clone_piximage(_GK.spacer_bottom_piximage); if (!_GK.spacer_top_meter_piximage) _GK.spacer_top_meter_piximage = gkrellm_clone_piximage(_GK.spacer_top_piximage); if (!_GK.spacer_bottom_meter_piximage) _GK.spacer_bottom_meter_piximage = gkrellm_clone_piximage(_GK.spacer_bottom_piximage); for (list = gkrellm_monitor_list; list; list = list->next) { GkrellmPiximage *top_pix, *bot_pix; mon = (GkrellmMonitor *) list->data; mp = mon->privat; if ((!mon->name || !mon->create_monitor) && mon != gkrellm_mon_host()) continue; if (mp->style_type == CHART_PANEL_TYPE) { top_pix = _GK.spacer_top_chart_piximage; bot_pix = _GK.spacer_bottom_chart_piximage; mp->top_type = mp->bottom_type = GKRELLM_SPACER_CHART; } else { top_pix = _GK.spacer_top_meter_piximage; bot_pix = _GK.spacer_bottom_meter_piximage; mp->top_type = mp->bottom_type = GKRELLM_SPACER_METER; } if (!mp->top_spacer.piximage) mp->top_spacer.piximage = gkrellm_clone_piximage(top_pix); gkrellm_set_piximage_border(mp->top_spacer.piximage, &_GK.spacer_top_border); if (!mp->bottom_spacer.piximage)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -