summaryrefslogtreecommitdiff
path: root/support/gv-savepos/gv-3.6.2-savepos.patch
blob: 9bc3ccda6a8a907973821f859f007580d725ddf2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
Binary files gv-3.6.2/doc/gv.info and gv-3.6.2-savepos/doc/gv.info differ
diff -u -r gv-3.6.2/src/actions.c gv-3.6.2-savepos/src/actions.c
--- gv-3.6.2/src/actions.c	2005-08-10 20:46:20.000000000 +0530
+++ gv-3.6.2-savepos/src/actions.c	2008-01-09 09:14:43.000000000 +0530
@@ -793,6 +793,23 @@
 }
 
 /*##################################################################*/
+/* action_savepos */
+/*##################################################################*/
+
+void
+action_savepos(w, event, params, num_params)
+  Widget w;
+  XEvent *event;
+  String *params;
+  Cardinal *num_params;
+{
+  BEGINMESSAGE(action_savepos)
+  if (!XtIsSensitive(saveposEntry)) {INFMESSAGE(insensitive) ENDMESSAGE(action_savepos) return; }
+  cb_savepos((Widget)NULL,(XtPointer)NULL,(XtPointer)NULL);
+  ENDMESSAGE(action_savepos)
+}
+
+/*##################################################################*/
 /* action_save */
 /* Popup the save file dialog box. */
 /*##################################################################*/
diff -u -r gv-3.6.2/src/actions.h gv-3.6.2-savepos/src/actions.h
--- gv-3.6.2/src/actions.h	2004-11-11 17:51:04.000000000 +0530
+++ gv-3.6.2-savepos/src/actions.h	2008-01-08 22:57:35.000000000 +0530
@@ -150,6 +150,15 @@
 #endif
 );
 
+extern void 			action_savepos (
+#if NeedFunctionPrototypes
+    Widget,
+    XEvent *,
+    String *,
+    Cardinal *
+#endif
+);
+
 extern void 			action_save (
 #if NeedFunctionPrototypes
     Widget,
diff -u -r gv-3.6.2/src/callbacks.c gv-3.6.2-savepos/src/callbacks.c
--- gv-3.6.2/src/callbacks.c	2005-08-10 17:03:21.000000000 +0530
+++ gv-3.6.2-savepos/src/callbacks.c	2008-01-13 22:46:05.000000000 +0530
@@ -90,6 +90,9 @@
 static char* save_directory = NULL;
 static char* open_directory = NULL;
 
+static int last_psx;
+static int last_psy;
+
 /*############################################################*/
 /* cb_showTitle */
 /*############################################################*/
@@ -826,6 +829,28 @@
 }
 
 /*##################################################################*/
+/* cb_savepos */
+/*##################################################################*/
+
+void
+cb_savepos(w, client_data, call_data)
+    Widget w;
+    XtPointer client_data, call_data;
+{
+    FILE* posfile = fopen("gv.savepos", "a");
+
+    BEGINMESSAGE(cb_savepos)
+    if (posfile == NULL) {
+       INFMESSAGE(cannot open file for writting)
+       ENDMESSAGE(cb_savepos)
+       return;
+    }
+    fprintf(posfile, "%i %i\n", last_psx, last_psy);
+    fclose(posfile);
+    ENDMESSAGE(cb_savepos)
+}
+
+/*##################################################################*/
 /* cb_redisplay */
 /*##################################################################*/
 
@@ -1134,6 +1159,8 @@
            }
            x=p->psx; y=p->psy;
         }
+        last_psx = p->psx;
+        last_psy = p->psy;
         ENDMESSAGE1(cb_track)
 	return;
     }
@@ -1374,5 +1401,3 @@
   XtDestroyWidget(toplevel);
   ENDMESSAGE(cb_doQuit)
 }
-
-
diff -u -r gv-3.6.2/src/callbacks.h gv-3.6.2-savepos/src/callbacks.h
--- gv-3.6.2/src/callbacks.h	2004-11-11 17:51:04.000000000 +0530
+++ gv-3.6.2-savepos/src/callbacks.h	2008-01-09 09:15:12.000000000 +0530
@@ -193,6 +193,14 @@
 #endif
 );
 
