Ejemplo n.º 1
0
static GtkWidget *_lib_history_create_button(dt_lib_module_t *self,int num, const char *label,gboolean enabled)
{
  /* create label */
  GtkWidget *widget = NULL;
  gchar numlabel[256];
  if(num==-1)
    g_snprintf(numlabel, sizeof(numlabel), "%d - %s", num+1, label);
  else
  {
    if(enabled)
      g_snprintf(numlabel, sizeof(numlabel), "%d - %s", num+1, label);
    else
      g_snprintf(numlabel, sizeof(numlabel), "%d - %s (%s)", num+1, label, _("off"));
  }

  /* create toggle button */
  widget =  dtgtk_togglebutton_new_with_label (numlabel,NULL,CPF_STYLE_FLAT);
  g_object_set_data (G_OBJECT (widget),"history_number",GINT_TO_POINTER(num+1));
  g_object_set_data (G_OBJECT (widget),"label",(gpointer) g_strdup(label));

  /* set callback when clicked */
  g_signal_connect (G_OBJECT (widget), "clicked",
                    G_CALLBACK (_lib_history_button_clicked_callback),
                    self);

  /* associate the history number */
  g_object_set_data(G_OBJECT(widget),"history-number",GINT_TO_POINTER(num+1));

  return widget;
}
Ejemplo n.º 2
0
void gui_init(dt_lib_module_t *self)
{
  /* initialize ui widgets */
  dt_lib_snapshots_t *d = (dt_lib_snapshots_t *)g_malloc(sizeof(dt_lib_snapshots_t));
  self->data = (void *)d;
  memset(d,0,sizeof(dt_lib_snapshots_t));

  /* initialize snapshot storages */
  d->size = 4;
  d->snapshot = (dt_lib_snapshot_t *)g_malloc(sizeof(dt_lib_snapshot_t)*d->size);
  d->vp_xpointer = 0.5;
  d->vp_ypointer = 0.5;
  d->vertical = TRUE;
  memset(d->snapshot,0,sizeof(dt_lib_snapshot_t)*d->size);

  /* initialize ui containers */
  self->widget = gtk_vbox_new(FALSE,2);
  d->snapshots_box = gtk_vbox_new(FALSE,0);

  /* create take snapshot button */
  GtkWidget *button = gtk_button_new_with_label(_("take snapshot"));
  d->take_button = button;
  g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(_lib_snapshots_add_button_clicked_callback), self);
  g_object_set(button, "tooltip-text",
               _("take snapshot to compare with another image or the same image at another stage of development"),
               (char *)NULL);

  /*
   * initialize snapshots
   */
  char wdname[32]= {0};
  char localtmpdir[4096]= {0};
  dt_loc_get_tmp_dir (localtmpdir, sizeof(localtmpdir));

  for (int k=0; k<d->size; k++)
  {
    /* create snapshot button */
    d->snapshot[k].button = dtgtk_togglebutton_new_with_label (wdname,NULL,CPF_STYLE_FLAT);
    g_signal_connect(G_OBJECT ( d->snapshot[k].button), "clicked",
                     G_CALLBACK (_lib_snapshots_toggled_callback),
                     self);

    /* assign snapshot number to widget */
    g_object_set_data(G_OBJECT(d->snapshot[k].button),"snapshot",GINT_TO_POINTER(k+1));

    /* setup filename for snapshot */
    snprintf(d->snapshot[k].filename, sizeof(d->snapshot[k].filename), "%s/dt_snapshot_%d.png",localtmpdir,k);

    /* add button to snapshot box */
    gtk_box_pack_start(GTK_BOX(d->snapshots_box),d->snapshot[k].button,TRUE,TRUE,0);

    /* prevent widget to show on external show all */
    gtk_widget_set_no_show_all(d->snapshot[k].button, TRUE);
  }

  /* add snapshot box and take snapshot button to widget ui*/
  gtk_box_pack_start(GTK_BOX(self->widget), d->snapshots_box,TRUE,TRUE,0);
  gtk_box_pack_start(GTK_BOX(self->widget), button, TRUE,TRUE,0);

}
Ejemplo n.º 3
0
void gui_init(dt_lib_module_t *self)
{
  /* initialize ui widgets */
  dt_lib_tool_filter_t *d = (dt_lib_tool_filter_t *)g_malloc0(sizeof(dt_lib_tool_filter_t));
  self->data = (void *)d;

  self->widget = gtk_hbox_new(FALSE,2);

  /**/
  GtkWidget *widget;

  /* list label */
  widget = gtk_label_new(_("view"));
  gtk_box_pack_start(GTK_BOX(self->widget), widget, FALSE, FALSE, 4);

  d->comparator = widget = dtgtk_togglebutton_new_with_label(comparators[dt_collection_get_rating_comparator(darktable.collection)], NULL, CPF_STYLE_BOX);
  gtk_box_pack_start(GTK_BOX(self->widget), widget, FALSE, FALSE, 4);
  g_signal_connect (G_OBJECT (widget), "toggled",
                    G_CALLBACK (_lib_filter_compare_button_changed),
                    (gpointer)self);

  /* create the filter combobox */
  d->filter = widget = gtk_combo_box_text_new();
  gtk_box_pack_start(GTK_BOX(self->widget), widget, FALSE, FALSE, 0);
  gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(widget), _("all"));
  gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(widget), _("unstarred only"));
  gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(widget), "★");
  gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(widget), "★ ★");
  gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(widget), "★ ★ ★");
  gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(widget), "★ ★ ★ ★");
  gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(widget), "★ ★ ★ ★ ★");
  gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(widget), _("rejected only"));
  gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(widget), _("all except rejected"));

  /* select the last selected value */
  gtk_combo_box_set_active(GTK_COMBO_BOX(widget),
                           dt_collection_get_rating(darktable.collection));

  g_signal_connect (G_OBJECT (widget), "changed",
                    G_CALLBACK (_lib_filter_combobox_changed),
                    (gpointer)self);

  /* sort by label */
  widget = gtk_label_new(_("sort by"));
  gtk_box_pack_start(GTK_BOX(self->widget), widget, FALSE, FALSE, 4);

  /* sort combobox */
  d->sort = widget = gtk_combo_box_text_new();
  gtk_box_pack_start(GTK_BOX(self->widget), widget, FALSE, FALSE, 0);
  gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(widget), _("filename"));
  gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(widget), _("time"));
  gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(widget), _("rating"));
  gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(widget), _("id"));
  gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(widget), _("color label"));

  /* select the last selected value */
  gtk_combo_box_set_active(GTK_COMBO_BOX(widget),
                           dt_collection_get_sort_field(darktable.collection));

  g_signal_connect (G_OBJECT (widget), "changed",
                    G_CALLBACK (_lib_filter_sort_combobox_changed),
                    (gpointer)self);

  /* reverse order checkbutton */
  d->reverse = widget = dtgtk_togglebutton_new(dtgtk_cairo_paint_solid_arrow, CPF_STYLE_BOX|CPF_DIRECTION_UP);
  if (darktable.collection->params.descending)
    dtgtk_togglebutton_set_paint(DTGTK_TOGGLEBUTTON(widget),
                                 dtgtk_cairo_paint_solid_arrow,
                                 CPF_STYLE_BOX|CPF_DIRECTION_DOWN);

  gtk_box_pack_start(GTK_BOX(self->widget), widget, FALSE, FALSE, 0);

  /* select the last value and connect callback */
  gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget),
                               dt_collection_get_sort_descending(darktable.collection));

  g_signal_connect (G_OBJECT (widget), "toggled",
                    G_CALLBACK (_lib_filter_reverse_button_changed),
                    (gpointer)self);

  /* initialize proxy */
  darktable.view_manager->proxy.filter.module = self;
  darktable.view_manager->proxy.filter.reset_filter = _lib_filter_reset;

  g_signal_connect_swapped(G_OBJECT(d->comparator), "map", G_CALLBACK(_lib_filter_sync_combobox_and_comparator), self);
}