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

📄 prefs_dialog_plugins_prefs.c

📁 网络编程
💻 C
📖 第 1 页 / 共 2 页
字号:
  label = gtk_label_new(str);  gtk_box_pack_start(GTK_BOX(vbox), label, TRUE, FALSE, 5);  gtk_widget_show(label); } separator = gtk_hseparator_new(); gtk_box_pack_start(GTK_BOX(vbox), separator, TRUE, FALSE, 5); gtk_widget_show(separator);}static intfile_dialog_hide(GtkWidget * filew, GtkWidget * nul){ gtk_widget_hide(filew); gtk_widget_destroy(filew); return 0;}static intfile_selected(GtkWidget * nul,	      GtkWidget * filew){  struct arglist * c; GtkWidget * entry; char * fname = (char*) gtk_file_selection_get_filename(GTK_FILE_SELECTION(filew)); gtk_widget_hide(filew); c = gtk_object_get_data(GTK_OBJECT(filew), "data"); entry = arg_get_value(c, "ENTRY"); gtk_entry_set_text(GTK_ENTRY(entry), fname); return 0;}	    static intselect_file(GtkWidget * b, 	    struct arglist * ctrls){ GtkWidget * filew = gtk_file_selection_new("Select file"); gtk_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(filew)->ok_button), 		"clicked", (GtkSignalFunc)file_selected, filew);  gtk_signal_connect_object (GTK_OBJECT (GTK_FILE_SELECTION (filew)->cancel_button),                                 "clicked",                                 GTK_SIGNAL_FUNC (file_dialog_hide),                                 GTK_OBJECT (filew));			  gtk_object_set_data(GTK_OBJECT(filew), "data", ctrls);		 gtk_widget_show(filew);		 return 0;		}static void pprefs_add_entry(ctrls, pref, value, credentials)  struct arglist * ctrls;  struct arglist * pref;  char * value;  int credentials;{ GtkWidget * vbox = arg_get_value(ctrls, credentials == 0 ? "VBOX":"VBOX_CREDENTIALS"); GtkWidget * entry, * text, * box; char * name = pref->name; char * fullname = arg_get_value(pref->value, "fullname"); struct arglist * pprefs = arg_get_value(Prefs, "PLUGINS_PREFS");  if(pprefs) {  int type;  if((type = arg_get_type(pprefs, fullname))>=0)  {   value = arg_get_value(pprefs, fullname);   if(type==ARG_INT)    {    if(value)value=strdup("yes");    else value = strdup("no");    }  } } box = gtk_hbox_new(FALSE, 0); gtk_box_pack_start(GTK_BOX(vbox), box, TRUE, FALSE, 5); gtk_widget_show(box);  text = gtk_label_new(estrdup(name)); gtk_box_pack_start(GTK_BOX(box), text,TRUE, TRUE, 5); gtk_widget_show(text);  entry = gtk_entry_new(); gtk_entry_set_text(GTK_ENTRY(entry), value); gtk_box_pack_end(GTK_BOX(box), entry, TRUE, TRUE, 5); gtk_widget_show(entry); arg_add_value(pref->value, "ENTRY", ARG_PTR, -1, entry);}static void pprefs_add_password(ctrls, pref, value, credentials)  struct arglist * ctrls;  struct arglist * pref;  char * value;  int credentials;{ GtkWidget * vbox = arg_get_value(ctrls, credentials == 0 ? "VBOX":"VBOX_CREDENTIALS"); GtkWidget * entry, * text, * box; char * name = pref->name; char * fullname = arg_get_value(pref->value, "fullname"); struct arglist * pprefs = arg_get_value(Prefs, "PLUGINS_PREFS");  if(pprefs) {  int type;  if((type = arg_get_type(pprefs, fullname))>=0)  {   value = arg_get_value(pprefs, fullname);   if(type==ARG_INT)    {    if(value)value=strdup("yes");    else value = strdup("no");    }  } } box = gtk_hbox_new(FALSE, 0); gtk_box_pack_start(GTK_BOX(vbox), box, TRUE, FALSE, 5); gtk_widget_show(box);  text = gtk_label_new(estrdup(name)); gtk_box_pack_start(GTK_BOX(box), text,TRUE, TRUE, 5); gtk_widget_show(text);  entry = gtk_entry_new(); gtk_entry_set_visibility(GTK_ENTRY(entry), FALSE); gtk_entry_set_text(GTK_ENTRY(entry), value); gtk_box_pack_end(GTK_BOX(box), entry, TRUE, TRUE, 5); gtk_widget_show(entry); arg_add_value(pref->value, "ENTRY", ARG_PTR, -1, entry);}static void pprefs_add_file(ctrls, pref, value, credentials)  struct arglist * ctrls;  struct arglist * pref;  char * value;  int credentials;{ GtkWidget * vbox = arg_get_value(ctrls, credentials == 0 ? "VBOX":"VBOX_CREDENTIALS"); GtkWidget * entry, * text, * box; GtkWidget * hbox, * button; char * name = pref->name; char * fullname = arg_get_value(pref->value, "fullname"); struct arglist * pprefs = arg_get_value(Prefs, "PLUGINS_PREFS");  if(pprefs) {  int type;  if((type = arg_get_type(pprefs, fullname))>=0)  {   value = arg_get_value(pprefs, fullname);   if(type==ARG_INT)    {    if(value)value=strdup("yes");    else value = strdup("no");    }  } } box = gtk_hbox_new(FALSE, 0); gtk_box_pack_start(GTK_BOX(vbox), box, TRUE, FALSE, 5); gtk_widget_show(box);  text = gtk_label_new(estrdup(name)); gtk_box_pack_start(GTK_BOX(box), text,TRUE, TRUE, 5); gtk_widget_show(text);  hbox = gtk_hbox_new(FALSE, 0); gtk_box_pack_end(GTK_BOX(box), hbox, TRUE, TRUE, 5); gtk_widget_show(hbox);  entry = gtk_entry_new(); gtk_entry_set_text(GTK_ENTRY(entry), value); gtk_box_pack_start(GTK_BOX(hbox), entry, TRUE, TRUE, 5); gtk_widget_show(entry); arg_add_value(pref->value, "ENTRY", ARG_PTR, -1, entry);  button = gtk_button_new_with_label("Select..."); gtk_box_pack_start(GTK_BOX(hbox), button, TRUE, TRUE, 5); gtk_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc)select_file, 			pref->value);			 gtk_widget_show(button);}static void pprefs_add_radio(ctrls, pref, value, credentials)  struct arglist * ctrls;  struct arglist * pref;  char * value;  int credentials;{ GtkWidget * vbox = arg_get_value(ctrls, credentials == 0 ? "VBOX":"VBOX_CREDENTIALS"); GtkWidget * orig; GtkWidget * button, * first_button; GtkWidget * label; char * t; GSList * list = NULL; char * fullname = arg_get_value(pref->value, "fullname"); struct arglist * pprefs = arg_get_value(Prefs, "PLUGINS_PREFS"); char * def = NULL; if(pprefs) {  int type;  if((type = arg_get_type(pprefs, fullname))>=0)  {   def = arg_get_value(pprefs, fullname);   if(type==ARG_INT)    {    if(def)def=strdup("yes");    else def = strdup("no");    }  } }   label = gtk_label_new(estrdup(pref->name)); gtk_box_pack_start(GTK_BOX(vbox), label, TRUE, FALSE, 5); gtk_widget_show(label);  t = strchr(value, ';'); if(t)t[0] = '\0'; first_button = orig = gtk_radio_button_new_with_label(NULL, value); gtk_box_pack_start(GTK_BOX(vbox), orig, TRUE, FALSE, 5); gtk_object_set_data(GTK_OBJECT(orig), "name", value); gtk_widget_show(orig);#if GTK_VERSION > 10 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(orig),TRUE);#else GTK_TOGGLE_BUTTON(orig)->active = TRUE;#endif value = t+sizeof(char); if(t)    while(value)    {      if((t = strchr(value, ';')))t[0]='\0';      button = gtk_radio_button_new_with_label(           gtk_radio_button_group(GTK_RADIO_BUTTON(orig)), 	   value);      gtk_object_set_data(GTK_OBJECT(button), "name", value);      if(def && !strcmp(def, value))       {#if GTK_VERSION > 10        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button),TRUE);#else	GTK_TOGGLE_BUTTON(button)->active = TRUE;#endif	}      gtk_box_pack_start(GTK_BOX(vbox), button, TRUE, FALSE, 5);      gtk_widget_show(button);      if(t)value = t+sizeof(char);      else value = NULL;     } list = gtk_radio_button_group(GTK_RADIO_BUTTON(orig)); arg_add_value(pref->value, "RADIOBUTTONS", ARG_PTR, -1, list);}static void pprefs_add_checkbox(ctrls, pref, value, credentials)  struct arglist * ctrls;  struct arglist * pref;  char * value;  int credentials;{ GtkWidget * vbox = arg_get_value(ctrls, credentials == 0 ? "VBOX":"VBOX_CREDENTIALS"); GtkWidget * box; GtkWidget * button; char * name = pref->name; struct arglist * pprefs = arg_get_value(Prefs, "PLUGINS_PREFS"); char * def = NULL; char * fullname = arg_get_value(pref->value, "fullname"); if(pprefs) {  int type;  if((type = arg_get_type(pprefs, fullname))>=0)  {   def = arg_get_value(pprefs, fullname);   if(type==ARG_INT)    {    if(def)def=strdup("yes");    else def = strdup("no");    }  } } box = gtk_hbox_new(FALSE, 0); gtk_box_pack_start(GTK_BOX(vbox), box, TRUE, FALSE, 5); gtk_widget_show(box);  button = gtk_check_button_new_with_label(estrdup(name)); gtk_box_pack_start(GTK_BOX(box), button, FALSE, FALSE, 5); gtk_widget_show(button); if(def) {  if(!strcmp(def, "yes"))    gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(button), TRUE);  else    gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(button), FALSE);  } else gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(button), !strcmp(value, "yes")); arg_add_value(pref->value, "CHECKBOX", ARG_PTR, -1, button);}#endif

⌨️ 快捷键说明

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