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

📄 main.c

📁 系统任务管理器
💻 C
📖 第 1 页 / 共 5 页
字号:
					_GK.spacer_top_height_chart : _GK.spacer_top_height_meter;		gkrellm_render_spacer(top_spacer, 0, 0,				_GK.frame_left_spacer_overlap, _GK.frame_right_spacer_overlap);		_GK.monitor_height += top_spacer->height;		}	else		gtk_widget_hide(top_spacer->vbox);	if (bottom_spacer->piximage)		{		if (bottom_spacer->height < 0)			bottom_spacer->height = (mp->style_type == CHART_PANEL_TYPE) ?					_GK.spacer_bottom_height_chart :					_GK.spacer_bottom_height_meter;		gkrellm_render_spacer(bottom_spacer, 0, 0,				_GK.frame_left_spacer_overlap, _GK.frame_right_spacer_overlap);		_GK.monitor_height += bottom_spacer->height;		}	else		gtk_widget_hide(bottom_spacer->vbox);	mon->privat->spacers_shown = TRUE;	/* ie, trying to show if they exist */	}voidgkrellm_spacers_set_types(GkrellmMonitor *mon, gint top_type, gint bot_type)	{	GkrellmMonprivate	*mp = (GkrellmMonprivate *) mon->privat;	GkrellmSpacer		*ts, *bs;	gboolean			shown;	mp->top_type = top_type;	mp->bottom_type = bot_type;	ts = &mp->top_spacer;	bs = &mp->bottom_spacer;	shown = mp->spacers_shown;	if (ts->piximage)		{		if (mp->spacers_shown)			_GK.monitor_height -= ts->height;		gkrellm_destroy_piximage(ts->piximage);		}	if (bs->piximage)		{		if (mp->spacers_shown)			_GK.monitor_height -= bs->height;		gkrellm_destroy_piximage(bs->piximage);		}	ts->piximage = gkrellm_clone_piximage((top_type == GKRELLM_SPACER_CHART) ?			_GK.spacer_top_chart_piximage : _GK.spacer_top_meter_piximage);	gkrellm_set_piximage_border(ts->piximage, &_GK.spacer_top_border);	bs->piximage = gkrellm_clone_piximage((bot_type == GKRELLM_SPACER_CHART) ?				_GK.spacer_bottom_chart_piximage :				_GK.spacer_bottom_meter_piximage);	gkrellm_set_piximage_border(bs->piximage, &_GK.spacer_bottom_border);	ts->height = (top_type == GKRELLM_SPACER_CHART) ?				_GK.spacer_top_height_chart : _GK.spacer_top_height_meter;	bs->height = (bot_type == GKRELLM_SPACER_CHART) ?				_GK.spacer_bottom_height_chart :				_GK.spacer_bottom_height_meter;	gkrellm_freeze_side_frame_packing();	render_monitor_spacers(mon);	if (!shown)		gkrellm_spacers_hide(mon);	gkrellm_thaw_side_frame_packing();	}  /* Builtin monitors need to control spacer visibility when they are  |  enabled/disabled.  Plugins have this done for them when enabling.  */voidgkrellm_spacers_show(GkrellmMonitor *mon)	{	GkrellmMonprivate	*mp;	if (!mon)		return;	mp = mon->privat;	if (mp->spacers_shown)		return;	if (mp->top_spacer.piximage)		{		gtk_widget_show(mp->top_spacer.vbox);		_GK.monitor_height += mp->top_spacer.height;		}	if (mp->bottom_spacer.piximage)		{		gtk_widget_show(mp->bottom_spacer.vbox);		_GK.monitor_height += mp->bottom_spacer.height;		}	mp->spacers_shown = TRUE;	gkrellm_pack_side_frames();	if (mon == gkrellm_mon_host())		gtk_widget_show(gtree.top1_event_box);	}voidgkrellm_spacers_hide(GkrellmMonitor *mon)	{	GkrellmMonprivate	*mp;	if (!mon)		return;	mp = mon->privat;	if (!mp->spacers_shown)		return;	if (mp->top_spacer.piximage)		{		gtk_widget_hide(mp->top_spacer.vbox);		_GK.monitor_height -= mp->top_spacer.height;		}	if (mp->bottom_spacer.piximage)		{		gtk_widget_hide(mp->bottom_spacer.vbox);		_GK.monitor_height -= mp->bottom_spacer.height;		}	mp->spacers_shown = FALSE;	gkrellm_pack_side_frames();	if (mon == gkrellm_mon_host())		gtk_widget_hide(gtree.top1_event_box);	}static voidcreate_widget_tree()	{	gchar		*title;#if GTK_CHECK_VERSION(2,4,0)	GdkPixbuf	*icon;#endif	gtree.window = gtk_window_new(GTK_WINDOW_TOPLEVEL);	gtk_widget_set_name(gtree.window, PACKAGE);#if GTK_CHECK_VERSION(2,4,0)	icon = gdk_pixbuf_new_from_xpm_data((const gchar **) icon_xpm);	gtk_window_set_default_icon(icon);#endif	title = gkrellm_make_config_file_name(NULL, PACKAGE);	gtk_window_set_title(GTK_WINDOW(gtree.window), title);//	gtk_window_set_wmclass(GTK_WINDOW(gtree.window), title, "Gkrellm");	g_free(title);	gtree.vbox = gtk_vbox_new(FALSE, 0);	gtk_container_add(GTK_CONTAINER(gtree.window), gtree.vbox);	gtree.top0_event_box = gtk_event_box_new();	gtk_container_add(GTK_CONTAINER(gtree.vbox), gtree.top0_event_box);	gtree.top0_vbox = gtk_vbox_new(FALSE, 0);	gtk_container_add(GTK_CONTAINER(gtree.top0_event_box), gtree.top0_vbox);	/* The middle hbox has left frame, monitors & a right frame.	*/	gtree.middle_hbox = gtk_hbox_new(FALSE, 0);	gtk_container_add(GTK_CONTAINER(gtree.vbox), gtree.middle_hbox);	gtree.left_event_box = gtk_event_box_new();	gtk_container_add(GTK_CONTAINER(gtree.middle_hbox), gtree.left_event_box);	gtree.left_vbox = gtk_vbox_new(FALSE, 0);	gtk_container_add(GTK_CONTAINER(gtree.left_event_box), gtree.left_vbox);	gtree.middle_vbox = gtk_vbox_new(FALSE, 0);	gtk_container_add(GTK_CONTAINER(gtree.middle_hbox), gtree.middle_vbox);	/* Hostname will go in an event box for moving gkrellm */	gtree.top1_event_box = gtk_event_box_new();	gtk_container_add(GTK_CONTAINER(gtree.middle_vbox), gtree.top1_event_box);	gtree.top1_vbox = gtk_vbox_new(FALSE, 0);	gtk_container_add(GTK_CONTAINER(gtree.top1_event_box), gtree.top1_vbox);	gtree.monitor_vbox = gtk_vbox_new(FALSE, 0);	gtk_container_add(GTK_CONTAINER(gtree.middle_vbox), gtree.monitor_vbox);	gtree.right_event_box = gtk_event_box_new();	gtk_container_add(GTK_CONTAINER(gtree.middle_hbox), gtree.right_event_box);	gtree.right_vbox = gtk_vbox_new(FALSE, 0);	gtk_container_add(GTK_CONTAINER(gtree.right_event_box), gtree.right_vbox);	gtree.bottom_vbox = gtk_vbox_new(FALSE, 0);	gtk_container_add(GTK_CONTAINER(gtree.vbox), gtree.bottom_vbox);	gtk_widget_realize(gtree.window);	/* gtk_window_set_resizable() */	g_object_set(G_OBJECT(gtree.window), "allow_shrink", FALSE, NULL);	g_object_set(G_OBJECT(gtree.window), "allow_grow", FALSE, NULL);	if (!decorated)		gtk_window_set_decorated((GtkWindow *) gtree.window, FALSE);	gtk_widget_show_all(gtree.vbox);	/* Probably don't need to realize all these here. Just a little paranoia.	*/	gtk_widget_realize(gtree.vbox);	gtk_widget_realize(gtree.top0_vbox);	gtk_widget_realize(gtree.middle_hbox);	gtk_widget_realize(gtree.left_vbox);	gtk_widget_realize(gtree.middle_vbox);	gtk_widget_realize(gtree.monitor_vbox);	gtk_widget_realize(gtree.top1_vbox);	gtk_widget_realize(gtree.right_vbox);	gtk_widget_realize(gtree.bottom_vbox);	}static gintcb_client_event(GtkWidget  *widget, GdkEventClient *event, gpointer data)	{	static GdkAtom	atom_gkrellm_read_theme = GDK_NONE;	if (!atom_gkrellm_read_theme)		atom_gkrellm_read_theme = gdk_atom_intern("_GKRELLM_READ_THEME",FALSE);	if (event->message_type == atom_gkrellm_read_theme) 		gkrellm_read_theme_event(NULL);	return FALSE;	}  /* Callback called when configure_event is received.  This can  |  be for window raise, lower, resize, move & maybe others  */static gintcb_size_allocate(GtkWidget *w, GtkAllocation *size, gpointer data)	{//	g_message("x = %d, y = %d, width = %d, height = %d, data = %p\n",//			size->x,size->y,size->width,size->height,data);	return FALSE;	}static gbooleancb_map_event(GtkWidget *widget, GdkEvent *event, gpointer data)	{	/* Some window managers don't recognize when _NET_WM_STATE property is set	|  prior to window mapping.  As a temporary hack send extra _NET_WM_STATE	|  changed messages in an attempt to get these window managers to work.	*/	if (_GK.sticky_state)		gtk_window_stick(GTK_WINDOW(top_window));	if (_GK.state_skip_pager)		gkrellm_winop_state_skip_pager(TRUE);	if (_GK.state_skip_taskbar)		gkrellm_winop_state_skip_taskbar(TRUE);	if (_GK.state_above)		gkrellm_winop_state_above(TRUE);	else if (_GK.state_below)		gkrellm_winop_state_below(TRUE);	return FALSE;	}static gbooleancb_configure_notify(GtkWidget *widget, GdkEventConfigure *ev, gpointer data)	{	gboolean	size_change, position_change;	gint        x, y, w, h, w_gkrellm, h_gkrellm;	static gint	x_prev, y_prev, w_prev, h_prev;	gdk_window_get_geometry(NULL, NULL, NULL, &_GK.w_display,				&_GK.h_display, NULL);#if !defined(WIN32)	gdk_window_get_position(widget->window, &x, &y);#else	/* Windows Gtk bug? */	x = ev->x;	y = ev->y;#endif	gdk_drawable_get_size(gtree.window->window, &w, &h);	w_gkrellm = _GK.chart_width + _GK.frame_left_width + _GK.frame_right_width;	h_gkrellm = _GK.monitor_height + _GK.total_frame_height;	/* If window manager decorated, I can't allow a user to resize GKrellM	|  via the window manager.  So, try to turn it into a no-op.	*/	if (   decorated && monitors_visible		&& (w_gkrellm != w || h_gkrellm != h)	   )		{		gdk_window_resize(top_window->window, w_gkrellm, h_gkrellm);		w = w_gkrellm;		h = h_gkrellm;		}	size_change = (w != w_prev) | (h != h_prev);	position_change = (x != x_prev) | (y != y_prev);	if (size_change)		apply_frame_transparency(FALSE);	/* This is abit of a hose... I have to defer applying the root pixmap	|  because windows just appearing by gtk_widget_show() are not in the	|  right place yet even though configure notify is sent.	*/	if ((size_change || position_change) && !moving_gkrellm)		check_rootpixmap_transparency = 3;	x_prev = x;	y_prev = y;	w_prev = w;	h_prev = h;	/* At startup can be a race for configure events to be reporting correct	|  move to position and pack_side_frames() first call.  Initial configure	|  events will be intermediate x,y values as intial mapping happens, so	|  using configure event position values is delayed.	*/	if (!configure_position_lock)		{		if (x >= 0 && x < _GK.w_display - 10)			_GK.x_position = x;		if (y >= 0 && y < _GK.h_display - 5 && y != y_pack)			_GK.y_position = y;		_GK.position_valid = TRUE;		if (!moving_gkrellm && (_GK.debug_level & DEBUG_POSITION))			printf("configure-event: x_pos=%d y_pos=%d x=%d y=%d y_pack=%d\n",						_GK.x_position, _GK.y_position, x, y, y_pack);		}	else if (_GK.debug_level & DEBUG_POSITION)			printf("locked configure-event: x=%d y=%d\n", x, y);	if (size_change || position_change)		gkrellm_winop_update_struts();	if (do_intro)		{		do_intro = FALSE;		gkrellm_message_dialog(_("GKrellM Introduction"), _(intro_msg));		}	/* If GKrellM is killed (signal, shutdown, etc) it might not get	|  a chance to save its position.  So write the position file	|  10 seconds after window moves stop.	*/	if (_GK.save_position)		save_position_countdown = 10 * _GK.update_HZ;	return FALSE;	}voidgkrellm_save_all()	{	gkrellm_net_save_data();	gkrellm_inet_save_data();	if (_GK.save_position)		set_or_save_position(1);	if (_GK.config_modified)		gkrellm_save_user_config();	gkrellm_save_theme_config();	}static voidcheck_gkrellm_directories(void)	{	gchar	*t, *u;	if (gkrellm_make_home_subdir(GKRELLM_DIR, NULL))		do_intro = TRUE;	/* Defer it until main window realizes */	gkrellm_make_home_subdir(GKRELLM_PLUGINS_DIR, NULL);	gkrellm_make_home_subdir(GKRELLM_THEMES_DIR, NULL);	gkrellm_make_home_subdir(GKRELLM_DATA_DIR, NULL);	/* If no user_config specified, force a check for host-specific config	*/	if (!_GK.config_suffix)		{		_GK.found_host_config = TRUE;		t = gkrellm_make_config_file_name(gkrellm_homedir(),							GKRELLM_THEME_CONFIG);		u = gkrellm_make_config_file_name(gkrellm_homedir(),							GKRELLM_USER_CONFIG);		if (!g_file_test(u, G_FILE_TEST_IS_REGULAR))			{			g_free(u);			u = gkrellm_make_config_file_name(gkrellm_homedir(),							GKRELLM_2_1_14_CONFIG);			}		if (   !g_file_test(u, G_FILE_TEST_IS_REGULAR)			&& !g_file_test(t, G_FILE_TEST_IS_REGULAR)		   )			_GK.found_host_config = FALSE;		g_free(t);		g_free(u);		}	}static gintcb_delete_event(GtkWidget *widget, GdkEvent *event, gpointer data)	{	/* Return FALSE to get GTK to emit the "destroy" signal.	|  Return TRUE to not destroy the window (for verify dialog pop up).	*/	return(FALSE);	}static voidcb_destroy_event()	{	gtk_main_quit();	}static gchar	*usage_string =N_("usage: gkrellm [options]\n""options:\n""   -t, --theme theme_dir    Select a theme directory.\n""   -g, --geometry +x+y      Position the window on the screen.\n""       --wm                 Allow window manager decorations.\n""       --m2                 Left button side frame shading (for 2 btn mice).\n""       --nt                 No transparency.\n""   -w, --withdrawn          Draw GKrellM in withdrawn mode.\n""   -c, --config suffix      Use alternate config files generated by\n""                            appending \"suffix\" to config file names.\n""   -f, --force-host-config  Creates config files generated by appending the\n""                            hostname to config file names.  Subsequent runs\n""                            automatically will use these configs unless a\n""                            specific config is specified with --config.\n""                            This is a convenience for allowing remote runs\n""                            with independent configs in a shared home dir\n""                            and for the hostname to be in the window title.\n""                            This option has no effect in client mode.\n""   -s, --server hostname    Run in client mode: connect to \"hostname\" and\n""                            read monitor data from a gkrellmd server.\n""   -P, --port server_port   Use \"server_port\" for the server connection.\n""       --nc                 No config mode prevents configuration changes.\n""   -p, --plugin plugin.so   While developing, load your plugin under test.\n""       --demo               Force enabling of many monitors so themers can\n""                            see everything. All config saving is inhibited.\n""   -v, --version            Print GKrellM version number and exit.\n""   -d, --debug-level n      Turn debugging on for selective code sections.\n""\ndebug-level numbers are (bitwise OR to debug multiple sections):\n""     0x10  mail\n""     0x20  net\n""     0x40  timer button\n""     0x80  sensors\n\n");static voidusage()	{	g_print(_(usage_string));	}GtkWidget *gkrellm_monitor_vbox(void)

⌨️ 快捷键说明

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