📄 plugins.c
字号:
/* GKrellM| Copyright (C) 1999-2006 Bill Wilson|| Author: Bill Wilson billw@gkrellm.net| Latest versions might be found at: http://gkrellm.net|| This program is free software which I release under the GNU General Public| License. You may redistribute and/or modify this program under the terms| of that license as published by the Free Software Foundation; either| version 2 of the License, or (at your option) any later version.|| This program is distributed in the hope that it will be useful,| but WITHOUT ANY WARRANTY; without even the implied warranty of| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the| GNU General Public License for more details. Version 2 is in the| COPYRIGHT file in the top level directory of this distribution.| | To get a copy of the GNU General Puplic License, write to the Free Software| Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA*/#include "gkrellm.h"#include "gkrellm-private.h"#include "gkrellm-sysdeps.h"#include <gmodule.h>#if defined(WIN32)#include "win32-plugin.h"#endif/* ======================================================================= *//* Plugin interface to GKrellM.*/gchar *gkrellm_get_hostname(void) { gchar *hostname; if (_GK.client_mode) hostname = _GK.server_hostname; else hostname = gkrellm_sys_get_host_name(); return hostname; }gchar *gkrellm_get_theme_path(void) { return _GK.theme_path; }GkrellmKrell *gkrellm_krell_new0(void) { GkrellmKrell *k; k = g_new0(GkrellmKrell, 1); return k; }GkrellmDecal *gkrellm_decal_new0(void) { GkrellmDecal *d; d = g_new0(GkrellmDecal, 1); return d; }GkrellmLabel *gkrellm_label_new0(void) { GkrellmLabel *l; l = g_new0(GkrellmLabel, 1); return l; }GkrellmStyle *gkrellm_style_new0(void) { GkrellmStyle *s; s = g_new0(GkrellmStyle, 1); return s; }GkrellmStyle *gkrellm_copy_style(GkrellmStyle *style) { GkrellmStyle *s = NULL; if (style) { s = gkrellm_style_new0(); *s = *style; } return s; }voidgkrellm_copy_style_values(GkrellmStyle *dst, GkrellmStyle *src) { if (src && dst) *dst = *src; }GkrellmTextstyle *gkrellm_textstyle_new0(void) { GkrellmTextstyle *t; t = g_new0(GkrellmTextstyle, 1); return t; }GkrellmTextstyle *gkrellm_copy_textstyle(GkrellmTextstyle *ts) { GkrellmTextstyle *t = gkrellm_textstyle_new0(); *t = *ts; return t; }GkrellmChart *gkrellm_chart_new0(void) { GkrellmChart *c; c = g_new0(GkrellmChart, 1); return c; }GkrellmChartconfig *gkrellm_chartconfig_new0(void) { GkrellmChartconfig *config; config = g_new0(GkrellmChartconfig, 1); return config; }GkrellmPanel *gkrellm_panel_new0(void) { GkrellmPanel *p; p = g_new0(GkrellmPanel, 1); p->label = gkrellm_label_new0(); return p; }static GkrellmStyle *get_style_from_list(GList *list, gint n) { GList *l; GkrellmStyle *style; l = g_list_nth(list, n); if (l == NULL || l->data == NULL) l = list; if (l->data == NULL) { printf("Warning: NULL style returned %d\n", n); abort(); } style = (GkrellmStyle *) l->data; return style; }GkrellmStyle *gkrellm_meter_style(gint n) { return get_style_from_list(_GK.meter_style_list, n); }GkrellmStyle *gkrellm_panel_style(gint n) { return get_style_from_list(_GK.panel_style_list, n); }GkrellmStyle *gkrellm_chart_style(gint n) { return get_style_from_list(_GK.chart_style_list, n); }static GkrellmStyle *get_style_from_list_by_name(GList *name_list, GList *style_list, gchar *name) { GList *list; gchar *p, buf[128]; gint n; strncpy(buf, name, sizeof(buf)); buf[sizeof(buf) - 1] = '\0'; if ( (p = strchr(buf, '.')) != NULL && (n = gkrellm_string_position_in_list(_GK.custom_name_list, name)) >= 0 ) list = _GK.custom_style_list; else { if (p) *p = '\0'; if ((n = gkrellm_string_position_in_list(name_list, buf)) < 0) n = 0; list = style_list; } return get_style_from_list(list, n); }GkrellmStyle *gkrellm_meter_style_by_name(gchar *name) { return get_style_from_list_by_name(_GK.meter_name_list, _GK.meter_style_list, name); }GkrellmStyle *gkrellm_panel_style_by_name(gchar *name) { return get_style_from_list_by_name(_GK.chart_name_list, _GK.panel_style_list, name); }GkrellmStyle *gkrellm_chart_style_by_name(gchar *name) { return get_style_from_list_by_name(_GK.chart_name_list, _GK.chart_style_list, name); }gintgkrellm_lookup_chart_style_id(gchar *name) { GList *list; gint i; for (list = _GK.chart_name_list, i = 0; list; list = list->next, ++i) if (name && !strcmp(name, (gchar *)list->data)) return i; return 0; }gintgkrellm_lookup_meter_style_id(gchar *name) { GList *list; gint i; for (list = _GK.meter_name_list, i = 0; list; list = list->next, ++i) if (name && !strcmp(name, (gchar *)list->data)) return i; return 0; }static GkrellmPiximage *get_piximage_from_list(GList *list, gint n) { GList *l; l = g_list_nth(list, n); if (l == NULL || l->data == NULL) l = list; if (l->data == NULL) { printf("Warning: NULL image returned %d\n", n); abort(); } return (GkrellmPiximage *) l->data; }GkrellmPiximage *gkrellm_bg_chart_piximage(gint n) { return get_piximage_from_list(_GK.bg_chart_piximage_list, n); }GkrellmPiximage *gkrellm_bg_grid_piximage(gint n) { return get_piximage_from_list(_GK.bg_grid_piximage_list, n); }GkrellmPiximage *gkrellm_bg_panel_piximage(gint n) { return get_piximage_from_list(_GK.bg_panel_piximage_list, n); }GkrellmPiximage *gkrellm_bg_meter_piximage(gint n) { return get_piximage_from_list(_GK.bg_meter_piximage_list, n); }GkrellmPiximage *gkrellm_krell_panel_piximage(gint n) { return get_piximage_from_list(_GK.krell_panel_piximage_list, n); }GkrellmPiximage *gkrellm_krell_meter_piximage(gint n) { return get_piximage_from_list(_GK.krell_meter_piximage_list, n); }voidgkrellm_get_decal_alarm_piximage(GkrellmPiximage **im, gint *frames) { if (im) *im = _GK.decal_alarm_piximage; if (frames) *frames = _GK.decal_alarm_frames; }voidgkrellm_get_decal_warn_piximage(GkrellmPiximage **im, gint *frames) { if (im) *im = _GK.decal_warn_piximage; if (frames) *frames = _GK.decal_warn_frames; }voidgkrellm_monitor_height_adjust(gint h) { _GK.monitor_height += h; }GdkPixmap *gkrellm_decal_misc_pixmap(void) { return _GK.decal_misc_pixmap; }GdkBitmap *gkrellm_decal_misc_mask(void) { return _GK.decal_misc_mask; }GdkPixmap **gkrellm_data_in_pixmap(void) { return &_GK.data_in_pixmap; }GdkPixmap *gkrellm_data_in_grid_pixmap(void) { return _GK.data_in_grid_pixmap; }GdkPixmap **gkrellm_data_out_pixmap(void) { return &_GK.data_out_pixmap; }GdkPixmap *gkrellm_data_out_grid_pixmap(void) { return _GK.data_out_grid_pixmap; }GkrellmPiximage *gkrellm_krell_slider_piximage(void) { return _GK.krell_slider_piximage; }GkrellmStyle *gkrellm_krell_slider_style(void) { return _GK.krell_slider_style; }GkrellmPiximage *gkrellm_krell_mini_piximage(void) { return _GK.krell_mini_piximage; }GkrellmStyle *gkrellm_krell_mini_style(void) { return _GK.krell_mini_style; }GdkGC *gkrellm_draw_GC(gint n) { GdkGC *gc; if (n == 0) return _GK.draw_stencil_GC; else if (n == 1) gc = _GK.draw1_GC; else if (n == 2) gc = _GK.draw2_GC; else gc = _GK.draw3_GC; return gc; }GdkGC *gkrellm_bit_GC(gint n) { if (n == 0) return _GK.bit0_GC; else return _GK.bit1_GC; }GkrellmTextstyle *gkrellm_chart_textstyle(gint n) { GkrellmStyle *style; GkrellmTextstyle *ts; style = get_style_from_list(_GK.chart_style_list, n); ts = &style->label_tsA; ts->font = *(ts->font_seed); return ts; }GkrellmTextstyle *gkrellm_panel_textstyle(gint n) { GkrellmStyle *style; GkrellmTextstyle *ts; style = get_style_from_list(_GK.panel_style_list, n); ts = &style->label_tsA; ts->font = *(ts->font_seed); return ts; }GkrellmTextstyle *gkrellm_meter_textstyle(gint n) { GkrellmStyle *style; GkrellmTextstyle *ts; style = get_style_from_list(_GK.meter_style_list, n); ts = &style->label_tsA; ts->font = *(ts->font_seed); return ts; }GkrellmTextstyle *gkrellm_chart_alt_textstyle(gint n) { GkrellmStyle *style; GkrellmTextstyle *ts; style = get_style_from_list(_GK.chart_style_list, n); ts = &style->label_tsB; ts->font = *(ts->font_seed); return ts; }GkrellmTextstyle *gkrellm_panel_alt_textstyle(gint n) { GkrellmStyle *style; GkrellmTextstyle *ts; style = get_style_from_list(_GK.panel_style_list, n); ts = &style->label_tsB; ts->font = *(ts->font_seed); return ts; }GkrellmTextstyle *gkrellm_meter_alt_textstyle(gint n) { GkrellmStyle *style; GkrellmTextstyle *ts; style = get_style_from_list(_GK.meter_style_list, n); ts = &style->label_tsB; ts->font = *(ts->font_seed); return ts; }PangoFontDescription *gkrellm_default_font(gint n) { if (n == 0) return _GK.small_font; else if (n == 1) return _GK.normal_font; else return _GK.large_font; }GdkColor *gkrellm_white_color(void) { return &_GK.white_color; }GdkColor *gkrellm_black_color(void) { return &_GK.background_color; }GdkColor *gkrellm_in_color(void) { return &_GK.in_color; }GdkColor *gkrellm_out_color(void) { return &_GK.out_color; }gbooleangkrellm_demo_mode(void) { return _GK.demo; }gintgkrellm_update_HZ(void) { return _GK.update_HZ; }gintgkrellm_chart_width(void) { return _GK.chart_width; }voidgkrellm_allow_scaling(gboolean *allow, gint *width_ref)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -