[SCM] gsequencer/master: New upstream version 0.4.2-72

jkraehemann-guest at users.alioth.debian.org jkraehemann-guest at users.alioth.debian.org
Sun Jun 21 08:29:06 UTC 2015


The following commit has been merged in the master branch:
commit dab7d29c66072ae7546ef4ee43ebcf52040c5379
Author: Joël Krähemann <jkraehemann-guest at users.alioth.debian.org>
Date:   Sun Jun 21 10:11:43 2015 +0200

    New upstream version 0.4.2-72

diff --git a/ChangeLog b/ChangeLog
index ef9fcd1..d7412e4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+ags (0.4.2-72-1)
+
+	[ Joël Krähemann (Maintainer of Advanced Gtk+ Sequencer) ]
+	* implemented basic editing key strokes like Ctrl-c, Ctrl-v and Ctrl-x
+	* implemented seeking for paste if position tool is selected
+	* updated clipboard version to 0.4.2
+
 ags (0.4.2-71-1)
 
 	[ Joël Krähemann (Maintainer of Advanced Gtk+ Sequencer) ]
diff --git a/configure b/configure
index 072e30b..13de830 100755
--- a/configure
+++ b/configure
@@ -1,8 +1,8 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.69 for ags 0.4.2-71.
+# Generated by GNU Autoconf 2.69 for ags 0.4.2-72.
 #
-# Report bugs to <jkraehemann at gmail.com>.
+# Report bugs to <jkraehemann-guest at users.alioth.debian.org>.
 #
 #
 # Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc.
@@ -267,10 +267,10 @@ fi
     $as_echo "$0: be upgraded to zsh 4.3.4 or later."
   else
     $as_echo "$0: Please tell bug-autoconf at gnu.org and
-$0: jkraehemann at gmail.com about your system, including any
-$0: error possibly output before this message. Then install
-$0: a modern shell, or manually run the script under such a
-$0: shell if you do have one."
+$0: jkraehemann-guest at users.alioth.debian.org about your
+$0: system, including any error possibly output before this
+$0: message. Then install a modern shell, or manually run
+$0: the script under such a shell if you do have one."
   fi
   exit 1
 fi
@@ -580,9 +580,9 @@ MAKEFLAGS=
 # Identity of this package.
 PACKAGE_NAME='ags'
 PACKAGE_TARNAME='ags'
-PACKAGE_VERSION='0.4.2-71'
-PACKAGE_STRING='ags 0.4.2-71'
-PACKAGE_BUGREPORT='jkraehemann at gmail.com'
+PACKAGE_VERSION='0.4.2-72'
+PACKAGE_STRING='ags 0.4.2-72'
+PACKAGE_BUGREPORT='jkraehemann-guest at users.alioth.debian.org'
 PACKAGE_URL=''
 
 ac_unique_file="config.h.in"
@@ -1317,7 +1317,7 @@ if test "$ac_init_help" = "long"; then
   # Omit some internal or obsolete options to make the list less imposing.
   # This message is too long to be a string in the A/UX 3.1 sh.
   cat <<_ACEOF
-\`configure' configures ags 0.4.2-71 to adapt to many kinds of systems.
+\`configure' configures ags 0.4.2-72 to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -1387,7 +1387,7 @@ fi
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
-     short | recursive ) echo "Configuration of ags 0.4.2-71:";;
+     short | recursive ) echo "Configuration of ags 0.4.2-72:";;
    esac
   cat <<\_ACEOF
 
@@ -1460,7 +1460,7 @@ Some influential environment variables:
 Use these variables to override the choices made by `configure' or to help
 it to find libraries and programs with nonstandard names/locations.
 
-Report bugs to <jkraehemann at gmail.com>.
+Report bugs to <jkraehemann-guest at users.alioth.debian.org>.
 _ACEOF
 ac_status=$?
 fi
@@ -1523,7 +1523,7 @@ fi
 test -n "$ac_init_help" && exit $ac_status
 if $ac_init_version; then
   cat <<\_ACEOF
