Gentoo Archives: gentoo-commits

From: "Andreas HAttel (dilfridge)" <dilfridge@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] gentoo-x86 commit in app-text/xournal/files: xournal-0.4.5_p20111022-gtk-recent.patch xournal-0.4.5_p20111022-aspectratio.patch
Date: Wed, 16 Nov 2011 22:55:53
Message-Id: 20111116225543.74CE12004B@flycatcher.gentoo.org
1 dilfridge 11/11/16 22:55:43
2
3 Added: xournal-0.4.5_p20111022-gtk-recent.patch
4 xournal-0.4.5_p20111022-aspectratio.patch
5 Log:
6 Add patches for gtk-recent support and preserving object aspect ratio
7
8 (Portage version: 2.1.10.34/cvs/Linux x86_64)
9
10 Revision Changes Path
11 1.1 app-text/xournal/files/xournal-0.4.5_p20111022-gtk-recent.patch
12
13 file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/app-text/xournal/files/xournal-0.4.5_p20111022-gtk-recent.patch?rev=1.1&view=markup
14 plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/app-text/xournal/files/xournal-0.4.5_p20111022-gtk-recent.patch?rev=1.1&content-type=text/plain
15
16 Index: xournal-0.4.5_p20111022-gtk-recent.patch
17 ===================================================================
18 https://sourceforge.net/tracker/?func=detail&aid=3249971&group_id=163434&atid=827735
19 When using GtkRecent for the management of recently used files, Xournal's recently used
20 files also appear in the shell. That's very convenient for the new document-centric shells
21 such as Gnome Shell and Unity.
22 Timo Kluck ( tkluck ) - 2011-03-27 10:40:08 PDT
23
24 === modified file 'src/main.c'
25 --- src/main.c 2011-03-10 18:14:21 +0000
26 +++ src/main.c 2011-03-27 16:32:52 +0000
27 @@ -334,7 +334,6 @@
28
29 if (bgpdf.status != STATUS_NOT_INIT) shutdown_bgpdf();
30
31 - save_mru_list();
32 if (ui.auto_save_prefs) save_config_to_file();
33
34 return 0;
35
36 === modified file 'src/xo-callbacks.c'
37 --- src/xo-callbacks.c 2011-03-10 18:14:21 +0000
38 +++ src/xo-callbacks.c 2011-03-27 16:32:52 +0000
39 @@ -3101,32 +3101,36 @@
40
41
42 void
43 -on_mru_activate (GtkMenuItem *menuitem,
44 +on_mru_activate (GtkRecentChooser *recentChooser,
45 gpointer user_data)
46 {
47 - int which;
48 gboolean success;
49 + gchar *uri, *name;
50 GtkWidget *dialog;
51
52 end_text();
53 if (!ok_to_close()) return; // user aborted on save confirmation
54
55 - for (which = 0 ; which < MRU_SIZE; which++) {
56 - if (ui.mrumenu[which] == GTK_WIDGET(menuitem)) break;
57 - }
58 - if (which == MRU_SIZE || ui.mru[which] == NULL) return; // not found...
59 -
60 + uri = gtk_recent_chooser_get_current_uri (recentChooser);
61 + name = g_filename_from_uri (uri, NULL, NULL);
62 set_cursor_busy(TRUE);
63 - success = open_journal(ui.mru[which]);
64 + success = open_journal(name);
65 set_cursor_busy(FALSE);
66 - if (success) return;
67 + if (success) {
68 + g_free(uri);
69 + g_free(name);
70 + return;
71 + }
72
73 /* open failed */
74 dialog = gtk_message_dialog_new(GTK_WINDOW (winMain), GTK_DIALOG_DESTROY_WITH_PARENT,
75 - GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, _("Error opening file '%s'"), ui.mru[which]);
76 + GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, _("Error opening file '%s'"), name);
77 gtk_dialog_run(GTK_DIALOG(dialog));
78 gtk_widget_destroy(dialog);
79 - delete_mru_entry(which);
80 +
81 + delete_mru_entry(name);
82 + g_free(uri);
83 + g_free(name);
84 }
85
86
87
88 === modified file 'src/xo-callbacks.h'
89 --- src/xo-callbacks.h 2011-03-10 18:14:21 +0000
90 +++ src/xo-callbacks.h 2011-03-27 16:32:52 +0000
91 @@ -481,7 +481,7 @@
92 gpointer user_data);
93
94 void
95 -on_mru_activate (GtkMenuItem *menuitem,
96 +on_mru_activate (GtkRecentChooser *recentChooser,
97 gpointer user_data);
98
99 void
100
101 === modified file 'src/xo-file.c'
102 --- src/xo-file.c 2011-03-10 18:14:21 +0000
103 +++ src/xo-file.c 2011-03-27 17:09:20 +0000
104 @@ -1211,99 +1211,53 @@
105 }
106 }
107
108 -// initialize the recent files list
109 +// initialize GtkRecentManager. Also backwards compatibility: import recent files into GtkRecentManager
110 void init_mru(void)
111 {
112 - int i;
113 + GtkRecentFilter *recentFilter = gtk_recent_filter_new ();
114 + gtk_recent_filter_add_application ( recentFilter, "xournal");
115 + gtk_recent_chooser_add_filter (GTK_RECENT_CHOOSER (GET_COMPONENT("fileRecentFiles_menu")), recentFilter);
116 +
117 gsize lfptr;
118 - char s[5];
119 GIOChannel *f;
120 - gchar *str;
121 + gchar *str, *uri;
122 GIOStatus status;
123 + GtkRecentManager *recentManager = gtk_recent_manager_get_default ();
124
125 - g_strlcpy(s, "mru0", 5);
126 - for (s[3]='0', i=0; i<MRU_SIZE; s[3]++, i++) {
127 - ui.mrumenu[i] = GET_COMPONENT(s);
128 - ui.mru[i] = NULL;
129 - }
130 f = g_io_channel_new_file(ui.mrufile, "r", NULL);
131 if (f) status = G_IO_STATUS_NORMAL;
132 else status = G_IO_STATUS_ERROR;
133 - i = 0;
134 - while (status == G_IO_STATUS_NORMAL && i<MRU_SIZE) {
135 + while (status == G_IO_STATUS_NORMAL) {
136 lfptr = 0;
137 status = g_io_channel_read_line(f, &str, NULL, &lfptr, NULL);
138 if (status == G_IO_STATUS_NORMAL && lfptr>0) {
139 str[lfptr] = 0;
140 - ui.mru[i] = str;
141 - i++;
142 + uri = g_filename_to_uri (str, NULL, NULL);
143 + gtk_recent_manager_add_item (recentManager, uri);
144 + g_free(uri);
145 + g_free(str);
146 }
147 }
148 if (f) {
149 g_io_channel_shutdown(f, FALSE, NULL);
150 g_io_channel_unref(f);
151 }
152 - update_mru_menu();
153 -}
154 -
155 -void update_mru_menu(void)
156 -{
157 - int i;
158 - gboolean anyone = FALSE;
159 - gchar *tmp;
160
161 - for (i=0; i<MRU_SIZE; i++) {
162 - if (ui.mru[i]!=NULL) {
163 - tmp = g_strdup_printf("_%d %s", i+1,
164 - g_strjoinv("__", g_strsplit_set(g_basename(ui.mru[i]),"_",-1)));
165 - gtk_label_set_text_with_mnemonic(GTK_LABEL(gtk_bin_get_child(GTK_BIN(ui.mrumenu[i]))),
166 - tmp);
167 - g_free(tmp);
168 - gtk_widget_show(ui.mrumenu[i]);
169 - anyone = TRUE;
170 - }
171 - else gtk_widget_hide(ui.mrumenu[i]);
172 - }
173 - gtk_widget_set_sensitive(GET_COMPONENT("fileRecentFiles"), anyone);
174 + g_unlink (ui.mrufile);
175 }
176
177 void new_mru_entry(char *name)
178 {
179 - int i, j;
180 -
181 - for (i=0;i<MRU_SIZE;i++)
182 - if (ui.mru[i]!=NULL && !strcmp(ui.mru[i], name)) {
183 - g_free(ui.mru[i]);
184 - for (j=i+1; j<MRU_SIZE; j++) ui.mru[j-1] = ui.mru[j];
185 - ui.mru[MRU_SIZE-1]=NULL;
186 - }
187 - if (ui.mru[MRU_SIZE-1]!=NULL) g_free(ui.mru[MRU_SIZE-1]);
188 - for (j=MRU_SIZE-1; j>=1; j--) ui.mru[j] = ui.mru[j-1];
189 - ui.mru[0] = g_strdup(name);
190 - update_mru_menu();
191 -}
192 -
193 -void delete_mru_entry(int which)
194 -{
195 - int i;
196 -
197 - if (ui.mru[which]!=NULL) g_free(ui.mru[which]);
198 - for (i=which+1;i<MRU_SIZE;i++)
199 - ui.mru[i-1] = ui.mru[i];
200 - ui.mru[MRU_SIZE-1] = NULL;
201 - update_mru_menu();
202 -}
203 -
204 -void save_mru_list(void)
205 -{
206 - FILE *f;
207 - int i;
208 -
209 - f = fopen(ui.mrufile, "w");
210 - if (f==NULL) return;
211 - for (i=0; i<MRU_SIZE; i++)
212 - if (ui.mru[i]!=NULL) fprintf(f, "%s\n", ui.mru[i]);
213 - fclose(f);
214 + gchar *uri = g_filename_to_uri (name, NULL, NULL);
215 + gtk_recent_manager_add_item (gtk_recent_manager_get_default(), uri);
216 + g_free(uri);
217 +}
218 +
219 +void delete_mru_entry(char *name)
220 +{
221 + gchar *uri = g_filename_to_uri(name, NULL, NULL);
222 + gtk_recent_manager_remove_item(gtk_recent_manager_get_default(), uri, NULL);
223 + g_free(uri);
224 }
225
226 void init_config_default(void)
227
228 === modified file 'src/xo-file.h'
229 --- src/xo-file.h 2011-03-10 18:14:21 +0000
230 +++ src/xo-file.h 2011-03-27 16:32:52 +0000
231 @@ -28,10 +28,8 @@
232 void bgpdf_update_bg(int pageno, struct BgPdfPage *bgpg);
233
234 void init_mru(void);
235 -void update_mru_menu(void);
236 void new_mru_entry(char *name);
237 -void delete_mru_entry(int which);
238 -void save_mru_list(void);
239 +void delete_mru_entry(char *name);
240
241 void init_config_default(void);
242 void load_config_from_file(void);
243
244 === modified file 'src/xo-interface.c'
245 --- src/xo-interface.c 2011-03-10 18:14:21 +0000
246 +++ src/xo-interface.c 2011-03-27 17:09:20 +0000
247 @@ -43,14 +43,6 @@
248 GtkWidget *separator1;
249 GtkWidget *fileRecentFiles;
250 GtkWidget *fileRecentFiles_menu;
251 - GtkWidget *mru0;
252 - GtkWidget *mru1;
253 - GtkWidget *mru2;
254 - GtkWidget *mru3;
255 - GtkWidget *mru4;
256 - GtkWidget *mru5;
257 - GtkWidget *mru6;
258 - GtkWidget *mru7;
259 GtkWidget *separator22;
260 GtkWidget *filePrintOptions;
261 GtkWidget *image624;
262 @@ -397,41 +389,9 @@
263 gtk_widget_show (fileRecentFiles);
264 gtk_container_add (GTK_CONTAINER (menuFile_menu), fileRecentFiles);
265
266 - fileRecentFiles_menu = gtk_menu_new ();
267 + fileRecentFiles_menu = gtk_recent_chooser_menu_new_for_manager (gtk_recent_manager_get_default ());
268 gtk_menu_item_set_submenu (GTK_MENU_ITEM (fileRecentFiles), fileRecentFiles_menu);
269 -
270 - mru0 = gtk_menu_item_new_with_mnemonic (_("0"));
271 - gtk_widget_show (mru0);
272 - gtk_container_add (GTK_CONTAINER (fileRecentFiles_menu), mru0);
273 -
274 - mru1 = gtk_menu_item_new_with_mnemonic (_("1"));
275 - gtk_widget_show (mru1);
276 - gtk_container_add (GTK_CONTAINER (fileRecentFiles_menu), mru1);
277 -
278 - mru2 = gtk_menu_item_new_with_mnemonic (_("2"));
279 - gtk_widget_show (mru2);
280 - gtk_container_add (GTK_CONTAINER (fileRecentFiles_menu), mru2);
281 -
282 - mru3 = gtk_menu_item_new_with_mnemonic (_("3"));
283 - gtk_widget_show (mru3);
284 - gtk_container_add (GTK_CONTAINER (fileRecentFiles_menu), mru3);
285 -
286 - mru4 = gtk_menu_item_new_with_mnemonic (_("4"));
287 - gtk_widget_show (mru4);
288 - gtk_container_add (GTK_CONTAINER (fileRecentFiles_menu), mru4);
289 -
290 - mru5 = gtk_menu_item_new_with_mnemonic (_("5"));
291 - gtk_widget_show (mru5);
292 - gtk_container_add (GTK_CONTAINER (fileRecentFiles_menu), mru5);
293 -
294 - mru6 = gtk_menu_item_new_with_mnemonic (_("6"));
295 - gtk_widget_show (mru6);
296 - gtk_container_add (GTK_CONTAINER (fileRecentFiles_menu), mru6);
297 -
298 - mru7 = gtk_menu_item_new_with_mnemonic (_("7"));
299 - gtk_widget_show (mru7);
300 - gtk_container_add (GTK_CONTAINER (fileRecentFiles_menu), mru7);
301 -
302 +
303 separator22 = gtk_separator_menu_item_new ();
304 gtk_widget_show (separator22);
305 gtk_container_add (GTK_CONTAINER (menuFile_menu), separator22);
306 @@ -1967,28 +1927,7 @@
307 g_signal_connect ((gpointer) fileSaveAs, "activate",
308 G_CALLBACK (on_fileSaveAs_activate),
309 NULL);
310 - g_signal_connect ((gpointer) mru0, "activate",
311 - G_CALLBACK (on_mru_activate),
312 - NULL);
313 - g_signal_connect ((gpointer) mru1, "activate",
314 - G_CALLBACK (on_mru_activate),
315 - NULL);
316 - g_signal_connect ((gpointer) mru2, "activate",
317 - G_CALLBACK (on_mru_activate),
318 - NULL);
319 - g_signal_connect ((gpointer) mru3, "activate",
320 - G_CALLBACK (on_mru_activate),
321 - NULL);
322 - g_signal_connect ((gpointer) mru4, "activate",
323 - G_CALLBACK (on_mru_activate),
324 - NULL);
325 - g_signal_connect ((gpointer) mru5, "activate",
326 - G_CALLBACK (on_mru_activate),
327 - NULL);
328 - g_signal_connect ((gpointer) mru6, "activate",
329 - G_CALLBACK (on_mru_activate),
330 - NULL);
331 - g_signal_connect ((gpointer) mru7, "activate",
332 + g_signal_connect ((gpointer) fileRecentFiles_menu, "item-activated",
333 G_CALLBACK (on_mru_activate),
334 NULL);
335 g_signal_connect ((gpointer) filePrintOptions, "activate",
336 @@ -2520,14 +2459,6 @@
337 GLADE_HOOKUP_OBJECT (winMain, separator1, "separator1");
338 GLADE_HOOKUP_OBJECT (winMain, fileRecentFiles, "fileRecentFiles");
339 GLADE_HOOKUP_OBJECT (winMain, fileRecentFiles_menu, "fileRecentFiles_menu");
340 - GLADE_HOOKUP_OBJECT (winMain, mru0, "mru0");
341 - GLADE_HOOKUP_OBJECT (winMain, mru1, "mru1");
342 - GLADE_HOOKUP_OBJECT (winMain, mru2, "mru2");
343 - GLADE_HOOKUP_OBJECT (winMain, mru3, "mru3");
344 - GLADE_HOOKUP_OBJECT (winMain, mru4, "mru4");
345 - GLADE_HOOKUP_OBJECT (winMain, mru5, "mru5");
346 - GLADE_HOOKUP_OBJECT (winMain, mru6, "mru6");
347 - GLADE_HOOKUP_OBJECT (winMain, mru7, "mru7");
348 GLADE_HOOKUP_OBJECT (winMain, separator22, "separator22");
349 GLADE_HOOKUP_OBJECT (winMain, filePrintOptions, "filePrintOptions");
350 GLADE_HOOKUP_OBJECT (winMain, image624, "image624");
351
352 === modified file 'src/xournal.h'
353 --- src/xournal.h 2011-03-10 18:14:21 +0000
354 +++ src/xournal.h 2011-03-27 16:32:52 +0000
355 @@ -257,8 +257,6 @@
356 GdkCursor *cursor;
357 gboolean progressive_bg; // update PDF bg's one at a time
358 char *mrufile, *configfile; // file names for MRU & config
359 - char *mru[MRU_SIZE]; // MRU data
360 - GtkWidget *mrumenu[MRU_SIZE];
361 gboolean bg_apply_all_pages;
362 int window_default_width, window_default_height, scrollbar_step_increment;
363 gboolean print_ruling; // print the paper ruling ?
364
365
366
367
368 1.1 app-text/xournal/files/xournal-0.4.5_p20111022-aspectratio.patch
369
370 file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/app-text/xournal/files/xournal-0.4.5_p20111022-aspectratio.patch?rev=1.1&view=markup
371 plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/app-text/xournal/files/xournal-0.4.5_p20111022-aspectratio.patch?rev=1.1&content-type=text/plain
372
373 Index: xournal-0.4.5_p20111022-aspectratio.patch
374 ===================================================================
375 https://sourceforge.net/tracker/?func=detail&aid=3082301&group_id=163434&atid=827735
376 To make the image patch even more useful, I've written this patch to allow the aspect ratio
377 to be preserved when resizing selections. (It doesn't just apply to images.) Simply resize using the right
378 mouse button (button-3) rather than the left mouse button.
379 This patch should be applied after the enhanced image patch. (Though it'd be easy enough to make the
380 changes to the raw 0.4.5 source directly since it doesn't change any of the image patch related areas.)
381 David Barton ( db9052 ) - 2010-10-06 09:30:56 PDT
382
383 diff -ur xournal-0.4.5/src/xo-paint.c xournal-0.4.5-aspectratio/src/xo-paint.c
384 --- xournal-0.4.5/src/xo-paint.c 2010-10-06 16:45:01.000000000 +0100
385 +++ xournal-0.4.5-aspectratio/src/xo-paint.c 2010-10-06 17:10:19.000000000 +0100
386 @@ -609,6 +609,12 @@
387 ui.selection->new_x2 = ui.selection->bbox.right;
388 gnome_canvas_item_set(ui.selection->canvas_item, "dash", NULL, NULL);
389 update_cursor_for_resize(pt);
390 +
391 + // Check whether we should preserve the aspect ratio
392 + if (event->button.button == 3)
393 + ui.cur_brush->tool_options |= TOOLOPT_SELECT_PRESERVE;
394 + else
395 + ui.cur_brush->tool_options &= ~TOOLOPT_SELECT_PRESERVE;
396 return TRUE;
397 }
398 return FALSE;
399 @@ -740,6 +746,38 @@
400 if (ui.selection->resizing_left) ui.selection->new_x1 = pt[0];
401 if (ui.selection->resizing_right) ui.selection->new_x2 = pt[0];
402
403 + if (ui.cur_brush->tool_options & TOOLOPT_SELECT_PRESERVE) {
404 + double aspectratio = (ui.selection->bbox.top - ui.selection->bbox.bottom)/(ui.selection->bbox.right - ui.selection->bbox.left);
405 + double newheight = ui.selection->new_y1 - ui.selection->new_y2;
406 + double newwidth = ui.selection->new_x2 - ui.selection->new_x1;
407 + gboolean boundheight;
408 +
409 + // Resizing from top or bottom only
410 + if ((ui.selection->resizing_top || ui.selection->resizing_bottom) && !(ui.selection->resizing_left || ui.selection->resizing_right))
411 + boundheight = 0;
412 + // Resizing from right or left only
413 + else if (!(ui.selection->resizing_top || ui.selection->resizing_bottom) && (ui.selection->resizing_left || ui.selection->resizing_right))
414 + boundheight = 1;
415 + // Resizing from a corner
416 + else if (newheight/aspectratio > newwidth)
417 + boundheight = 0;
418 + else
419 + boundheight = 1;
420 +
421 + if (boundheight) {
422 + // Bound the height
423 + newheight = newwidth*aspectratio;
424 + if (ui.selection->resizing_top) ui.selection->new_y1 = ui.selection->new_y2 + newheight;
425 + else ui.selection->new_y2 = ui.selection->new_y1 - newheight;
426 + }
427 + else {
428 + // Bound the width
429 + newwidth = newheight/aspectratio;
430 + if (ui.selection->resizing_left) ui.selection->new_x1 = ui.selection->new_x2 - newwidth;
431 + else ui.selection->new_x2 = ui.selection->new_x1 + newwidth;
432 + }
433 + }
434 +
435 gnome_canvas_item_set(ui.selection->canvas_item,
436 "x1", ui.selection->new_x1, "x2", ui.selection->new_x2,
437 "y1", ui.selection->new_y1, "y2", ui.selection->new_y2, NULL);
438 diff -ur xournal-0.4.5/src/xournal.h xournal-0.4.5-aspectratio/src/xournal.h
439 --- xournal-0.4.5/src/xournal.h 2010-10-06 16:45:01.000000000 +0100
440 +++ xournal-0.4.5-aspectratio/src/xournal.h 2010-10-06 16:31:07.000000000 +0100
441 @@ -130,6 +130,7 @@
442 #define TOOLOPT_ERASER_STANDARD 0
443 #define TOOLOPT_ERASER_WHITEOUT 1
444 #define TOOLOPT_ERASER_STROKES 2
445 +#define TOOLOPT_SELECT_PRESERVE 1 // Preserve the aspect ratio of the selection when resizing
446
447 extern double predef_thickness[NUM_STROKE_TOOLS][THICKNESS_MAX];