Пример #1
0
void
gpa_progress_bar_set_context (GpaProgressBar *pbar, GpaContext *context)
{
  g_return_if_fail (GTK_IS_PROGRESS_BAR (pbar));

  if (pbar->context)
    {
      g_signal_handler_disconnect (G_OBJECT (pbar->context),
				   pbar->sig_id_start);
      g_signal_handler_disconnect (G_OBJECT (pbar->context),
				   pbar->sig_id_done);
      g_signal_handler_disconnect (G_OBJECT (pbar->context),
				   pbar->sig_id_progress);
    }
  
  pbar->context = context;
  if (context)
    {
      pbar->sig_id_start = g_signal_connect (G_OBJECT (context), "start",
					     G_CALLBACK (start_cb), pbar);
      pbar->sig_id_done = g_signal_connect (G_OBJECT (context), "done",
					    G_CALLBACK (done_cb), pbar);
      pbar->sig_id_progress = g_signal_connect (G_OBJECT (context), "progress",
						G_CALLBACK (progress_cb), pbar);
    }
}
Пример #2
0
static void
update_pulse_time (GtkAdjustment *adjustment, GtkWidget *widget)
{
  gdouble value;
  guint pulse_id;

  value = gtk_adjustment_get_value (adjustment);

  pulse_id = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (widget), "pulse_id"));

  /* vary between 50 and 450 */
  pulse_time = 50 + 4 * value;

  if (value == 100)
    {
      g_object_set_data (G_OBJECT (widget), "pulse_id", NULL);
    }
  else if (value < 100)
    {
      if (pulse_id == 0 && (GTK_IS_PROGRESS_BAR (widget) || pulse_entry_mode % 3 == 2))
        {
          pulse_id = g_timeout_add (pulse_time, (GSourceFunc)pulse_it, widget);
          g_object_set_data_full (G_OBJECT (widget), "pulse_id", GUINT_TO_POINTER (pulse_id), remove_pulse);
        }
    }
}
Пример #3
0
/**
* operation: The operation to process
* message: The message that will be pushed to the status bar
* fract: The fraction of the progress bar to fill
* swidget: The SeahorseWidget to extract the gtk widgets from
*
* This gets called whenever an operation updates it's progress status thingy.
* We update the appbar as appropriate. If operation != NULL then we only
* display the latest operation in our special list
*
**/
static void
operation_progress (SeahorseOperation *operation, const gchar *message, 
                    gdouble fract, SeahorseWidget *swidget)
{
    GtkProgressBar *progress;
    GtkStatusbar *status;
    guint id; 
    
    progress = GTK_PROGRESS_BAR (seahorse_widget_get_widget (swidget, "progress"));
    status = GTK_STATUSBAR (seahorse_widget_get_widget (swidget, "status"));
    
    if (!seahorse_operation_is_running (operation))
        fract = 0.0;
    
    if (message != NULL && status) {
        g_return_if_fail (GTK_IS_STATUSBAR (status));
        id = gtk_statusbar_get_context_id (status, "operation-progress");
        gtk_statusbar_pop (status, id);
        if (message[0])
            gtk_statusbar_push (status, id, message);
    }

    if(progress) {
        g_return_if_fail (GTK_IS_PROGRESS_BAR (progress));
        if (fract >= 0.0) {
            stop_pulse (progress);
            gtk_progress_bar_set_fraction (progress, fract);        
        } else { 
            start_pulse (progress);
        }
    }
}
Пример #4
0
/* update the animation information for each widget. This will also queue a redraw
 * and stop the animation if it is done. */
