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

📄 test_for_ip_valid.c~

📁 LINUX 2.4下面使用GTK书写的一个系统控制面板
💻 C~
字号:
#include <ctype.h>#include <gtk/gtk.h>int count_for_doc;void insert_text_handler (GtkEntry    *entry,                          const gchar *text,                          gint         length,                          gint        *position,                          gpointer     data){  GtkEditable *editable = GTK_EDITABLE(entry);  int i, count=0;  gchar *result = g_new (gchar, length);  for (i=0; i < length; i++) {    if ((text[i] != '1') & (text[i] != '2') & (text[i] != '3') & (text[i] != '4') & (text[i] != '5') & (text[i] != '6')  & (text[i] != '7') & (text[i] != '8') & (text[i] != '9') & (text[i] != '0') & (text[i] != '.'))	continue;     //if ([0] == '.') continue;     //if ((i > 1) & (text[i] == '.') & (text[i-1] == '.')) continue;     //if (text[i] == '.')       //{	//	count_for_doc++;	//	if (count_for_doc = 4) continue;       //}    //result[count++] = islower(text[i]) ? toupper(text[i]) : text[i];    result[count++] = text[i];  }    if (count > 0) {    g_signal_handlers_block_by_func (G_OBJECT (editable),                                     G_CALLBACK (insert_text_handler),                                     data);    gtk_editable_insert_text (editable, result, count, position);    g_signal_handlers_unblock_by_func (G_OBJECT (editable),                                       G_CALLBACK (insert_text_handler),                                       data);  }  g_signal_stop_emission_by_name (G_OBJECT (editable), "insert_text");  g_free (result);}int main (int   argc,          char *argv[]){  GtkWidget *window;  GtkWidget *entry;  count_for_doc=0;  gtk_init (&argc, &argv);    /* create a new window */  window = gtk_window_new(GTK_WINDOW_TOPLEVEL);  gtk_window_set_title(GTK_WINDOW (window), "GTK Entry");  g_signal_connect (G_OBJECT (window), "destroy",                    G_CALLBACK (gtk_main_quit),                    NULL);  entry = gtk_entry_new();  g_signal_connect(G_OBJECT(entry), "insert_text",		     G_CALLBACK(insert_text_handler),		     NULL);  gtk_container_add(GTK_CONTAINER (window), entry);  gtk_widget_show(entry);    gtk_widget_show(window);    gtk_main();  return(0);}

⌨️ 快捷键说明

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