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

📄 bookmarks.c

📁 一个linux下的ftp程序。它是使用文件传输协议的一系列程序的集合。
💻 C
📖 第 1 页 / 共 3 页
字号:
    {      tempentry = new_bookmarks->children;      while (tempentry->next != NULL)	tempentry = tempentry->next;      tempentry->next = newentry;    }  text[0] = text[1] = newentry->path;  if (newentry->isfolder)    newentry->cnode = gtk_ctree_insert_node (GTK_CTREE (tree),                                              new_bookmarks->cnode, NULL,			                     text, 5, closedir_pixmap,                                              closedir_bitmap, opendir_pixmap,			                     opendir_bitmap, FALSE, FALSE);  else    newentry->cnode = gtk_ctree_insert_node (GTK_CTREE (tree),                                              new_bookmarks->cnode, NULL,                                             text, 5, NULL, NULL, NULL, NULL,                                              TRUE, FALSE);  gtk_ctree_node_set_row_data (GTK_CTREE (tree), newentry->cnode, newentry);  g_hash_table_insert (new_bookmarks_htable, newentry->path, newentry);}static voidnew_folder_entry (gpointer data){  MakeEditDialog (_("New Folder"),		  _("Enter the name of the new folder to create"), NULL, 1,		  NULL, gftp_dialog_button_create,                   do_make_new, (gpointer) 0x1, NULL, NULL);}static voidnew_item_entry (gpointer data){  MakeEditDialog (_("New Folder"),		  _("Enter the name of the new item to create"), NULL, 1,		  NULL, gftp_dialog_button_create,                  do_make_new, NULL, NULL, NULL);}static voiddo_delete_entry (gftp_bookmarks_var * entry, gftp_dialog_data * ddata){  gftp_bookmarks_var * tempentry, * delentry;  g_hash_table_remove (new_bookmarks_htable, entry->path);  gtk_ctree_remove_node (GTK_CTREE (tree), entry->cnode);  if (entry->prev->children == entry)    entry->prev->children = entry->prev->children->next;  else    {      tempentry = entry->prev->children;      while (tempentry->next != entry)	tempentry = tempentry->next;      tempentry->next = entry->next;    }  entry->prev = NULL;  entry->next = NULL;  tempentry = entry;  while (tempentry != NULL)    {      gftp_free_bookmark (tempentry, 0);      if (tempentry->children != NULL)	{	  tempentry = tempentry->children;	  continue;	}      else if (tempentry->next == NULL && tempentry->prev != NULL)	{	  delentry = tempentry->prev;	  g_free (tempentry);	  tempentry = delentry->next;	  if (delentry != entry)	    g_free (delentry);	}      else	tempentry = tempentry->next;    }  g_free (entry);}static voiddelete_entry (gpointer data){  gftp_bookmarks_var * entry;  char *tempstr, *pos;  if (GTK_CLIST (tree)->selection == NULL)    return;  entry =    gtk_ctree_node_get_row_data (GTK_CTREE (tree),				 GTK_CLIST (tree)->selection->data);  if (entry == NULL || entry->prev == NULL)    return;  if (!entry->isfolder)    do_delete_entry (entry, NULL);  else    {      if ((pos = strrchr (entry->path, '/')) == NULL)	pos = entry->path;      else	pos++;      tempstr = g_strdup_printf (_("Are you sure you want to erase the bookmark\n%s and all it's children?"), pos);      MakeYesNoDialog (_("Delete Bookmark"), tempstr, do_delete_entry, entry,                        NULL, NULL);      g_free (tempstr);    }}static voidset_userpass_visible (GtkWidget * checkbutton, GtkWidget * entry){  gtk_widget_set_sensitive (bm_useredit, !GTK_TOGGLE_BUTTON (anon_chk)->active);  gtk_widget_set_sensitive (bm_passedit, !GTK_TOGGLE_BUTTON (anon_chk)->active);  gtk_widget_set_sensitive (bm_acctedit, !GTK_TOGGLE_BUTTON (anon_chk)->active);}static void_add_tree_node (gftp_bookmarks_var * entry, char *path, int isleaf,                int expanded){  static GdkPixmap * closedir_pixmap = NULL,                   * opendir_pixmap = NULL;  static GdkBitmap * closedir_bitmap = NULL,                   * opendir_bitmap = NULL;  static int initialized = 0;  GtkCTreeNode * parent;  char *text[2], *pos;  if (!initialized)    {      gftp_get_pixmap (tree, "open_dir.xpm", &opendir_pixmap, &opendir_bitmap);      gftp_get_pixmap (tree, "dir.xpm", &closedir_pixmap, &closedir_bitmap);      initialized = 1;    }  if (path == NULL)    {      if ((pos = strrchr (entry->path, '/')) == NULL)        pos = entry->path;      else        pos++;    }  else    pos = path;  text[0] = text[1] = pos;  if (entry->prev == NULL)    parent = NULL;  else    parent = entry->prev->cnode;  if (isleaf)     entry->cnode = gtk_ctree_insert_node (GTK_CTREE (tree), parent, NULL, text,                                          5, NULL, NULL, NULL, NULL, TRUE,                                          expanded);  else    entry->cnode = gtk_ctree_insert_node (GTK_CTREE (tree), parent, NULL,                                          text, 5, closedir_pixmap,                                          closedir_bitmap, opendir_pixmap,                                          opendir_bitmap, FALSE, expanded);  gtk_ctree_node_set_row_data (GTK_CTREE (tree), entry->cnode, entry);}static voidbuild_bookmarks_tree (void){  gftp_bookmarks_var * tempentry, * preventry;  char *pos, *tempstr;  _add_tree_node (new_bookmarks, _("Bookmarks"), 0, 1);  tempentry = new_bookmarks->children;  while (tempentry != NULL)    {      tempentry->cnode = NULL;      if (tempentry->children != NULL)	{	  tempentry = tempentry->children;	  continue;	}      else if (strchr (tempentry->path, '/') == NULL && tempentry->isfolder)        _add_tree_node (tempentry, NULL, 0, 0);      else        {          pos = tempentry->path;          while ((pos = strchr (pos, '/')) != NULL)            {              *pos = '\0';              tempstr = g_strdup (tempentry->path);              *pos++ = '/';              preventry = g_hash_table_lookup (new_bookmarks_htable, tempstr);              g_free (tempstr);              if (preventry->cnode == NULL)                _add_tree_node (preventry, NULL, 0, 0);            }          _add_tree_node (tempentry, NULL, TRUE, 0);	}      while (tempentry->next == NULL && tempentry->prev != NULL)        tempentry = tempentry->prev;      tempentry = tempentry->next;    }}static voidentry_apply_changes (GtkWidget * widget, gftp_bookmarks_var * entry){  gftp_bookmarks_var * tempentry, * nextentry, * bmentry;  char *pos, *newpath, tempchar, *tempstr;  GtkWidget * tempwid;  size_t oldpathlen;  const char *str;  tempstr = g_strdup (gtk_entry_get_text (GTK_ENTRY (bm_pathedit)));  while ((pos = strchr (tempstr, '/')) != NULL)    *pos = ' ';  oldpathlen = strlen (entry->path);  if ((pos = strrchr (entry->path, '/')) != NULL)    {      pos = entry->path;      tempchar = *pos;      *pos = '\0';      newpath = gftp_build_path (NULL, entry->path, tempstr, NULL);      *pos = tempchar;      g_free (tempstr);    }  else    newpath = tempstr;  str = gtk_entry_get_text (GTK_ENTRY (bm_hostedit));  if (entry->hostname != NULL)    g_free (entry->hostname);  entry->hostname = g_strdup (str);  str = gtk_entry_get_text (GTK_ENTRY (bm_portedit));  entry->port = strtol (str, NULL, 10);  tempwid = gtk_menu_get_active (GTK_MENU (bm_protocol));  str = gtk_object_get_user_data (GTK_OBJECT (tempwid));  if (entry->protocol != NULL)    g_free (entry->protocol);  entry->protocol = g_strdup (str);  str = gtk_entry_get_text (GTK_ENTRY (bm_remotediredit));  if (entry->remote_dir != NULL)    g_free (entry->remote_dir);  entry->remote_dir = g_strdup (str);  str = gtk_entry_get_text (GTK_ENTRY (bm_localdiredit));  if (entry->local_dir != NULL)    g_free (entry->local_dir);  entry->local_dir = g_strdup (str);  if (GTK_TOGGLE_BUTTON (anon_chk)->active)    str = GFTP_ANONYMOUS_USER;  else    str = gtk_entry_get_text (GTK_ENTRY (bm_useredit));  if (entry->user != NULL)    g_free (entry->user);  entry->user = g_strdup (str);  if (strcasecmp (entry->user, GFTP_ANONYMOUS_USER) == 0)    str = "@EMAIL@";  else    str = gtk_entry_get_text (GTK_ENTRY (bm_passedit));  if (entry->pass != NULL)    g_free (entry->pass);  entry->pass = g_strdup (str);  entry->save_password = *entry->pass != '\0';  str = gtk_entry_get_text (GTK_ENTRY (bm_acctedit));  if (entry->acct != NULL)    g_free (entry->acct);  entry->acct = g_strdup (str);  gftp_gtk_save_bookmark_options (entry);  if (strcmp (entry->path, newpath) != 0)    {      tempentry = entry;      nextentry = entry->next;      entry->next = NULL;      while (tempentry != NULL)	{	  g_hash_table_remove (new_bookmarks_htable, tempentry->path);          bmentry = g_hash_table_lookup (gftp_bookmarks_htable,                                         tempentry->path);          if (bmentry->oldpath == NULL)            bmentry->oldpath = tempentry->path;          else            g_free (tempentry->path);          if (*(tempentry->path + oldpathlen) == '\0')	    tempentry->path = g_strdup (newpath);          else	    tempentry->path = gftp_build_path (NULL, newpath,                                               tempentry->path + oldpathlen,                                               NULL);	  g_hash_table_insert (new_bookmarks_htable, tempentry->path,                               tempentry);          gtk_ctree_node_set_text (GTK_CTREE (tree), tempentry->cnode, 0,                                   tempentry->path);	  if (tempentry->children != NULL)	    tempentry = tempentry->children;          else            {	      while (tempentry->next == NULL && tempentry != entry &&                     tempentry->prev != NULL)                tempentry = tempentry->prev;	      tempentry = tempentry->next;            }	}      entry->next = nextentry;    }  g_free (newpath);}#if GTK_MAJOR_VERSION == 1static voidentry_close_dialog (void * data){  gtk_widget_destroy (bm_dialog);  bm_dialog = NULL;}#elsestatic voidbmedit_action (GtkWidget * widget, gint response, gpointer user_data){  switch (response)    {      case GTK_RESPONSE_APPLY:        entry_apply_changes (widget, user_data);        break;      case GTK_RESPONSE_OK:        entry_apply_changes (widget, user_data);        /* no break */      default:        gtk_widget_destroy (widget);        bm_dialog = NULL;    }}   #endifstatic voidedit_entry (gpointer data){  GtkWidget * table, * tempwid, * menu, * notebook;  gftp_bookmarks_var * entry;  int i, num;  char *pos;  if (bm_dialog != NULL)    {      gtk_widget_grab_focus (bm_dialog);      return;    }  if (GTK_CLIST (tree)->selection == NULL)    return;  entry = gtk_ctree_node_get_row_data (GTK_CTREE (tree),				 GTK_CLIST (tree)->selection->data);  if (entry == NULL || entry == new_bookmarks)    return;#if GTK_MAJOR_VERSION == 1  bm_dialog = gtk_dialog_new ();  gtk_window_set_title (GTK_WINDOW (bm_dialog), _("Edit Entry"));  gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (bm_dialog)->action_area), 15);#else  bm_dialog = gtk_dialog_new_with_buttons (_("Edit Entry"), NULL, 0,                                           GTK_STOCK_SAVE,                                           GTK_RESPONSE_OK,                                           GTK_STOCK_CANCEL,                                           GTK_RESPONSE_CANCEL,                                           GTK_STOCK_APPLY,                                           GTK_RESPONSE_APPLY,                                           NULL);#endif  gtk_window_set_wmclass (GTK_WINDOW (bm_dialog), "Edit Bookmark Entry",                          "gFTP");  gtk_window_set_position (GTK_WINDOW (bm_dialog), GTK_WIN_POS_MOUSE);  gtk_container_border_width (GTK_CONTAINER (GTK_DIALOG (bm_dialog)->vbox), 10);  gtk_widget_realize (bm_dialog);  if (gftp_icon != NULL)    {      gdk_window_set_icon (bm_dialog->window, NULL, gftp_icon->pixmap,                           gftp_icon->bitmap);      gdk_window_set_icon_name (bm_dialog->window, gftp_version);    }  notebook = gtk_notebook_new ();  gtk_box_pack_start (GTK_BOX (GTK_DIALOG (bm_dialog)->vbox), notebook, TRUE,		      TRUE, 0);  gtk_widget_show (notebook);  table = gtk_table_new (11, 2, FALSE);  gtk_container_border_width (GTK_CONTAINER (table), 5);  gtk_table_set_row_spacings (GTK_TABLE (table), 5);  gtk_table_set_col_spacings (GTK_TABLE (table), 5);  gtk_widget_show (table);  tempwid = gtk_label_new (_("Bookmark"));

⌨️ 快捷键说明

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