TSP: The Transport Sample Protocol



Main Page | Modules | Alphabetical List | Data Structures | File List | Data Fields | Globals | Related Pages

gdisp_symbols.c

Go to the documentation of this file.
00001 
00043 /*
00044  * System includes.
00045  */
00046 #include <stdio.h>
00047 #include <stdlib.h>
00048 #include <assert.h>
00049 #include <string.h>
00050 
00051 
00052 /*
00053  * GDISP+ includes.
00054  */
00055 #include "gdisp_kernel.h"
00056 #include "gdisp_prototypes.h"
00057 #include "gdisp_dragAndDrop.h"
00058 
00059 
00060 /*
00061  --------------------------------------------------------------------
00062                              STATIC ROUTINES
00063  --------------------------------------------------------------------
00064 */
00065 
00066 /*
00067  * Insert all available symbols into the Gtk CList.
00068  * Take care of requested sorting method.
00069  */
00070 static gint
00071 gdispInsertAndSortSymbols (Kernel_T  *kernel,
00072                            gchar    **stringFilter,
00073                            guint      stringFilterSize)
00074 {
00075 
00076 #define GD_MAKE_DIFFERENCE_WITH_PIXMAP
00077 
00078   GList      *providerItem   =      (GList*)NULL;
00079   Symbol_T   *symbolPtr      =   (Symbol_T*)NULL;
00080   Provider_T *provider       = (Provider_T*)NULL;
00081   gint        symbolCpt      =                 0,
00082               rowNumber      =                 0;
00083   gchar      *symbolInfos[_SYMBOL_CLIST_COLUMNS_NB_] =
00084                                                     { (gchar*)NULL,
00085                                                       "n/a",
00086                                                       "undefined" };
00087 #if defined(GD_MAKE_DIFFERENCE_WITH_PIXMAP)
00088   Pixmap_T   *idPixmap       = (Pixmap_T*)NULL;
00089 #endif
00090 
00091   assert(kernel);
00092 
00093   /* ------------------------ LIST OF SYMBOLS ------------------------ */
00094 
00095   gtk_clist_freeze(GTK_CLIST(kernel->widgets.symbolCList));
00096   gtk_clist_clear (GTK_CLIST(kernel->widgets.symbolCList));
00097 
00098 
00099   /*
00100    * When sorting method is GD_SORT_BY_PROVIDER or GD_SORT_BY_NAME,
00101    * loop over all provider, then loop over all provider symbols.
00102    */
00103   if (kernel->sortingMethod == GD_SORT_BY_PROVIDER     ||
00104       kernel->sortingMethod == GD_SORT_BY_NAME         ||
00105       kernel->sortingMethod == GD_SORT_BY_NAME_REVERSE    ) {
00106  
00107     /*
00108      * Insert all symbols into the cList.
00109      */
00110     providerItem = g_list_first(kernel->providerList);
00111     while (providerItem != (GList*)NULL) {
00112 
00113       provider = (Provider_T*)providerItem->data;
00114       if (provider->pStatus == GD_SESSION_OPENED) {
00115 
00116         symbolPtr = provider->pSymbolList;
00117         for (symbolCpt=0; symbolCpt<provider->pSymbolNumber; symbolCpt++) {
00118 
00119           if (stringFilterSize == 0 /* insert all symbols */ ||
00120               gdisp_strStr(symbolPtr->sInfo.name,
00121                            stringFilter,
00122                            stringFilterSize) != (gchar*)NULL ) {
00123 
00124             symbolInfos[0] = symbolPtr->sInfo.name;
00125 
00126             rowNumber =
00127               gtk_clist_append(GTK_CLIST(kernel->widgets.symbolCList),
00128                                symbolInfos);
00129 
00130             /*
00131              * If there are several providers, show symbol appartenance.
00132              */
00133             if (gdisp_getProviderNumber(kernel) > 1) {
00134 
00135 #if defined(GD_MAKE_DIFFERENCE_WITH_PIXMAP)
00136 
00137               idPixmap = gdisp_getProviderIdPixmap(kernel,
00138                                                    kernel->widgets.symbolCList,
00139                                                    provider->pIdentity);
00140 
00141               gtk_clist_set_pixtext(GTK_CLIST(kernel->widgets.symbolCList),
00142                                     rowNumber,
00143                                     0, /* first column */
00144                                     symbolPtr->sInfo.name,
00145                                     5, /* spacing */
00146                                     idPixmap->pixmap,
00147                                     idPixmap->mask);
00148 
00149 #else
00150 
00151               /*
00152                * Provider color may have not been calculated before.
00153                * Provider color still may be null if the maximum number
00154                * of providers is excedeed. Cf. << gdisp_colormap.c >>
00155                */
00156               if (provider->pColor == (GdkColor*)NULL)
00157                 provider->pColor = gdisp_getProviderColor(kernel,
00158                                                           provider->pIdentity);
00159 
00160               gtk_clist_set_background(GTK_CLIST(kernel->widgets.symbolCList),
00161                                        rowNumber, /* row */
00162                                        provider->pColor);
00163 
00164 #endif
00165 
00166             }
00167 
00168             /*
00169              * Remember here the symbol the row refers to.
00170              */
00171             gtk_clist_set_row_data(GTK_CLIST(kernel->widgets.symbolCList),
00172                                    rowNumber, /* row */
00173                                    (gpointer)symbolPtr);
00174 
00175           } /* filter */
00176 
00177           symbolPtr++;
00178 
00179         } /* symbolCpt */
00180 
00181       } /* provider status */
00182 
00183       providerItem = g_list_next(providerItem);
00184 
00185     }
00186 
00187   }
00188 
00189 
00190   /*
00191    * If sorting method is GD_SORT_BY_NAME, keep on
00192    * sorting all symbols into the CList alphabetically.
00193    */
00194   if (kernel->sortingMethod == GD_SORT_BY_NAME         ||
00195       kernel->sortingMethod == GD_SORT_BY_NAME_REVERSE    ) {
00196 
00197     /*
00198      * Specify sorting method.
00199      */
00200     gtk_clist_set_sort_column(GTK_CLIST(kernel->widgets.symbolCList),
00201                               0 /* first column */ );
00202 
00203     gtk_clist_set_sort_type(GTK_CLIST(kernel->widgets.symbolCList),
00204                             kernel->sortingMethod == GD_SORT_BY_NAME ?
00205                             GTK_SORT_ASCENDING : GTK_SORT_DESCENDING);
00206 
00207     gtk_clist_sort(GTK_CLIST(kernel->widgets.symbolCList));
00208 
00209   }
00210 
00211 
00212   /*
00213    * Allow graphic refreshes.
00214    */
00215   gtk_clist_thaw(GTK_CLIST(kernel->widgets.symbolCList));
00216 
00217   return (rowNumber + 1);
00218 
00219 }
00220 
00221 
00222 /*
00223  * This callback is called whenever a sorting-method button is pressed.
00224  * The argument "data" is the kernel itself.
00225  * The only way to determine which button has been pressed (ie the
00226  * sorting method  which is requested), is to compare the argument
00227  * "widget" (the target button) to all radio button pointers stored
00228  * into the kernel.
00229  */
00230 static void
00231 gdisp_changeSortingMethodCallback (GtkWidget *radioButtonWidget,
00232                                    gpointer   data )
00233 {
00234 
00235   Kernel_T *kernel = (Kernel_T*)data;
00236 
00237 
00238   /*
00239    * Compare 'radioButtonWidget' with radio buttons in the kernel.
00240    */
00241   if (radioButtonWidget == kernel->widgets.pRadioButton) {
00242 
00243     kernel->sortingMethod = GD_SORT_BY_PROVIDER;
00244 
00245   }
00246   else if (radioButtonWidget == kernel->widgets.naRadioButton) {
00247 
00248     kernel->sortingMethod = GD_SORT_BY_NAME;
00249 
00250   }
00251   else if (radioButtonWidget == kernel->widgets.ndRadioButton) {
00252 
00253     kernel->sortingMethod = GD_SORT_BY_NAME_REVERSE;
00254 
00255   }
00256   else {
00257 
00258     /* no check because this should never happend...  */
00259 
00260   }
00261 
00262 }
00263 
00264 
00265 /*
00266  * This callback is called whenever a DnD-scope button is pressed.
00267  * The argument "data" is the kernel itself.
00268  * The only way to determine which button has been pressed (ie the
00269  * DnD-scope which is requested), is to compare the argument
00270  * "widget" (the target button) to all radio button pointers stored
00271  * into the kernel.
00272  */
00273 static void
00274 gdisp_changeDnDScopeCallback (GtkWidget *radioButtonWidget,
00275                               gpointer   data )
00276 {
00277 
00278   Kernel_T *kernel = (Kernel_T*)data;
00279 
00280 
00281   /*
00282    * Compare 'radioButtonWidget' with radio buttons in the kernel.
00283    */
00284   if (radioButtonWidget == kernel->widgets.uRadioButton) {
00285 
00286     kernel->dndScope = GD_DND_UNICAST;
00287 
00288   }
00289   else if (radioButtonWidget == kernel->widgets.spRadioButton) {
00290 
00291     kernel->dndScope = GD_DND_MULTICAST;
00292 
00293   }
00294   else if (radioButtonWidget == kernel->widgets.apRadioButton) {
00295 
00296     kernel->dndScope = GD_DND_BROADCAST;
00297 
00298   }
00299   else {
00300 
00301     /* no check because this should never happend...  */
00302 
00303   }
00304 
00305 }
00306 
00307 
00308 /*
00309  * List Selection callback.
00310  */
00311 static void
00312 gdisp_listSelectionCallback ( GtkWidget      *widget /* symbol cList */,
00313                               gint            row, 
00314                               gint            column,
00315                               GdkEventButton *event,
00316                               gpointer        data )
00317 {
00318 
00319   Kernel_T *kernel = (Kernel_T*)data;
00320 
00321   /*
00322    * Add the selected symbol into the DND selection list.
00323    */
00324   kernel->dndSelection =
00325     g_list_append(kernel->dndSelection,
00326                   gtk_clist_get_row_data(GTK_CLIST(widget),
00327                                          row));
00328 
00329 }
00330 
00331 
00332 /*
00333  * List Deselection callback.
00334  */
00335 static void
00336 gdisp_listDeselectionCallback ( GtkWidget      *widget /* symbol cList */,
00337                                 gint            row, 
00338                                 gint            column,
00339                                 GdkEventButton *event,
00340                                 gpointer        data )
00341 {
00342 
00343   Kernel_T *kernel = (Kernel_T*)data;
00344 
00345   /*
00346    * Remove the selected symbol from the DND selection list.
00347    */
00348   kernel->dndSelection =
00349     g_list_remove(kernel->dndSelection,
00350                   gtk_clist_get_row_data(GTK_CLIST(widget),
00351                                          row));
00352 
00353 }
00354 
00355 
00356 /*
00357  * DND "drag_begin" handler : this is called whenever a drag starts.
00358  */
00359 static void
00360 gdisp_beginDNDCallback (GtkWidget      *widget /* symbol cList */,
00361                         GdkDragContext *dragContext,
00362                         gpointer        data)
00363 {
00364 
00365   Kernel_T *kernel = (Kernel_T*)data;
00366 
00367   /*
00368    * Put any needed drag begin setup code here.
00369    */
00370   assert(kernel);
00371   assert(dragContext);
00372 
00373 #if defined(_DND_DEBUG_)
00374   fprintf(stdout,"begin DND Callback for symbol list.\n");
00375   fflush (stdout);
00376 #endif
00377 
00378   /*
00379    * Noting to be done.
00380    */
00381 
00382 }
00383 
00384 
00385 /*
00386  * DND "drag_end" handler : this is called when a drag and drop has
00387  * completed. So this function is the last one to be called in
00388  * any given DND operation.
00389  */
00390 static void
00391 gdisp_endDNDCallback (GtkWidget      *widget /* symbol cList */,
00392                       GdkDragContext *dragContext,
00393                       gpointer        data)
00394 {
00395 
00396   Kernel_T *kernel = (Kernel_T*)data;
00397 
00398   /*
00399    * Put any needed drag end cleanup code here.
00400    */
00401   assert(kernel);
00402   assert(dragContext);
00403 
00404 #if defined(_DND_DEBUG_)
00405   fprintf(stdout,"end DND Callback for symbol list.\n");
00406   fflush (stdout);
00407 #endif
00408 
00409   /*
00410    * Clear selection on the symbol list, so that the user has to
00411    * choose other symbols before beginning another DND operation.
00412    */
00413   gtk_clist_unselect_all(GTK_CLIST(kernel->widgets.symbolCList));
00414 
00415   /*
00416    * Free kernel DND selection list.
00417    */
00418   if (kernel->dndSelection != (GList*)NULL) {
00419 
00420     g_list_free(kernel->dndSelection);
00421     kernel->dndSelection = (GList*)NULL;
00422 
00423   }
00424 
00425   /*
00426    * Now all is done, what about removing icon window ?
00427    */
00428   if (kernel->dndIconWindow != (GdkWindow*)NULL) {
00429 
00430     gdk_window_destroy(kernel->dndIconWindow);
00431     kernel->dndIconWindow       = (GdkWindow*)NULL;
00432     kernel->dndIconWindowParent = (GdkWindow*)NULL;
00433     kernel->dndIconPixmap       = (GdkPixmap*)NULL;
00434     kernel->dndIconPixmapMask   = (GdkBitmap*)NULL;
00435 
00436     gdk_gc_destroy(kernel->dndIconWindowGc);
00437     kernel->dndIconWindowGc = (GdkGC*)NULL;
00438 
00439   }
00440 
00441 }
00442 
00443 
00444 /*
00445  * DND "drag_data_get" handler, for handling requests for DND
00446  * data on the specified widget. This function is called when
00447  * there is need for DND data on the source, so this function is
00448  * responsable for setting up the dynamic data exchange buffer
00449  * (DDE as sometimes it is called) and sending it out.
00450  */
00451 static void
00452 gdisp_dataRequestDNDCallback (GtkWidget        *widget /* symbol cList */,
00453                               GdkDragContext   *dragContext,
00454                               GtkSelectionData *selectionData,
00455                               guint             entryInfo,
00456                               guint             time,
00457                               gpointer          data)
00458 {
00459 
00460   Kernel_T *kernel = (Kernel_T*)data;
00461   gchar    *action = GD_DND_SYMBOL_LIST_EXCHANGE;
00462 
00463   /*
00464    * Put any needed data request code here.
00465    */
00466   assert(kernel);
00467   assert(dragContext);
00468 
00469 #if defined(_DND_DEBUG_)
00470   fprintf(stdout,"data Request DND Callback for symbol list.\n");
00471   fflush (stdout);
00472 #endif
00473 
00474   /*
00475    * Send out the data using the selection system,
00476    * this is also used for cut and paste but
00477    * GTK uses it for drag and drop as well. When
00478    * sending a string, GTK will ensure that a null
00479    * terminating byte is added to the end so we
00480    * do not need to add it. GTK also coppies the
00481    * data so the original will never be modified.
00482    */
00483   gtk_selection_data_set(selectionData,
00484                          GDK_SELECTION_TYPE_STRING,
00485                          8,     /* 8 bits per character */
00486                          action,
00487                          strlen(action));
00488 
00489 }
00490 
00491 
00492 /*
00493  * DND "drag_data_received" handler. When 'gdisp_dataRequestDNDCallback'
00494  * calls 'gtk_selection_data_set()' to send out the data, this function
00495  * receives it and is responsible for handling it.
00496  *
00497  * This is also the only DND callback function where the given
00498  * inputs may reflect those of the drop target, so we need to check
00499  * if this is the same structure or not.
00500  *
00501  * NOT THE CASE HERE, just for checking DND process.
00502  */
00503 static void
00504 gdisp_dataReceivedDNDCallback (GtkWidget        *widget /* symbol cList */,
00505                                GdkDragContext   *dragContext,
00506                                gint              x,
00507                                gint              y,
00508                                GtkSelectionData *selectionData,
00509                                guint             entryInfo,
00510                                guint             time,
00511                                gpointer          data)
00512 {
00513 
00514   Kernel_T *kernel = (Kernel_T*)data;
00515 
00516   /*
00517    * Put any needed data received code here.
00518    */
00519   assert(kernel);
00520   assert(dragContext);
00521 
00522 #if defined(_DND_DEBUG_)
00523   fprintf(stdout,"data Receive DND Callback for symbol list.\n");
00524   fflush (stdout);
00525 #endif
00526 
00527   /*
00528    * This procedure does nothing because there is nothing to be done here.
00529    * The symbol list will never receive any data.
00530    */
00531 
00532 }
00533 
00534 
00535 /*
00536  * DND "drag_data_delete" handler, this function is called when
00537  * the data on the source `should' be deleted (ie if the DND was
00538  * a move).
00539  *
00540  * NOT THE CASE HERE, just for checking DND process.
00541  */
00542 static void
00543 gdisp_dataDestroyedDNDCallback (GtkWidget      *widget /* symbol cList */,
00544                                 GdkDragContext *dragContext,
00545                                 gpointer        data)
00546 {
00547 
00548   Kernel_T *kernel = (Kernel_T*)data;
00549 
00550   /*
00551    * Put any needed data destroyed code here.
00552    */
00553   assert(kernel);
00554   assert(dragContext);
00555 
00556 #if defined(_DND_DEBUG_)
00557   fprintf(stdout,"data Destroy DND Callback for symbol list.\n");
00558   fflush (stdout);
00559 #endif
00560 
00561   /*
00562    * This procedure does nothing because there is nothing to be done here.
00563    * All symbols are duplicated (DND is a COPY action).
00564    * So nothing to be destroyed.
00565    */
00566 
00567 }
00568 
00569 
00570 /*
00571  --------------------------------------------------------------------
00572                              PUBLIC ROUTINES
00573  --------------------------------------------------------------------
00574 */
00575 
00576 
00577 /*
00578  * Apply callback (activated from databook widget).
00579  */
00580 void
00581 gdisp_symbolApplyCallback (GtkWidget *applyButtonWidget,
00582                            gpointer   data )
00583 {
00584 
00585   Kernel_T  *kernel          = (Kernel_T*)data;
00586   gint       symbolCount     =               0;
00587   gchar     *filter          =    (gchar*)NULL;
00588   GString   *messageString   =  (GString*)NULL;
00589 
00590   gchar    **stringTable     =   (gchar**)NULL;
00591   guint      stringTableSize =               0;
00592 
00593 
00594   /*
00595    * Get back filter.
00596    * Turn the filter (a coma-separated string list) into a string table.
00597    */
00598   filter = gtk_entry_get_text(GTK_ENTRY(kernel->widgets.filterEntry));
00599   if (strlen(filter) == 0)
00600     filter = (gchar*)NULL;
00601 
00602   gdisp_getStringTableFromStringList(filter,
00603                                      &stringTable,
00604                                      &stringTableSize);
00605 
00606   /*
00607    * Apply changes, with a possible filter.
00608    */
00609   symbolCount = gdispInsertAndSortSymbols(kernel,
00610                                           stringTable,
00611                                           stringTableSize);
00612 
00613 
00614   /*
00615    * Free allocated memory for string table.
00616    */
00617   gdisp_freeStringTable(&stringTable,
00618                         &stringTableSize);
00619 
00620 
00621   /*
00622    * Change symbol list frame label to reflect the exact number
00623    * of listed symbols.
00624    */
00625   messageString = g_string_new((gchar*)NULL);
00626   g_string_sprintf(messageString,
00627                    " Available Symbols : %d ",
00628                    symbolCount);
00629   gtk_frame_set_label(GTK_FRAME(kernel->widgets.symbolFrame),
00630                       messageString->str);
00631   g_string_free(messageString,TRUE);
00632 
00633 }
00634 
00635 
00636 /*
00637  * Create GDISP+ symbol list.
00638  */
00639 void
00640 gdisp_createSymbolList ( Kernel_T  *kernel,
00641                          GtkWidget *parent )
00642 {
00643 
00644   GtkWidget      *otherVBox         =   (GtkWidget*)NULL;
00645   GtkWidget      *otherHBox         =   (GtkWidget*)NULL;
00646   GtkWidget      *frame             =   (GtkWidget*)NULL;
00647   GtkWidget      *scrolledWindow    =   (GtkWidget*)NULL;
00648   GtkWidget      *hSeparator        =   (GtkWidget*)NULL;
00649   GtkWidget      *label             =   (GtkWidget*)NULL;
00650   GtkTooltips    *toolTipGroup      = (GtkTooltips*)NULL;
00651 
00652   GtkTargetEntry  targetEntry;
00653 
00654   GSList         *radioButtonGroup  = (GSList*)NULL;
00655   gboolean        radioStatuses[]   = { TRUE, FALSE, FALSE };
00656 
00657   GString        *messageString     = (GString*)NULL;
00658 
00659   gint            symbolCount       = 0;
00660   GtkWidget      *cList             = (GtkWidget*)NULL;
00661   gchar          *cListTitles[_SYMBOL_CLIST_COLUMNS_NB_] =
00662                                                       { "Name",
00663                                                         "Unit",
00664                                                         "Comment" };
00665 
00666   /* ------------------------ TOOLTIP GROUP ------------------------ */
00667 
00668   /*
00669    * Create the group of tooltips.
00670    * Look downwards for the association of tooltips and widgets.
00671    */
00672   toolTipGroup = gtk_tooltips_new();
00673 
00674 
00675   /* ------------------------ FRAME WITH LABEL ------------------------ */
00676 
00677   /*
00678    * Create a Frame that will contain a scrolled window for symbols.
00679    * Align the label at the left of the frame.
00680    * Set the style of the frame.
00681    */
00682   frame = gtk_frame_new(" Available Symbols ");
00683   gtk_frame_set_label_align(GTK_FRAME(frame),0.1,0.0);
00684   gtk_frame_set_shadow_type(GTK_FRAME(frame),GTK_SHADOW_ETCHED_IN);
00685 
00686   gtk_container_add(GTK_CONTAINER(parent),frame);
00687   gtk_widget_show(frame);
00688 
00689   kernel->widgets.symbolFrame = frame; /* in order to change its text */
00690 
00691 
00692   /* ------------ VERTICAL PACKING BOX INTO THE FRAME ------------ */
00693 
00694   /*
00695    * We need a vertical packing box for managing the scrolled window.
00696    */
00697   otherVBox = gtk_vbox_new(FALSE, /* homogeneous */
00698                             5      /* spacing     */ );
00699   gtk_container_border_width(GTK_CONTAINER(otherVBox),3);
00700   gtk_container_add(GTK_CONTAINER(frame),otherVBox);
00701   gtk_widget_show(otherVBox);
00702 
00703 
00704   /* ----------- SCROLLED WINDOW FOR THE LIST OF SYMBOLS  ----------- */
00705 
00706   /*
00707    * This is the scrolled window to put the List widget inside.
00708    */
00709   scrolledWindow = gtk_scrolled_window_new(NULL /* H Adjustment */,
00710                                            NULL /* V Adjustment */);
00711   gtk_container_border_width(GTK_CONTAINER(scrolledWindow),5);
00712   gtk_widget_set_usize(scrolledWindow,350,300);
00713   gtk_box_pack_start(GTK_BOX(otherVBox),
00714                      scrolledWindow,
00715                      TRUE  /* expand  */,
00716                      TRUE  /* fill    */,
00717                      0     /* padding */);
00718   gtk_widget_show(scrolledWindow);
00719 
00720 
00721   /* -------------- CLIST FOR SYMBOL INFORMATION --------------- */
00722 
00723   /*
00724    * Create the CList. For our needs, we use 2 columns.
00725    */
00726   cList = gtk_clist_new_with_titles(_SYMBOL_CLIST_COLUMNS_NB_,cListTitles);
00727   gtk_clist_column_titles_show((GtkCList*)cList);
00728   kernel->widgets.symbolCList = cList;
00729 
00730   /*
00731    * It isn't necessary to shadow the border, but it looks nice.
00732    */
00733   gtk_clist_set_shadow_type(GTK_CLIST(cList),GTK_SHADOW_OUT);
00734 
00735   /*
00736    * Multiple selection is possible.
00737    */
00738   gtk_clist_set_selection_mode(GTK_CLIST(cList),
00739                                GTK_SELECTION_EXTENDED);
00740 
00741   /*
00742    * What however is important, is that we set the column widths as
00743    * they will never be right otherwise.
00744    * Note that the columns are numbered from 0 and up (to 2 in our case).
00745    */
00746   gtk_clist_set_column_width(GTK_CLIST(cList),0,200);
00747   gtk_clist_set_column_width(GTK_CLIST(cList),1,050);
00748 
00749   gtk_clist_set_button_actions(GTK_CLIST(cList),
00750                                0, /* left button performs selection & DND */
00751                                GTK_BUTTON_SELECTS | GTK_BUTTON_DRAGS);
00752   gtk_clist_set_use_drag_icons(GTK_CLIST(cList),
00753                                FALSE /* use icons */);
00754 
00755   gtk_signal_connect(GTK_OBJECT(cList),
00756                      "select_row",
00757                      gdisp_listSelectionCallback,
00758                      kernel);
00759 
00760   gtk_signal_connect(GTK_OBJECT(cList),
00761                      "unselect_row",
00762                      gdisp_listDeselectionCallback,
00763                      kernel);
00764 
00765   /*
00766    * Add the CList widget to the vertical box and show it.
00767    */
00768   gtk_container_add(GTK_CONTAINER(scrolledWindow),cList);
00769   gtk_widget_show(cList);
00770 
00771   /*
00772    * Drag And Drop settings.
00773    * Set up the 'cList' as a potential DND source.
00774    * First we set up 'targetEntry' which is a structure which specifies
00775    * the kinds (which we define) of drags accepted on this widget.
00776    */
00777   targetEntry.target = GD_DND_TARGET_NAME;
00778   targetEntry.flags  = 0;
00779   targetEntry.info   = GD_DND_TARGET_INFO;
00780 
00781   gtk_drag_source_set(cList,
00782                       GDK_BUTTON1_MASK,
00783                       &targetEntry,
00784                       sizeof(targetEntry) / sizeof(GtkTargetEntry),
00785                       GDK_ACTION_COPY);
00786 
00787   /*
00788    * Set DND signals on 'cList'.
00789    */
00790   gtk_signal_connect(GTK_OBJECT(cList),
00791                      "drag_begin",
00792                      GTK_SIGNAL_FUNC(gdisp_beginDNDCallback),
00793                      kernel);
00794 
00795   gtk_signal_connect(GTK_OBJECT(cList),
00796                      "drag_end",
00797                      GTK_SIGNAL_FUNC(gdisp_endDNDCallback),
00798                      kernel);
00799 
00800   gtk_signal_connect(GTK_OBJECT(cList),
00801                      "drag_data_get",
00802                      GTK_SIGNAL_FUNC(gdisp_dataRequestDNDCallback),
00803                      kernel);
00804 
00805   gtk_signal_connect(GTK_OBJECT(cList),
00806                      "drag_data_received",
00807                      GTK_SIGNAL_FUNC(gdisp_dataReceivedDNDCallback),
00808                      kernel);
00809 
00810   gtk_signal_connect(GTK_OBJECT(cList),
00811                      "drag_data_delete",
00812                      GTK_SIGNAL_FUNC(gdisp_dataDestroyedDNDCallback),
00813                      kernel);
00814 
00815 
00816   /* ------------------------ FRAME WITH LABEL ----------------------- */
00817 
00818   /*
00819    * Create a Frame that will contain every sorting methods.
00820    * Align the label at the left of the frame.
00821    * Set the style of the frame.
00822    */
00823   frame = gtk_frame_new((gchar*)NULL);
00824   gtk_frame_set_shadow_type(GTK_FRAME(frame),GTK_SHADOW_ETCHED_IN);
00825 
00826   gtk_box_pack_start(GTK_BOX(parent),
00827                      frame,
00828                      FALSE /* expand  */,
00829                      TRUE  /* fill    */,
00830                      0     /* padding */);
00831   gtk_widget_show(frame);
00832 
00833 
00834   /* ------------------------ ANOTHER V BOX ----------------------- */
00835 
00836   /*
00837    * We need a vertical packing box.
00838    */
00839   otherVBox = gtk_vbox_new(FALSE, /* homogeneous */
00840                            5      /* spacing     */ );
00841   gtk_container_border_width(GTK_CONTAINER(otherVBox),3);
00842   gtk_container_add(GTK_CONTAINER(frame),otherVBox);
00843   gtk_widget_show(otherVBox);
00844 
00845 
00846   /* ------------- HORIZONTAL PACKING BOX INTO THE FRAME ------------- */
00847 
00848   /*
00849    * We need a horizontal packing box for managing the radio buttons.
00850    */
00851   otherHBox = gtk_hbox_new(FALSE, /* homogeneous */
00852                            5      /* spacing     */ );
00853   gtk_container_border_width(GTK_CONTAINER(otherHBox),3);
00854   gtk_box_pack_start(GTK_BOX(otherVBox),
00855                      otherHBox,
00856                      FALSE /* expand  */,
00857                      TRUE  /* fill    */,
00858                      0     /* padding */);
00859   gtk_widget_show(otherHBox);
00860 
00861 
00862   /* ---------------- RADIO BUTTON FOR SORTING METHODS --------------- */
00863 
00864   /*
00865    * Just a label to better understand.
00866    */
00867   label = gtk_label_new("Sort By   ");
00868   gtk_box_pack_start(GTK_BOX(otherHBox),
00869                      label,
00870                      FALSE /* expand  */,
00871                      TRUE  /* fill    */,
00872                      0     /* padding */);
00873   gtk_widget_show(label);
00874 
00875   /*
00876    * Sort by provider (default).
00877    */
00878   kernel->widgets.pRadioButton = gtk_radio_button_new_with_label((GSList*)NULL,
00879                                                                  "Provider");
00880   gtk_box_pack_start(GTK_BOX(otherHBox),
00881                      kernel->widgets.pRadioButton,
00882                      TRUE  /* expand  */,
00883                      TRUE  /* fill    */,
00884                      0     /* padding */);
00885   gtk_widget_show(kernel->widgets.pRadioButton);
00886 
00887   gtk_signal_connect(GTK_OBJECT(kernel->widgets.pRadioButton),
00888                      "clicked",
00889                      GTK_SIGNAL_FUNC(gdisp_changeSortingMethodCallback),
00890                      (gpointer)kernel);
00891 
00892   gtk_tooltips_set_tip(GTK_TOOLTIPS(toolTipGroup),
00893                        kernel->widgets.pRadioButton,
00894                        "Sort all symbols by provider",
00895                        "");
00896 
00897   /*
00898    * This radio button must be set to "no sensitive" when only one
00899    * provider is available.
00900    * Then choose correct sorting method.
00901    */
00902   if (gdisp_getProviderNumber(kernel) == 1) {
00903 
00904     gtk_widget_set_sensitive(kernel->widgets.pRadioButton,
00905                              FALSE /* not sensitive */);
00906     if (kernel->sortingMethod == GD_SORT_BY_PROVIDER)
00907       kernel->sortingMethod = GD_SORT_BY_NAME;
00908 
00909   }
00910 
00911   /*
00912    * Sort by name (ascending).
00913    */
00914   radioButtonGroup =
00915     gtk_radio_button_group(GTK_RADIO_BUTTON(kernel->widgets.pRadioButton));
00916 
00917   kernel->widgets.naRadioButton =
00918     gtk_radio_button_new_with_label(radioButtonGroup,
00919                                     "Name Ascending");
00920 
00921   gtk_box_pack_start(GTK_BOX(otherHBox),
00922                      kernel->widgets.naRadioButton,
00923                      TRUE  /* expand  */,
00924                      TRUE  /* fill    */,
00925                      0     /* padding */);
00926   gtk_widget_show(kernel->widgets.naRadioButton);
00927 
00928   gtk_signal_connect(GTK_OBJECT(kernel->widgets.naRadioButton),
00929                      "clicked",
00930                      GTK_SIGNAL_FUNC(gdisp_changeSortingMethodCallback),
00931                      (gpointer)kernel);
00932 
00933   gtk_tooltips_set_tip(GTK_TOOLTIPS(toolTipGroup),
00934                        kernel->widgets.naRadioButton,
00935                        "Sort all symbols alphabetically",
00936                        "");
00937 
00938   /*
00939    * Sort by name (descending).
00940    */
00941   radioButtonGroup =
00942     gtk_radio_button_group(GTK_RADIO_BUTTON(kernel->widgets.naRadioButton));
00943 
00944   kernel->widgets.ndRadioButton =
00945     gtk_radio_button_new_with_label(radioButtonGroup,
00946                                     "Name Descending");
00947 
00948   gtk_box_pack_start(GTK_BOX(otherHBox),
00949                      kernel->widgets.ndRadioButton,
00950                      TRUE  /* expand  */,
00951                      TRUE  /* fill    */,
00952                      0     /* padding */);
00953   gtk_widget_show(kernel->widgets.ndRadioButton);
00954 
00955   gtk_signal_connect(GTK_OBJECT(kernel->widgets.ndRadioButton),
00956                      "clicked",
00957                      GTK_SIGNAL_FUNC(gdisp_changeSortingMethodCallback),
00958                      (gpointer)kernel);
00959 
00960   gtk_tooltips_set_tip(GTK_TOOLTIPS(toolTipGroup),
00961                        kernel->widgets.ndRadioButton,
00962                        "Sort all symbols reverse-alphabetically",
00963                        "");
00964 
00965   /*
00966    * Take care of current sorting method in the kernel.
00967    */
00968   switch (kernel->sortingMethod) {
00969 
00970   case GD_SORT_BY_PROVIDER :
00971     radioStatuses[0 /* sort by provider        */] = TRUE;
00972     radioStatuses[1 /* sort by name ascending  */] = FALSE;
00973     radioStatuses[2 /* sort by name descending */] = FALSE;
00974     break;
00975 
00976   case GD_SORT_BY_NAME         :
00977     radioStatuses[0 /* sort by provider        */] = FALSE;
00978     radioStatuses[1 /* sort by name ascending  */] = TRUE;
00979     radioStatuses[2 /* sort by name descending */] = FALSE;
00980     break;
00981 
00982   case GD_SORT_BY_NAME_REVERSE :
00983     radioStatuses[0 /* sort by provider        */] = FALSE;
00984     radioStatuses[1 /* sort by name ascending  */] = FALSE;
00985     radioStatuses[2 /* sort by name descending */] = TRUE;
00986     break;
00987 
00988   default :
00989     break;
00990 
00991   }
00992 
00993   gtk_toggle_button_set_active(
00994                   GTK_TOGGLE_BUTTON(kernel->widgets.pRadioButton),
00995                   radioStatuses[0 /* sort by provider        */]);
00996 
00997   gtk_toggle_button_set_active(
00998                   GTK_TOGGLE_BUTTON(kernel->widgets.naRadioButton),
00999                   radioStatuses[1 /* sort by name ascending  */]);
01000 
01001   gtk_toggle_button_set_active(
01002                   GTK_TOGGLE_BUTTON(kernel->widgets.ndRadioButton),
01003                   radioStatuses[2 /* sort by name descending */]);
01004 
01005 
01006   /* -------------------- HORIZONTAL SEPARATOR --------------------- */
01007 
01008   hSeparator = gtk_hseparator_new();
01009   gtk_box_pack_start(GTK_BOX(otherVBox),
01010                      hSeparator,
01011                      FALSE /* expand  */,
01012                      TRUE  /* fill    */,
01013                      0     /* padding */);
01014   gtk_widget_show(hSeparator);
01015 
01016 
01017   /* ------------------------ PACKING BOX ------------------------ */
01018 
01019   /*
01020    * We need a horizontal packing box for managing the filter and the label.
01021    */
01022   otherHBox = gtk_hbox_new(FALSE, /* homogeneous */
01023                            5      /* spacing     */ );
01024   gtk_container_border_width(GTK_CONTAINER(otherHBox),5);
01025   gtk_box_pack_start(GTK_BOX(otherVBox),
01026                      otherHBox,
01027                      FALSE /* expand  */,
01028                      TRUE  /* fill    */,
01029                      0     /* padding */);
01030   gtk_widget_show(otherHBox);
01031 
01032 
01033   /* ---------------------- LABEL + FILTER --------------------- */
01034 
01035   /*
01036    * Just a label to better understand.
01037    */
01038   label = gtk_label_new("Filter     ");
01039   gtk_box_pack_start(GTK_BOX(otherHBox),
01040                      label,
01041                      FALSE /* expand  */,
01042                      TRUE  /* fill    */,
01043                      0     /* padding */);
01044   gtk_widget_show(label);
01045 
01046   /*
01047    * Create the entry to enter any filter information.
01048    */
01049   kernel->widgets.filterEntry = gtk_entry_new();
01050   gtk_box_pack_start(GTK_BOX(otherHBox),
01051                      kernel->widgets.filterEntry,
01052                      TRUE  /* expand  */,
01053                      TRUE  /* fill    */,
01054                      0     /* padding */);
01055   gtk_widget_show(kernel->widgets.filterEntry);
01056 
01057   gtk_tooltips_set_tip(GTK_TOOLTIPS(toolTipGroup),
01058                        kernel->widgets.filterEntry,
01059                        "Add coma-separated strings to reduce the size "
01060                        "of the list (case sensitive)",
01061                        "");
01062 
01063 
01064   /* -------------------- HORIZONTAL SEPARATOR --------------------- */
01065 
01066   hSeparator = gtk_hseparator_new();
01067   gtk_box_pack_start(GTK_BOX(otherVBox),
01068                      hSeparator,
01069                      FALSE /* expand  */,
01070                      TRUE  /* fill    */,
01071                      0     /* padding */);
01072   gtk_widget_show(hSeparator);
01073 
01074 
01075   /* ------------- HORIZONTAL PACKING BOX INTO THE FRAME ------------- */
01076 
01077   /*
01078    * We need a horizontal packing box for managing the radio buttons.
01079    */
01080   otherHBox = gtk_hbox_new(FALSE, /* homogeneous */
01081                            5      /* spacing     */ );
01082   gtk_container_border_width(GTK_CONTAINER(otherHBox),3);
01083   gtk_box_pack_start(GTK_BOX(otherVBox),
01084                      otherHBox,
01085                      FALSE /* expand  */,
01086                      TRUE  /* fill    */,
01087                      0     /* padding */);
01088   gtk_widget_show(otherHBox);
01089 
01090 
01091   /* ---------------- RADIO BUTTON FOR DnD SCOPE --------------- */
01092 
01093   /*
01094    * Just a label to better understand.
01095    */
01096   label = gtk_label_new("Drag & Drop Scope       ");
01097   gtk_box_pack_start(GTK_BOX(otherHBox),
01098                      label,
01099                      FALSE  /* expand  */,
01100                      FALSE /* fill    */,
01101                      0     /* padding */);
01102   gtk_widget_show(label);
01103 
01104   /*
01105    * Drag & Drop Scope is "Unique" (the target is a unique graphic plot).
01106    */
01107   kernel->widgets.uRadioButton = gtk_radio_button_new_with_label((GSList*)NULL,
01108                                                                  "Unique");
01109   gtk_box_pack_start(GTK_BOX(otherHBox),
01110                      kernel->widgets.uRadioButton,
01111                      TRUE  /* expand  */,
01112                      TRUE  /* fill    */,
01113                      0     /* padding */);
01114   gtk_widget_show(kernel->widgets.uRadioButton);
01115 
01116   gtk_signal_connect(GTK_OBJECT(kernel->widgets.uRadioButton),
01117                      "clicked",
01118                      GTK_SIGNAL_FUNC(gdisp_changeDnDScopeCallback),
01119                      (gpointer)kernel);
01120 
01121   gtk_tooltips_set_tip(GTK_TOOLTIPS(toolTipGroup),
01122                        kernel->widgets.uRadioButton,
01123                        "Only the graphic plot on which the drop action "
01124                        "occured will receive the new symbols",
01125                        "");
01126 
01127   /*
01128    * Drag & Drop Scope is "Single Page".
01129    * All graphic plots inside the page that received the drop action will
01130    * be given the symbols.
01131    */
01132   radioButtonGroup =
01133     gtk_radio_button_group(GTK_RADIO_BUTTON(kernel->widgets.uRadioButton));
01134 
01135   kernel->widgets.spRadioButton =
01136     gtk_radio_button_new_with_label(radioButtonGroup,
01137                                     "Single Page");
01138 
01139   gtk_box_pack_start(GTK_BOX(otherHBox),
01140                      kernel->widgets.spRadioButton,
01141                      TRUE  /* expand  */,
01142                      TRUE  /* fill    */,
01143                      0     /* padding */);
01144   gtk_widget_show(kernel->widgets.spRadioButton);
01145 
01146   gtk_signal_connect(GTK_OBJECT(kernel->widgets.spRadioButton),
01147                      "clicked",
01148                      GTK_SIGNAL_FUNC(gdisp_changeDnDScopeCallback),
01149                      (gpointer)kernel);
01150 
01151   gtk_tooltips_set_tip(GTK_TOOLTIPS(toolTipGroup),
01152                        kernel->widgets.spRadioButton,
01153                        "All graphic plots belonging to the page on which "
01154                        "the drop action occured will receive the new symbols",
01155                        "");
01156 
01157 
01158   /*
01159    * Drag & Drop Scope is "All Pages".
01160    * All graphic plots of all existing pages will be given the symbols.
01161    */
01162   radioButtonGroup =
01163     gtk_radio_button_group(GTK_RADIO_BUTTON(kernel->widgets.spRadioButton));
01164 
01165   kernel->widgets.apRadioButton =
01166     gtk_radio_button_new_with_label(radioButtonGroup,
01167                                     "All Pages");
01168 
01169   gtk_box_pack_start(GTK_BOX(otherHBox),
01170                      kernel->widgets.apRadioButton,
01171                      TRUE  /* expand  */,
01172                      TRUE  /* fill    */,
01173                      0     /* padding */);
01174   gtk_widget_show(kernel->widgets.apRadioButton);
01175 
01176   gtk_signal_connect(GTK_OBJECT(kernel->widgets.apRadioButton),
01177                      "clicked",
01178                      GTK_SIGNAL_FUNC(gdisp_changeDnDScopeCallback),
01179                      (gpointer)kernel);
01180 
01181   gtk_tooltips_set_tip(GTK_TOOLTIPS(toolTipGroup),
01182                        kernel->widgets.apRadioButton,
01183                        "All graphic plots of all graphic pages "
01184                        "will receive the new symbols",
01185                        "");
01186 
01187 
01188   /* ------------------------ LIST OF SYMBOLS  ------------------------ */
01189 
01190   /*
01191    * Insert symbols into the corresponding CList.
01192    * ...according to the default sorting method in the kernel...
01193    */
01194   symbolCount = gdispInsertAndSortSymbols(kernel,
01195                                           (gchar**)NULL /* no filter */,
01196                                           (guint)0      /* no filter */);
01197 
01198 
01199   /*
01200    * Keep in mind that the GString is released into the
01201    * 'gdispOutputWrite' function.
01202    * Do not 'g_string_free' it.
01203    */
01204   messageString = g_string_new((gchar*)NULL);
01205   g_string_sprintf(messageString,
01206                    "A total of %d symbols have been processed.",
01207                    symbolCount);
01208   kernel->outputFunc(kernel,messageString,
01209                      symbolCount == 0 ? GD_ERROR : GD_MESSAGE);
01210 
01211 
01212   /*
01213    * Change frame label.
01214    */
01215   messageString = g_string_new((gchar*)NULL);
01216   g_string_sprintf(messageString,
01217                    " Available Symbols : %d ",
01218                    symbolCount);
01219   gtk_frame_set_label(GTK_FRAME(kernel->widgets.symbolFrame),
01220                       messageString->str);
01221   g_string_free(messageString,TRUE);
01222 
01223 }
01224 
01225 
01226 /*
01227  * Destroy GDISP+ symbol list.
01228  */
01229 void
01230 gdisp_destroySymbolList ( Kernel_T *kernel )
01231 {
01232 
01233   /*
01234    * Nothing by now.
01235    */
01236 
01237 }
Framework Home Page.

Beware !! TSP wave is coming...