static gboolean
update_animation_info (gpointer key, gpointer value, gpointer user_data)
{
	AnimationInfo *animation_info = value;
	GtkWidget *widget = key;
	gdouble elapsed;
	
	if ((widget == NULL) || (animation_info == NULL))
		g_assert_not_reached ();
	
	/* remove the widget from the hash table if it is not drawable */
	if (!GTK_WIDGET_DRAWABLE (widget))
		return TRUE;
	
	if (GTK_IS_PROGRESS_BAR (widget))
	{
		gfloat fraction = gtk_progress_bar_get_fraction (GTK_PROGRESS_BAR (widget));
		
		/* stop animation for filled/not filled progress bars */
		if (fraction <= 0.0 || fraction >= 1.0)
			return TRUE;
	}
	
	force_widget_redraw (widget);
	
	/* stop at stop_time */
	if (animation_info->stop_time != 0 &&
	    g_timer_elapsed (animation_info->timer, NULL) > animation_info->stop_time)
		return TRUE;
	
	return FALSE;
}
Пример #5
0
/* This forces a redraw on a widget */
static gboolean
force_widget_redraw (GtkWidget *widget)
{
	if (GTK_IS_PROGRESS_BAR (widget))
		gtk_widget_queue_resize (widget);
	else
		gtk_widget_queue_draw (widget);
}
Пример #6
0
/* This forces a redraw on a widget */
static void
force_widget_redraw(GtkWidget *widget)
{
    if (GTK_IS_PROGRESS_BAR(widget)) {
        gtk_widget_queue_resize(widget);
    } else {
        gtk_widget_queue_draw(widget);
    }
}
Пример #7
0
static void
move_progress(GtkWidget *entry, gpointer progress)
{
	gdouble step;
	g_return_if_fail(GTK_IS_PROGRESS_BAR(progress));
	
	step = g_random_double_range(0.03, 0.1);
	gtk_progress_bar_set_pulse_step(GTK_PROGRESS_BAR(progress), step);
	gtk_progress_bar_pulse(GTK_PROGRESS_BAR(progress));
}
Пример #8
0
/**
* progress: The progress bar to pulse
*
* Called to pulse the progress bar when we're in pulse mode
*
* Returns TRUE if the bar pulsed
**/
static gboolean
pulse_timer (GtkProgressBar *progress)
{
    g_assert (GTK_IS_PROGRESS_BAR (progress));
    
    if (gtk_progress_bar_get_pulse_step (progress) != 0) {
        gtk_progress_bar_pulse (progress);
         return TRUE;
    }
    
    return FALSE;
}
Пример #9
0
void
hide_pulse_progress_bar (AnjutaCommand *command, guint return_code,
						 GtkProgressBar *progress_bar)
{
	guint timer_id;
	
	/* If the progress bar has already been destroyed, the timer should be 
	 * stopped by stop_pulse_timer */
	if (GTK_IS_PROGRESS_BAR (progress_bar))
	{
		timer_id = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (progress_bar),
														"pulse-timer-id")); 
		
		g_source_remove (GPOINTER_TO_UINT (timer_id));
		gtk_widget_hide (GTK_WIDGET (progress_bar));
	}
}
Пример #10
0
/* update the animation information for each widget. This will also queue a redraw
 * and stop the animation if it is done. */
