OCT 1. 修正状态栏更新模式
This commit is contained in:
parent
efb39449a9
commit
64a72d81f7
|
@ -21,6 +21,7 @@ static GtkWidget *g_statusBar = NULL;
|
|||
static GtkTextBuffer *g_pTxtBuf[4];
|
||||
static GtkWidget *g_ptvDHcp[4];
|
||||
static guint g_timer_id = 0;
|
||||
static PDHCP_INFO g_preInfo = NULL;
|
||||
static const char *g_mess_info[] = {"NONE", "DISCOVER", "OFFER", "REQUEST", "DECLINE",
|
||||
"ACK", "NAK", "RELEASE", "INFORM"};
|
||||
|
||||
|
@ -29,7 +30,6 @@ static gboolean delete_event(GtkWidget *widget, GdkEventAny *event) {
|
|||
* 返回 TRUE,你不希望关闭窗口。
|
||||
* 当你想弹出“你确定要退出吗?”对话框时它很有用。*/
|
||||
//gtk_widget_hide_all(window_test);
|
||||
|
||||
if (g_timer_id) {
|
||||
g_source_remove(g_timer_id);
|
||||
}
|
||||
|
@ -276,26 +276,25 @@ static void create_dhcp_tree_mode(PDHCP_PACKAGE p, U32 nBytes, GtkWidget *treeVi
|
|||
}
|
||||
}
|
||||
|
||||
static PDHCP_INFO g_preInfo = NULL;
|
||||
|
||||
static gboolean timer_proc(gpointer user_data) {
|
||||
static gboolean upgrade_statusbar_proc(gpointer user_data) {
|
||||
PDHCP_INFO pInfo = (PDHCP_INFO)user_data;
|
||||
int ret;
|
||||
DHCP_OPT opt;
|
||||
char buf[1024] = {0};
|
||||
S32 tmOffer = 0, tmAck = 0;
|
||||
const char *pIp = NULL, *pNetmask = NULL, *pGw = NULL, *pDns1 = NULL, *pDns2 = NULL;
|
||||
|
||||
if (g_preInfo) {
|
||||
if (pInfo) {
|
||||
tmOffer = MAX(0,
|
||||
(g_preInfo->pOfferBuf.tm.tv_sec * 1000000 + g_preInfo->pOfferBuf.tm.tv_usec) -
|
||||
(g_preInfo->pDiscBuf.tm.tv_sec * 1000000 + g_preInfo->pDiscBuf.tm.tv_usec));
|
||||
(pInfo->pOfferBuf.tm.tv_sec * 1000000 + pInfo->pOfferBuf.tm.tv_usec) -
|
||||
(pInfo->pDiscBuf.tm.tv_sec * 1000000 + pInfo->pDiscBuf.tm.tv_usec));
|
||||
tmAck = MAX(0,
|
||||
(g_preInfo->pAckBuf.tm.tv_sec * 1000000 + g_preInfo->pAckBuf.tm.tv_usec) -
|
||||
(g_preInfo->pReqBuf.tm.tv_sec * 1000000 + g_preInfo->pReqBuf.tm.tv_usec));
|
||||
(pInfo->pAckBuf.tm.tv_sec * 1000000 + pInfo->pAckBuf.tm.tv_usec) -
|
||||
(pInfo->pReqBuf.tm.tv_sec * 1000000 + pInfo->pReqBuf.tm.tv_usec));
|
||||
|
||||
if (g_preInfo->pAckBuf.p) {
|
||||
PDHCP_PACKAGE pkg = (PDHCP_PACKAGE)g_preInfo->pAckBuf.p;
|
||||
U32 optSize = g_preInfo->pAckBuf.buf_size - sizeof(DHCP_PACKAGE);
|
||||
if (pInfo->pAckBuf.p) {
|
||||
PDHCP_PACKAGE pkg = (PDHCP_PACKAGE)pInfo->pAckBuf.p;
|
||||
U32 optSize = pInfo->pAckBuf.buf_size - sizeof(DHCP_PACKAGE);
|
||||
pIp = u32_to_str_ip_safe(pkg->dhcp.yiaddr);
|
||||
|
||||
ret = dhcp_get_option(OPT_NETMASK, pkg->dhcp.options, optSize, &opt);
|
||||
|
@ -318,6 +317,8 @@ static gboolean timer_proc(gpointer user_data) {
|
|||
pDns2 = u32_to_str_ip_safe(*pVal);
|
||||
}
|
||||
}
|
||||
|
||||
g_source_remove(g_timer_id);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -428,9 +429,11 @@ void details_wnd_show(PDHCP_INFO pInfo) {
|
|||
add_dhcp_tree_colums(g_ptvDHcp[i]);
|
||||
create_dhcp_tree_mode((PDHCP_PACKAGE)hexBuf[i]->p, hexBuf[i]->buf_size, g_ptvDHcp[i]);
|
||||
}
|
||||
|
||||
upgrade_statusbar_proc(pInfo);
|
||||
}
|
||||
|
||||
g_timer_id = g_timeout_add(1000, (GSourceFunc)timer_proc, NULL);
|
||||
g_timer_id = g_timeout_add(1000, (GSourceFunc)upgrade_statusbar_proc, NULL);
|
||||
gtk_widget_show_all(g_detailWnd);
|
||||
}
|
||||
|
||||
|
@ -460,6 +463,7 @@ void switch_page(GtkNotebook *UNUSED(self),
|
|||
gpointer UNUSED(user_data)) {
|
||||
if (g_preInfo) {
|
||||
details_wnd_show(g_preInfo);
|
||||
upgrade_statusbar_proc(g_preInfo);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -558,7 +562,7 @@ void details_wnd_create(GtkBuilder *builder) {
|
|||
}
|
||||
|
||||
g_statusBar = gtk_statusbar_new();
|
||||
gtk_box_pack_start(GTK_BOX(vBox), g_statusBar, FALSE, FALSE, 1);
|
||||
gtk_box_pack_start(GTK_BOX(vBox), g_statusBar, FALSE, FALSE, 0);
|
||||
//gtk_widget_set_size_request(vBox, -1, 16);
|
||||
|
||||
g_signal_connect(G_OBJECT(window), "delete_event", G_CALLBACK(delete_event), builder);
|
||||
|
|
Loading…
Reference in New Issue