-ags configure 0.4.2-71
+ags configure 0.4.2-72
 generated by GNU Autoconf 2.69
 
 Copyright (C) 2012 Free Software Foundation, Inc.
@@ -1922,9 +1922,9 @@ $as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;}
 $as_echo "$as_me: WARNING: $2:     section \"Present But Cannot Be Compiled\"" >&2;}
     { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5
 $as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;}
-( $as_echo "## ------------------------------------ ##
-## Report this to jkraehemann at gmail.com ##
-## ------------------------------------ ##"
+( $as_echo "## -------------------------------------------------------- ##
+## Report this to jkraehemann-guest at users.alioth.debian.org ##
+## -------------------------------------------------------- ##"
      ) | sed "s/^/$as_me: WARNING:     /" >&2
     ;;
 esac
@@ -2000,7 +2000,7 @@ cat >config.log <<_ACEOF
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 
-It was created by ags $as_me 0.4.2-71, which was
+It was created by ags $as_me 0.4.2-72, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   $ $0 $@
@@ -2866,7 +2866,7 @@ fi
 
 # Define the identity of the package.
  PACKAGE='ags'
- VERSION='0.4.2-71'
+ VERSION='0.4.2-72'
 
 
 cat >>confdefs.h <<_ACEOF
@@ -7161,7 +7161,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
 # report actual input values of CONFIG_FILES etc. instead of their
 # values after options handling.
 ac_log="
-This file was extended by ags $as_me 0.4.2-71, which was
+This file was extended by ags $as_me 0.4.2-72, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
@@ -7221,13 +7221,13 @@ $config_headers
 Configuration commands:
 $config_commands
 
-Report bugs to <jkraehemann at gmail.com>."
+Report bugs to <jkraehemann-guest at users.alioth.debian.org>."
 
 _ACEOF
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
 ac_cs_version="\\
-ags config.status 0.4.2-71
+ags config.status 0.4.2-72
 configured by $0, generated by GNU Autoconf 2.69,
   with options \\"\$ac_cs_config\\"
 
diff --git a/configure.ac b/configure.ac
index 2679120..8fe7d0d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2,7 +2,7 @@
 # Process this file with autoconf to produce a configure script.
 
 AC_PREREQ([2.69])
-AC_INIT([ags],[0.4.2-71],[jkraehemann at gmail.com])
+AC_INIT([ags],[0.4.2-72],[jkraehemann-guest at users.alioth.debian.org])
 AM_INIT_AUTOMAKE([foreign])
 AC_CONFIG_SRCDIR([config.h.in])
 AC_CONFIG_HEADERS([config.h])
diff --git a/src/ags/X/ags_editor.c b/src/ags/X/ags_editor.c
index a4aa2a1..4c552c5 100644
--- a/src/ags/X/ags_editor.c
+++ b/src/ags/X/ags_editor.c
@@ -29,6 +29,9 @@
 #include <math.h>
 #include <cairo.h>
 
+#include <libxml/tree.h>
+#include <libxml/xpath.h>
+
 void ags_editor_class_init(AgsEditorClass *editor);
 void ags_editor_connectable_interface_init(AgsConnectableInterface *connectable);
 void ags_editor_init(AgsEditor *editor);
@@ -371,6 +374,381 @@ ags_editor_real_machine_changed(AgsEditor *editor, AgsMachine *machine)
 }
 
 /**
+ * ags_editor_select_all:
+ * @editor: an #AgsEditor
+ *
+ * Is emitted as machine changed of editor.
+ *
+ * Since: 0.4.2
+ */
+void
+ags_editor_select_all(AgsEditor *editor)
+{
+  AgsMachine *machine;
+  
+  cairo_t *cr;
+    
+  GList *list_notation;
+
+  gint i;
+  gint selected_channel;
+
+  if(editor->selected_machine != NULL){
+    machine = editor->selected_machine;
+
+    cr = gdk_cairo_create(GTK_WIDGET(editor->note_edit->drawing_area)->window);
+    cairo_push_group(cr);
+      
+    list_notation = machine->audio->notation;
+    i = 0;
+
+    while((selected_channel = ags_notebook_next_active_tab(editor->notebook,
+							   i)) != -1){
+      list_notation = g_list_nth(machine->audio->notation,
+				 selected_channel);
+      ags_notation_add_all_to_selection(AGS_NOTATION(list_notation->data));
+
+      i++;
+    }
+
+    ags_note_edit_draw_segment(editor->note_edit, cr);
+    ags_note_edit_draw_notation(editor->note_edit, cr);
+
+    cairo_pop_group_to_source(cr);
+    cairo_paint(cr);
+  }
+}
+
+/**
+ * ags_editor_paste:
+ * @editor: an #AgsEditor
+ *
+ * Is emitted as machine changed of editor.
+ *
+ * Since: 0.4.2
+ */
+void
+ags_editor_paste(AgsEditor *editor)
+{
+  AgsMachine *machine;
+  
+  AgsNotation *notation;
+
+  xmlDocPtr clipboard;
+  xmlNodePtr audio_node, notation_node;
+  cairo_t *cr;
+  
+  gchar *buffer;
+  guint position_x, position_y;
+  guint last_x;
+  gboolean paste_from_position;
+  
+  void ags_editor_paste_read_notation(){
+    xmlXPathContextPtr xpathCtxt;
+    xmlXPathObjectPtr xpathObj;
+    xmlNodeSetPtr nodes;
+    GList *notation_list;
+
+    xpathCtxt = xmlXPathNewContext(clipboard);
+    xpathObj = xmlXPathEvalExpression("/audio/notation\0", xpathCtxt);
+
+    if(xpathObj != NULL){
+      int i, size;
+      guint audio_channel;
+      guint current_x;
+      
+      nodes = xpathObj->nodesetval;
+      size = (nodes != NULL) ? nodes->nodeNr: 0;
+
+      for(i = 0; i < size; i++){
+	audio_channel = (guint) g_ascii_strtoull(xmlGetProp(nodes->nodeTab[i],
+							    "audio-channel\0"),
+						 NULL,
+						 10);
+	notation_list = g_list_nth(machine->audio->notation,
+				   audio_channel);
+	
+	if(paste_from_position){
+	  xmlNode *child;
+
+	  guint x_boundary;
+	  
+	  ags_notation_insert_from_clipboard(AGS_NOTATION(notation_list->data),
+					     nodes->nodeTab[i],
+					     TRUE, position_x,
+					     TRUE, position_y);
+
+	  child = nodes->nodeTab[i]->children;
+	  current_x = 0;
+	  
+	  while(child != NULL){
+	    if(child->type == XML_ELEMENT_NODE){
+	      if(!xmlStrncmp(child->name,
+			     "note\0",
+			     5)){
+		guint tmp;
+
+		tmp = g_ascii_strtoull(xmlGetProp(child,
+						  "x1\0"),
+				       NULL,
+				       10);
+
+		if(tmp > current_x){
+		  current_x = tmp;
+		}
+	      }
+	    }
+
+	    child = child->next;
+	  }
+
+	  x_boundary = g_ascii_strtoull(xmlGetProp(nodes->nodeTab[i],
+						   "x_boundary\0"),
+					NULL,
+					10);
+
+	  
+	  if(position_x > x_boundary){
+	    current_x += (position_x - x_boundary);
+	  }else{
+	    current_x -= (x_boundary - position_x);
+	  }
+	  
+	  if(current_x > last_x){
+	    last_x = current_x;
+	  }	
+	}else{
+	  xmlNode *child;
+
+	  ags_notation_insert_from_clipboard(AGS_NOTATION(notation_list->data),
+					     nodes->nodeTab[i],
+					     FALSE, 0,
+					     FALSE, 0);
+
+	  child = nodes->nodeTab[i]->children;
+	  current_x = 0;
+	  
+	  while(child != NULL){
+	    if(child->type == XML_ELEMENT_NODE){
+	      if(!xmlStrncmp(child->name,
+			     "note\0",
+			     5)){
+		guint tmp;
+
+		tmp = g_ascii_strtoull(xmlGetProp(child,
+						  "x1\0"),
+				       NULL,
+				       10);
+
+		if(tmp > current_x){
+		  current_x = tmp;
+		}
+	      }
+	    }
+
+	    child = child->next;
+	  }
+
+	  if(current_x > last_x){
+	    last_x = current_x;
+	  }
+	}
+      }
+
+      xmlXPathFreeObject(xpathObj);
+    }
+  }
+  
+  if((machine = editor->selected_machine) != NULL){
+    /* get clipboard */
+    buffer = gtk_clipboard_wait_for_text(gtk_clipboard_get(GDK_SELECTION_CLIPBOARD));
+    
+    if(buffer == NULL)
+      return;
+
+    /* get position */
+    if(editor->toolbar->selected_edit_mode == editor->toolbar->position){
+      last_x = 0;
+      paste_from_position = TRUE;
+
+      position_x = editor->note_edit->selected_x;
+      position_y = editor->note_edit->selected_y;
+
+#ifdef DEBUG
+      printf("pasting at position: [%u,%u]\n\0", position_x, position_y);
+#endif
+    }else{
+      paste_from_position = FALSE;
+    }
+
+    /* get xml tree */
+    clipboard = xmlReadMemory(buffer, strlen(buffer),
+			      NULL, "UTF-8\0",
+			      0);
+    audio_node = xmlDocGetRootElement(clipboard);
+    
+    /* iterate xml tree */
+    while(audio_node != NULL){
+      if(audio_node->type == XML_ELEMENT_NODE && !xmlStrncmp("audio\0", audio_node->name, 6)){
+	notation_node = audio_node->children;
+	
+	ags_editor_paste_read_notation();
+
+	break;
+      }
+      
+      audio_node = audio_node->next;
+    }
+
+    xmlFreeDoc(clipboard); 
+
+    cr = gdk_cairo_create(GTK_WIDGET(editor->note_edit->drawing_area)->window);
+    cairo_push_group(cr);
+
+    ags_note_edit_draw_segment(editor->note_edit, cr);
+    ags_note_edit_draw_notation(editor->note_edit, cr);
+
+    if(paste_from_position){
+      editor->note_edit->selected_x = (guint) ceil((double) last_x / 16.0) * 16;
+      ags_note_edit_draw_position(editor->note_edit, cr);
+    }
+    
+    cairo_pop_group_to_source(cr);
+    cairo_paint(cr);
+  }
+}
+
+/**
+ * ags_editor_copy:
+ * @editor: an #AgsEditor
+ *
+ * Is emitted as machine changed of editor.
+ *
+ * Since: 0.4.2
+ */
+void
+ags_editor_copy(AgsEditor *editor)
+{
+  AgsMachine *machine;
+  
+  AgsNotation *notation;
+
+  GList *list_notation;
+  xmlDocPtr clipboard;
+  xmlNodePtr audio_node, notation_node;
+
+  xmlChar *buffer;
+  int size;
+  gint i;
+  gint selected_channel;
+
+  if(editor->selected_machine != NULL){
+    machine = editor->selected_machine;
+    /* create document */
+    clipboard = xmlNewDoc(BAD_CAST XML_DEFAULT_VERSION);
+
+    /* create root node */
+    audio_node = xmlNewNode(NULL, BAD_CAST "audio\0");
+    xmlDocSetRootElement(clipboard, audio_node);
+
+    /* create notation nodes */
+    list_notation = machine->audio->notation;
+    i = 0;
+
+    while((selected_channel = ags_notebook_next_active_tab(editor->notebook,
+							   i)) != -1){
+      list_notation = g_list_nth(machine->audio->notation,
+				 selected_channel);
+
+      notation_node = ags_notation_copy_selection(AGS_NOTATION(list_notation->data));
+      
+      xmlAddChild(audio_node, notation_node);
+
+      i++;
+    }
+    
+    /* write to clipboard */
+    xmlDocDumpFormatMemoryEnc(clipboard, &buffer, &size, "UTF-8\0", TRUE);
+    gtk_clipboard_set_text(gtk_clipboard_get(GDK_SELECTION_CLIPBOARD),
+			   buffer, size);
+    gtk_clipboard_store(gtk_clipboard_get(GDK_SELECTION_CLIPBOARD));
+
+    xmlFreeDoc(clipboard);
+  }
+}
+
+/**
+ * ags_editor_cut:
+ * @editor: an #AgsEditor
+ *
+ * Is emitted as machine changed of editor.
+ *
+ * Since: 0.4.2
+ */
+void
+ags_editor_cut(AgsEditor *editor)
+{
+  AgsMachine *machine;
+  
+  AgsNotation *notation;
+
+  xmlDocPtr clipboard;
+  xmlNodePtr audio_node, notation_node;
+  cairo_t *cr;
+
+  GList *list_notation;
+
+  xmlChar *buffer;
+  int size;
+  gint i;
+  gint selected_channel;
+
+  if(editor->selected_machine != NULL){
+    machine = editor->selected_machine;
+
+    /* create document */
+    clipboard = xmlNewDoc(BAD_CAST XML_DEFAULT_VERSION);
+
+    /* create root node */
+    audio_node = xmlNewNode(NULL, BAD_CAST "audio\0");
+    xmlDocSetRootElement(clipboard, audio_node);
+
+    /* create notation nodes */
+    list_notation = machine->audio->notation;
+    i = 0;
+
+    cr = gdk_cairo_create(GTK_WIDGET(editor->note_edit->drawing_area)->window);
+      cairo_push_group(cr);
+
+    while((selected_channel = ags_notebook_next_active_tab(editor->notebook,
+							   i)) != -1){
+      list_notation = g_list_nth(machine->audio->notation,
+				 selected_channel);
+
+      notation_node = ags_notation_cut_selection(AGS_NOTATION(list_notation->data));
+
+      ags_note_edit_draw_segment(editor->note_edit, cr);
+      ags_note_edit_draw_notation(editor->note_edit, cr);
+
+      i++;
+    }
+
+    cairo_pop_group_to_source(cr);
+    cairo_paint(cr);
+      
+    xmlAddChild(audio_node, notation_node);
+
+    /* write to clipboard */
+    xmlDocDumpFormatMemoryEnc(clipboard, &buffer, &size, "UTF-8\0", TRUE);
+    gtk_clipboard_set_text(gtk_clipboard_get(GDK_SELECTION_CLIPBOARD),
+			   buffer, size);
+    gtk_clipboard_store(gtk_clipboard_get(GDK_SELECTION_CLIPBOARD));
+
+    xmlFreeDoc(clipboard);
+  }
+}
+
+/**
  * ags_editor_machine_changed:
  * @editor: an #AgsEditor
  * @machine: the new #AgsMachine
diff --git a/src/ags/X/ags_editor.h b/src/ags/X/ags_editor.h
index b5e7920..0d8976a 100644
--- a/src/ags/X/ags_editor.h
+++ b/src/ags/X/ags_editor.h
@@ -86,6 +86,12 @@ struct _AgsEditorClass
 
 GType ags_editor_get_type(void);
 
+void ags_editor_select_all(AgsEditor *editor);
+
+void ags_editor_paste(AgsEditor *copy);
+void ags_editor_copy(AgsEditor *copy);
+void ags_editor_cut(AgsEditor *copy);
+
 void ags_editor_machine_changed(AgsEditor *editor, AgsMachine *machine);
 
 AgsEditor* ags_editor_new();
diff --git a/src/ags/X/editor/ags_note_edit_callbacks.c b/src/ags/X/editor/ags_note_edit_callbacks.c
index acb0d4c..78bc50a 100644
--- a/src/ags/X/editor/ags_note_edit_callbacks.c
+++ b/src/ags/X/editor/ags_note_edit_callbacks.c
@@ -713,14 +713,12 @@ ags_note_edit_drawing_area_motion_notify_event(GtkWidget *widget, GdkEventMotion
 gboolean
 ags_note_edit_drawing_area_key_press_event(GtkWidget *widget, GdkEventKey *event, AgsNoteEdit *note_edit)
 {
-  AgsMachine *machine;
   AgsEditor *editor;
-  
+
   editor = (AgsEditor *) gtk_widget_get_ancestor(GTK_WIDGET(note_edit),
 						 AGS_TYPE_EDITOR);
 
   if(editor->selected_machine != NULL){
-    machine = editor->selected_machine;
 
     switch(event->keyval){
     case GDK_KEY_Control_L:
@@ -735,35 +733,33 @@ ags_note_edit_drawing_area_key_press_event(GtkWidget *widget, GdkEventKey *event
       break;
     case GDK_KEY_a:
       {
-	/* select notes */
+	/* select all notes */
 	if((AGS_NOTE_EDIT_KEY_L_CONTROL & (note_edit->key_mask)) != 0 || (AGS_NOTE_EDIT_KEY_R_CONTROL & (note_edit->key_mask)) != 0){
-	  cairo_t *cr;
-    
-	  GList *list_notation;
-
-	  gint i;
-	  gint selected_channel;
-
-	  cr = gdk_cairo_create(widget->window);
-	  cairo_push_group(cr);
-      
-	  list_notation = machine->audio->notation;
-	  i = 0;
-
-	  while((selected_channel = ags_notebook_next_active_tab(editor->notebook,
-								 i)) != -1){
-	    list_notation = g_list_nth(machine->audio->notation,
-				       selected_channel);
-	    ags_notation_add_all_to_selection(AGS_NOTATION(list_notation->data));
-
-	    i++;
-	  }
-
-	  ags_note_edit_draw_segment(note_edit, cr);
-	  ags_note_edit_draw_notation(note_edit, cr);
-
-	  cairo_pop_group_to_source(cr);
-	  cairo_paint(cr);
+	  ags_editor_select_all(editor);
+	}
+      }
+      break;
+    case GDK_KEY_c:
+      {
+	/* copy notes */
+	if((AGS_NOTE_EDIT_KEY_L_CONTROL & (note_edit->key_mask)) != 0 || (AGS_NOTE_EDIT_KEY_R_CONTROL & (note_edit->key_mask)) != 0){
+	  ags_editor_copy(editor);
+	}
+      }
+      break;
+    case GDK_KEY_v:
+      {
+	/* paste notes */
+	if((AGS_NOTE_EDIT_KEY_L_CONTROL & (note_edit->key_mask)) != 0 || (AGS_NOTE_EDIT_KEY_R_CONTROL & (note_edit->key_mask)) != 0){
+	  ags_editor_paste(editor);
+	}
+      }
+      break;
+    case GDK_KEY_x:
+      {
+	/* cut notes */
+	if((AGS_NOTE_EDIT_KEY_L_CONTROL & (note_edit->key_mask)) != 0 || (AGS_NOTE_EDIT_KEY_R_CONTROL & (note_edit->key_mask)) != 0){
+	  ags_editor_cut(editor);
 	}
       }
       break;
