GkrellmMonitor * gkrellm_init_proc_monitor(void) { GkrellmChartconfig *cf; monitor_proc.name = _(monitor_proc.name); proc.panel_label = g_strdup(_("Proc")); proc.enabled = TRUE; proc.extra_info = TRUE; style_id = gkrellm_add_chart_style(&monitor_proc, PROC_STYLE_NAME); gkrellm_locale_dup_string(&text_format, _(DEFAULT_TEXT_FORMAT), &text_format_locale); mon_proc = &monitor_proc; if (setup_proc_interface()) { /* Set chart config defaults. Turn off auto grid resolution and | don't let user config it back on. */ cf = proc.chart_config = gkrellm_chartconfig_new0(); gkrellm_set_chartconfig_grid_resolution(cf, 100); gkrellm_set_chartconfig_auto_grid_resolution(cf, FALSE); gkrellm_set_chartconfig_flags(cf, NO_CONFIG_AUTO_GRID_RESOLUTION); return &monitor_proc; } return NULL; }
static void cb_text_format(GtkWidget *widget, gpointer data) { gchar *s; GtkWidget *entry; entry = gtk_bin_get_child(GTK_BIN(text_format_combo_box)); s = gkrellm_gtk_entry_get_text(&entry); gkrellm_locale_dup_string(&text_format, s, &text_format_locale); new_text_format = TRUE; refresh_proc_chart(proc.chart); }
void do_switch_station(int nr) { gchar *text_utf8 = NULL, *text_locale = NULL; nr %= nstations; currentstation = nr; start_mute_timer(); radio_setfreq(stations[nr].freq); gkrellm_locale_dup_string(&text_utf8, stations[nr].station_name, &text_locale); gkrellm_draw_decal_text(panel, station_text, text_locale, -1); gkrellm_draw_panel_layers(panel); gkrellm_config_modified(); }
static void load_proc_config(gchar *arg) { gchar config[32], name[16], item[CFG_BUFSIZE], item1[CFG_BUFSIZE]; gint n; n = sscanf(arg, "%31s %[^\n]", config, item); if (n == 2) { if (!strcmp(config, "enable")) sscanf(item, "%d %d\n", &proc.enabled, &proc.extra_info); else if (!strcmp(config, "launch")) proc_launch.command = g_strdup(item); else if (!strcmp(config, "tooltip_comment")) proc_launch.tooltip_comment = g_strdup(item); else if (!strcmp(config, "sensor_mode")) sscanf(item, "%d\n", &sensor_separate_mode); else if (!strcmp(config, "text_format")) { gkrellm_locale_dup_string(&text_format, item, &text_format_locale); new_text_format = TRUE; } else if (!strcmp(config, GKRELLM_CHARTCONFIG_KEYWORD)) gkrellm_load_chartconfig(&proc.chart_config, item, 2); else if (!strcmp(config, GKRELLM_ALERTCONFIG_KEYWORD)) { if (sscanf(item, "%15s %[^\n]", name, item1) == 2) { if (!strcmp(name, "load")) { if (!load_alert) create_load_alert(); gkrellm_load_alertconfig(&load_alert, item1); } else if (!strcmp(name, "users")) { if (!users_alert) create_users_alert(); gkrellm_load_alertconfig(&users_alert, item1); } else if (!strcmp(name, "processes")) { if (!processes_alert) create_processes_alert(); gkrellm_load_alertconfig(&processes_alert, item1); } } } } }
static void create_plugin(GtkWidget *vbox, gint first_create) { GkrellmStyle *style; GkrellmTextstyle *ts, *ts_alt; GkrellmMargin *margin; GdkPixmap *pixmap; GdkBitmap *mask; gint y; gint x; gchar *text_utf8 = NULL, *text_locale = NULL; if (first_create) { panel = gkrellm_panel_new0(); gkrellm_disable_plugin_connect(plugin_monitor,close_radio); /* create the frequency menu */ create_freq_menu(); } else gkrellm_destroy_decal_list(panel); style = gkrellm_meter_style(style_id); /* Each GkrellmStyle has two text styles. The theme designer has picked the | colors and font sizes, presumably based on knowledge of what you draw | on your panel. You just do the drawing. You probably could assume | the ts font is larger than the ts_alt font, but again you can be | overridden by the theme designer. */ ts = gkrellm_meter_textstyle(style_id); ts_alt = gkrellm_meter_alt_textstyle(style_id); panel->textstyle = ts; /* would be used for a panel label */ y = 2; /* some border */ station_text = gkrellm_create_decal_text(panel, _("Hello World"), ts_alt, style, 2, y, 40); /* Create a pixmap decal and place it to the right of station_text. Use | decals from the builtin decal_misc.xpm. */ pixmap = gkrellm_decal_misc_pixmap(); mask = gkrellm_decal_misc_mask(); x = station_text->x + station_text->w + 4; decal_onoff_pix = gkrellm_create_decal_pixmap(panel, pixmap, mask, N_MISC_DECALS, NULL, x, y); /* Configure the panel to hold the above created decals, add in a little | bottom margin for looks, and create the panel. */ gkrellm_panel_configure(panel, NULL, style); gkrellm_panel_create(vbox, plugin_monitor,panel); /* After the panel is created, the decals can be converted into buttons. | First draw the initial text into the text decal button and then | put the text decal into a meter button. But for the decal_onoff_pix, | we can directly convert it into a decal button since it is a pixmap | decal. Just pass the frame we want to be the out image and the | frame for the in or pressed image. */ gkrellm_locale_dup_string(&text_utf8, station_name(radio_getfreq()), &text_locale); gkrellm_draw_decal_text(panel, station_text, text_locale, button_state); margin = gkrellm_get_style_margins(style); gkrellm_put_decal_in_meter_button(panel, station_text, cb_button, GINT_TO_POINTER(1),margin); onoff_button = gkrellm_make_decal_button(panel, decal_onoff_pix, cb_button, GINT_TO_POINTER(2), onoff_state ? D_MISC_BUTTON_ON : D_MISC_BUTTON_OUT, D_MISC_BUTTON_IN); /* Note: all of the above gkrellm_draw_decal_XXX() calls will not | appear on the panel until a gkrellm_draw_layers(panel); call is | made. This will be done in update_plugin(), otherwise we would | make the call here and anytime the decals are changed. */ if (first_create) { g_signal_connect(GTK_OBJECT (panel->drawing_area), "expose_event", (GtkSignalFunc) panel_expose_event, NULL); g_signal_connect(GTK_OBJECT (panel->drawing_area), "button_release_event", GTK_SIGNAL_FUNC(button_release_event), NULL); g_signal_connect(GTK_OBJECT (panel->drawing_area), "scroll_event", GTK_SIGNAL_FUNC(scroll_event), NULL); reopen_radio(); } gkrellm_draw_panel_layers(panel); }
static void set_text_freq(float freq) { gchar *text_utf8 = NULL, *text_locale = NULL; gkrellm_locale_dup_string(&text_utf8, station_name(freq), &text_locale); gkrellm_draw_decal_text(panel, station_text, text_locale, -1); gkrellm_draw_panel_layers(panel); }