⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gui.c

📁 系统任务管理器
💻 C
📖 第 1 页 / 共 5 页
字号:
			if (n && _GK.state_above)				gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(above_button),						FALSE);			gkrellm_winop_state_below(n);			}		}#endif	}static voidcb_dock_type(GtkWidget *widget, gpointer data)	{	gboolean	sensitive;	_GK.dock_type = GTK_TOGGLE_BUTTON(dock_type_button)->active;	sensitive = !_GK.dock_type;	if (!sensitive)		{		gtk_toggle_button_set_active(					GTK_TOGGLE_BUTTON(decorated_button), FALSE);		gtk_toggle_button_set_active(					GTK_TOGGLE_BUTTON(skip_taskbar_button), FALSE);		gtk_toggle_button_set_active(					GTK_TOGGLE_BUTTON(skip_pager_button), FALSE);		}	gtk_widget_set_sensitive(decorated_button, sensitive);	gtk_widget_set_sensitive(skip_taskbar_button, sensitive);	gtk_widget_set_sensitive(skip_pager_button, sensitive);	}static gchar	*general_info_text[]	={N_("<h>Krells\n"),N_("Krells are the horizontally moving indicators below each chart and\n""on meter style monitors.  Depending on the monitor, they show fast\n""response data rates, a percentage of some capacity, or something else.\n"),"\n",N_("<h>Charts\n"),N_("The default for most charts is to automatically adjust the number of\n"	"grid lines drawn and the resolution per grid so drawn data will be\n"	"nicely visible.  You may change this to fixed grids of 1-5 and/or\n"	"fixed grid resolutions in the chart config windows.  However,\n"	"some combination of the auto scaling modes may give best results.\n"),"\n",N_("See the README or do a \"man gkrellm\" for more information.\n"),"\n",N_("<h>Chart Labels\n"),N_("Chart label format strings place text on charts using position codes:\n"),N_("\t\\t    top left\n"),N_("\t\\b    bottom left\n"),N_("\t\\n    next line\n"),N_("\t\\N    next line only if last string had visible characters\n"),N_("\t\\p    previous line\n"),N_("\t\\c    center the text\n"),N_("\t\\C    begin drawing text at the center\n"),N_("\t\\r    right justify\n"),N_("\t\\f    use alternate font for the next string\n"),N_("\t\\w    use the following string to define a field width\n"),N_("\t\\a    draw left justified in the defined field width\n"),N_("\t\\e    draw right justified in the defined field width\n"),N_("\t\\.     no-op.  Used to break a string into two strings.\n"),N_("\t\\D0   bottom of charts first data view (D2 for second data view ...)\n"),N_("\t\\D1   top of charts first data view (D3 for second data view ...)\n"),N_("<h>\nCommands\n"),N_("\tMany monitors can be configured to launch commands.  Just enter the\n"   "\tcommand where you see a \"command\" entry and also a comment if you\n"   "\twant a tooltip to appear for the command.  After a command is entered,\n"   "\tfor a monitor, a button for launching it will become visible when you\n"   "\tmove the mouse into the panel area of the monitor.\n\n"),N_("See the README or do a \"man gkrellm\" for more information.\n"),"\n",N_("<h>\nMouse Button Actions:\n"),N_("<b>\tLeft "),N_("clicking on charts will toggle a display of some extra info.\n"),N_("<b>\tRight "),N_("clicking on charts brings up a chart configuration window.\n"),N_("<b>\tRight "),N_("clicking on many panels opens its monitor configuration window.\n")};static voidcreate_general_tab(GtkWidget *tab_vbox)	{	GtkWidget		*tabs;	GtkWidget		*vbox, *vbox1, *vbox2;	GtkWidget		*hbox;	GtkWidget		*label, *text;	gint			i;	tabs = gtk_notebook_new();	gtk_notebook_set_tab_pos(GTK_NOTEBOOK(tabs), GTK_POS_TOP);	gtk_box_pack_start(GTK_BOX(tab_vbox), tabs, TRUE, TRUE, 0);/* --Options tab */	vbox = gkrellm_gtk_framed_notebook_page(tabs, _("Options"));	vbox1 = gtk_vbox_new(FALSE, 0);	gtk_box_pack_start(GTK_BOX(vbox), vbox1, FALSE, FALSE, 0);	hbox = gtk_hbox_new (FALSE, 0);	gtk_box_pack_start(GTK_BOX(vbox1), hbox, FALSE, FALSE, 0);	gkrellm_gtk_check_button_connected(hbox, &enable_hst_button,			_GK.enable_hostname, FALSE, FALSE, 0,			cb_hostname_sysname, NULL,			_("Hostname display"));	if (gkrellm_hostname_can_shorten())		gkrellm_gtk_check_button_connected(hbox, &hostname_short_button,				_GK.hostname_short, FALSE, FALSE, 10,				cb_hostname_sysname, NULL,				_("Short hostname"));	gkrellm_gtk_check_button_connected(vbox, &enable_sysname_button,			_GK.enable_system_name, FALSE, FALSE, 0,			cb_hostname_sysname, NULL,			_("System name display"));	gkrellm_gtk_check_button_connected(vbox, &save_position_button,			_GK.save_position, FALSE, FALSE, 6,			cb_general, NULL,		_("Remember screen location at exit and move to it at next startup"));#if !defined(WIN32)	gkrellm_gtk_check_button_connected(vbox, &allow_multiple_button,			_GK.allow_multiple_instances, FALSE, FALSE, 0,			cb_general, NULL,			_("Allow multiple instances"));#endif#if defined(WIN32)	gkrellm_gtk_check_button_connected(vbox, &on_top_button,			_GK.on_top, FALSE, FALSE, 0,			cb_general, NULL,_("Make gkrellm a topmost window (restart gkrellm for this to take effect)."));#endif	if (_GK.client_mode)		{		hbox = gtk_hbox_new(FALSE, 0);		gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, TRUE, 6);		gkrellm_gtk_alert_button(hbox, NULL, FALSE, FALSE, 4, TRUE,					gkrellm_gkrellmd_disconnect_cb, NULL);		label = gtk_label_new(_("gkrellmd server disconnect"));		gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, TRUE, 4);		}	vbox = gkrellm_gtk_framed_vbox_end(vbox, NULL, 4, FALSE, 0, 2);	gkrellm_gtk_spin_button(vbox, NULL, (gfloat) _GK.update_HZ,			2.0, 20.0, 1.0, 1.0, 0, 55,			cb_HZ_spin, NULL, FALSE,			_("Krell and LED updates per second."));	gkrellm_gtk_spin_button(vbox, NULL, (gfloat) _GK.chart_width,			(gfloat) CHART_WIDTH_MIN, (gfloat) CHART_WIDTH_MAX,			5.0, 10.0, 0, 55,			cb_width_spin, NULL, FALSE,			_("GKrellM width"));#if !defined(WIN32)/* --Window options tab */	vbox = gkrellm_gtk_framed_notebook_page(tabs, _("Properties"));	gkrellm_gtk_check_button_connected(vbox, &sticky_state_button,			_GK.sticky_state, FALSE, FALSE, 0, cb_general, NULL,			_("Set sticky state"));	gkrellm_gtk_check_button_connected(vbox, &above_button,			_GK.state_above, FALSE, FALSE, 0, cb_general, NULL,			_("Set on top of other windows of the same type"));	gkrellm_gtk_check_button_connected(vbox, &below_button,			_GK.state_below, FALSE, FALSE, 0, cb_general, NULL,			_("Set below other windows of the same type"));	vbox1 = gkrellm_gtk_framed_vbox(vbox, NULL, 4, FALSE, 2, 0);	vbox2 = gkrellm_gtk_framed_vbox(vbox1, NULL, 0, FALSE, 0, 0);	gkrellm_gtk_check_button_connected(vbox2, &dock_type_button,			_GK.dock_type, FALSE, FALSE, 0,			cb_dock_type, NULL,						_("Set window type to be a dock or panel"));	vbox2 = gkrellm_gtk_framed_vbox(vbox1, NULL, 0, FALSE, 0, 0);	gkrellm_gtk_check_button_connected(vbox2, &decorated_button,			_GK.decorated, FALSE, FALSE, 0, cb_general, NULL,			_("Use window manager decorations"));	gkrellm_gtk_check_button_connected(vbox2, &skip_taskbar_button,			_GK.state_skip_taskbar, FALSE, FALSE, 0, cb_general, NULL,			_("Do not include on a taskbar"));	gkrellm_gtk_check_button_connected(vbox2, &skip_pager_button,			_GK.state_skip_pager, FALSE, FALSE, 0, cb_general, NULL,			_("Do not include on a pager"));	if (_GK.dock_type)		{		gtk_widget_set_sensitive(decorated_button, FALSE);		gtk_widget_set_sensitive(skip_taskbar_button, FALSE);		gtk_widget_set_sensitive(skip_pager_button, FALSE);		}	text = gtk_label_new(_("Some of these properties require a standards compliant window manager.\n"  "You may have to restart gkrellm for them to take effect.\n"));	gtk_box_pack_end(GTK_BOX(vbox), text, FALSE, TRUE, 4);#endif/* --Info tab */	vbox = gkrellm_gtk_framed_notebook_page(tabs, _("Info"));	text = gkrellm_gtk_scrolled_text_view(vbox, NULL,				GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);	for (i = 0; i < sizeof(general_info_text)/sizeof(gchar *); ++i)		gkrellm_gtk_text_view_append(text, _(general_info_text[i]));	}/* ------------------Themes Tab----------------------------------*/#define	THEME_SCALE_UP		0#define	THEME_SCALE_DOWN	1#define	THEME_RELOAD		2#define	THEME_NEXT			3#define	THEME_PREV			4#define	THEME_ALT_NEXT		5#define	THEME_ALT_PREV		6enum	{	THEME_COLUMN,	PATH_COLUMN,	N_THEME_COLUMNS	};typedef struct	{	gchar	*path;	gchar	*name;	}	Theme;static GtkTreeView      *theme_treeview;static GtkTreeSelection *theme_selection;static GList		*themes_list;static GList		*theme_position_in_list;static GtkWidget	*theme_alt_spin_button;static GtkWidget	*theme_alt_label;static GtkWidget	*theme_entry,					*author_label;static gboolean		theme_modified;typedef struct	{	GtkFontSelectionDialog	*fontseldlg;	GtkWidget				*entry;	GtkWidget				*browse_button;	gchar					*name;	gchar					*string;//	PangoFontDescription	*font_desc;	}	AltFontSelect;static AltFontSelect			large_font,			normal_font,			small_font;gchar *gkrellm_get_large_font_string(void)	{	return large_font.string;	}gchar *gkrellm_get_normal_font_string(void)	{	return normal_font.string;	}gchar *gkrellm_get_small_font_string(void)	{	return small_font.string;	}static gbooleanget_font_entries(void)	{	gchar		*s;	gboolean	modified = FALSE;	s = (gchar *) gtk_entry_get_text(GTK_ENTRY(large_font.entry));	modified |= gkrellm_dup_string(&large_font.string, s);	s = (gchar *) gtk_entry_get_text(GTK_ENTRY(normal_font.entry));	modified |= gkrellm_dup_string(&normal_font.string, s);	s = (gchar *) gtk_entry_get_text(GTK_ENTRY(small_font.entry));	modified |= gkrellm_dup_string(&small_font.string, s);	return modified;	}static voidcb_font_dialog_ok(GtkWidget *w, AltFontSelect *afs)	{	gchar	*fontname;	fontname = gtk_font_selection_dialog_get_font_name(afs->fontseldlg);	if (fontname)		gtk_entry_set_text(GTK_ENTRY(afs->entry), fontname);	gtk_widget_destroy(GTK_WIDGET(afs->fontseldlg));	theme_modified = TRUE;	get_font_entries();	gkrellm_build();	}static voidcb_font_dialog(GtkWidget *widget, AltFontSelect *afs)	{	GtkWidget				*w;	GtkFontSelectionDialog	*fsd;	if (afs->fontseldlg)		return;	w = gtk_font_selection_dialog_new(_(afs->name));	gtk_window_set_wmclass(GTK_WINDOW(w),				"Gkrellm_dialog", "Gkrellm");	fsd = GTK_FONT_SELECTION_DIALOG(w);	afs->fontseldlg = fsd;	gtk_font_selection_dialog_set_font_name(fsd, afs->string);	g_signal_connect(G_OBJECT(fsd->ok_button), "clicked",			G_CALLBACK(cb_font_dialog_ok), afs);	g_signal_connect_swapped(G_OBJECT(fsd->cancel_button), "clicked",			G_CALLBACK(gtk_widget_destroy), fsd);	g_signal_connect(G_OBJECT(fsd), "destroy",			G_CALLBACK(gtk_widget_destroyed), &afs->fontseldlg);	gtk_widget_show(GTK_WIDGET(fsd));	}static gchar *get_theme_author(gchar *path)	{	static gchar	buf[128];	FILE			*f;	gchar			*s, *q, *rcfile, line[128];	buf[0] = '\0';	if (!path || *path == '\0')		return buf;	rcfile = g_strdup_printf("%s/%s", path, GKRELLMRC);	f = fopen(rcfile, "r");	g_free(rcfile);	if (!f)		return buf;	while (fgets(line, sizeof(line), f))		{		if (   (s = strtok(line, " :=\t\n")) == NULL			|| strcmp(s, "author") != 0		   )			continue;		s = strtok(NULL, "\n");		/* Rest of line is Author string */		if (s)			{			while (   *s == ' ' || *s == '\t' || *s == '"' || *s == '='					|| *s == ':')				++s;			q = strchr(s, (int) '"');			if (q)				*q = '\0';			strcpy(buf, s);			break;			}		}	fclose(f);	return buf;	}static Theme *find_theme_in_list(gchar *name)	{	GList	*list;	Theme	*theme;	if (!name || !*name)		return NULL;	for (list = themes_list ; list; list = list->next)		{		theme = (Theme *) list->data;		if (!strcmp(theme->name, name))			return theme;		}	return NULL;	}static voidadd_themes_to_list(gchar *theme_dir, gboolean in_gkrellm2)	{	GDir	*dir;	Theme	*theme;	gchar	*name;	gchar	*path;	if ((dir = g_dir_open(theme_dir, 0, NULL)) == NULL)		return;	while ((name = (gchar *) g_dir_read_name(dir)) != NULL)		{		if (find_theme_in_list(name))			continue;		if (in_gkrellm2)			path = g_build_filename(theme_dir, name, "gkrellm2", NULL);		else			path = g_build_filename(theme_dir, name, NULL);		if (g_file_test(path, G_FILE_TEST_IS_DIR))			{			theme = g_new0(Theme, 1);			theme->path = path;			theme->name = g_strdup(name);			themes_list = g_list_append(themes_list, theme);			}		else			g_free(path);		}	g_dir_close(dir);	}static voidfind_theme_position_in_list(void)	{	GList	*list;	Theme	*theme;	gchar	*name;	name = *(_GK.theme_path) ? _GK.theme_path : "Default";	for (list = themes_list; list; list = list->next)		{		theme = (Theme *) list->data;		if (!strcmp(name, theme->path))			break;		}	theme_position_in_list = list ? list : themes_list;	}ginttheme_compare(Theme *th1, Theme *th2)	{	return strcmp(th1->name, th2->name);	}voidgkrellm_make_themes_list(void)	{	GList	*list;	Theme	*theme;	gchar	*theme_dir;	for (list = themes_list; list; list = list->next)		{		theme = (Theme *) list->data;		g_free(theme->path);		g_free(theme->name);		}	gkrellm_free_glist_and_data(&themes_list);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -