Пример #1
0
static void _lib_modulelist_populate_callback(gpointer instance, gpointer user_data)
{
  dt_lib_module_t *self = (dt_lib_module_t *)user_data;

  /* go thru list of iop modules and add tp table */
  GList *modules = g_list_last(darktable.develop->iop);
  int ti = 0, tj = 0;
  while(modules)
  {
    dt_iop_module_t *module = (dt_iop_module_t *)(modules->data);
    if(!dt_iop_is_hidden(module) && !(module->flags() & IOP_FLAGS_DEPRECATED))
    {
      module->showhide = dtgtk_tristatebutton_new(NULL,0);
      char filename[1024], datadir[1024];
      dt_loc_get_datadir(datadir, 1024);
      snprintf(filename, 1024, "%s/pixmaps/plugins/darkroom/%s.png", datadir, module->op);
      if(!g_file_test(filename, G_FILE_TEST_IS_REGULAR))
	snprintf(filename, 1024, "%s/pixmaps/plugins/darkroom/template.png", datadir);
      GtkWidget *image = gtk_image_new_from_file(filename);
      gtk_button_set_image(GTK_BUTTON(module->showhide), image);

      /* set button state */
      char option[1024];
      snprintf(option, 1024, "plugins/darkroom/%s/visible", module->op);
      gboolean active = dt_conf_get_bool (option);
      snprintf(option, 1024, "plugins/darkroom/%s/favorite", module->op);
      gboolean favorite = dt_conf_get_bool (option);
      gint state=0;
      if(active)
      {
	state++;
	if(favorite) state++;
      }
      _lib_modulelist_tristate_set_state(module->showhide,state,module);
      dtgtk_tristatebutton_set_state(DTGTK_TRISTATEBUTTON(module->showhide), state);

      /* connect tristate button callback*/
      g_signal_connect(G_OBJECT(module->showhide), "tristate-changed",
		       G_CALLBACK(_lib_modulelist_tristate_changed_callback), module);
      gtk_table_attach(GTK_TABLE(self->widget), module->showhide, ti, ti+1, tj, tj+1,
		       GTK_FILL | GTK_EXPAND | GTK_SHRINK,
		       GTK_SHRINK,
		       0, 0);
      if(ti < 5) ti++;
      else { ti = 0; tj ++; }
    }

    modules = g_list_previous(modules);
  }
}
Пример #2
0
static gboolean _tristatebutton_button_press(GtkWidget *widget, GdkEventButton *eb, gpointer data)
{
  gint cs = DTGTK_TRISTATEBUTTON(widget)->state + 1;
  /* handle left click on tristate button */
  if(eb->button == 1) cs %= 3;
  /* handle right click on tristate button */
  else if(eb->button == 2)
    cs = 0;

  dtgtk_tristatebutton_set_state(DTGTK_TRISTATEBUTTON(widget), cs);
  gtk_widget_queue_draw(widget);

  /* lets other connected get the signal... */
  return FALSE;
}