src/interface/vapiGtkMacrosTables.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 "vapiGtkEventsMacros.h"
00007 #include "vapiGtkInterface.h"
00008 #include "vapiGtkTable.h"
00009 #include "vapiGtkMacro.h"
00010 #include "vapiMacroBypass.h"
00011 
00012 #define ByPassColumnName "Executar"
00013 #define StopByColumnName "Mostrar"
00014 
00018 //#define USE_SCROLLED_WINDOWS
00019 
00020 static struct _vMacroTables
00021 {
00022         GtkWidget *MacroNotebook;
00023         GtkWidget *lblMainMacro;
00024         GtkWidget *MainMacroTable;
00025         vMacroList *MacroList;
00026         gulong NotebookEventId;
00027         GtkWidget *cbMacro;
00028         vImages *Images;
00029 } MacroTables;
00030 
00031 typedef struct _vMacroTagDecode
00032 {
00033         int *Indexes;
00034         int NumberOfIndexes;
00035         char *MacroName;
00036 } vMacroTagDecode;
00037 
00038 vMacroTablesSelect *MacroTablesSelect;
00039 
00040 
00041 /*
00042  * Protótipos.
00043  */
00044 static void vapiGtkMacroTagDecodeAddIndex (vMacroTagDecode * MacroTagDecode,
00045                                            int newIndex);
00046 
00047 static void vMacroTagDecodeFree (vMacroTagDecode * vFree);
00048 
00049 vMacroTagDecode *vapiGtkTablesMacroTagDecoder (const char *macroTag);
00050 
00051 static char *vapiGtkMacroMacroTagEncode (vMacroTagDecode * MacroTagDecode);
00052 
00053 static int vapiGtkMacroTablesAddTable (GtkWidget * table, GtkWidget * label);
00054 
00055 static const char *vapiGtkMacroTablesGetMacroTag (int notebook_page);
00056 
00057 void
00058 vapiGtkMacrosTablesInit (GladeXML * xml, vMacroList * MacroList,
00059                          GList ** List0, GList ** List1, GList ** List2,
00060                          vImages * Images)
00061 {
00062         GtkCellRenderer *renderer;
00063 
00064         MacroTablesSelect = malloc (sizeof (vMacroTablesSelect));;
00065         MacroTables.MacroNotebook =
00066                 glade_xml_get_widget (xml, "MacroNotebook");
00067         MacroTables.lblMainMacro = glade_xml_get_widget (xml, "lblMainMacro");
00068         MacroTables.MainMacroTable = glade_xml_get_widget (xml, "treeMacro");
00069         MacroTablesSelect->txtOperation =
00070                 glade_xml_get_widget (xml, "txtOperation");
00071         MacroTables.cbMacro = glade_xml_get_widget (xml, "cbMacro");
00072         MacroTablesSelect->imActual = glade_xml_get_widget (xml, "imActual");
00073         MacroTables.MacroList = MacroList;
00074         MacroTablesSelect->Images = Images;
00075         MacroTables.Images = Images;
00076         MacroTablesSelect->MacroList = MacroList;
00077 
00078         MacroTablesSelect->Lists[0] = List0;
00079         MacroTablesSelect->Lists[1] = List1;
00080         MacroTablesSelect->Lists[2] = List2;
00081 
00082         gtk_notebook_set_scrollable ((GtkNotebook *) MacroTables.
00083                                      MacroNotebook, TRUE);
00084         gtk_notebook_set_show_tabs ((GtkNotebook *) MacroTables.
00085                                     MacroNotebook, TRUE);
00086 
00087 
00088         gtk_tree_selection_set_mode (gtk_tree_view_get_selection
00089                                      (GTK_TREE_VIEW
00090                                       (MacroTables.MainMacroTable)),
00091                                      GTK_SELECTION_SINGLE);
00092 
00093         renderer = gtk_cell_renderer_text_new ();
00094         gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW
00095                                                      (MacroTables.
00096                                                       MainMacroTable), -1,
00097                                                      "id", renderer, "text",
00098                                                      0, NULL);
00099 
00100         renderer = gtk_cell_renderer_toggle_new ();
00101         g_signal_connect (renderer, "toggled",
00102                           G_CALLBACK (vapiGtkMacroSetStopby), NULL);
00103         g_object_set (renderer, "activatable", TRUE, NULL);
00104         gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW
00105                                                      (MacroTables.
00106                                                       MainMacroTable), -1,
00107                                                      StopByColumnName,
00108                                                      renderer, "active", 1,
00109                                                      NULL);
00110 
00111 
00112         renderer = gtk_cell_renderer_toggle_new ();
00113         g_signal_connect (renderer, "toggled",
00114                           G_CALLBACK (vapiGtkMacroSetBypass), NULL);
00115         g_object_set (renderer, "activatable", TRUE, NULL);
00116         gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW
00117                                                      (MacroTables.
00118                                                       MainMacroTable), -1,
00119                                                      ByPassColumnName,
00120                                                      renderer, "active", 2,
00121                                                      NULL);
00122 
00123 
00124         renderer = gtk_cell_renderer_text_new ();
00125         gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW
00126                                                      (MacroTables.
00127                                                       MainMacroTable), -1,
00128                                                      "Operação", renderer,
00129                                                      "text", 3, NULL);
00130         /*
00131          * Adicionar uma linha em banco para apenas aparecer o título da Coluna
00132          */
00133         vapiGtkMacrosTablesCleanToDefault ();
00134 
00135         MacroTables.NotebookEventId =
00136                 g_signal_connect_after (G_OBJECT (MacroTables.MacroNotebook),
00137                                         "switch-page",
00138                                         G_CALLBACK
00139                                         (vapiGtkMacrosTableSetSelectedMacro),
00140                                         NULL);
00141 
00142         g_signal_connect (G_OBJECT (MacroTables.MainMacroTable),
00143                           "row_activated",
00144                           G_CALLBACK (vapiGtkMacroSelectItem),
00145                           MacroTablesSelect);
00146 
00147 
00148         g_signal_connect (G_OBJECT (MacroTables.cbMacro), "changed",
00149                           G_CALLBACK (vapiGtkMacroSelect), NULL);
00150 
00151 }
00152 
00153 static void
00154 vapiGtkMacrosTablesClean ()
00155 {
00156         int n_pages, i;
00157 
00158         n_pages =
00159                 gtk_notebook_get_n_pages ((GtkNotebook *) MacroTables.
00160                                           MacroNotebook);
00161 
00162         if (n_pages == 1)
00163         {
00164                 return;
00165         }
00166         for (i = (n_pages - 1); i > 0; i--)
00167         {
00168 
00169                 gtk_notebook_remove_page ((GtkNotebook *) MacroTables.
00170                                           MacroNotebook, i);
00171         }
00172 }
00173 
00174 void
00175 vapiGtkMacrosTablesCleanToDefault ()
00176 {
00177         GtkTreeStore *treeStore;
00178 
00179         vapiGtkMacrosTablesClean ();
00180         gtk_label_set_text ((GtkLabel *) MacroTables.lblMainMacro,
00181                             "Tarefa Principal");
00182         treeStore =
00183                 gtk_tree_store_new (3, G_TYPE_INT, G_TYPE_OBJECT,
00184                                     G_TYPE_STRING);
00185 
00186         gtk_tree_view_set_model (GTK_TREE_VIEW (MacroTables.MainMacroTable),
00187                                  GTK_TREE_MODEL (treeStore));
00188         g_object_unref (treeStore);
00189 }
00190 
00191 void
00192 vapiGtkMacroTable ()
00193 {
00194         GtkTreeStore *treeStore;
00195         int macro_number;
00196         vMacroHeader *MacroHeader;
00197 
00198         if (SelectedMacroGlobal == -1)
00199         {
00200                 return;
00201         }
00202         g_signal_handler_block (MacroTables.MacroNotebook,
00203                                 MacroTables.NotebookEventId);
00204         vapiGtkMacrosTablesClean ();
00205         v_bypass_reload ();
00206         macro_number = SelectedMacroGlobal;
00207         MacroHeader =
00208                 vapiMacroListSelectItem (MacroTables.MacroList, macro_number);
00209 
00210         gtk_label_set_text ((GtkLabel *) MacroTables.lblMainMacro,
00211                             MacroHeader->MacroName);
00212         v_bypass_append ("0", v_list_count_elements (MacroHeader->Macro));
00213         treeStore = vapiGtkMacroTableModel (MacroHeader, "0");
00214         v_bypass_set_updatable (vFALSE);
00215 
00216         gtk_tree_view_set_model (GTK_TREE_VIEW (MacroTables.MainMacroTable),
00217                                  GTK_TREE_MODEL (treeStore));
00218 
00219         g_object_unref (treeStore);
00220 
00221         g_signal_handler_unblock (MacroTables.MacroNotebook,
00222                                   MacroTables.NotebookEventId);
00223 }
00224 
00225 GtkTreeStore *
00226 vapiGtkMacroTableModel (vMacroHeader * MacroHeader, const char *macroTag)
00227 {
00228 
00229         int i, total, second_macro;
00230         char *newID;
00231         vMacroItem *item;
00232         GtkTreeIter iter;
00233         GtkTreeStore *treeStore;
00234         /*
00235          * Iniciar conteudo da Tabela Macro.
00236          */
00237         if (macroTag == NULL)
00238         {
00239                 treeStore =
00240                         gtk_tree_store_new (4, G_TYPE_INT, G_TYPE_BOOLEAN,
00241                                             G_TYPE_BOOLEAN, G_TYPE_STRING);
00242         }
00243         else
00244         {
00245                 treeStore =
00246                         gtk_tree_store_new (4, G_TYPE_STRING, G_TYPE_BOOLEAN,
00247                                             G_TYPE_BOOLEAN, G_TYPE_STRING);
00248         }
00249 
00250         if (MacroHeader == NULL)
00251         {
00252                 goto set_store;
00253         }
00254 
00255 
00256         total = vapiMacroCountElements (MacroHeader->Macro);
00257         for (i = 0; i < total; i++)
00258         {
00259                 item = vapiMacroSelectItem (MacroHeader->Macro, i);
00260                 /*
00261                  * Adicionar Nova linha na tabela.
00262                  */
00263                 gtk_tree_store_append (treeStore, &iter, NULL);
00264                 if (macroTag != NULL)
00265                 {
00266                         newID = g_strdup_printf ("%s.%d", macroTag, i);
00267                         gtk_tree_store_set (treeStore, &iter, 0, newID, 1,
00268                                             v_stopby_get (macroTag, i), 2,
00269                                             v_bypass_get (macroTag, i), 3,
00270                                             item->Operation->name, -1);
00271                         g_free (newID);
00272                 }
00273                 else
00274                 {
00275                         gtk_tree_store_set (treeStore, &iter, 0, i, 1,
00276                                             v_stopby_get (macroTag, i), 2,
00277                                             v_bypass_get (macroTag, i), 3,
00278                                             item->Operation->name, -1);
00279                 }
00280                 v_debug ("Nome da Macro %s", item->Operation->name);
00281                 if (!strcmp (item->Operation->name, "Executar Tarefa")
00282                     && strcmp (item->Options->chars[0].ch,
00283                                MacroHeader->MacroName))
00284                 {
00285                         second_macro =
00286                                 vapiMacroListMacroExist (MacroTables.
00287                                                          MacroList,
00288                                                          item->Options->
00289                                                          chars[0].ch, 0);
00290                         v_debug ("numero da segunda macro %d", second_macro);
00291                         if (second_macro >= 0)
00292                         {
00293                                 vapiGtkMacroTableAux (second_macro, macroTag,
00294                                                       i);
00295                         }
00296                 }
00297         }
00298       set_store:
00299         return treeStore;
00300 }
00301 
00302 void
00303 vapiGtkMacroTableAux (int macro_number, const char *previousMacroTag,
00304                       int operationNumber)
00305 {
00306         /*
00307          * Adicionar uma Macro Secundária.
00308          */
00309         vMacroHeader *MacroHeader;
00310         GtkWidget *tempLabel;
00311         GtkWidget *tempTable;
00312         int book_page_number;
00313         GtkTreeStore *treeStore;
00314         char *macroTag, *pageLabel;
00315 
00316         if (macro_number < 0)
00317         {
00318                 return;
00319         }
00320         MacroHeader =
00321                 vapiMacroListSelectItem (MacroTables.MacroList, macro_number);
00322         macroTag = vapiMacroTag (previousMacroTag, operationNumber);
00323         v_bypass_append (macroTag,
00324                          v_list_count_elements (MacroHeader->Macro));
00325         pageLabel =
00326                 g_strdup_printf ("%s %s", macroTag, MacroHeader->MacroName);
00327         tempLabel = gtk_label_new (pageLabel);
00328 
00329         tempTable = vapiGtkMacrosTablesCreateTable ();
00330 
00331         treeStore = vapiGtkMacroTableModel (MacroHeader, macroTag);
00332 
00333         gtk_tree_view_set_model (GTK_TREE_VIEW (tempTable),
00334                                  GTK_TREE_MODEL (treeStore));
00335 
00336         book_page_number = vapiGtkMacroTablesAddTable (tempTable, tempLabel);
00337 
00338         g_object_unref (treeStore);
00339         v_debug ("esta mcro é a seleccionada?: %d, %d",
00340                  SelectedMacro, macro_number);
00341 
00342         if (SelectedMacro == macro_number)
00343         {
00344                 v_debug ("esta mcro é a seleccionada: %d, %d, %d",
00345                          SelectedMacro, macro_number, book_page_number);
00346 
00347                 gtk_notebook_set_current_page ((GtkNotebook *) MacroTables.
00348                                                MacroNotebook,
00349                                                book_page_number);
00350 
00351         }
00352 }
00353 
00354 GtkWidget *
00355 vapiGtkMacrosTablesCreateTable ()
00356 {
00357         GtkCellRenderer *renderer;
00358         GtkWidget *tempTable;
00359         GtkTreeSelection *selection;
00360 
00361         tempTable = gtk_tree_view_new ();
00362 
00363 
00364         selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (tempTable));
00365         gtk_tree_selection_set_mode (selection, GTK_SELECTION_SINGLE);
00366 
00367         renderer = gtk_cell_renderer_text_new ();
00368         gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW
00369                                                      (tempTable), -1,
00370                                                      "id", renderer, "text",
00371                                                      0, NULL);
00372         renderer = gtk_cell_renderer_toggle_new ();
00373 
00374         g_signal_connect (renderer, "toggled",
00375                           G_CALLBACK (vapiGtkMacroSetStopby), NULL);
00376         g_object_set (renderer, "activatable", TRUE, NULL);
00377         gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW
00378                                                      (tempTable), -1,
00379                                                      StopByColumnName,
00380                                                      renderer, "active", 1,
00381                                                      NULL);
00382         renderer = gtk_cell_renderer_toggle_new ();
00383 
00384         g_signal_connect (renderer, "toggled",
00385                           G_CALLBACK (vapiGtkMacroSetBypass), NULL);
00386         g_object_set (renderer, "activatable", TRUE, NULL);
00387         gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW
00388                                                      (tempTable), -1,
00389                                                      ByPassColumnName,
00390                                                      renderer, "active", 2,
00391                                                      NULL);
00392 
00393 
00394         renderer = gtk_cell_renderer_text_new ();
00395         gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW
00396                                                      (tempTable), -1,
00397                                                      "Operação", renderer,
00398                                                      "text", 3, NULL);
00399         return tempTable;
00400 }
00401 
00402 int
00403 vapiGtkMacroTableGetSelected ()
00404 {
00405         int selectedRow;
00406         GtkWidget *tempTable;
00407 
00408         tempTable = vapiGtkMacroTablesGetTable (-1);
00409 
00410         selectedRow = vapiGtkTableGetSelectedRow (tempTable);
00411         gtk_widget_grab_focus (tempTable);
00412         return selectedRow;
00413 }
00414 
00415 void
00416 vapiGtkMacrosTableSetSelectedMacro (GtkNotebook * notebook,
00417                                     gint arg1, gpointer user_data)
00418 {
00419         int n_page;
00420         const char *macroTag;
00421         vMacroTagDecode *MacroTagDecode;
00422         n_page = gtk_notebook_get_current_page (notebook);
00423 
00424         if (n_page == 0 && SelectedMacroGlobal >= 0)
00425         {
00426                 SelectedMacro = SelectedMacroGlobal;
00427                 return;
00428         }
00429         if (n_page == 0 && SelectedMacroGlobal < 0)
00430         {
00431                 SelectedMacro = -1;
00432                 return;
00433         }
00434         macroTag = vapiGtkMacroTablesGetMacroTag (n_page);
00435 
00436         MacroTagDecode = vapiGtkTablesMacroTagDecoder (macroTag);
00437 
00438         SelectedMacro =
00439                 vapiMacroListMacroExist (MacroTables.MacroList,
00440                                          MacroTagDecode->MacroName, 0);
00441         if (SelectedMacro < 0)
00442         {
00443                 /*
00444                  * Confirmar que fic a -1;
00445                  */
00446                 SelectedMacro = -1;
00447         }
00448         vMacroTagDecodeFree (MacroTagDecode);
00449         v_debug ("selected Macro agora %d", SelectedMacro);
00450 }
00451 
00452 vBoolean
00453 vapiGtkMacroTableSelectRow (int row)
00454 {
00455         GtkWidget *child;
00456 
00457         child = vapiGtkMacroTablesGetTable (-1);
00458         return (vapiGtkTableSelectRow (child, row));
00459 }
00460 
00461 void
00462 vapiGtkMacroApplyAllMacros ()
00463 {
00464         int currentNotebookPage;
00465         const char *macroTag;
00466 
00467         currentNotebookPage =
00468                 gtk_notebook_get_current_page ((GtkNotebook *) MacroTables.
00469                                                MacroNotebook);
00470         if (currentNotebookPage == 0)
00471         {
00472                 return;
00473         }
00474         macroTag = vapiGtkMacroTablesGetMacroTag (currentNotebookPage);
00475         vapiGtkMacroTablesApplyUntil (macroTag);
00476 }
00477 
00478 void
00479 vapiGtkCbMacroStart ()
00480 {
00481 
00482         int i, ListSize;
00483         GtkTreeStore *treeStore;
00484         GtkTreeIter iter, iter2;
00485         vMacroHeader *MacroHeader;
00486         treeStore = gtk_tree_store_new (1, G_TYPE_STRING);
00487         ListSize = vapiMacroListCountElements (MacroTables.MacroList);
00488         if (ListSize > 0)
00489         {
00490                 for (i = 0; i < ListSize; i++)
00491                 {
00492                         MacroHeader =
00493                                 vapiMacroListSelectItem (MacroTables.
00494                                                          MacroList, i);
00495                         gtk_tree_store_append (treeStore, &iter, NULL);
00496                         gtk_tree_store_set (treeStore, &iter, 0,
00497                                             MacroHeader->MacroName, -1);
00498                         if (i == SelectedMacro)
00499                         {
00500                                 iter2 = iter;
00501                         }
00502 
00503                 }
00504         }
00505         gtk_combo_box_set_model ((GtkComboBox *) MacroTables.cbMacro,
00506                                  GTK_TREE_MODEL (treeStore));
00507         if (SelectedMacro > -1)
00508         {
00509                 gtk_combo_box_set_active_iter ((GtkComboBox *) MacroTables.
00510                                                cbMacro, &iter2);
00511         }
00512         g_object_unref (treeStore);
00513 }
00514 
00515 void
00516 vapiGtkMacroTablesApplyUntil (const char *macroTag)
00517 {
00518         vMacroTagDecode *MacroTagDecode;
00519         vMacroHeader *MacroHeader, *PreviousMacroHeader;
00520         vMacroItem *item;
00521         int index, macro_number, i;
00522         /*
00523          * MacroTag tem o formato: MacroDeOrigem:OperaçãoEmqueAMacroÉexecutada"
00524          *  macro de origem é sempre 0.
00525          */
00526 
00527         MacroTagDecode = vapiGtkTablesMacroTagDecoder (macroTag);
00528 
00529         /*
00530          * Primeiro: Aplica-se a MacroBase até à operação indice-1.
00531          */
00532         MacroHeader =
00533                 vapiMacroListSelectItem (MacroTables.MacroList,
00534                                          SelectedMacroGlobal);
00535         i = 1;
00536         index = MacroTagDecode->Indexes[i];
00537         vResultReset (MacroHeader->PreviousResult);
00538 
00539         MacroHeader->PreviousResult->macroTag = v_printf ("0");
00540         vapiApplyMacroUntil (MacroHeader, MacroTables.Images, (index - 1));
00541 
00542         if (i == MacroTagDecode->NumberOfIndexes - 1)
00543         {
00544                 vMacroTagDecodeFree (MacroTagDecode);
00545                 return;
00546         }
00547         for (; i < MacroTagDecode->NumberOfIndexes; i++)
00548         {
00549                 item = vapiMacroSelectItem (MacroHeader->Macro, index);
00550                 macro_number =
00551                         vapiMacroListMacroExist (MacroTables.MacroList,
00552                                                  item->Options->chars[0].ch,
00553                                                  0);
00554                 if (macro_number >= 0)
00555                 {
00556                         PreviousMacroHeader = MacroHeader;
00557                         MacroHeader =
00558                                 vapiMacroListSelectItem (MacroTables.
00559                                                          MacroList,
00560                                                          macro_number);
00561                         index = MacroTagDecode->Indexes[i];
00562                 }
00563                 else
00564                 {
00565                         index = MacroTagDecode->Indexes[++i];
00566                         continue;
00567                 }
00568                 vResultReset (MacroHeader->PreviousResult);
00569                 MacroHeader->PreviousResult->macroTag =
00570                         v_printf ("%s",
00571                                   PreviousMacroHeader->PreviousResult->
00572                                   macroTag);
00573                 vapiApplyMacroUntil (MacroHeader, MacroTables.Images,
00574                                      (index - 1));
00575         }
00576         vMacroTagDecodeFree (MacroTagDecode);
00577 }
00578 
00579 vMacroTagDecode *
00580 vapiGtkTablesMacroTagDecoder (const char *macroTag)
00581 {
00582         char CharPtr, *indexString, *indexString2;
00583         vMacroTagDecode *MacroTagDecode = malloc (sizeof (vMacroTagDecode));
00584         int newIndex, len, j;
00585         /*
00586          * Init MacroTagDecode.
00587          */
00588         MacroTagDecode->NumberOfIndexes = 0;
00589 
00590         len = strlen (macroTag);
00591         indexString = v_printf ("");
00592         printf ("original %s\n", macroTag);
00593         for (j = 0; j < len; j++)
00594         {
00595                 CharPtr = macroTag[j];
00596                 printf ("char seleccionado %c\n", CharPtr);
00597                 if (CharPtr == ':' || CharPtr == '.')
00598                 {
00599                         /*
00600                          * chegou a 2 pontos ':'.
00601                          */
00602                         newIndex = atoi (indexString);
00603                         vapiGtkMacroTagDecodeAddIndex (MacroTagDecode,
00604                                                        newIndex);
00605                         v_debug ("10");
00606                         v_debug ("numero %d string %s\n",
00607                                  MacroTagDecode->Indexes[MacroTagDecode->
00608                                                          NumberOfIndexes - 1],
00609                                  indexString);
00610                         free (indexString);
00611                         indexString = v_printf ("");
00612                         continue;
00613                 }
00614                 if (CharPtr == ' ')
00615                 {
00616                         newIndex = atoi (indexString);
00617                         vapiGtkMacroTagDecodeAddIndex (MacroTagDecode,
00618                                                        newIndex);
00619                         v_debug ("numero %d string %s\n",
00620                                  MacroTagDecode->Indexes[MacroTagDecode->
00621                                                          NumberOfIndexes - 1],
00622                                  indexString);
00623                         free (indexString);
00624                         indexString = strchr (macroTag, ' ');
00625                         v_debug ("nome da macro :%s", indexString);
00626                         MacroTagDecode->MacroName =
00627                                 v_printf ("%s", ++indexString);
00628                         return MacroTagDecode;
00629                 }
00630                 indexString2 = indexString;
00631                 indexString = v_printf ("%s%c", indexString2, CharPtr);
00632                 free (indexString2);
00633         }
00634         return MacroTagDecode;
00635 }
00636 
00637 static void
00638 vapiGtkMacroTagDecodeAddIndex (vMacroTagDecode * MacroTagDecode, int newIndex)
00639 {
00640         if (MacroTagDecode->NumberOfIndexes == 0)
00641         {
00642                 MacroTagDecode->Indexes = malloc (sizeof (int));
00643                 ++MacroTagDecode->NumberOfIndexes;
00644         }
00645         else
00646         {
00647                 MacroTagDecode->Indexes =
00648                         realloc (MacroTagDecode->Indexes,
00649                                  ++MacroTagDecode->NumberOfIndexes *
00650                                  sizeof (int));
00651         }
00652         MacroTagDecode->Indexes[MacroTagDecode->NumberOfIndexes - 1] =
00653                 newIndex;
00654 }
00655 static void
00656 vMacroTagDecodeFree (vMacroTagDecode * vFree)
00657 {
00658         free (vFree->Indexes);
00659         free (vFree->MacroName);
00660         free (vFree);
00661 }
00662 
00663 char *
00664 vapiGtkMacroMacroTagEncode (vMacroTagDecode * MacroTagDecode)
00665 {
00666         int i;
00667         char *tempMacroTag, *macroTag;
00668 
00669 
00670         tempMacroTag = v_printf ("%d", MacroTagDecode->Indexes[0]);
00671         macroTag = tempMacroTag;
00672         for (i = 1; i < MacroTagDecode->NumberOfIndexes; i++)
00673         {
00674                 macroTag =
00675                         v_printf ("%s:%d", tempMacroTag,
00676                                   MacroTagDecode->Indexes[i]);
00677                 free (tempMacroTag);
00678                 tempMacroTag = macroTag;
00679         }
00680         return macroTag;
00681 }
00682 
00683 char *
00684 vapiGtkMacroGetMacroTag ()
00685 {
00686         int current_notebook_page;
00687         const gchar *tab_label;
00688         vMacroTagDecode *MacroTagDecode;
00689 
00690         current_notebook_page =
00691                 gtk_notebook_get_current_page ((GtkNotebook *) MacroTables.
00692                                                MacroNotebook);
00693         if (current_notebook_page == 0)
00694         {
00695                 return v_printf ("0");
00696         }
00697 
00698         tab_label = vapiGtkMacroTablesGetMacroTag (current_notebook_page);
00699 
00700         MacroTagDecode = vapiGtkTablesMacroTagDecoder (tab_label);
00701 
00702         return vapiGtkMacroMacroTagEncode (MacroTagDecode);
00703 }
00704 
00705 GtkWidget *
00706 vapiGtkMacroTablesGetTable (int notebook_page)
00707 {
00708         GtkWidget *table;
00709         GtkWidget *NotebookChild;
00710 
00711         if (notebook_page < 0)
00712         {
00713                 notebook_page =
00714                         gtk_notebook_get_current_page ((GtkNotebook *)
00715                                                        MacroTables.
00716                                                        MacroNotebook);
00717         }
00718 #ifndef USE_SCROLLED_WINDOWS
00719         if (notebook_page == 0)
00720         {
00721 #endif
00722                 NotebookChild =
00723                         gtk_notebook_get_nth_page ((GtkNotebook *)
00724                                                    MacroTables.MacroNotebook,
00725                                                    notebook_page);
00726 
00727                 table = gtk_bin_get_child ((GtkBin *) NotebookChild);
00728 #ifndef USE_SCROLLED_WINDOWS
00729         }
00730         else
00731         {
00732 
00733                 table = gtk_notebook_get_nth_page ((GtkNotebook *)
00734                                                    MacroTables.MacroNotebook,
00735                                                    notebook_page);
00736         }
00737 #endif
00738 
00739         return table;
00740 }
00741 
00742 static const char *
00743 vapiGtkMacroTablesGetMacroTag (int notebook_page)
00744 {
00745         GtkWidget *child;
00746         const char *macroTag;
00747         if (notebook_page < 0)
00748         {
00749                 notebook_page =
00750                         gtk_notebook_get_current_page ((GtkNotebook *)
00751                                                        MacroTables.
00752                                                        MacroNotebook);
00753         }
00754 
00755         child = gtk_notebook_get_nth_page ((GtkNotebook *) MacroTables.
00756                                            MacroNotebook, notebook_page);
00757         macroTag =
00758                 gtk_notebook_get_tab_label_text ((GtkNotebook *) MacroTables.
00759                                                  MacroNotebook, child);
00760 
00761         return macroTag;
00762 }
00763 
00764 static int
00765 vapiGtkMacroTablesAddTable (GtkWidget * table, GtkWidget * label)
00766 {
00767         int book_page;
00768 
00769 #ifdef USE_SCROLLED_WINDOWS
00770         GtkWidget *scrolledWindow;
00771 
00772         scrolledWindow = gtk_scrolled_window_new (NULL, NULL);
00773         gtk_scrolled_window_set_policy ((GtkScrolledWindow *) scrolledWindow,
00774                                         GTK_POLICY_AUTOMATIC,
00775                                         GTK_POLICY_AUTOMATIC);
00776         gtk_scrolled_window_add_with_viewport ((GtkScrolledWindow *)
00777                                                scrolledWindow, table);
00778 
00779         book_page = gtk_notebook_append_page ((GtkNotebook *) MacroTables.
00780                                               MacroNotebook, scrolledWindow,
00781                                               label);
00782 
00783         gtk_widget_show_all (scrolledWindow);
00784 #else
00785         book_page = gtk_notebook_append_page ((GtkNotebook *) MacroTables.
00786                                               MacroNotebook, table, label);
00787         gtk_widget_show_all (table);
00788 
00789 #endif
00790         gtk_widget_show (label);
00791         g_signal_connect (G_OBJECT (table),
00792                           "row_activated",
00793                           G_CALLBACK (vapiGtkMacroSelectItem),
00794                           MacroTablesSelect);
00795         return book_page;
00796 }

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