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

📄 misc-gtk.c

📁 一个linux下的ftp程序。它是使用文件传输协议的一系列程序的集合。
💻 C
📖 第 1 页 / 共 3 页
字号:
                        &graphic->bitmap, &style->bg[GTK_STATE_NORMAL], exfile);  g_free (exfile);  if (graphic->pixmap == NULL)    {      g_free (graphic);      ftp_log (gftp_logging_error, NULL, _("Error opening file %s: %s\n"),                exfile, g_strerror (errno));      return (NULL);    }  graphic->filename = g_strdup (filename);  g_hash_table_insert (graphic_hash_table, graphic->filename, graphic);  return (graphic);}voidgftp_free_pixmap (char *filename){  gftp_graphic * graphic;  if ((graphic = g_hash_table_lookup (graphic_hash_table, filename)) == NULL)    return;#if GTK_MAJOR_VERSION == 1  gdk_pixmap_unref (graphic->pixmap);  gdk_bitmap_unref (graphic->bitmap);#else  g_object_unref (graphic->pixmap);  g_object_unref (graphic->bitmap);#endif  g_hash_table_remove (graphic_hash_table, filename);  g_free (graphic->filename);  g_free (graphic);}voidgftp_get_pixmap (GtkWidget * widget, char *filename, GdkPixmap ** pix,                 GdkBitmap ** bitmap){  gftp_graphic * graphic;  if (filename == NULL || *filename == '\0')    {      *pix = NULL;      *bitmap = NULL;      return;    }  if ((graphic = g_hash_table_lookup (graphic_hash_table, filename)) == NULL)    graphic = open_xpm (widget, filename);  if (graphic == NULL)    {      *pix = NULL;      *bitmap = NULL;      return;    }  *pix = graphic->pixmap;  *bitmap = graphic->bitmap;}intcheck_status (char *name, gftp_window_data *wdata, int check_other_stop,              int only_one, int at_least_one, int func){  gftp_window_data * owdata;  owdata = wdata == &window1 ? &window2 : &window1;  if (wdata->request->stopable)    {      ftp_log (gftp_logging_error, NULL,	       _("%s: Please hit the stop button first to do anything else\n"),	       name);      return (0);    }  if (check_other_stop && owdata->request->stopable)    {      ftp_log (gftp_logging_error, NULL,	       _("%s: Please hit the stop button first to do anything else\n"),	       name);      return (0);    }  if (!GFTP_IS_CONNECTED (wdata->request))    {      ftp_log (gftp_logging_error, NULL,	       _("%s: Not connected to a remote site\n"), name);      return (0);    }  if (!func)    {      ftp_log (gftp_logging_error, NULL,	       _("%s: This feature is not available using this protocol\n"),	       name);      return (0);    }  if (only_one && !IS_ONE_SELECTED (wdata))    {      ftp_log (gftp_logging_error, NULL,	       _("%s: You must only have one item selected\n"), name);      return (0);    }  if (at_least_one && !only_one && IS_NONE_SELECTED (wdata))    {      ftp_log (gftp_logging_error, NULL,	       _("%s: You must have at least one item selected\n"), name);      return (0);    }  return (1);}static gchar *gftp_item_factory_translate (const char *path, gpointer func_data){  const gchar *strip_prefix = func_data;  const char *result;    if (strip_prefix)    {      char *tmp_path = g_strconcat (strip_prefix, path, NULL);      result = gettext (tmp_path);      if (result == tmp_path)        result = path;      g_free (tmp_path);    }  else    result = gettext (path);  return (char *)result;}GtkItemFactory *item_factory_new (GtkType container_type, const char *path,		  GtkAccelGroup *accel_group, const char *strip_prefix){  GtkItemFactory *result = gtk_item_factory_new (container_type, path, accel_group);  gchar *strip_prefix_dup = g_strdup (strip_prefix);    gtk_item_factory_set_translate_func (result, gftp_item_factory_translate,				       strip_prefix_dup, NULL);  if (strip_prefix_dup)    gtk_object_set_data_full (GTK_OBJECT (result), "gftp-strip-prefix",			      strip_prefix_dup, (GDestroyNotify)g_free);  return result;}voidcreate_item_factory (GtkItemFactory * ifactory, guint n_entries,		     GtkItemFactoryEntry * entries, gpointer callback_data){  const char *strip_prefix;  size_t strip_prefix_len;  size_t i;  strip_prefix = gtk_object_get_data (GTK_OBJECT (ifactory), "gftp-strip-prefix");  if (strip_prefix)    strip_prefix_len = strlen (strip_prefix);  else    strip_prefix_len = 0;  for (i = 0; i < n_entries; i++)    {      GtkItemFactoryEntry dummy_item = entries[i];      if (strip_prefix && strncmp (entries[i].path, strip_prefix, strip_prefix_len) == 0)	dummy_item.path += strip_prefix_len;            gtk_item_factory_create_item (ifactory, &dummy_item, callback_data, 1);    }}voidadd_history (GtkWidget * widget, GList ** history, unsigned int *histlen,              const char *str){  GList *node, *delnode;  char *tempstr;  int i;  if (str == NULL || *str == '\0')    return;  for (node = *history; node != NULL; node = node->next)    {      if (strcmp ((char *) node->data, str) == 0)	break;    }  if (node == NULL)    {      if (*histlen >= MAX_HIST_LEN)	{	  node = *history;	  for (i = 1; i < MAX_HIST_LEN; i++)	    node = node->next;	  node->prev->next = NULL;	  node->prev = NULL;	  delnode = node;	  while (delnode != NULL)	    {	      if (delnode->data)		g_free (delnode->data);	      delnode = delnode->next;	    }	  g_list_free (node);	}      tempstr = g_strdup (str);      *history = g_list_prepend (*history, tempstr);      ++*histlen;    }  else if (node->prev != NULL)    {      node->prev->next = node->next;      if (node->next != NULL)	node->next->prev = node->prev;      node->prev = NULL;      node->next = *history;      if (node->next != NULL)	node->next->prev = node;      *history = node;    }  gtk_combo_set_popdown_strings (GTK_COMBO (widget), *history);}intcheck_reconnect (gftp_window_data *wdata){  return (wdata->request->cached && wdata->request->datafd < 0 &&           !wdata->request->always_connected &&	  !ftp_connect (wdata, wdata->request, 0) ? -1 : 0);}voidadd_file_listbox (gftp_window_data * wdata, gftp_file * fle){  char *add_data[7] = { NULL, NULL, NULL, NULL, NULL, NULL, NULL };  char *tempstr, *str, *pos, *attribs;  gftp_config_list_vars * tmplistvar;  gftp_file_extensions * tempext;  intptr_t show_hidden_files;  GdkBitmap * bitmap;  GList * templist;  GdkPixmap * pix;  int clist_num;  size_t stlen;  gftp_lookup_request_option (wdata->request, "show_hidden_files",                               &show_hidden_files);  if (wdata->show_selected)    {      fle->shown = fle->was_sel;      if (!fle->shown)        return;    }  else if ((!show_hidden_files && *fle->file == '.' &&             strcmp (fle->file, "..") != 0) ||           !gftp_match_filespec (fle->file, wdata->filespec))    {      fle->shown = 0;      fle->was_sel = 0;      return;    }  else    fle->shown = 1;  clist_num = gtk_clist_append (GTK_CLIST (wdata->listbox), add_data);  if (fle->was_sel)    {      fle->was_sel = 0;      gtk_clist_select_row (GTK_CLIST (wdata->listbox), clist_num, 0);    }  pix = NULL;  bitmap = NULL;  if (strcmp (fle->file, "..") == 0)    gftp_get_pixmap (wdata->listbox, "dotdot.xpm", &pix, &bitmap);  else if (S_ISLNK (fle->st_mode) && S_ISDIR (fle->st_mode))    gftp_get_pixmap (wdata->listbox, "linkdir.xpm", &pix, &bitmap);  else if (S_ISLNK (fle->st_mode))    gftp_get_pixmap (wdata->listbox, "linkfile.xpm", &pix, &bitmap);  else if (S_ISDIR (fle->st_mode))    gftp_get_pixmap (wdata->listbox, "dir.xpm", &pix, &bitmap);  else if ((fle->st_mode & S_IXUSR) ||           (fle->st_mode & S_IXGRP) ||           (fle->st_mode & S_IXOTH))    gftp_get_pixmap (wdata->listbox, "exe.xpm", &pix, &bitmap);   else    {      stlen = strlen (fle->file);      gftp_lookup_global_option ("ext", &tmplistvar);      templist = tmplistvar->list;      while (templist != NULL)        {          tempext = templist->data;          if (stlen >= tempext->stlen &&              strcmp (&fle->file[stlen - tempext->stlen], tempext->ext) == 0)            {              gftp_get_pixmap (wdata->listbox, tempext->filename, &pix,                                &bitmap);              break;            }          templist = templist->next;        }    }  if (pix == NULL && bitmap == NULL)    gftp_get_pixmap (wdata->listbox, "doc.xpm", &pix, &bitmap);     gtk_clist_set_pixmap (GTK_CLIST (wdata->listbox), clist_num, 0, pix, bitmap);  if (fle->utf8_file)    gtk_clist_set_text (GTK_CLIST (wdata->listbox), clist_num, 1,                         fle->utf8_file);  else if (fle->file)    gtk_clist_set_text (GTK_CLIST (wdata->listbox), clist_num, 1, fle->file);  if (GFTP_IS_SPECIAL_DEVICE (fle->st_mode))    tempstr = g_strdup_printf ("%d, %d", major (fle->size),                               minor (fle->size));  else    tempstr = insert_commas (fle->size, NULL, 0);  gtk_clist_set_text (GTK_CLIST (wdata->listbox), clist_num, 2, tempstr);  g_free (tempstr);  if (fle->user)    gtk_clist_set_text (GTK_CLIST (wdata->listbox), clist_num, 3, fle->user);  if (fle->group)    gtk_clist_set_text (GTK_CLIST (wdata->listbox), clist_num, 4, fle->group);  if ((str = ctime (&fle->datetime)))    {      if ((pos = strchr (str, '\n')) != NULL)        *pos = '\0';      gtk_clist_set_text (GTK_CLIST (wdata->listbox), clist_num, 5, str);    }  attribs = gftp_convert_attributes_from_mode_t (fle->st_mode);  gtk_clist_set_text (GTK_CLIST (wdata->listbox), clist_num, 6, attribs);  g_free (attribs);}voiddestroy_dialog (gftp_dialog_data * ddata){  if (ddata->dialog != NULL)    {      gtk_widget_destroy (ddata->dialog);      ddata->dialog = NULL;    }}#if GTK_MAJOR_VERSION == 1static voidok_dialog_response (GtkWidget * widget, gftp_dialog_data * ddata){  if (ddata->edit == NULL)    {      gtk_widget_destroy (ddata->dialog);      ddata->dialog = NULL;      ddata->checkbox = NULL;    }   if (ddata->yesfunc != NULL)    ddata->yesfunc (ddata->yespointer, ddata);  if (ddata->edit != NULL &&      ddata->dialog != NULL)    gtk_widget_destroy (ddata->dialog);  g_free (ddata);}static voidcancel_dialog_response (GtkWidget * widget, gftp_dialog_data * ddata){  if (ddata->edit == NULL)    {      gtk_widget_destroy (ddata->dialog);      ddata->dialog = NULL;      ddata->checkbox = NULL;    }   if (ddata->nofunc != NULL)    ddata->nofunc (ddata->nopointer, ddata);  if (ddata->edit != NULL &&      ddata->dialog != NULL)    gtk_widget_destroy (ddata->dialog);  g_free (ddata);}#elsestatic voiddialog_response (GtkWidget * widget, gint response, gftp_dialog_data * ddata){  if (ddata->edit == NULL)    {      gtk_widget_destroy (ddata->dialog);      ddata->dialog = NULL;      ddata->checkbox = NULL;    }  switch (response)    {      case GTK_RESPONSE_YES:        if (ddata->yesfunc != NULL)          ddata->yesfunc (ddata->yespointer, ddata);        break;

⌨️ 快捷键说明

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