ges/ges-timeline-transition.c: initialize vtype enum type from static list of
authorBrandon Lewis <brandon@collabora.co.uk>
Fri, 4 Jun 2010 16:07:39 +0000 (18:07 +0200)
committerEdward Hervey <edward.hervey@collabora.co.uk>
Wed, 9 Jun 2010 09:28:46 +0000 (11:28 +0200)
GEnumValues

ges/ges-timeline-transition.c

index ad4d49064dbf6dd90ec0d29848829b0242af85da..f3752131d15e7752c3af2e0df7a170dcc16725d3 100644 (file)
@@ -152,91 +152,329 @@ ges_tl_transition_create_track_object (GESTimelineObject * obj,
   return res;
 }
 
-GESTimelineTransition *
-ges_timeline_transition_new (gint vtype)
-{
-  GESTimelineTransition *ret = g_object_new
-      (GES_TYPE_TIMELINE_TRANSITION, NULL);
-
-  g_object_set (ret, "vtype", (gint) vtype, NULL);
-  return ret;
-}
-
-static GEnumClass *smpte_enum_class = NULL;
-
-static void
-_ensure_smpte_enum_class ()
-{
-  /* is there a better way to do this? */
-
-  if (!smpte_enum_class) {
-    GstElement *element = gst_element_factory_make ("smpte", NULL);
-    GstElementClass *element_class = GST_ELEMENT_GET_CLASS (element);
-
-    GParamSpec *pspec =
-        g_object_class_find_property (G_OBJECT_CLASS (element_class), "type");
-
-    smpte_enum_class = G_ENUM_CLASS (g_type_class_ref (pspec->value_type));
-  }
-
-}
+static GEnumValue transition_types[] = {
+  {
+        1,
+        "A bar moves from left to right",
+      "bar-wipe-lr"},
+  {
+        2,
+        "A bar moves from top to bottom",
+      "bar-wipe-tb"},
+  {
+        3,
+        "A box expands from the upper-left corner to the lower-right corner",
+      "box-wipe-tl"},
+  {
+        4,
+        "A box expands from the upper-right corner to the lower-left corner",
+      "box-wipe-tr"},
+  {
+        5,
+        "A box expands from the lower-right corner to the upper-left corner",
+      "box-wipe-br"},
+  {
+        6,
+        "A box expands from the lower-left corner to the upper-right corner",
+      "box-wipe-bl"},
+  {
+        7,
+        "A box shape expands from each of the four corners toward the center",
+      "four-box-wipe-ci"},
+  {
+        8,
+        "A box shape expands from the center of each quadrant toward the corners of each quadrant",
+      "four-box-wipe-co"},
+  {
+        21,
+        "A central, vertical line splits and expands toward the left and right edges",
+      "barndoor-v"},
+  {
+        22,
+        "A central, horizontal line splits and expands toward the top and bottom edges",
+      "barndoor-h"},
+  {
+        23,
+        "A box expands from the top edge's midpoint to the bottom corners",
+      "box-wipe-tc"},
+  {
+        24,
+        "A box expands from the right edge's midpoint to the left corners",
+      "box-wipe-rc"},
+  {
+        25,
+        "A box expands from the bottom edge's midpoint to the top corners",
+      "box-wipe-bc"},
+  {
+        26,
+        "A box expands from the left edge's midpoint to the right corners",
+      "box-wipe-lc"},
+  {
+        41,
+        "A diagonal line moves from the upper-left corner to the lower-right corner",
+      "diagonal-tl"},
+  {
+        42,
+        "A diagonal line moves from the upper right corner to the lower-left corner",
+      "diagonal-tr"},
+  {
+        43,
+        "Two wedge shapes slide in from the top and bottom edges toward the center",
+      "bowtie-v"},
+  {
+        44,
+        "Two wedge shapes slide in from the left and right edges toward the center",
+      "bowtie-h"},
+  {
+        45,
+        "A diagonal line from the lower-left to upper-right corners splits and expands toward the opposite corners",
+      "barndoor-dbl"},
+  {
+        46,
+        "A diagonal line from upper-left to lower-right corners splits and expands toward the opposite corners",
+      "barndoor-dtl"},
+  {
+        47,
+        "Four wedge shapes split from the center and retract toward the four edges",
+      "misc-diagonal-dbd"},
+  {
+        48,
+        "A diamond connecting the four edge midpoints simultaneously contracts toward the center and expands toward the edges",
+      "misc-diagonal-dd"},
+  {
+        61,
+        "A wedge shape moves from top to bottom",
+      "vee-d"},
+  {
+        62,
+        "A wedge shape moves from right to left",
+      "vee-l"},
+  {
+        63,
+        "A wedge shape moves from bottom to top",
+      "vee-u"},
+  {
+        64,
+        "A wedge shape moves from left to right",
+      "vee-r"},
+  {
+        65,
+        "A 'V' shape extending from the bottom edge's midpoint to the opposite corners contracts toward the center and expands toward the edges",
+      "barnvee-d"},
+  {
+        66,
+        "A 'V' shape extending from the left edge's midpoint to the opposite corners contracts toward the center and expands toward the edges",
+      "barnvee-l"},
+  {
+        67,
+        "A 'V' shape extending from the top edge's midpoint to the opposite corners contracts toward the center and expands toward the edges",
+      "barnvee-u"},
+  {
+        68,
+        "A 'V' shape extending from the right edge's midpoint to the opposite corners contracts toward the center and expands toward the edges",
+      "barnvee-r"},
+  {
+        101,
+        "A rectangle expands from the center.",
+      "iris-rect"},
+  {
+        201,
+        "A radial hand sweeps clockwise from the twelve o'clock position",
+      "clock-cw12"},
+  {
+        202,
+        "A radial hand sweeps clockwise from the three o'clock position",
+      "clock-cw3"},
+  {
+        203,
+        "A radial hand sweeps clockwise from the six o'clock position",
+      "clock-cw6"},
+  {
+        204,
+        "A radial hand sweeps clockwise from the nine o'clock position",
+      "clock-cw9"},
+  {
+        205,
+        "Two radial hands sweep clockwise from the twelve and six o'clock positions",
+      "pinwheel-tbv"},
+  {
+        206,
+        "Two radial hands sweep clockwise from the nine and three o'clock positions",
+      "pinwheel-tbh"},
+  {
+        207,
+        "Four radial hands sweep clockwise",
+      "pinwheel-fb"},
+  {
+        211,
+        "A fan unfolds from the top edge, the fan axis at the center",
+      "fan-ct"},
+  {
+        212,
+        "A fan unfolds from the right edge, the fan axis at the center",
+      "fan-cr"},
+  {
+        213,
+        "Two fans, their axes at the center, unfold from the top and bottom",
+      "doublefan-fov"},
+  {
+        214,
+        "Two fans, their axes at the center, unfold from the left and right",
+      "doublefan-foh"},
+  {
+        221,
+        "A radial hand sweeps clockwise from the top edge's midpoint",
+      "singlesweep-cwt"},
+  {
+        222,
+        "A radial hand sweeps clockwise from the right edge's midpoint",
+      "singlesweep-cwr"},
+  {
+        223,
+        "A radial hand sweeps clockwise from the bottom edge's midpoint",
+      "singlesweep-cwb"},
+  {
+        224,
+        "A radial hand sweeps clockwise from the left edge's midpoint",
+      "singlesweep-cwl"},
+  {
+        225,
+        "Two radial hands sweep clockwise and counter-clockwise from the top and bottom edges' midpoints",
+      "doublesweep-pv"},
+  {
+        226,
+        "Two radial hands sweep clockwise and counter-clockwise from the left and right edges' midpoints",
+      "doublesweep-pd"},
+  {
+        227,
+        "Two radial hands attached at the top and bottom edges' midpoints sweep from right to left",
+      "doublesweep-ov"},
+  {
+        228,
+        "Two radial hands attached at the left and right edges' midpoints sweep from top to bottom",
+      "doublesweep-oh"},
+  {
+        231,
+        "A fan unfolds from the bottom, the fan axis at the top edge's midpoint",
+      "fan-t"},
+  {
+        232,
+        "A fan unfolds from the left, the fan axis at the right edge's midpoint",
+      "fan-r"},
+  {
+        233,
+        "A fan unfolds from the top, the fan axis at the bottom edge's midpoint",
+      "fan-b"},
+  {
+        234,
+        "A fan unfolds from the right, the fan axis at the left edge's midpoint",
+      "fan-l"},
+  {
+        235,
+        "Two fans, their axes at the top and bottom, unfold from the center",
+      "doublefan-fiv"},
+  {
+        236,
+        "Two fans, their axes at the left and right, unfold from the center",
+      "doublefan-fih"},
+  {
+        241,
+        "A radial hand sweeps clockwise from the upper-left corner",
+      "singlesweep-cwtl"},
+  {
+        242,
+        "A radial hand sweeps counter-clockwise from the lower-left corner.",
+      "singlesweep-cwbl"},
+  {
+        243,
+        "A radial hand sweeps clockwise from the lower-right corner",
+      "singlesweep-cwbr"},
+  {
+        244,
+        "A radial hand sweeps counter-clockwise from the upper-right corner",
+      "singlesweep-cwtr"},
+  {
+        245,
+        "Two radial hands attached at the upper-left and lower-right corners sweep down and up",
+      "doublesweep-pdtl"},
+  {
+        246,
+        "Two radial hands attached at the lower-left and upper-right corners sweep down and up",
+      "doublesweep-pdbl"},
+  {
+        251,
+        "Two radial hands attached at the upper-left and upper-right corners sweep down",
+      "saloondoor-t"},
+  {
+        252,
+        "Two radial hands attached at the upper-left and lower-left corners sweep to the right",
+      "saloondoor-l"},
+  {
+        253,
+        "Two radial hands attached at the lower-left and lower-right corners sweep up",
+      "saloondoor-b"},
+  {
+        254,
+        "Two radial hands attached at the upper-right and lower-right corners sweep to the left",
+      "saloondoor-r"},
+  {
+        261,
+        "Two radial hands attached at the midpoints of the top and bottom halves sweep from right to left",
+      "windshield-r"},
+  {
+        262,
+        "Two radial hands attached at the midpoints of the left and right halves sweep from top to bottom",
+      "windshield-u"},
+  {
+        263,
+        "Two sets of radial hands attached at the midpoints of the top and bottom halves sweep from top to bottom and bottom to top",
+      "windshield-v"},
+  {
+        264,
+        "Two sets of radial hands attached at the midpoints of the left and right halves sweep from left to right and right to left",
+      "windshield-h"},
+  {
+        VTYPE_CROSSFADE,
+        "Crossfade between two clips",
+      "crossfade"},
+  {0, NULL, NULL}
+};
 
 /* how many types could GType type if GType could type types? */
 
 static GType
 ges_type_timeline_transition_vtype_get_type (void)
 {
-  _ensure_smpte_enum_class ();
-
   static GType the_type = 0;
+  static gsize once = 0;
 
-  if (!the_type) {
-    GEnumValue *values, *src, *dst;
-    gint i, n;
+  if (g_once_init_enter (&once)) {
+    g_assert (!once);
 
-    n = smpte_enum_class->n_values;
-
-    /* plus one for sentinel, plus another for the crossfade GEnumValue */
-    values = g_new0 (GEnumValue, 2 + n);
-
-    for (i = 0, dst = values, src = smpte_enum_class->values; i < n;
-        i++, dst++, src++) {
-      dst->value = src->value;
-      dst->value_nick = src->value_nick;
-      dst->value_name = src->value_name;
-    }
-
-    dst->value = VTYPE_CROSSFADE;
-    dst->value_name = "Cross-fade between two sources";
-    dst->value_nick = "crossfade";
-
-    dst++;
-
-    dst->value = 0;
-    dst->value_nick = NULL;
-    dst->value_name = NULL;
-
-    the_type = g_enum_register_static ("GESTimelineTransitionVType", values);
+    the_type = g_enum_register_static ("GESTimelineTransitionVType",
+        transition_types);
+    g_once_init_leave (&once, 1);
   }
 
   return the_type;
 }
 
 GESTimelineTransition *
-ges_timeline_transition_new_for_nick (char *nick)
+ges_timeline_transition_new (gint vtype)
 {
+  GESTimelineTransition *ret;
 
-  _ensure_smpte_enum_class ();
-
-  if (!strcmp ("crossfade", nick)) {
-    return ges_timeline_transition_new (VTYPE_CROSSFADE);
-  }
-
-  GEnumValue *value = g_enum_get_value_by_nick (smpte_enum_class, nick);
+  ret = g_object_new (GES_TYPE_TIMELINE_TRANSITION, "vtype", (gint) vtype,
+      NULL);
+  return ret;
+}
 
-  if (!value) {
-    return NULL;
-  }
+GESTimelineTransition *
+ges_timeline_transition_new_for_nick (gchar * nick)
+{
+  GESTimelineTransition *ret;
+  ret = g_object_new (GES_TYPE_TIMELINE_TRANSITION, NULL);
+  g_object_set (ret, "vtype", (gchar *) nick, NULL);
 
-  return ges_timeline_transition_new (value->value);
+  return ret;
 }