Ejemplo n.º 1
0
static void
player_error_cb (PtPlayer *player,
                 GError   *error,
                 PtWindow *win)
{
    destroy_progress_dlg (win);
    pt_window_ready_to_play (win, FALSE);
    pt_error_message (win, error->message);
}
Ejemplo n.º 2
0
static void
pt_window_ready_to_play (PtWindow *win,
                         gboolean  state)
{
    /* Set up widget sensitivity/visibility, actions, labels, window title
       and timer according to the state of PtPlayer (ready to play or not).
       Reset tooltips for insensitive widgets. */

    gchar     *display_name = NULL;

    enable_win_actions (win, state);
    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (win->priv->button_play), FALSE);
    gtk_widget_set_visible (win->priv->button_play, state);
    gtk_widget_set_visible (win->priv->button_open, !state);

    gtk_widget_set_sensitive (win->priv->button_play, state);
    gtk_widget_set_sensitive (win->priv->button_fast_back, state);
    gtk_widget_set_sensitive (win->priv->button_fast_forward, state);
    gtk_widget_set_sensitive (win->priv->button_jump_back, state);
    gtk_widget_set_sensitive (win->priv->button_jump_forward, state);
    gtk_widget_set_sensitive (win->priv->speed_scale, state);

    if (state) {
        destroy_progress_dlg (win);
        display_name = pt_player_get_filename (win->priv->player);
        if (display_name) {
            gtk_window_set_title (GTK_WINDOW (win), display_name);
            g_free (display_name);
        }
        gtk_recent_manager_add_item (
            win->priv->recent,
            pt_player_get_uri (win->priv->player));

        change_play_button_tooltip (win);
        change_jump_back_tooltip (win);
        change_jump_forward_tooltip (win);
        pt_waveslider_set_follow_cursor (PT_WAVESLIDER (win->priv->waveslider), TRUE);
        win->priv->wavedata = pt_player_get_data (win->priv->player);
        pt_waveslider_set_wave (PT_WAVESLIDER (win->priv->waveslider),
                                win->priv->wavedata);
        /* add timer after waveslider, didn't update cursor otherwise sometimes */
        add_timer (win);

    } else {
        gtk_label_set_text (GTK_LABEL (win->priv->pos_label), "00:00.0");
        gtk_window_set_title (GTK_WINDOW (win), "Parlatype");
        gtk_widget_set_tooltip_text (win->priv->button_jump_back, NULL);
        gtk_widget_set_tooltip_text (win->priv->button_jump_forward, NULL);
        remove_timer (win);
        pt_wavedata_free (win->priv->wavedata);
        win->priv->wavedata = NULL;
        pt_waveslider_set_wave (PT_WAVESLIDER (win->priv->waveslider),
                                win->priv->wavedata);
    }
}
Ejemplo n.º 3
0
static void
open_cb (PtPlayer     *player,
         GAsyncResult *res,
         gpointer     *data)
{
    PtWindow *win = (PtWindow *) data;
    GError	 *error = NULL;

    destroy_progress_dlg (win);

    if (!pt_player_open_uri_finish (player, res, &error)) {
        pt_error_message (win, error->message);
        g_error_free (error);
        return;
    }

    pt_window_ready_to_play (win, TRUE);
}
Ejemplo n.º 4
0
static void
pt_window_dispose (GObject *object)
{
    PtWindow *win;
    win = PT_WINDOW (object);

    close_dbus_service (win);

    if (win->priv->editor) {
        gint x;
        gint y;
        gtk_window_get_position (GTK_WINDOW (win), &x, &y);
        g_settings_set_int (win->priv->editor, "x-pos", x);
        g_settings_set_int (win->priv->editor, "y-pos", y);
        gtk_window_get_size (GTK_WINDOW (win), &x, &y);
        g_settings_set_int (win->priv->editor, "width", x);
        g_settings_set_int (win->priv->editor, "height", y);
    }

    remove_timer (win);
    g_clear_object (&win->priv->editor);
    g_clear_object (&win->priv->proxy);
    destroy_progress_dlg (win);
    /* Using g_clear_object or g_object_unref + win->priv->player = NULL
       doesn't dispose the object properly, it doesn't remember last
       position (called in dispose). Don't know why. This solution seems to work. */
    if (G_IS_OBJECT (win->priv->player)) {
        g_object_unref (win->priv->player);
    }
    if (win->priv->wavedata) {
        pt_wavedata_free (win->priv->wavedata);
        win->priv->wavedata = NULL;
    }

    G_OBJECT_CLASS (pt_window_parent_class)->dispose (object);
}
Ejemplo n.º 5
0
ph_stats_t*
ph_stats_new(void)
{
    ph_stats_t	*ps;
    frame_data	*frame;
    guint		tot_packets, tot_bytes;
    progdlg_t	*progbar = NULL;
    gboolean	stop_flag;
    int		count;
    float		progbar_val;
    GTimeVal	start_time;
    gchar		status_str[100];
    int		progbar_nextstep;
    int		progbar_quantum;

    /* Initialize the data */
    ps = g_new(ph_stats_t, 1);
    ps->tot_packets = 0;
    ps->tot_bytes = 0;
    ps->stats_tree = g_node_new(NULL);
    ps->first_time = 0.0;
    ps->last_time = 0.0;

    /* Update the progress bar when it gets to this value. */
    progbar_nextstep = 0;
    /* When we reach the value that triggers a progress bar update,
       bump that value by this amount. */
    progbar_quantum = cfile.count/N_PROGBAR_UPDATES;
    /* Count of packets at which we've looked. */
    count = 0;
    /* Progress so far. */
    progbar_val = 0.0f;

    stop_flag = FALSE;
    g_get_current_time(&start_time);

    tot_packets = 0;
    tot_bytes = 0;

    for (frame = cfile.plist_start; frame != NULL; frame = frame->next) {
        /* Create the progress bar if necessary.
           We check on every iteration of the loop, so that
           it takes no longer than the standard time to create
           it (otherwise, for a large file, we might take
           considerably longer than that standard time in order
           to get to the next progress bar step). */
        if (progbar == NULL)
            progbar = delayed_create_progress_dlg(
                          "Computing", "protocol hierarchy statistics",
                          TRUE, &stop_flag, &start_time, progbar_val);

        /* Update the progress bar, but do it only N_PROGBAR_UPDATES
           times; when we update it, we have to run the GTK+ main
           loop to get it to repaint what's pending, and doing so
           may involve an "ioctl()" to see if there's any pending
           input from an X server, and doing that for every packet
           can be costly, especially on a big file. */
        if (count >= progbar_nextstep) {
            /* let's not divide by zero. I should never be started
             * with count == 0, so let's assert that
             */
            g_assert(cfile.count > 0);

            progbar_val = (gfloat) count / cfile.count;

            if (progbar != NULL) {
                g_snprintf(status_str, sizeof(status_str),
                           "%4u of %u frames", count, cfile.count);
                update_progress_dlg(progbar, progbar_val, status_str);
            }

            progbar_nextstep += progbar_quantum;
        }

        if (stop_flag) {
            /* Well, the user decided to abort the statistics.
               computation process  Just stop. */
            break;
        }

        /* Skip frames that are hidden due to the display filter.
           XXX - should the progress bar count only packets that
           passed the display filter?  If so, it should
           probably do so for other loops (see "file.c") that
           look only at those packets. */
        if (frame->flags.passed_dfilter) {

            if (tot_packets == 0) {
                double cur_time = nstime_to_sec(&frame->abs_ts);
                ps->first_time = cur_time;
                ps->last_time = cur_time;
            }

            /* we don't care about colinfo */
            if (!process_frame(frame, NULL, ps)) {
                /*
                 * Give up, and set "stop_flag" so we
                 * just abort rather than popping up
                 * the statistics window.
                 */
                stop_flag = TRUE;
                break;
            }

            tot_packets++;
            tot_bytes += frame->pkt_len;
        }

        count++;
    }

    /* We're done calculating the statistics; destroy the progress bar
           if it was created. */
    if (progbar != NULL)
        destroy_progress_dlg(progbar);

    if (stop_flag) {
        /*
         * We quit in the middle; throw away the statistics
         * and return NULL, so our caller doesn't pop up a
         * window with the incomplete statistics.
         */
        ph_stats_free(ps);
        return NULL;
    }

    ps->tot_packets = tot_packets;
    ps->tot_bytes = tot_bytes;

    return ps;
}
Ejemplo n.º 6
0
void progress_window_destroy(progdlg *progress_dialog) {
    destroy_progress_dlg(progress_dialog);
}