예제 #1
0
void dt_control_progress_destroy(dt_control_t *control, dt_progress_t *progress)
{
  dt_pthread_mutex_lock(&control->progress_system.mutex);

  // tell the gui
  if(control->progress_system.proxy.module != NULL)
    control->progress_system.proxy.destroyed(control->progress_system.proxy.module, progress->gui_data);

  // remove the object from the global list
  control->progress_system.list = g_list_remove(control->progress_system.list, progress);
  control->progress_system.list_length--;

  dt_pthread_mutex_unlock(&control->progress_system.mutex);

#ifdef HAVE_UNITY
  if(progress->has_progress_bar)
  {
    unity_launcher_entry_set_progress(progress->darktable_launcher, 1.0);
    unity_launcher_entry_set_progress_visible(progress->darktable_launcher, FALSE);
  }
#endif

#ifdef MAC_INTEGRATION
#ifdef GTK_TYPE_OSX_APPLICATION
  gtk_osxapplication_attention_request(g_object_new(GTK_TYPE_OSX_APPLICATION, NULL), INFO_REQUEST);
#else
  gtkosx_application_attention_request(g_object_new(GTKOSX_TYPE_APPLICATION, NULL), INFO_REQUEST);
#endif
#endif

  // free the object
  dt_pthread_mutex_destroy(&progress->mutex);
  free(progress);
}
예제 #2
0
파일: progress.c 프로젝트: dtorop/darktable
void dt_control_progress_destroy(dt_control_t *control, dt_progress_t *progress)
{
  dt_pthread_mutex_lock(&control->progress_system.mutex);

  // tell the gui
  if(control->progress_system.proxy.module != NULL)
    control->progress_system.proxy.destroyed(control->progress_system.proxy.module, progress->gui_data);

  // remove the object from the global list
  control->progress_system.list = g_list_remove(control->progress_system.list, progress);
  control->progress_system.list_length--;

  dt_pthread_mutex_unlock(&control->progress_system.mutex);

#ifdef HAVE_UNITY
  if(progress->has_progress_bar)
  {
    unity_launcher_entry_set_progress(progress->darktable_launcher, 1.0);
    unity_launcher_entry_set_progress_visible(progress->darktable_launcher, FALSE);
  }
#endif

  // free the object
  dt_pthread_mutex_destroy(&progress->mutex);
  g_free(progress->message);
  free(progress);
}
예제 #3
0
dt_progress_t * dt_control_progress_create(dt_control_t *control, gboolean has_progress_bar, const gchar *message)
{
  // create the object
  _dt_progress_t *progress = (_dt_progress_t*)calloc(1, sizeof(_dt_progress_t));
  dt_pthread_mutex_init(&(progress->mutex), NULL);

  // fill it with values
  progress->message = g_strdup(message);
  progress->has_progress_bar = has_progress_bar;

  dt_pthread_mutex_lock(&control->progress_system.mutex);

  // add it to the global list
  control->progress_system.list = g_list_append(control->progress_system.list, progress);
  control->progress_system.list_length++;

  // tell the gui
  if(control->progress_system.proxy.module != NULL)
    progress->gui_data = control->progress_system.proxy.added(control->progress_system.proxy.module, has_progress_bar, message);

  dt_pthread_mutex_unlock(&control->progress_system.mutex);

#ifdef HAVE_UNITY
  if(has_progress_bar)
  {
    progress->darktable_launcher = unity_launcher_entry_get_for_desktop_id("darktable.desktop");
    unity_launcher_entry_set_progress(progress->darktable_launcher, 0.0);
    unity_launcher_entry_set_progress_visible(progress->darktable_launcher, TRUE);
  }
#endif

  // return the object
  return progress;
}
예제 #4
0
static void
progress_ui_handler_update_unity_launcher_entry (NemoProgressUIHandler *self,
                                                 NemoProgressInfo *info,
                                                 UnityLauncherEntry *entry)
{
	g_return_if_fail (self);
	g_return_if_fail (entry);

	if (self->priv->active_infos > 0) {
		unity_launcher_entry_set_progress_visible (entry, TRUE);
		progress_ui_handler_show_unity_quicklist (self, entry, TRUE);
		progress_ui_handler_unity_progress_changed (NULL, self);

		if (self->priv->active_infos > 1) {
			unity_launcher_entry_set_count (entry, self->priv->active_infos);
			unity_launcher_entry_set_count_visible (entry, TRUE);
		} else {
			unity_launcher_entry_set_count_visible (entry, FALSE);
		}
	} else {
		unity_launcher_entry_set_progress_visible (entry, FALSE);
		unity_launcher_entry_set_progress (entry, 0.0);
		unity_launcher_entry_set_count_visible (entry, FALSE);
		progress_ui_handler_show_unity_quicklist (self, entry, FALSE);
		GCancellable *pc = nemo_progress_info_get_cancellable (info);

		if (!g_cancellable_is_cancelled (pc)) {
			unity_launcher_entry_set_urgent (entry, TRUE);

			g_timeout_add_seconds (2, (GSourceFunc)
				               progress_ui_handler_disable_unity_urgency,
					       entry);
		}
	}
}
예제 #5
0
static void _lib_backgroundjobs_progress(dt_lib_module_t *self, const guint *key, double progress)
{
  if(!darktable.control->running) return;
  dt_lib_backgroundjobs_t *d = (dt_lib_backgroundjobs_t*)self->data;
  gboolean i_own_lock = dt_control_gdk_lock();

  dt_bgjob_t *j = (dt_bgjob_t*)g_hash_table_lookup(d->jobs, key);
  if(j)
  {
    /* check if progress is above 1.0 and destroy bgjob if finished */
    /* FIXME: actually we are having some rounding issues, where the */
    /* FIXME: last item doesn't bring to total to 1.0 flat */
    /* FIXME: so this is why we have the ugly kludge below */
    if (progress > 0.999999)
    {
      if (GTK_IS_WIDGET(j->widget))
        gtk_container_remove( GTK_CONTAINER(d->jobbox), j->widget );

#ifdef HAVE_UNITY
      unity_launcher_entry_set_progress( j->darktable_launcher, 1.0 );
      unity_launcher_entry_set_progress_visible( j->darktable_launcher, FALSE );
#endif
#ifdef MAC_INTEGRATION
#ifdef GTK_TYPE_OSX_APPLICATION
      gtk_osxapplication_attention_request(g_object_new(GTK_TYPE_OSX_APPLICATION, NULL), INFO_REQUEST);
#else
      gtkosx_application_attention_request(g_object_new(GTKOSX_TYPE_APPLICATION, NULL), INFO_REQUEST);
#endif
#endif

      /* hide jobbox if theres no jobs left */
      if (g_list_length(gtk_container_get_children(GTK_CONTAINER(d->jobbox))) == 0 )
        gtk_widget_hide(d->jobbox);
    }
    else
    {
      if( j->type == 0 )
        gtk_progress_bar_set_fraction( GTK_PROGRESS_BAR(j->progressbar), progress );

#ifdef HAVE_UNITY
      unity_launcher_entry_set_progress( j->darktable_launcher, progress );
#endif
    }
  }

  if(i_own_lock) dt_control_gdk_unlock();
}
예제 #6
0
void UnityTaskbarManager::setProgressValue(int completed, int total) {
	if (_launcher == NULL)
		return;

	double percentage = (double)completed / (double)total;
	unity_launcher_entry_set_progress(_launcher, percentage);
	unity_launcher_entry_set_progress_visible(_launcher, TRUE);
}
예제 #7
0
void ResizerUnity::updateProgressBar(int min, int max, int val)
{
    if(min>max)
        std::swap(min,max);
    if(val<0 || min<0 || max<=0 || min==max){
        unity_launcher_entry_set_progress_visible(unity, false);
    }else{
        double progress = (val-min)/(max-min);
        unity_launcher_entry_set_progress(unity, progress);
        unity_launcher_entry_set_progress_visible(unity, true);
    }
}
예제 #8
0
static const guint * _lib_backgroundjobs_create(dt_lib_module_t *self,int type,const gchar *message)
{
  dt_lib_backgroundjobs_t *d = (dt_lib_backgroundjobs_t *)self->data;

  /* lets make this threadsafe */
  gboolean i_own_lock = dt_control_gdk_lock();

  /* initialize a new job */
  dt_bgjob_t *j=(dt_bgjob_t*)g_malloc(sizeof(dt_bgjob_t));
  j->type = type;
  j->widget = gtk_event_box_new();

  guint *key = g_malloc(sizeof(guint));
  *key = g_direct_hash((gconstpointer)j);

  /* create in hash out of j pointer*/
  g_hash_table_insert(d->jobs, key, j);

  /* intialize the ui elements for job */
  gtk_widget_set_name (GTK_WIDGET (j->widget), "background_job_eventbox");
  GtkBox *vbox = GTK_BOX (gtk_vbox_new (FALSE,0));
  GtkBox *hbox = GTK_BOX (gtk_hbox_new (FALSE,0));
  gtk_container_set_border_width (GTK_CONTAINER(vbox),2);
  gtk_container_add (GTK_CONTAINER(j->widget), GTK_WIDGET(vbox));

  /* add job label */
  j->label = gtk_label_new(message);
  gtk_misc_set_alignment(GTK_MISC(j->label), 0.0, 0.5);
  gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET(j->label), TRUE, TRUE, 0);
  gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET(hbox), TRUE, TRUE, 0);

  /* use progressbar ? */
  if (type == 0)
  {
    j->progressbar = gtk_progress_bar_new();
    gtk_box_pack_start( GTK_BOX( vbox ), j->progressbar, TRUE, FALSE, 2);

#ifdef HAVE_UNITY
    j->darktable_launcher = unity_launcher_entry_get_for_desktop_id("darktable.desktop");
    unity_launcher_entry_set_progress( j->darktable_launcher, 0.0 );
    unity_launcher_entry_set_progress_visible( j->darktable_launcher, TRUE );
#endif
  }

  /* lets show jobbox if its hidden */
  gtk_box_pack_start(GTK_BOX(d->jobbox), j->widget, TRUE, FALSE, 1);
  gtk_box_reorder_child(GTK_BOX(d->jobbox), j->widget, 1);
  gtk_widget_show_all(j->widget);
  gtk_widget_show(d->jobbox);

  if(i_own_lock) dt_control_gdk_unlock();
  return key;
}
예제 #9
0
파일: progress.c 프로젝트: dtorop/darktable
void dt_control_progress_set_progress(dt_control_t *control, dt_progress_t *progress, double value)
{
  // set the value
  dt_pthread_mutex_lock(&progress->mutex);
  progress->progress = value;
  dt_pthread_mutex_unlock(&progress->mutex);

  // tell the gui
  dt_pthread_mutex_lock(&control->progress_system.mutex);
  if(control->progress_system.proxy.module != NULL)
    control->progress_system.proxy.updated(control->progress_system.proxy.module, progress->gui_data, value);
  dt_pthread_mutex_unlock(&control->progress_system.mutex);

#ifdef HAVE_UNITY
  if(progress->has_progress_bar)
    unity_launcher_entry_set_progress(progress->darktable_launcher, CLAMP(value, 0, 1.0));
#endif
}
예제 #10
0
static void _lib_backgroundjobs_progress(dt_lib_module_t *self, const guint *key, double progress)
{
  if(!darktable.control->running) return;
  gboolean i_own_lock = dt_control_gdk_lock();
  dt_lib_backgroundjobs_t *d = (dt_lib_backgroundjobs_t*)self->data;

  dt_bgjob_t *j = (dt_bgjob_t*)g_hash_table_lookup(d->jobs, key);
  if(j)
  {
    if( j->type == 0 )
      gtk_progress_bar_set_fraction( GTK_PROGRESS_BAR(j->progressbar), progress );

#ifdef HAVE_UNITY
    unity_launcher_entry_set_progress( j->darktable_launcher, progress );
#endif
  }

  if(i_own_lock) dt_control_gdk_unlock();
}
예제 #11
0
static void _lib_backgroundjobs_destroy(dt_lib_module_t *self, const guint *key)
{
  gboolean i_own_lock = dt_control_gdk_lock();

  dt_lib_backgroundjobs_t *d = (dt_lib_backgroundjobs_t*)self->data;

  dt_bgjob_t *j = (dt_bgjob_t*)g_hash_table_lookup(d->jobs, key);
  if(j)
  {
    g_hash_table_remove(d->jobs, key);

    /* remove job widget from jobbox */
    if(j->widget && GTK_IS_WIDGET(j->widget))
      gtk_container_remove(GTK_CONTAINER(d->jobbox),j->widget);
    j->widget = 0;

#ifdef HAVE_UNITY
    if( j->type == 0 )
    {
      unity_launcher_entry_set_progress( j->darktable_launcher, 1.0 );
      unity_launcher_entry_set_progress_visible( j->darktable_launcher, FALSE );
    }
#endif
#ifdef MAC_INTEGRATION
#ifdef GTK_TYPE_OSX_APPLICATION
    gtk_osxapplication_attention_request(g_object_new(GTK_TYPE_OSX_APPLICATION, NULL), INFO_REQUEST);
#else
    gtkosx_application_attention_request(g_object_new(GTKOSX_TYPE_APPLICATION, NULL), INFO_REQUEST);
#endif
#endif

    /* if jobbox is empty lets hide */
    if(g_list_length(gtk_container_get_children(GTK_CONTAINER(d->jobbox)))==0)
      gtk_widget_hide(d->jobbox);

    /* free allocted mem */
    g_free(j);
    g_free((guint*)key);
  }
  if(i_own_lock) dt_control_gdk_unlock();
}
예제 #12
0
static void
progress_ui_handler_unity_progress_changed (NemoProgressInfo *info,
                                            NemoProgressUIHandler *self)
{
	g_return_if_fail (self);
	g_return_if_fail (self->priv->unity_quicklist_handler);
	g_return_if_fail (self->priv->manager);

	GList *infos, *l;
	double progress = 0;
	double c, current = 0;
	double t, total = 0;

	infos = nemo_progress_info_manager_get_all_infos (self->priv->manager);

	for (l = infos; l; l = l->next) {
		NemoProgressInfo *i = l->data;
		c = nemo_progress_info_get_current (i);
		t = nemo_progress_info_get_total (i);

		if (c < 0) c = 0;
		if (t <= 0) continue;

		total += t;
		current += c;
	}

	if (current >= 0 && total > 0)
		progress = current / total;

	if (progress > 1.0)
		progress = 1.0;

	for (l = unity_quicklist_get_launcher_entries (self->priv->unity_quicklist_handler); l; l = l->next) {
		UnityLauncherEntry *entry = l->data;
		unity_launcher_entry_set_progress (entry, progress);
	}
}
예제 #13
0
void setProgress(double value)
{
    unity_launcher_entry_set_progress(entry, value);
}