]> git.donarmstrong.com Git - xournal.git/blobdiff - src/xo-paint.c
custom color chooser; misc patches
[xournal.git] / src / xo-paint.c
index 79099411aec7634bd41b6ed8dbeeb033a88e542b..85e3536a488430b7c81833475f7431cdd5c1eea9 100644 (file)
@@ -608,6 +608,7 @@ gboolean start_resizesel(GdkEvent *event)
     ui.selection->new_x1 = ui.selection->bbox.left;
     ui.selection->new_x2 = ui.selection->bbox.right;
     gnome_canvas_item_set(ui.selection->canvas_item, "dash", NULL, NULL);
+    update_cursor_for_resize(pt);
     return TRUE;
   }
   return FALSE;
@@ -1045,7 +1046,7 @@ void clipboard_paste(void)
       }
       p+= 2*item->path->num_points*sizeof(double);
       if (item->brush.variable_width) {
-        g_memmove(p, item->widths, (item->path->num_points-1)*sizeof(double));
+        item->widths = g_memdup(p, (item->path->num_points-1)*sizeof(double));
         p+= (item->path->num_points-1)*sizeof(double);
       }
       else item->widths = NULL;
@@ -1076,11 +1077,16 @@ void clipboard_paste(void)
   
   gtk_selection_data_free(sel_data);
   update_copy_paste_enabled();
+  update_color_menu();
+  update_thickness_buttons();
+  update_color_buttons();
+  update_font_button();  
+  update_cursor(); // FIXME: can't know if pointer is within selection!
 }
 
 // modify the color or thickness of pen strokes in a selection
 
-void recolor_selection(int color)
+void recolor_selection(int color_no, guint color_rgba)
 {
   GList *itemlist;
   struct Item *item;
@@ -1102,8 +1108,8 @@ void recolor_selection(int color)
     g_memmove(brush, &(item->brush), sizeof(struct Brush));
     undo->auxlist = g_list_append(undo->auxlist, brush);
     // repaint the stroke
-    item->brush.color_no = color;
-    item->brush.color_rgba = predef_colors_rgba[color];
+    item->brush.color_no = color_no;
+    item->brush.color_rgba = color_rgba;
     if (item->canvas_item!=NULL) {
       if (!item->brush.variable_width)
         gnome_canvas_item_set(item->canvas_item, 
@@ -1209,6 +1215,17 @@ void start_text(GdkEvent *event, struct Item *item)
   get_pointer_coords(event, pt);
   ui.cur_item_type = ITEM_TEXT;
 
+  // HACK TO BYPASS GTK+ 2.17 issues
+  if (!gtk_check_version(2, 17, 0)) {
+    /* first we make *all* canvas subwindows become XInput aware, 
+       so that it'll be safe to disable XInput later on... (!!!) */
+    gtk_widget_set_extension_events(GTK_WIDGET (canvas), 
+       ui.use_xinput?GDK_EXTENSION_EVENTS_ALL:GDK_EXTENSION_EVENTS_NONE);
+    /* then we ask the canvas's leave-notify handler to disable 
+       xinput when it's safe to do so... */
+    ui.need_emergency_disable_xinput = TRUE;
+  }
+
   if (item==NULL) {
     item = g_new(struct Item, 1);
     item->text = NULL;
@@ -1271,6 +1288,14 @@ void end_text(void)
   GnomeCanvasItem *tmpitem;
 
   if (ui.cur_item_type!=ITEM_TEXT) return; // nothing for us to do!
+
+  // HACK TO BYPASS GTK+ 2.17 issues
+  if (!gtk_check_version(2, 17, 0)) {
+    // re-enable XInput if needed (we disabled it during text edition)
+    gdk_input_set_extension_events(GTK_WIDGET(canvas)->window, 
+      GDK_POINTER_MOTION_MASK | GDK_BUTTON_MOTION_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK,
+      ui.use_xinput?GDK_EXTENSION_EVENTS_ALL:GDK_EXTENSION_EVENTS_NONE);
+  }
   
   // finalize the text that's been edited... 
   buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(ui.cur_item->widget));