diff --git a/src/ags/X/editor/ags_toolbar_callbacks.c b/src/ags/X/editor/ags_toolbar_callbacks.c
index f8aaf06..550dd0f 100644
--- a/src/ags/X/editor/ags_toolbar_callbacks.c
+++ b/src/ags/X/editor/ags_toolbar_callbacks.c
@@ -21,9 +21,6 @@
 #include <ags/X/ags_editor.h>
 #include <ags/X/editor/ags_note_edit.h>
 
-#include <libxml/tree.h>
-#include <libxml/xpath.h>
-
 #include <math.h>
 
 void
@@ -149,163 +146,22 @@ ags_toolbar_copy_or_cut_callback(GtkWidget *widget, AgsToolbar *toolbar)
   editor = AGS_EDITOR(gtk_widget_get_ancestor(GTK_WIDGET(toolbar), AGS_TYPE_EDITOR));
 
   if((machine = editor->selected_machine) != NULL){
-    /* create document */
-    clipboard = xmlNewDoc(BAD_CAST XML_DEFAULT_VERSION);
-
-    /* create root node */
-    audio_node = xmlNewNode(NULL, BAD_CAST "audio\0");
-    xmlDocSetRootElement(clipboard, audio_node);
-
-    /* create notation nodes */
-    list_notation = machine->audio->notation;
-    i = 0;
-
-    while((selected_channel = ags_notebook_next_active_tab(editor->notebook,
-							   i)) != -1){
-      list_notation = g_list_nth(machine->audio->notation,
-				 selected_channel);
-
-      if(widget == (GtkWidget *) toolbar->copy){
-	notation_node = ags_notation_copy_selection(AGS_NOTATION(list_notation->data));
-      }else{
-	cairo_t *cr;
-
-	cr = gdk_cairo_create(GTK_WIDGET(editor->note_edit->drawing_area)->window);
-	cairo_push_group(cr);
-
-	notation_node = ags_notation_cut_selection(AGS_NOTATION(list_notation->data));
-
-	ags_note_edit_draw_segment(editor->note_edit, cr);
-	ags_note_edit_draw_notation(editor->note_edit, cr);
-
-	cairo_pop_group_to_source(cr);
-	cairo_paint(cr);
-      }
-      
-      xmlAddChild(audio_node, notation_node);
-
-      i++;
+    if(widget == (GtkWidget *) toolbar->copy){
+      ags_editor_copy(editor);
+    }else{
+      ags_editor_cut(editor);
     }
-    
-    /* write to clipboard */
-    xmlDocDumpFormatMemoryEnc(clipboard, &buffer, &size, "UTF-8\0", TRUE);
-    gtk_clipboard_set_text(gtk_clipboard_get(GDK_SELECTION_CLIPBOARD),
-			   buffer, size);
-    gtk_clipboard_store(gtk_clipboard_get(GDK_SELECTION_CLIPBOARD));
-
-    xmlFreeDoc(clipboard);
   }
 }
 
 void
 ags_toolbar_paste_callback(GtkWidget *widget, AgsToolbar *toolbar)
 {
-  AgsMachine *machine;
   AgsEditor *editor;
 
-  AgsNotation *notation;
-
-  xmlDocPtr clipboard;
-  xmlNodePtr audio_node, notation_node;
-  cairo_t *cr;
-  
-  gchar *buffer;
-  guint position_x, position_y;
-  gboolean paste_from_position;
-  
-  void ags_toolbar_paste_callback_read_notation(){
-    xmlXPathContextPtr xpathCtxt;
-    xmlXPathObjectPtr xpathObj;
-    xmlNodeSetPtr nodes;
-    GList *notation_list;
-
-    xpathCtxt = xmlXPathNewContext(clipboard);
-
-    xpathObj = xmlXPathEvalExpression("/audio/notation\0", xpathCtxt);
-
-    if(xpathObj != NULL){
-      int i, size;
-
-      nodes = xpathObj->nodesetval;
-      size = (nodes != NULL) ? nodes->nodeNr: 0;
-
-      notation_list = machine->audio->notation;
-
-      for(i = 0; i < size && notation_list != NULL; i++){
-	if(paste_from_position){
-	  ags_notation_insert_from_clipboard(AGS_NOTATION(notation_list->data),
-					     nodes->nodeTab[i],
-					     TRUE, position_x,
-					     TRUE, position_y);
-	}else{
-	  ags_notation_insert_from_clipboard(AGS_NOTATION(notation_list->data),
-					     nodes->nodeTab[i],
-					     FALSE, 0,
-					     FALSE, 0);
-	}
-
-	notation_list = notation_list->next;
-      }
-
-      xmlXPathFreeObject(xpathObj);
-    }
-
-    if(xpathCtxt != NULL)
-      xmlXPathFreeContext(xpathCtxt);
-  }
-
-  /* retrieve AgsEditor */
-  editor = AGS_EDITOR(gtk_widget_get_ancestor(GTK_WIDGET(toolbar), AGS_TYPE_EDITOR));
-
-  if((machine = editor->selected_machine) != NULL){
-    /* get clipboard */
-    buffer = gtk_clipboard_wait_for_text(gtk_clipboard_get(GDK_SELECTION_CLIPBOARD));
-    
-    if(buffer == NULL)
-      return;
-
-    /* get position */
-    if(toolbar->selected_edit_mode == toolbar->position){
-      paste_from_position = TRUE;
-
-      position_x = editor->note_edit->selected_x;
-      position_y = editor->note_edit->selected_y;
-
-      printf("pasting at position: [%u,%u]\n\0", position_x, position_y);
-    }else{
-      paste_from_position = FALSE;
-    }
-
-    /* get xml tree */
-    clipboard = xmlReadMemory(buffer, strlen(buffer),
-			      NULL, "UTF-8\0",
-			      0);
-    audio_node = xmlDocGetRootElement(clipboard);
-    
-    /* iterate xml tree */
-    while(audio_node != NULL){
-      if(audio_node->type == XML_ELEMENT_NODE && !xmlStrncmp("audio\0", audio_node->name, 6)){
-	notation_node = audio_node->children;
-	
-	ags_toolbar_paste_callback_read_notation();
-
-	break;
-      }
-      
-      audio_node = audio_node->next;
-    }
-
-    xmlFreeDoc(clipboard); 
-  }
-
-  cr = gdk_cairo_create(GTK_WIDGET(editor->note_edit->drawing_area)->window);
-  cairo_push_group(cr);
-
-  ags_note_edit_draw_segment(editor->note_edit, cr);
-  ags_note_edit_draw_notation(editor->note_edit, cr);
+  editor = (AgsEditor *) gtk_widget_get_ancestor(GTK_WIDGET(toolbar), AGS_TYPE_EDITOR);
 
-  cairo_pop_group_to_source(cr);
-  cairo_paint(cr);
+  ags_editor_paste(editor);
 }
 
 void