static gboolean
qtcAnimationUpdateInfo(gpointer key, gpointer value, gpointer user_data)
{
    QTC_UNUSED(user_data);
    AnimationInfo *animation_info = value;
    GtkWidget *widget = key;

    if ((widget == NULL) || (animation_info == NULL))
        g_assert_not_reached();

    /* remove the widget from the hash table if it is not drawable */
    if (!gtk_widget_is_drawable(widget))
        return TRUE;

    if (GTK_IS_PROGRESS_BAR(widget)) {
        gfloat fraction =
            gtk_progress_bar_get_fraction(GTK_PROGRESS_BAR(widget));
        /* stop animation for filled/not filled progress bars */
        if (fraction <= 0.0 || fraction >= 1.0) {
            return TRUE;
        }
    } else if (GTK_IS_ENTRY(widget)) {
        gfloat fraction = gtk_entry_get_progress_fraction(GTK_ENTRY(widget));

        /* stop animation for filled/not filled progress bars */
        if(fraction <= 0.0 || fraction >= 1.0) {
            return TRUE;
        }
    }

    force_widget_redraw(widget);

    /* stop at stop_time */
    if(animation_info->stop_time != 0 &&
       g_timer_elapsed(animation_info->timer, NULL) > animation_info->stop_time)
        return TRUE;
    return FALSE;
}
Пример #11
0
GpaContext *
gpa_progress_bar_get_context (GpaProgressBar *pbar)
{
  g_return_val_if_fail (GTK_IS_PROGRESS_BAR (pbar), 0);
  return pbar->context;
}
Пример #12
0
EaseDialogProgress* ease_dialog_progress_construct (GType object_type, const char* title, gboolean cancellable, double max, GtkWindow* modal) {
#line 104 "ease-dialog-progress.c"
	EaseDialogProgress * self;
	GtkBuilder* _tmp0_;
	GObject* _tmp3_;
	GtkDialog* _tmp4_;
	GObject* _tmp5_;
	GtkButton* _tmp6_;
	GObject* _tmp7_;
	GtkProgressBar* _tmp8_;
	GError * _inner_error_ = NULL;
#line 43 "ease-dialog-progress.vala"
	g_return_val_if_fail (title != NULL, NULL);
#line 43 "ease-dialog-progress.vala"
	self = (EaseDialogProgress*) g_object_new (object_type, NULL);
#line 46 "ease-dialog-progress.vala"
	self->priv->max_val = max;
#line 48 "ease-dialog-progress.vala"
	self->priv->builder = (_tmp0_ = gtk_builder_new (), _g_object_unref0 (self->priv->builder), _tmp0_);
#line 122 "ease-dialog-progress.c"
	{
		char* _tmp1_;
		char* _tmp2_;
#line 51 "ease-dialog-progress.vala"
		gtk_builder_add_from_file (self->priv->builder, _tmp2_ = ease_data_path (_tmp1_ = g_build_filename (EASE_TEMP_UI_DIR, EASE_DIALOG_PROGRESS_UI_FILE, NULL)), &_inner_error_);
#line 128 "ease-dialog-progress.c"
		_g_free0 (_tmp2_);
		_g_free0 (_tmp1_);
		if (_inner_error_ != NULL) {
			goto __catch8_g_error;
		}
	}
	goto __finally8;
	__catch8_g_error:
	{
		GError * e;
		e = _inner_error_;
		_inner_error_ = NULL;
		{
#line 54 "ease-dialog-progress.vala"
			g_error ("ease-dialog-progress.vala:54: Error loading UI: %s", e->message);
#line 144 "ease-dialog-progress.c"
			_g_error_free0 (e);
		}
	}
	__finally8:
	if (_inner_error_ != NULL) {
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
		g_clear_error (&_inner_error_);
		return NULL;
	}
#line 57 "ease-dialog-progress.vala"
	self->priv->dialog = (_tmp4_ = _g_object_ref0 ((_tmp3_ = gtk_builder_get_object (self->priv->builder, "dialog"), GTK_IS_DIALOG (_tmp3_) ? ((GtkDialog*) _tmp3_) : NULL)), _g_object_unref0 (self->priv->dialog), _tmp4_);
#line 58 "ease-dialog-progress.vala"
	self->priv->cancel = (_tmp6_ = _g_object_ref0 ((_tmp5_ = gtk_builder_get_object (self->priv->builder, "cancel"), GTK_IS_BUTTON (_tmp5_) ? ((GtkButton*) _tmp5_) : NULL)), _g_object_unref0 (self->priv->cancel), _tmp6_);
#line 59 "ease-dialog-progress.vala"
	self->priv->progress = (_tmp8_ = _g_object_ref0 ((_tmp7_ = gtk_builder_get_object (self->priv->builder, "progress"), GTK_IS_PROGRESS_BAR (_tmp7_) ? ((GtkProgressBar*) _tmp7_) : NULL)), _g_object_unref0 (self->priv->progress), _tmp8_);
#line 62 "ease-dialog-progress.vala"
	gtk_window_set_title ((GtkWindow*) self->priv->dialog, title);
#line 63 "ease-dialog-progress.vala"
	gtk_widget_set_visible ((GtkWidget*) self->priv->cancel, cancellable);
#line 164 "ease-dialog-progress.c"
	return self;
}
END_TEST
#endif

