src/interface/vapiGtkMacroItemMove.c

Ir para a documentação deste ficheiro.
00001 #include <gtk/gtk.h>
00002 #include <glade/glade.h>
00003 #include "vapiMacroList.h"
00004 #include "vapiMacro.h"
00005 #include "vapiGtkMacrosTables.h"
00006 #include "vapiGtkMacroItemMove.h"
00007 #include "vapiGtkMacro.h"
00008 #include "vapiMacroBypass.h"
00009 
00010 static struct _vGtkMacroItemMove
00011 {
00012 
00013         vMacroList *MacroList;
00014 } GtkMacroItemMove;
00015 
00016 void
00017 vapiGtkMacroItemMoveInit (GladeXML * xml, vMacroList * MacroList)
00018 {
00019         GtkWidget *MoveToTop;
00020         GtkWidget *MoveUp;
00021         GtkWidget *MoveDown;
00022         GtkWidget *MoveToBottom;
00023 
00024         GtkMacroItemMove.MacroList = MacroList;
00025         MoveUp = glade_xml_get_widget (xml, "btMacroItemUp");
00026         MoveDown = glade_xml_get_widget (xml, "btMacroItemDown");
00027         MoveToTop = glade_xml_get_widget (xml, "btMacroItemToTop");
00028         MoveToBottom = glade_xml_get_widget (xml, "btMacroItemToBottom");
00029 
00030         g_signal_connect (G_OBJECT (MoveUp), "clicked",
00031                           G_CALLBACK (vapiGtkMacroItemMoveUp), NULL);
00032         g_signal_connect (G_OBJECT (MoveDown), "clicked",
00033                           G_CALLBACK (vapiGtkMacroItemMoveDown), NULL);
00034         g_signal_connect (G_OBJECT (MoveToTop), "clicked",
00035                           G_CALLBACK (vapiGtkMacroItemMoveToTop), NULL);
00036         g_signal_connect (G_OBJECT (MoveToBottom), "clicked",
00037                           G_CALLBACK (vapiGtkMacroItemMoveToBottom), NULL);
00038 
00039 }
00040 
00041 void
00042 vapiGtkMacroItemMoveUp (GtkWidget * widget, gpointer data)
00043 {
00044         int selectedItem;
00045         vMacroHeader *MacroHeader;
00046         vMacroItem *Item;
00047         if (SelectedMacro < 0)
00048         {
00049                 return;
00050         }
00051 
00052         selectedItem = vapiGtkMacroTableGetSelected ();
00053 
00054         if (selectedItem <= 0)
00055         {
00056                 return;
00057         }
00058 
00059 
00060         MacroHeader =
00061                 vapiMacroListSelectItem (GtkMacroItemMove.MacroList,
00062                                          SelectedMacro);
00063 
00064         Item = v_list_get (MacroHeader->Macro, selectedItem);
00065 
00066         v_list_delete_item (MacroHeader->Macro, NULL, selectedItem);
00067 
00068         selectedItem--;
00069 
00070         v_list_insert (MacroHeader->Macro, Item, selectedItem);
00071 
00072         v_bypass_set_updatable(vTRUE);
00073         vapiGtkMacroTable ();
00074         
00075         vapiGtkMacroTableSelectRow(selectedItem);
00076 }
00077 
00078 void
00079 vapiGtkMacroItemMoveDown (GtkWidget * widget, gpointer data)
00080 {
00081         int selectedItem, MacroSize;
00082         vMacroHeader *MacroHeader;
00083         vMacroItem *Item;
00084         if (SelectedMacro < 0)
00085         {
00086                 return;
00087         }
00088 
00089         selectedItem = vapiGtkMacroTableGetSelected ();
00090         MacroHeader =
00091                 vapiMacroListSelectItem (GtkMacroItemMove.MacroList,
00092                                          SelectedMacro);
00093 
00094         MacroSize = vapiMacroCountElements (MacroHeader->Macro);
00095         if (selectedItem < 0 || selectedItem == (MacroSize - 1))
00096         {
00097                 return;
00098         }
00099 
00100         Item = v_list_get (MacroHeader->Macro, selectedItem);
00101 
00102         v_list_delete_item (MacroHeader->Macro, NULL, selectedItem);
00103 
00104         selectedItem++;
00105 
00106         if (selectedItem < (MacroSize - 1))
00107         {
00108                 v_list_insert (MacroHeader->Macro, Item, selectedItem);
00109         }
00110         else
00111         {
00112                 v_list_append (MacroHeader->Macro, Item);
00113         }
00114         v_bypass_set_updatable(vTRUE);
00115         vapiGtkMacroTable ();
00116         vapiGtkMacroTableSelectRow(selectedItem);
00117 }
00118 
00119 void
00120 vapiGtkMacroItemMoveToTop (GtkWidget * widget, gpointer data)
00121 {
00122         int selectedItem;
00123         vMacroHeader *MacroHeader;
00124         vMacroItem *Item;
00125         if (SelectedMacro < 0)
00126         {
00127                 return;
00128         }
00129 
00130         selectedItem = vapiGtkMacroTableGetSelected ();
00131 
00132         if (selectedItem <= 0)
00133         {
00134                 return;
00135         }
00136 
00137 
00138         MacroHeader =
00139                 vapiMacroListSelectItem (GtkMacroItemMove.MacroList,
00140                                          SelectedMacro);
00141 
00142         Item = v_list_get (MacroHeader->Macro, selectedItem);
00143 
00144         v_list_delete_item (MacroHeader->Macro, NULL, selectedItem);
00145 
00146         
00147 
00148         v_list_insert (MacroHeader->Macro, Item, 0);
00149         v_bypass_set_updatable(vTRUE);
00150         vapiGtkMacroTable ();
00151         vapiGtkMacroTableSelectRow(0);
00152 }
00153 
00154 void
00155 vapiGtkMacroItemMoveToBottom (GtkWidget * widget, gpointer data)
00156 {
00157         int selectedItem, MacroSize;
00158         vMacroHeader *MacroHeader;
00159         vMacroItem *Item;
00160         if (SelectedMacro < 0)
00161         {
00162                 return;
00163         }
00164 
00165         selectedItem = vapiGtkMacroTableGetSelected ();
00166         MacroHeader =
00167                 vapiMacroListSelectItem (GtkMacroItemMove.MacroList,
00168                                          SelectedMacro);
00169 
00170         MacroSize = vapiMacroCountElements (MacroHeader->Macro);
00171         if (selectedItem < 0 || selectedItem == (MacroSize - 1))
00172         {
00173                 return;
00174         }
00175 
00176         Item = v_list_get (MacroHeader->Macro, selectedItem);
00177 
00178         v_list_delete_item (MacroHeader->Macro, NULL, selectedItem);
00179 
00180         v_list_append (MacroHeader->Macro, Item);
00181         
00182         v_bypass_set_updatable(vTRUE);
00183         vapiGtkMacroTable ();
00184         
00185         vapiGtkMacroTableSelectRow(MacroSize-1);
00186 }

Gerado em Tue Jul 24 10:34:58 2007 para Vapi por  doxygen 1.5.1