Skip to content

Commit

Permalink
remove gee as requested
Browse files Browse the repository at this point in the history
  • Loading branch information
dankamongmen committed Jan 7, 2013
1 parent d409358 commit e5f561b
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 44 deletions.
33 changes: 10 additions & 23 deletions src/cheese-effects-manager.vala
Expand Up @@ -20,17 +20,16 @@
*/

using GLib;
using Gee;

const string GROUP_NAME = "Effect";

internal class Cheese.EffectsManager : GLib.Object
{
public ArrayList<Effect> effects;
public GLib.Array<Effect> effects;

public EffectsManager ()
{
effects = new ArrayList<Effect>(Gee.Functions.get_equal_func_for(typeof(Effect)));
effects = new Array<Effect>();
}

/**
Expand All @@ -40,15 +39,15 @@ internal class Cheese.EffectsManager : GLib.Object
{
GLib.List<Cheese.Effect> effect_list = Cheese.Effect.load_effects ();
for (int i = 0; i < effect_list.length (); i++)
effects.add (effect_list<Cheese.Effect>.nth (i).data);
effects.append_val (effect_list<Cheese.Effect>.nth (i).data);

effects.sort (Gee.Functions.get_compare_func_for(typeof(Cheese.Effect)));
effects.sort ((GLib.CompareFunc)sort_value);

/* add identity effect as the first in the effect list */
if (effects.size > 0)
if (effects.length > 0)
{
Effect e = new Effect (_("No Effect"), "identity");
effects.insert (0, e);
effects.prepend_val (e);
}
}

Expand All @@ -60,26 +59,14 @@ internal class Cheese.EffectsManager : GLib.Object
*/
public Effect ? get_effect (string name)
{
foreach (Effect eff in effects)
{
if (eff.name == name)
return eff;
for(int i = 0 ; i < effects.length ; ++i){
if((string)effects.index(i) == name){
return effects.index(i);
}
}
return null;
}

/**
* Compare two effects by the pipeline description.
*
* @param a an effect to compare against
* @param b another effect to compare against
* @return true if the effects are the same, false otherwise
*/
private static bool cmp_value (Effect a, Effect b)
{
return a.pipeline_desc == b.pipeline_desc;
}

/**
* A sort function for effects
*
Expand Down
41 changes: 20 additions & 21 deletions src/cheese-window.vala
Expand Up @@ -26,7 +26,6 @@ using Clutter;
using Config;
using Eog;
using Gst;
using Gee;
using CanberraGtk;

[DBus(name = "org.freedesktop.PackageKit.Modify")]
Expand Down Expand Up @@ -77,7 +76,7 @@ public class Cheese.MainWindow : Gtk.ApplicationWindow

private Clutter.Box current_effects_grid;
private int current_effects_page = 0;
private ArrayList<Clutter.Box> effects_grids;
private GLib.Array<Clutter.Box> effects_grids;

private Gtk.ToggleAction wide_mode_action;
private Gtk.Action countdown_action;
Expand Down Expand Up @@ -1076,7 +1075,7 @@ public class Cheese.MainWindow : Gtk.ApplicationWindow
[CCode (instance_pos = -1)]
public void on_next_effects_page (Gtk.Action action)
{
if (current_effects_page != (effects_manager.effects.size / EFFECTS_PER_PAGE))
if (current_effects_page != (effects_manager.effects.length / EFFECTS_PER_PAGE))
{
activate_effects_page (current_effects_page + 1);
}
Expand All @@ -1096,15 +1095,15 @@ public class Cheese.MainWindow : Gtk.ApplicationWindow
{
viewport_layout.remove ((Clutter.Actor) current_effects_grid);
}
current_effects_grid = effects_grids[number];
current_effects_grid = effects_grids.index(number);
current_effects_grid.set ("opacity", 0);
viewport_layout.add ((Clutter.Actor) current_effects_grid);
current_effects_grid.animate (Clutter.AnimationMode.LINEAR, 1000, "opacity", 255);

for (int i = 0; i < effects_manager.effects.size; i++)
for (int i = 0; i < effects_manager.effects.length; i++)
{
int page_of_effect = i / EFFECTS_PER_PAGE;
Cheese.Effect effect = effects_manager.effects[i];
Cheese.Effect effect = effects_manager.effects.index(i);
if (page_of_effect == number)
{
if (!effect.is_preview_connected ())
Expand All @@ -1130,7 +1129,7 @@ public class Cheese.MainWindow : Gtk.ApplicationWindow
{
effects_page_prev_action.sensitive = (is_effects_selector_active && current_effects_page != 0);
effects_page_next_action.sensitive =
(is_effects_selector_active && current_effects_page != effects_manager.effects.size / EFFECTS_PER_PAGE);
(is_effects_selector_active && current_effects_page != effects_manager.effects.length / EFFECTS_PER_PAGE);
}

/**
Expand All @@ -1145,7 +1144,7 @@ public class Cheese.MainWindow : Gtk.ApplicationWindow
{
video_preview.hide ();

if (effects_grids.size == 0)
if (effects_grids.length == 0)
{
error_layer.text = _("No effects found");
error_layer.show ();
Expand All @@ -1158,7 +1157,7 @@ public class Cheese.MainWindow : Gtk.ApplicationWindow
}
else
{
if (effects_grids.size == 0)
if (effects_grids.length == 0)
{
error_layer.hide ();
}
Expand All @@ -1184,26 +1183,26 @@ public class Cheese.MainWindow : Gtk.ApplicationWindow
effects_manager.load_effects ();

/* Must initialize effects_grids before returning, as it is dereferenced later, bug 654671. */
effects_grids = new ArrayList<Clutter.Box> ();
effects_grids = new GLib.Array<Clutter.Box> ();

if (effects_manager.effects.size == 0)
if (effects_manager.effects.length == 0)
{
warning ("gnome-video-effects is not installed.");
return;
}

for (int i = 0; i <= effects_manager.effects.size / EFFECTS_PER_PAGE; i++)
for (int i = 0; i <= effects_manager.effects.length / EFFECTS_PER_PAGE; i++)
{
Clutter.TableLayout table_layout = new TableLayout ();
Clutter.Box grid = new Clutter.Box (table_layout);
effects_grids.add (grid);
effects_grids.append_val (grid);
table_layout.set_column_spacing (10);
table_layout.set_row_spacing (10);
}

for (int i = 0; i < effects_manager.effects.size; i++)
for (int i = 0; i < effects_manager.effects.length; i++)
{
Effect effect = effects_manager.effects[i];
Effect effect = effects_manager.effects.index(i);
Clutter.Texture texture = new Clutter.Texture ();
Clutter.BinLayout layout = new Clutter.BinLayout (Clutter.BinAlignment.CENTER,
Clutter.BinAlignment.CENTER);
Expand Down Expand Up @@ -1234,19 +1233,19 @@ public class Cheese.MainWindow : Gtk.ApplicationWindow
"x-align", Clutter.BinAlignment.CENTER,
"y-align", Clutter.BinAlignment.END, null);

Clutter.TableLayout table_layout = (Clutter.TableLayout) effects_grids[i / EFFECTS_PER_PAGE].layout_manager;
Clutter.TableLayout table_layout = (Clutter.TableLayout) effects_grids.index(i / EFFECTS_PER_PAGE).layout_manager;
table_layout.pack ((Clutter.Actor) box,
(i % EFFECTS_PER_PAGE) % 3,
(i % EFFECTS_PER_PAGE) / 3);
table_layout.set_expand (box, false, false);
}

setup_effects_page_switch_sensitivity ();
current_effects_grid = effects_grids[0];
current_effects_grid = effects_grids.index(0);
}
}

private Gee.HashMap<string, bool> action_sensitivities;
private HashTable<string, bool> action_sensitivities;
/**
* Toggle the sensitvity of the camera actions.
*
Expand All @@ -1257,16 +1256,16 @@ public class Cheese.MainWindow : Gtk.ApplicationWindow
is_camera_actions_sensitive = active;
if (active)
{
foreach (string key in action_sensitivities.keys)
/*List<string> keys = new List<string>(action_sensitivities.get_keys());*/
foreach (string key in action_sensitivities.get_keys())
{
Gtk.Action action = gtk_builder.get_object (key) as Gtk.Action;
action.sensitive = action_sensitivities.get (key);
}
}
else
{
action_sensitivities = new HashMap<string, bool>
(Gee.Functions.get_hash_func_for(typeof(string)));
action_sensitivities = new GLib.HashTable<string, bool>(str_hash, str_equal);
GLib.SList<weak GLib.Object> objects = gtk_builder.get_objects ();
foreach (GLib.Object obj in objects)
{
Expand Down

0 comments on commit e5f561b

Please sign in to comment.