diff --git a/src/ags/audio/ags_notation.c b/src/ags/audio/ags_notation.c
index be4a0bc..6f2c94a 100644
--- a/src/ags/audio/ags_notation.c
+++ b/src/ags/audio/ags_notation.c
@@ -72,7 +72,7 @@ void ags_notation_insert_native_piano_from_clipboard(AgsNotation *notation,
  * #AgsNotation acts as a container of #AgsNote.
  */
 
-#define AGS_NOTATION_CLIPBOARD_VERSION "0.3.12\0"
+#define AGS_NOTATION_CLIPBOARD_VERSION "0.4.2\0"
 #define AGS_NOTATION_CLIPBOARD_TYPE "AgsNotationClipboardXml\0"
 #define AGS_NOTATION_CLIPBOARD_FORMAT "AgsNotationNativePiano\0"
 
@@ -1145,6 +1145,7 @@ ags_notation_copy_selection(AgsNotation *notation)
   xmlNewProp(notation_node, BAD_CAST "version\0", BAD_CAST AGS_NOTATION_CLIPBOARD_VERSION);
   xmlNewProp(notation_node, BAD_CAST "format\0", BAD_CAST AGS_NOTATION_CLIPBOARD_FORMAT);
   xmlNewProp(notation_node, BAD_CAST "base_frequency\0", BAD_CAST g_strdup_printf("%u\0", notation->base_frequency));
+  xmlNewProp(notation_node, BAD_CAST "audio-channel\0", BAD_CAST g_strdup_printf("%u\0", notation->audio_channel));
 
   selection = notation->selection;
 
@@ -1438,6 +1439,9 @@ ags_notation_insert_native_piano_from_clipboard(AgsNotation *notation,
 
   if(!xmlStrncmp("0.3.12\0", version, 7)){
     ags_notation_insert_native_piano_from_clipboard_version_0_3_12();
+  }else if(!xmlStrncmp("0.4.2\0", version, 7)){
+    /* changes contain only for UI relevant new informations */
+    ags_notation_insert_native_piano_from_clipboard_version_0_3_12();
   }
 }
 

-- 
gsequencer packaging



More information about the pkg-multimedia-commits mailing list