/* ----- Test case for new_cancel_with_progress_bar -----*/

/**
 * Purpose: Check that note dialog is properly created with description regular values.
 * Cases considered:
 *    - Create new confirmation note with description set to TEST_STRING and NULL GtkProgressBar.
 *    - Create new confirmation note with description set to "" and correct GtkProgressBar.
 *
 */
START_TEST (test_new_cancel_with_progress_bar_regular)
{
    const gchar * description = NULL;
    const gchar * ret_description = NULL;
    GValue value= {0, };
    GValue enum_value= {0, };
    GtkProgressBar * progress_bar=NULL;

    HildonNoteType note_type;

    g_value_init (&value, G_TYPE_STRING);
    g_value_init (&enum_value, G_TYPE_INT);

    /* Test 1: create new confirmation note with description set to TEST_STRING and NULL GtkProgressBar */
    description = TEST_STRING;
    note = HILDON_NOTE(hildon_note_new_cancel_with_progress_bar(n_window,description,progress_bar));
    fail_if(!HILDON_IS_NOTE(note),
            "hildon-note: Creation failed with hildon_note_new_cancel_with_progress_bar");

    g_object_get_property(G_OBJECT (note),"description",&value);
    ret_description = g_value_get_string (&value);
    fail_if( strcmp (description,ret_description) != 0,
             "hildon-note: Description (%s) was not set properly on creation. Returned description: %s",
             description,ret_description);

    g_object_get_property(G_OBJECT (note),"note_type",&enum_value);
    note_type = g_value_get_int(&enum_value);
    fail_if( note_type != HILDON_NOTE_TYPE_PROGRESSBAR,
             "hildon-note: Type was not set property on creation (HILDON_NOTE_TYPE_PROGRESSBAR)",note_type);

    gtk_widget_destroy (GTK_WIDGET (note));
    note=NULL;

    /* Test 2: create new confirmation note with description set to "" */
    description = "";
    progress_bar = GTK_PROGRESS_BAR(gtk_progress_bar_new());
    fail_if(!GTK_IS_PROGRESS_BAR(progress_bar),
            "hildon-note: Progress bar creation failed in hildon_note_new_cancel_with_progress_bar");

    gtk_progress_bar_set_fraction(progress_bar,0.5);

    note = HILDON_NOTE(hildon_note_new_cancel_with_progress_bar(n_window,description,progress_bar));
    fail_if(!HILDON_IS_NOTE(note),
            "hildon-note: Creation failed with hildon_note_new_cancel_with_progress_bar");

    g_object_get_property(G_OBJECT (note),"description",&value);
    ret_description = g_value_get_string (&value);
    fail_if( strcmp (description,ret_description) != 0,
             "hildon-note: Description (%s) was not set properly on creation. Returned description: %s",
             description,ret_description);

    g_object_get_property(G_OBJECT (note),"note_type",&enum_value);
    note_type = g_value_get_int(&enum_value);
    fail_if( note_type != HILDON_NOTE_TYPE_PROGRESSBAR,
             "hildon-note: Type was not set property on creation (HILDON_NOTE_TYPE_PROGRESSBAR)",note_type);

    gtk_widget_destroy (GTK_WIDGET (progress_bar));
    gtk_widget_destroy (GTK_WIDGET (note));
    note=NULL;

    g_value_unset(&value);
    g_value_unset(&enum_value);
}