📄 config.c
字号:
mp->bottom_spacer.piximage = gkrellm_clone_piximage(bot_pix); gkrellm_set_piximage_border(mp->bottom_spacer.piximage, &_GK.spacer_bottom_border); } }typedef struct { gchar *name; gchar **xpm; GkrellmPiximage **im; GList **image_list; gchar *name_in_list; } ImageTable;static ImageTable base_theme_piximages[] = { /* Images in this table which have a non NULL _xpm default form the | minimal set of required images for a complete theme change. | If there is a NULL xpm, the image will be somehow constructed to | a default image in the code. */{ "frame_top", frame_top_xpm, &_GK.frame_top_piximage, NULL, NULL},{ "frame_bottom", frame_bottom_xpm, &_GK.frame_bottom_piximage, NULL, NULL},{ "frame_left", frame_left_xpm, &_GK.frame_left_piximage, NULL, NULL},{ "frame_right", frame_right_xpm, &_GK.frame_right_piximage, NULL, NULL},{ "button_panel_out", NULL, &_GK.button_panel_out_piximage, NULL, NULL},{ "button_panel_in", NULL, &_GK.button_panel_in_piximage, NULL, NULL},{ "button_meter_out", NULL, &_GK.button_meter_out_piximage, NULL, NULL},{ "button_meter_in", NULL, &_GK.button_meter_in_piximage, NULL, NULL},{ "bg_chart", bg_chart_xpm, NULL, &_GK.bg_chart_piximage_list, "*" },{ "bg_grid", bg_grid_xpm, NULL, &_GK.bg_grid_piximage_list, "*"},{ "bg_panel", bg_panel_xpm, NULL, &_GK.bg_panel_piximage_list, "*" },{ "bg_meter", bg_meter_xpm, NULL, &_GK.bg_meter_piximage_list, "*" },{ "decal_alarm", decal_alarm_xpm, &_GK.decal_alarm_piximage, NULL, NULL},{ "decal_warn", decal_warn_xpm, &_GK.decal_warn_piximage, NULL, NULL},{ "decal_misc", decal_misc_xpm, &_GK.decal_misc_piximage, NULL, NULL},{ "decal_button", decal_button_xpm, &_GK.decal_button_piximage, NULL, NULL},{ "data_in", NULL, &_GK.data_in_piximage, NULL, NULL},{ "data_in_grid", NULL, &_GK.data_in_grid_piximage, NULL, NULL},{ "data_out", NULL, &_GK.data_out_piximage, NULL, NULL},{ "data_out_grid", NULL, &_GK.data_out_grid_piximage, NULL, NULL},{ "bg_separator", NULL, &_GK.bg_separator_piximage, NULL, NULL},{ "spacer_top", NULL, &_GK.spacer_top_piximage, NULL, NULL},{ "spacer_bottom", NULL, &_GK.spacer_bottom_piximage, NULL, NULL},{ "spacer_top_chart", NULL, &_GK.spacer_top_chart_piximage, NULL, NULL},{ "spacer_bottom_chart",NULL, &_GK.spacer_bottom_chart_piximage,NULL, NULL},{ "spacer_top_meter", NULL, &_GK.spacer_top_meter_piximage, NULL, NULL},{ "spacer_bottom_meter",NULL, &_GK.spacer_bottom_meter_piximage,NULL, NULL},{ "cap_top_left_chart", NULL, &_GK.cap_top_left_chart_piximage, NULL, NULL},{ "cap_bottom_left_chart", NULL,&_GK.cap_bottom_left_chart_piximage,NULL,NULL},{ "cap_top_right_chart", NULL, &_GK.cap_top_right_chart_piximage, NULL,NULL},{"cap_bottom_right_chart",NULL,&_GK.cap_bottom_right_chart_piximage,NULL,NULL},{ "cap_top_left_meter", NULL, &_GK.cap_top_left_meter_piximage, NULL, NULL},{ "cap_bottom_left_meter", NULL,&_GK.cap_bottom_left_meter_piximage,NULL,NULL},{ "cap_top_right_meter", NULL, &_GK.cap_top_right_meter_piximage, NULL,NULL},{"cap_bottom_right_meter",NULL,&_GK.cap_bottom_right_meter_piximage,NULL,NULL},{ "krell_panel", krell_panel_xpm, NULL, &_GK.krell_panel_piximage_list, "*"},{ "krell_meter", krell_meter_xpm, NULL, &_GK.krell_meter_piximage_list, "*"},{ "krell_mail", krell_mail_xpm, NULL, &_GK.krell_meter_piximage_list, MAIL_STYLE_NAME },{ "krell_slider", krell_slider_xpm, &_GK.krell_slider_piximage, NULL, NULL},{ "krell_mini", krell_mini_xpm, &_GK.krell_mini_piximage, NULL, NULL} };static ImageTable default_theme_piximages[] = {{ NULL, button_panel_out_xpm, &_GK.button_panel_out_piximage,NULL, NULL},{ NULL, button_panel_in_xpm, &_GK.button_panel_in_piximage, NULL, NULL},{ NULL, button_meter_out_xpm,&_GK.button_meter_out_piximage, NULL, NULL},{ NULL, button_meter_in_xpm, &_GK.button_meter_in_piximage, NULL, NULL},{ NULL, bg_separator_xpm, &_GK.bg_separator_piximage, NULL, NULL},{ NULL, bg_panel_cal_xpm, NULL, &_GK.bg_meter_piximage_list, CAL_STYLE_NAME},{ NULL, bg_panel_clock_xpm, NULL, &_GK.bg_meter_piximage_list, CLOCK_STYLE_NAME},{ NULL, bg_panel_mem_xpm, NULL, &_GK.bg_meter_piximage_list, MEM_STYLE_NAME},{ NULL, bg_panel_host_xpm, NULL, &_GK.bg_meter_piximage_list, HOST_STYLE_NAME},{ NULL, bg_panel_uptime_xpm, NULL, &_GK.bg_meter_piximage_list, UPTIME_STYLE_NAME},{ NULL, bg_panel_timer_xpm, NULL, &_GK.bg_meter_piximage_list, TIMER_STYLE_NAME},{ NULL, bg_panel_swap_xpm, NULL, &_GK.bg_meter_piximage_list, SWAP_STYLE_NAME},{ NULL, data_in_xpm, &_GK.data_in_piximage, NULL, NULL},{ NULL, data_in_grid_xpm, &_GK.data_in_grid_piximage, NULL, NULL},{ NULL, data_out_xpm, &_GK.data_out_piximage, NULL, NULL},{ NULL, data_out_grid_xpm, &_GK.data_out_grid_piximage, NULL, NULL},{ NULL, krell_mem_xpm, NULL, &_GK.krell_meter_piximage_list, MEM_STYLE_NAME},{ NULL, krell_swap_xpm, NULL, &_GK.krell_meter_piximage_list, SWAP_STYLE_NAME}, };static ImageTable default_theme_alt0_piximages[] = {{ NULL, bg_panel_fs_xpm, NULL, &_GK.bg_meter_piximage_list, FS_STYLE_NAME},{ NULL, bg_panel_sensors_xpm, NULL,&_GK.bg_meter_piximage_list, "sensors" },/* Plugins */{ NULL, bg_panel_timers_xpm, NULL, &_GK.bg_meter_piximage_list, "timers"},{ NULL, bg_panel_volume_xpm, NULL, &_GK.bg_meter_piximage_list, "volume"},{ NULL, krell_gkrellmms_xpm, NULL, &_GK.krell_meter_piximage_list, "gkrellmms"},{ NULL, bg_panel_gkrellmms_xpm, NULL, &_GK.bg_meter_piximage_list, "gkrellmms"},{ NULL, bg_panel_pmu_xpm, NULL, &_GK.bg_meter_piximage_list, "pmu"}, };static ImageTable default_theme_alt1_piximages[] = {{ NULL, bg_panel_fs_1_xpm, NULL, &_GK.bg_meter_piximage_list, FS_STYLE_NAME},{ NULL, bg_panel_sensors_1_xpm, NULL, &_GK.bg_meter_piximage_list, "sensors"},/* Plugins */{ NULL, bg_panel_timers_1_xpm, NULL, &_GK.bg_meter_piximage_list, "timers"},{ NULL, bg_panel_volume_1_xpm, NULL, &_GK.bg_meter_piximage_list, "volume"},{ NULL, bg_panel_gkrellmms_1_xpm, NULL, &_GK.bg_meter_piximage_list, "gkrellmms"},{ NULL, bg_panel_pmu_1_xpm, NULL, &_GK.bg_meter_piximage_list, "pmu"}, };static ImageTable default_theme_alt2_piximages[] = {{ NULL, bg_panel_fs_2_xpm, NULL, &_GK.bg_meter_piximage_list, FS_STYLE_NAME},{ NULL, bg_panel_sensors_2_xpm, NULL, &_GK.bg_meter_piximage_list, "sensors"},/* Plugins */{ NULL, bg_panel_timers_2_xpm, NULL, &_GK.bg_meter_piximage_list, "timers"},{ NULL, bg_panel_volume_2_xpm, NULL, &_GK.bg_meter_piximage_list, "volume"},{ NULL, bg_panel_gkrellmms_2_xpm, NULL, &_GK.bg_meter_piximage_list, "gkrellmms"},{ NULL, bg_panel_pmu_2_xpm, NULL, &_GK.bg_meter_piximage_list, "pmu"}, }; /* Need a trap to look for extra custom and extension images I've made for | the default theme. */static GkrellmPiximage *default_theme_extension_piximage(gchar *name, gchar *subdir) { GkrellmPiximage *im = NULL; if (!strcmp(subdir, "gkrellmms")) { if (!strcmp(name, "bg_scroll")) im = gkrellm_piximage_new_from_xpm_data(bg_scroll_gkrellmms_xpm); if (!strcmp(name, "play_button")) im = gkrellm_piximage_new_from_xpm_data(gkrellmms_play_button_xpm); if (!strcmp(name, "prev_button")) im = gkrellm_piximage_new_from_xpm_data(gkrellmms_prev_button_xpm); if (!strcmp(name, "stop_button")) im = gkrellm_piximage_new_from_xpm_data(gkrellmms_stop_button_xpm); if (!strcmp(name, "next_button")) im = gkrellm_piximage_new_from_xpm_data(gkrellmms_next_button_xpm); if (!strcmp(name, "eject_button")) im =gkrellm_piximage_new_from_xpm_data(gkrellmms_eject_button_xpm); if (!strcmp(name, "led_indicator")) im=gkrellm_piximage_new_from_xpm_data(gkrellmms_led_indicator_xpm); } else if (!strcmp(subdir, CPU_STYLE_NAME) && !strcmp(name, "nice")) im = gkrellm_piximage_new_from_xpm_data(nice_xpm); else if (!strcmp(subdir, CPU_STYLE_NAME) && !strcmp(name,"nice_grid")) im = gkrellm_piximage_new_from_xpm_data(nice_grid_xpm); return im; }gbooleangkrellm_load_piximage_from_inline(gchar *name, const guint8 *data, GkrellmPiximage **image, gchar *subdir, gboolean copy_pixels) { GkrellmPiximage *im = NULL; gchar *fname; if (gkrellm_using_default_theme() && name && subdir) im = default_theme_extension_piximage(name, subdir); else if (name && (fname = gkrellm_theme_file_exists(name, subdir)) != NULL) { name = fname; im = gkrellm_piximage_new_from_file(fname); if (im == NULL) printf(_(" Cannot load file image: %s\n"), fname); } if (im == NULL && data) { im = gkrellm_piximage_new_from_inline(data, copy_pixels); if (im == NULL) printf(_(" Cannot load GdkPixbuf inline data.\n")); } if (im && image) { if (*image) gkrellm_destroy_piximage(*image); *image = im; } return (im ? TRUE : FALSE); }gbooleangkrellm_load_piximage(gchar *name, gchar **xpm, GkrellmPiximage **image, gchar *subdir) { GkrellmPiximage *im = NULL; gchar *fname; if (gkrellm_using_default_theme() && name && subdir) im = default_theme_extension_piximage(name, subdir); else if (name && (fname = gkrellm_theme_file_exists(name, subdir)) != NULL) { name = fname; im = gkrellm_piximage_new_from_file(fname); if (im == NULL) printf(_(" Cannot load file image: %s\n"), fname); } if (im == NULL && xpm) { im = gkrellm_piximage_new_from_xpm_data(xpm); if (im == NULL) printf(_(" Cannot load xpm: %s\n"), name); } if (im && image) { if (*image) gkrellm_destroy_piximage(*image); *image = im; } return (im ? TRUE : FALSE); }static voidload_from_piximage_list(gchar *name, GList *image_list, gint index, gchar *subdir) { GList *list; GkrellmPiximage **im; list = g_list_nth(image_list, index); if (list) { im = (GkrellmPiximage **) (&list->data); gkrellm_load_piximage(name, NULL, im, subdir); } else printf("Bad index %d for image list (meter/panel problem?)\n", index); }static voidload_monitor_specific_piximages(void) { GkrellmMonitor *mon; GList *list; gchar *subdir; gint i; for (list = gkrellm_monitor_list; list; list = list->next) { mon = (GkrellmMonitor *) list->data; if ((subdir = mon->privat->style_name) == NULL) continue; i = mon->privat->style_id; if (mon->privat->style_type == CHART_PANEL_TYPE) { load_from_piximage_list("bg_chart", _GK.bg_chart_piximage_list, i, subdir); load_from_piximage_list("bg_grid", _GK.bg_grid_piximage_list, i, subdir); load_from_piximage_list("bg_panel", _GK.bg_panel_piximage_list, i, subdir); load_from_piximage_list("krell", _GK.krell_panel_piximage_list, i, subdir); } else { load_from_piximage_list("krell", _GK.krell_meter_piximage_list, i, subdir); load_from_piximage_list("bg_panel", _GK.bg_meter_piximage_list, i, subdir); load_from_piximage_list("bg_meter", _GK.bg_meter_piximage_list, i, subdir); } gkrellm_load_piximage("spacer_top", NULL, &mon->privat->top_spacer.piximage, subdir); gkrellm_load_piximage("spacer_bottom", NULL, &mon->privat->bottom_spacer.piximage, subdir); } }static voidassign_gkrellmrc_spacer(gchar *source_line, gchar *area, gchar *string) { GkrellmMonitor *mon = NULL; gchar style_name[32], arg[32], *s; gint n; if ((n = sscanf(string, "%31s %31[^\n]", style_name, arg)) < 1) return; if (n == 1) strcpy(arg, style_name); else if ((mon = gkrellm_monitor_from_style_name(style_name)) == NULL) return; for (s = arg; *s == ' ' || *s == '=' || *s == '\t'; ++s) ; if (!strncmp(area, "spacer_top_height", 17)) { if (n == 1 && !strcmp(area, "spacer_top_height_chart")) _GK.spacer_top_height_chart = atoi(s); else if (n == 1 && !strcmp(area, "spacer_top_height_meter")) _GK.spacer_top_height_meter = atoi(s); else if (n == 1) { _GK.spacer_top_height_chart = atoi(s); _GK.spacer_top_height_meter = _GK.spacer_top_height_chart; } else mon->privat->top_spacer.height = atoi(s); } else if (!strncmp(area, "spacer_bottom_height", 20)) { if (n == 1 && !strcmp(area, "spacer_bottom_height_chart")) _GK.spacer_bottom_height_chart = atoi(s); else if (n == 1 && !strcmp(area, "spacer_bottom_height_meter")) _GK.spacer_bottom_height_meter = atoi(s); else if (n == 1) { _GK.spacer_bottom_height_chart = atoi(s); _GK.spacer_bottom_height_meter = _GK.spacer_bottom_height_chart; } else mon->privat->bottom_spacer.height = atoi(s); } } /* I have to do something about separate chart/meter lists. */static GList *lookup_piximage_from_name(GList *image_list, gchar *name) { GList *n_list, *i_list; for (n_list = _GK.chart_name_list, i_list = image_list; n_list && i_list; n_list = n_list->next, i_list = i_list->next) if (!strcmp(name, (gchar *) n_list->data)) return i_list; for (n_list = _GK.meter_name_list, i_list = image_list; n_list && i_list; n_list = n_list->next, i_list = i_list->next) if (!strcmp(name, (gchar *) n_list->data)) return i_list; return NULL; }static voidload_piximage_table(ImageTable *ti, gint n_piximages, gchar *subdir) { GkrellmPiximage **im; GList *list; gint i; for (i = 0; i < n_piximages; ++i, ++ti) { if (ti->image_list) {/* list = g_list_nth(*(ti->image_list), ti->list_index); */ list = lookup_piximage_from_name(*(ti->image_list), ti->name_in_list); if (list) { im = (GkrellmPiximage **) (&list->data); gkrellm_load_piximage(ti->name, ti->xpm, im, subdir); } } else gkrellm_load_piximage(ti->name, ti->xpm, ti->im, subdir); } } /* When loading a new theme, required base level images are not cleaned | so the program will not crash if a theme does not have all images yet. | It will just look funny. But all optional base level images are cleaned | so they will not carry over to the new theme. There are no optional | base level images in the image_lists. */static voidclean_base_piximage_table(void) { ImageTable *ti; gint i; ti = &base_theme_piximages[0]; for (i = 0; i < sizeof(base_theme_piximages) / sizeof(ImageTable); ++i, ++ti) if (ti->xpm == NULL && ti->im && *(ti->im)) /* Is an optional image */ { gkrellm_destroy_piximage(*(ti->im)); *(ti->im) = NULL; } }static voiddestroy_piximage(GkrellmPiximage **im) { if (im && *im) { gkrellm_destroy_piximage(*im); *im = NULL; } }static voiddestroy_piximage_list(GList *list, GList *name_list, gchar *debug_name) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -