[Gimp-developer] sf-dirname patch

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

   first message in this list and first micro patch for add the new type
   SF-DIRNAME to the list of types that are possible to use in the
   script-fu dialog box.

Regards, MOP.

-- 
  Matteo Nastasi  -  Milano - Italy  | HomePage: mop.netdyna.com
  Sostenere e supportare GNU/Linux ! | ICQ-Numb:38095675  IRCnet:#c-it
  Milano Linux                       | E-Mail:   nastasiN@xxxxxxxxxxxxxxxxx
         Users Group  www.milug.org  |  (togli N e SPAM per l'indir. vero)
Index: plug-ins/script-fu/script-fu-scripts.c
===================================================================
RCS file: /cvs/gnome/gimp/plug-ins/script-fu/script-fu-scripts.c,v
retrieving revision 1.74
diff -u -r1.74 script-fu-scripts.c
--- plug-ins/script-fu/script-fu-scripts.c	2001/10/29 12:51:21	1.74
+++ plug-ins/script-fu/script-fu-scripts.c	2001/11/20 19:53:25
@@ -649,6 +649,34 @@
 		  args[i + 1].description = script->arg_labels[i];
 		 break;
 
+		case SF_DIRNAME:
+		  if (!TYPEP (car (a), tc_string))
+		    return my_err ("script-fu-register: dirname defaults must be string values", NIL);
+		  script->arg_defaults[i].sfa_file.filename = 
+		    g_strdup (get_c_string (car (a)));
+
+#ifdef G_OS_WIN32
+		  /* Replace POSIX slashes with Win32 backslashes. This
+		   * is just so script-fus can be written with only
+		   * POSIX directory separators.
+		   */
+		  val = script->arg_defaults[i].sfa_file.filename;
+		  while (*val)
+		    {
+		      if (*val == '/')
+			*val = '\\';
+		      val++;
+		    }
+#endif
+		  script->arg_values[i].sfa_file.filename =  
+		    g_strdup (script->arg_defaults[i].sfa_file.filename);
+		  script->arg_values[i].sfa_file.fileselection = NULL;
+
+		  args[i + 1].type = GIMP_PDB_STRING;
+		  args[i + 1].name = "dirname";
+		  args[i + 1].description = script->arg_labels[i];
+		 break;
+
 		case SF_FONT:
 		  if (!TYPEP (car (a), tc_string))
 		    return my_err ("script-fu-register: font defaults must be string values", NIL);
@@ -921,6 +949,7 @@
 
 		  case SF_STRING:
 		  case SF_FILENAME:
+		  case SF_DIRNAME:
 		    escaped = ESCAPE (params[i + 1].data.d_string);
 		    length += strlen (escaped) + 3;
 		    g_free (escaped);
@@ -986,6 +1015,7 @@
 
                         case SF_STRING:
                         case SF_FILENAME:
+                        case SF_DIRNAME:
                           escaped = ESCAPE (params[i + 1].data.d_string);
                           g_snprintf (buffer, sizeof (buffer), "\"%s\"",
 				      escaped);
@@ -1119,6 +1149,7 @@
 	      break;
 
 	    case SF_FILENAME:
+	    case SF_DIRNAME:
 	      g_free (script->arg_defaults[i].sfa_file.filename);
 	      g_free (script->arg_values[i].sfa_file.filename);
 	      break;
@@ -1381,12 +1412,12 @@
 	  break;
 
 	case SF_FILENAME:
-	  widget_leftalign = FALSE
-;
-	  sf_interface->args_widgets[i] =
+	case SF_DIRNAME:
+	  widget_leftalign = FALSE;
+	  sf_interface->args_widgets[i] =  
 	    gimp_file_selection_new (_("Script-Fu File Selection"),
 				     script->arg_values[i].sfa_file.filename,
-				     FALSE, TRUE);
+				     (script->arg_types[i] == SF_DIRNAME ? TRUE : FALSE), TRUE);
 	  script->arg_values[i].sfa_file.fileselection = 
 	    sf_interface->args_widgets[i];
 
@@ -1770,6 +1801,7 @@
 	break;
 
       case SF_FILENAME:
+      case SF_DIRNAME:
 	escaped = ESCAPE (script->arg_values[i].sfa_file.filename);
 	length += strlen (escaped) + 3;
 	g_free (escaped);
@@ -1872,6 +1904,7 @@
 	  break;
 
 	case SF_FILENAME:
+	case SF_DIRNAME:
 	  escaped = ESCAPE (script->arg_values[i].sfa_file.filename);
 	  g_snprintf (buffer, sizeof (buffer), "\"%s\"", escaped);
 	  g_free (escaped);
@@ -2099,6 +2132,7 @@
 	break;
 
       case SF_FILENAME:
+      case SF_DIRNAME:
 	g_free (script->arg_values[i].sfa_file.filename);
 	script->arg_values[i].sfa_file.filename =
 	  g_strdup (script->arg_defaults[i].sfa_file.filename);
Index: plug-ins/script-fu/script-fu-enums.h
===================================================================
RCS file: /cvs/gnome/gimp/plug-ins/script-fu/script-fu-enums.h,v
retrieving revision 1.10
diff -u -r1.10 script-fu-enums.h
--- plug-ins/script-fu/script-fu-enums.h	2000/04/28 00:02:10	1.10
+++ plug-ins/script-fu/script-fu-enums.h	2001/11/20 19:15:32
@@ -37,6 +37,7 @@
   SF_BRUSH,
   SF_GRADIENT,
   SF_FILENAME,
+  SF_DIRNAME,
   SF_OPTION
 } SFArgType;
 
Index: plug-ins/script-fu/siod-wrapper.c
===================================================================
RCS file: /cvs/gnome/gimp/plug-ins/script-fu/siod-wrapper.c,v
retrieving revision 1.2
diff -u -r1.2 siod-wrapper.c
--- plug-ins/script-fu/siod-wrapper.c	2001/07/22 22:18:00	1.2
+++ plug-ins/script-fu/siod-wrapper.c	2001/11/20 19:54:37
@@ -288,6 +288,7 @@
   setvar (cintern ("SF-VALUE"),       flocons (SF_VALUE),      NIL);
   setvar (cintern ("SF-STRING"),      flocons (SF_STRING),     NIL);
   setvar (cintern ("SF-FILENAME"),    flocons (SF_FILENAME),   NIL);
+  setvar (cintern ("SF-DIRNAME"),     flocons (SF_DIRNAME),    NIL);
   setvar (cintern ("SF-ADJUSTMENT"),  flocons (SF_ADJUSTMENT), NIL);
   setvar (cintern ("SF-FONT"),        flocons (SF_FONT),       NIL);
   setvar (cintern ("SF-PATTERN"),     flocons (SF_PATTERN),    NIL);

[Index of Archives]     [Video For Linux]     [Photo]     [Yosemite News]     [gtk]     [GIMP for Windows]     [KDE]     [GEGL]     [Gimp's Home]     [Gimp on GUI]     [Gimp on Windows]     [Steve's Art]

  Powered by Linux