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

📄 wizard_gtk.c

📁 GNUnet是一个安全的点对点网络框架
💻 C
📖 第 1 页 / 共 2 页
字号:
/*     This file is part of GNUnet.     (C) 2005, 2006 Christian Grothoff (and other contributing authors)     GNUnet is free software; you can redistribute it and/or modify     it under the terms of the GNU General Public License as published     by the Free Software Foundation; either version 2, or (at your     option) any later version.     GNUnet is distributed in the hope that it will be useful, but     WITHOUT ANY WARRANTY; without even the implied warranty of     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU     General Public License for more details.     You should have received a copy of the GNU General Public License     along with GNUnet; see the file COPYING.  If not, write to the     Free Software Foundation, Inc., 59 Temple Place - Suite 330,     Boston, MA 02111-1307, USA.*//** * @file setup/gtk/wizard_gtk.c * @brief A easy-to-use configuration assistant * @author Nils Durner * @author Christian Grothoff */#include "platform.h"#include "gnunet_util.h"#include "glade_support.h"#include "wizard_gtk.h"#include "wizard_util.h"#include "gconf.h"/** * Current open window. */static GtkWidget *curwnd;static int doOpenEnhConfigurator = 0;static int doAutoStart = 0;static int doUpdate = GNUNET_YES;static char *user_name = NULL;static char *group_name = NULL;static struct GNUNET_GC_Configuration *editCfg = NULL;static struct GNUNET_GE_Context *err_ctx = NULL;static const char *cfg_fn = NULL;/* 1 = terminate app on "assi_destroy" */static int quit;static int daemon_config;/** * Destroy the current window (without exiting). * Also unrefs the current glade XML context. */static voiddestroyCurrentWindow (){  GNUNET_GE_ASSERT (err_ctx, mainXML != NULL);  GNUNET_GE_ASSERT (err_ctx, curwnd != NULL);  quit = 0;  gtk_widget_destroy (curwnd);  curwnd = NULL;  destroyMainXML ();  quit = 1;}voidon_assi_destroysetup_gtk (GtkObject * object, gpointer user_data){  /* Don't terminate if the user just clicked "Next" */  if (quit)    gtk_main_quit ();}struct insert_nic_cls{  GtkWidget *cmbNIC;  int nic_item_count;};voidon_cmbNIC_changedsetup_gtk (GtkComboBox * combobox, gpointer user_data){  GtkTreeIter iter;  GValue val;  char *entry;#ifdef MINGW  char nic[21], *idx;  char *dst;#else  char *nic;#endif  GtkTreeModel *model;  gtk_combo_box_get_active_iter (combobox, &iter);  model = gtk_combo_box_get_model (combobox);  memset (&val, 0, sizeof (val));  gtk_tree_model_get_value (model, &iter, 0, &val);  entry = (char *) g_value_get_string (&val);#ifdef MINGW  idx = strrchr (entry, '-');  if (!idx)    return;  idx += 2;  dst = nic;  while (*idx)    *dst++ = *idx++;  dst[-1] = 0;#else  nic = entry;#endif  GNUNET_GC_set_configuration_value_string (editCfg,                                            err_ctx, "NETWORK", "INTERFACE",                                            nic);  GNUNET_GC_set_configuration_value_string (editCfg, err_ctx, "LOAD",                                            "INTERFACES", nic);}static intinsert_nic (const char *name, int defaultNIC, void *cls){  gchar *utf8_name;  gsize unused;  struct insert_nic_cls *inc = cls;  GtkWidget *cmbNIC = inc->cmbNIC;  utf8_name = g_locale_to_utf8 (name, -1, NULL, &unused, NULL);  if (!utf8_name)    utf8_name = GNUNET_strdup (_("(unknown connection)"));  gtk_combo_box_append_text (GTK_COMBO_BOX (cmbNIC), utf8_name);  free (utf8_name);  defaultNIC = GNUNET_GNS_wiz_is_nic_default (editCfg, name, defaultNIC);  if (defaultNIC)    gtk_combo_box_set_active (GTK_COMBO_BOX (cmbNIC), inc->nic_item_count);  return GNUNET_OK;}voidload_step2setup_gtk (GtkButton * button, gpointer prev_window){  GtkWidget *entIP;  GtkTreeIter iter;  GtkListStore *model;  struct insert_nic_cls cls;  char *val;  destroyCurrentWindow ();  curwnd = get_xml ("assi_step2");  cls.cmbNIC = lookup_widget ("cmbNIC");  GNUNET_GE_ASSERT (err_ctx, cls.cmbNIC != NULL);  cls.nic_item_count = 0;  model = gtk_list_store_new (1, G_TYPE_STRING);  gtk_combo_box_set_model (GTK_COMBO_BOX (cls.cmbNIC),                           GTK_TREE_MODEL (model));  gtk_combo_box_entry_set_text_column (GTK_COMBO_BOX_ENTRY (cls.cmbNIC), 0);  GNUNET_list_network_interfaces (err_ctx, &insert_nic, &cls);  if (cls.nic_item_count != 0)    {      GNUNET_GC_get_configuration_value_string (editCfg,                                                "NETWORK",                                                "INTERFACE",                                                GNUNET_DEFAULT_INTERFACE,                                                &val);      gtk_combo_box_append_text (GTK_COMBO_BOX (cls.cmbNIC), val);      gtk_tree_model_get_iter_first (GTK_TREE_MODEL (model), &iter);      gtk_combo_box_set_active_iter (GTK_COMBO_BOX (cls.cmbNIC), &iter);      on_cmbNIC_changedsetup_gtk (GTK_COMBO_BOX (cls.cmbNIC), NULL);      GNUNET_free (val);    }  gtk_widget_set_usize (cls.cmbNIC, 10, -1);  entIP = lookup_widget ("entIP");  GNUNET_GC_get_configuration_value_string (editCfg, "NETWORK", "IP", "",                                            &val);  gtk_entry_set_text (GTK_ENTRY (entIP), val);  GNUNET_free (val);  gtk_widget_show (curwnd);}voidload_step3setup_gtk (GtkButton * button, gpointer prev_window){  GtkWidget *entUp;  GtkWidget *entDown;  GtkWidget *radGNUnet;  GtkWidget *radShare;  GtkWidget *entCPU;  char *val;  destroyCurrentWindow ();  curwnd = get_xml ("assi_step3");  entUp = lookup_widget ("entUp");  entDown = lookup_widget ("entDown");  radGNUnet = lookup_widget ("radGNUnet");  radShare = lookup_widget ("radShare");  entCPU = lookup_widget ("entCPU");  GNUNET_GC_get_configuration_value_string (editCfg,                                            "LOAD",                                            "MAXNETUPBPSTOTAL", "50000",                                            &val);  gtk_entry_set_text (GTK_ENTRY (entUp), val);  GNUNET_free (val);  GNUNET_GC_get_configuration_value_string (editCfg,                                            "LOAD",                                            "MAXNETDOWNBPSTOTAL", "50000",                                            &val);  gtk_entry_set_text (GTK_ENTRY (entDown), val);  GNUNET_free (val);  gtk_toggle_button_set_active    (GTK_TOGGLE_BUTTON     ((GNUNET_GC_get_configuration_value_yesno (editCfg,                                                "LOAD",                                                "BASICLIMITING",                                                GNUNET_NO) == GNUNET_YES)      ? radGNUnet : radShare), TRUE);  GNUNET_GC_get_configuration_value_string (editCfg,                                            "LOAD", "MAXCPULOAD", "50", &val);  gtk_entry_set_text (GTK_ENTRY (entCPU), val);  GNUNET_free (val);  gtk_widget_show (curwnd);}voidload_step4setup_gtk (GtkButton * button, gpointer prev_window){  GtkWidget *entUser;  GtkWidget *entGroup;  char *uname = NULL;  char *gname = NULL;  int cap;  destroyCurrentWindow ();  curwnd = get_xml ("assi_step4");  entUser = lookup_widget ("entUser");  entGroup = lookup_widget ("entGroup");  if (NULL != user_name)    {      GNUNET_GC_get_configuration_value_string (editCfg,                                                "GNUNETD", "USER", "gnunet",                                                &uname);    }  if (NULL != group_name)    {      GNUNET_GC_get_configuration_value_string (editCfg,                                                "GNUNETD",                                                "GROUP", "gnunet", &gname);    }#ifndef MINGW  if (NULL == uname || strlen (uname) == 0)    {      struct passwd *pwd;      if ((geteuid () == 0) && (NULL != getpwnam ("gnunet")))        user_name = GNUNET_strdup ("gnunet");      else        {          pwd = getpwuid (geteuid ());          if (pwd != NULL)            user_name = GNUNET_strdup (pwd->pw_name);          else            {              if (NULL != getenv ("USER"))                user_name = GNUNET_strdup (getenv ("USER"));              else                user_name = NULL;            }        }    }  else    {      user_name = GNUNET_strdup (uname);    }  if (NULL == gname || strlen (gname) == 0)    {      struct group *grp;      if ((geteuid () == 0) || (NULL != getgrnam ("gnunet")))        group_name = GNUNET_strdup ("gnunet");      else        {          grp = getgrgid (getegid ());          if ((grp != NULL) && (grp->gr_name != NULL))            group_name = GNUNET_strdup (grp->gr_name);          else            group_name = NULL;        }    }  else    {      group_name = GNUNET_strdup (gname);    }#else  if (NULL == uname || strlen (uname) == 0)    user_name = GNUNET_strdup ("");  else    user_name = GNUNET_strdup (uname);  if (NULL == gname || strlen (gname) == 0)    group_name = GNUNET_strdup ("");  else    group_name = GNUNET_strdup (gname);#endif  if (user_name != NULL)    gtk_entry_set_text (GTK_ENTRY (entUser), user_name);  if (group_name != NULL)    gtk_entry_set_text (GTK_ENTRY (entGroup), group_name);  cap =    GNUNET_configure_autostart (err_ctx, GNUNET_YES, GNUNET_YES, NULL, NULL,                                NULL, NULL);  gtk_widget_set_sensitive (entUser, cap);#ifdef WINDOWS  cap = FALSE;#endif  gtk_widget_set_sensitive (entGroup, cap);  gtk_widget_show (curwnd);  GNUNET_free_non_null (uname);  GNUNET_free_non_null (gname);}voidload_step5setup_gtk (GtkButton * button, gpointer prev_window){  GtkWidget *chkMigr;  GtkWidget *entQuota;  GtkWidget *chkEnh;  GtkWidget *chkStart;  char *val;  destroyCurrentWindow ();  curwnd = get_xml ("assi_step5");  entQuota = lookup_widget ("entQuota");  chkMigr = lookup_widget ("chkMigr");  chkStart = lookup_widget ("chkStart");  chkEnh = lookup_widget ("chkEnh");

⌨️ 快捷键说明

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