+extern void			cb_savepos (
+#if NeedFunctionPrototypes
+   Widget,
+   XtPointer,
+   XtPointer
+#endif
+);
+
 extern void			cb_redisplay (
 #if NeedFunctionPrototypes
    Widget,
@@ -313,4 +321,5 @@
 #endif
 );
 
+
 #endif /* _GV_CALLBACKS_H_ */
diff -u -r gv-3.6.2/src/gv_misc_res.dat gv-3.6.2-savepos/src/gv_misc_res.dat
--- gv-3.6.2/src/gv_misc_res.dat	2005-04-01 02:44:27.000000000 +0530
+++ gv-3.6.2-savepos/src/gv_misc_res.dat	2008-01-09 09:25:28.000000000 +0530
@@ -401,6 +401,7 @@
  <Key>p:		GV_Print(all)		\n\
  ~c ~s <Key>period:	GV_Page(redisplay)	\n\
  <Key>period:		GV_Reopen()		\n\
+ <Key>Z:		GV_SavePos()		\n\
  c <Key>L:		GV_Page(redisplay)	\n\
  <Key>M:		GV_SetPageMark(current,mark)\n\
  <Key>N:		GV_SetPageMark(current,unmark)\n\
diff -u -r gv-3.6.2/src/main.c gv-3.6.2-savepos/src/main.c
--- gv-3.6.2/src/main.c	2006-09-15 00:26:08.000000000 +0530
+++ gv-3.6.2-savepos/src/main.c	2008-01-09 09:14:43.000000000 +0530
@@ -236,6 +236,7 @@
  { "GV_Print"		, action_print			},
  { "GV_Quit"		, action_quit			},
  { "GV_Reopen"		, action_reopen			},
+ { "GV_SavePos"		, action_savepos			},
  { "GV_Resizing"	, action_autoResize		},
  { "GV_Save"		, action_save			},
  { "GV_SetScale"	, action_setScale		},
@@ -780,6 +781,7 @@
        { &fileMenu,         "menu", NULL ,NULL},
        { &openEntry,        "open", cb_openFile, NULL},
        { &reopenEntry,      "reopen", cb_reopen, NULL},
+       { &saveposEntry,     "savepos", cb_savepos, NULL},
        { &updateEntry,      "update", cb_checkFile, (XtPointer)CHECK_FILE_VERSION },
        { NULL,              "line", NULL, NULL },
        { &printAllEntry,    "printAllPages", cb_print, (XtPointer)PAGE_MODE_ALL},
diff -u -r gv-3.6.2/src/main_globals.h gv-3.6.2-savepos/src/main_globals.h
--- gv-3.6.2/src/main_globals.h	2005-03-31 17:44:09.000000000 +0530
+++ gv-3.6.2-savepos/src/main_globals.h	2008-01-09 09:18:00.000000000 +0530
@@ -171,6 +171,7 @@
 EXTERN Widget            fileMenu;
 EXTERN Widget               openEntry;
 EXTERN Widget               reopenEntry;
+EXTERN Widget               saveposEntry;
 EXTERN Widget               updateEntry;
 EXTERN Widget               printAllEntry;
 EXTERN Widget               printMarkedEntry;
diff -u -r gv-3.6.2/src/misc.c gv-3.6.2-savepos/src/misc.c
--- gv-3.6.2/src/misc.c	2005-08-10 17:03:21.000000000 +0530
+++ gv-3.6.2-savepos/src/misc.c	2008-01-09 09:18:00.000000000 +0530
@@ -1084,6 +1084,7 @@
     misc_setSensitive(w_unmarkAllPages    , show_unmarkAllPages    , (toc_text    != NULL));
 
     XtSetSensitive(reopenEntry,      (gv_psfile   != NULL));
+    XtSetSensitive(saveposEntry,      (gv_psfile   != NULL));
     XtSetSensitive(printAllEntry,    (gv_psfile   != NULL));
     XtSetSensitive(printMarkedEntry, (toc_text    != NULL));
     XtSetSensitive(saveAllEntry,     (gv_psfile   != NULL));