diff options
Diffstat (limited to 'src/project.c')
| -rw-r--r-- | src/project.c | 95 | 
1 files changed, 85 insertions, 10 deletions
diff --git a/src/project.c b/src/project.c index cf76a33..14261f3 100644 --- a/src/project.c +++ b/src/project.c @@ -44,6 +44,10 @@ typedef struct _loaded_binary  {      GOpenidaBinary *binary;                 /* Binaire en question         */ +    bool lines_set;                         /* Construction complète       */ +    GMutex *mutex;                          /* Accès à la variable         */ +    GCond *cond;                            /* Attente de changement       */ +      GtkWidget *views[BVW_COUNT];            /* Composants pour l'affichage */  } loaded_binary; @@ -52,6 +56,9 @@ typedef struct _loaded_binary  /* Met en place un nouveau binaire pour un projet. */  loaded_binary *load_openida_binary(GOpenidaBinary *); +/* Prend note de la fin d'une construction d'une visualisation. */ +static void notify_loaded_binary(GtkBinView *, loaded_binary *); +  /* Fournit un support d'affichage donné pour un binaire chargé. */  GtkWidget *get_loaded_binary_view(const loaded_binary *, BinaryView); @@ -68,6 +75,7 @@ struct openida_project      loaded_binary **binaries;               /* Fichiers binaires associés  */      size_t binaries_count;                  /* Nombre de ces fichiers      */ +    GMutex *mutex;                          /* Modification de la liste    */ @@ -108,8 +116,15 @@ loaded_binary *load_openida_binary(GOpenidaBinary *binary)      result->binary = binary; +    result->mutex = g_mutex_new(); +    result->cond = g_cond_new(); +      for (i = 0; i < BVW_COUNT; i++)      { +        /* Préparation du support */ + +        gdk_threads_enter(); +          scrolledwindow = qck_create_scrolled_window(NULL, NULL);          switch (i) @@ -123,15 +138,37 @@ loaded_binary *load_openida_binary(GOpenidaBinary *binary)                  break;          } +        gdk_flush (); +        gdk_threads_leave(); + +        result->lines_set = false; + +        g_signal_connect(view, "lines-set", G_CALLBACK(notify_loaded_binary), result); +          gtk_bin_view_set_rendering_lines(GTK_BIN_VIEW(view), binary,                                           g_openida_binary_get_lines(binary), NULL); +        /* Attente de la fin de construction */ +        g_mutex_lock(result->mutex); +        while (!result->lines_set) +            g_cond_wait(result->cond, result->mutex); +        g_mutex_unlock(result->mutex); + +        g_signal_handlers_disconnect_by_func(view, G_CALLBACK(notify_loaded_binary), result); + +        /* Intégration finale */ + +        gdk_threads_enter(); +          gtk_widget_show(view);          gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolledwindow), view);          result->views[i] = scrolledwindow; +        gdk_flush (); +        gdk_threads_leave(); +      }      return result; @@ -139,8 +176,29 @@ loaded_binary *load_openida_binary(GOpenidaBinary *binary)  } +/****************************************************************************** +*                                                                             * +*  Paramètres  : view   = composant d'affichage prêt à utilisation.           * +*                binary = binaire chargé et encadré.                          * +*                                                                             * +*  Description : Prend note de la fin d'une construction d'une visualisation. * +*                                                                             * +*  Retour      : -                                                            * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +static void notify_loaded_binary(GtkBinView *view, loaded_binary *binary) +{ +    g_mutex_lock(binary->mutex); +    binary->lines_set = true; +    g_cond_signal(binary->cond); +    g_mutex_unlock(binary->mutex); + +} @@ -220,8 +278,16 @@ openida_project *create_empty_openida_project(GObject *ref)      result->ref = ref; +    result->mutex = g_mutex_new(); +    if (result->mutex == NULL) +        goto crop_error; +      return result; + crop_error: + +    return NULL; +  } @@ -402,18 +468,28 @@ bool has_storing_filename(const openida_project *project)  *                                                                             *  *  Description : Attache un fichier donné à un projet donné.                  *  *                                                                             * -*  Retour      : -                                                            * +*  Retour      : Emplacement de l'élément créé.                               *  *                                                                             *  *  Remarques   : -                                                            *  *                                                                             *  ******************************************************************************/ -void attach_binary_to_openida_project(openida_project *project, GOpenidaBinary *binary) +size_t attach_binary_to_openida_project(openida_project *project, GOpenidaBinary *binary)  { +    size_t result;                          /* Indice à retourner          */ + +    g_mutex_lock(project->mutex); +      project->binaries = (loaded_binary **)realloc(project->binaries, -                                                   ++project->binaries_count * sizeof(loaded_binary *)); +                                                  ++project->binaries_count * sizeof(loaded_binary *)); + +    result = project->binaries_count - 1; + +    g_mutex_unlock(project->mutex); -    project->binaries[project->binaries_count - 1] = load_openida_binary(binary); +    project->binaries[result] = load_openida_binary(binary); + +    return result;  } @@ -679,11 +755,7 @@ void display_new_binary_of_openida_project(GOpenidaBinary *binary, openida_proje      GtkDockItem *ditem;                     /* Panneau avec ses infos.     */      GtkBinView *binview;                    /* Affichage à faire défiler   */ - - - -    attach_binary_to_openida_project(project, binary); -    index = project->binaries_count - 1; +    index = attach_binary_to_openida_project(project, binary);      dpanel = GTK_DOCK_PANEL(g_object_get_data(project->ref, "binpanel")); @@ -691,10 +763,13 @@ void display_new_binary_of_openida_project(GOpenidaBinary *binary, openida_proje      title = g_openida_binary_to_string(binary); +    gdk_threads_enter(); +      ditem = gtk_dock_item_new(strrchr(title, '/') + 1, view);      gtk_dock_item_set_desc(ditem, title);      gtk_dock_panel_add_item(dpanel, ditem); - +    gdk_flush (); +    gdk_threads_leave();  }  | 
