static void
method_changed_cb (GtkButton *button,
		   gpointer   user_data)
{
	GthFileToolGrayscale *self = user_data;
	apply_changes (self);
}
Beispiel #2
0
void
edit_main_rep::print (url name, bool conform, int first, int last) {
  if (inside ("screens")) {
    tree style= copy (get_style ());
    tree init = copy (get_init ());
    tree t    = copy (subtree (et, rp));
    call ("dynamic-make-slides");
    apply_changes ();
    print_bis (name, conform, first, last);
    set_style (style);
    set_init (init);
    assign (rp, t);
    apply_changes ();
  }
  else print_bis (name, conform, first, last);
}
Beispiel #3
0
void
edit_interface_rep::handle_repaint (SI x1, SI y1, SI x2, SI y2) {
  if (is_nil (eb)) apply_changes ();
  if (env_change != 0) {
    system_warning ("Invalid situation (" * as_string (env_change) * ")",
		    "(edit_interface_rep::handle_repaint)");
    return;
  }

  /*
  // In the past, we used the code below in order to hide the trace of
  // a moving cursor. This code is now incorrect, because the rectangle
  // (x1, y1)--(x2, y2) does not correspond to the repaint region clipping.
  // Nevertheless, the code seems no longer necessary. In case it would be,
  // it should be moved somewhere inside the internal repaint routines.
  SI extra= 3 * get_init_int (FONT_BASE_SIZE) * PIXEL / (2*sfactor);
  SI X1= (x1-extra) * sfactor, Y1= (y1-extra) * sfactor;
  SI X2= (x2+extra) * sfactor, Y2= (y2+extra) * sfactor;
  draw_with_stored (rectangle (X1, Y1, X2, Y2));
  */

  // cout << "Repainting\n";
  draw_with_stored (rectangle (x1, y1, x2, y2) * sfactor);
  if (last_change-last_update > 0)
    last_change = texmacs_time ();
  // cout << "Repainted\n";
}
/* called when the ok button is clicked. */
static void
ok_cb (GtkWidget  *widget,
       DialogData *data)
{
	apply_changes (data, data->image, data->image, FALSE, FALSE);
	gtk_widget_destroy (data->dialog);
}
/**
 * apply_cb
 * @w: widget
 * @data: callback data
 *
 * Description:
 * handles apply button events
 *
 * Returns:
 * TRUE if the event was handled
 **/
static void
apply_cb (GtkWidget * w, gpointer data)
{
  apply_changes ();

  gtk_widget_destroy (propbox);
  propbox = NULL;
}
Beispiel #6
0
int cmd_playlist_add_track(int argc, char **argv)
{
	sp_link *plink, *tlink;
	sp_track *t;
	sp_playlist *pl;
	int i;
	struct pl_update_work *puw;

	if(argc < 4) {
		printf("add [playlist uri] [position] [track uri] <[track uri]>...\n");
		return 1;
	}

	plink = sp_link_create_from_string(argv[1]);
	if (!plink) {
		fprintf(stderr, "%s is not a spotify link\n", argv[1]);
		return -1;
	}

	if(sp_link_type(plink) != SP_LINKTYPE_PLAYLIST) {
		fprintf(stderr, "%s is not a playlist link\n", argv[1]);
		sp_link_release(plink);
		return -1;
	}

	puw = malloc(sizeof(struct pl_update_work));
	puw->position = atoi(argv[2]);
	puw->tracks = malloc(sizeof(sp_track *) * argc - 3);
	puw->num_tracks = 0;
	for(i = 0; i < argc - 3; i++) {
		tlink = sp_link_create_from_string(argv[i + 3]);
		if(tlink == NULL) {
			fprintf(stderr, "%s is not a spotify link, skipping\n", argv[i + 3]);
			continue;
		}
		if(sp_link_type(tlink) != SP_LINKTYPE_TRACK) {
			fprintf(stderr, "%s is not a track link, skipping\n", argv[i + 3]);
			continue;
		}
		t = sp_link_as_track(tlink);
		sp_track_add_ref(t);
		puw->tracks[puw->num_tracks++] = t;
		sp_link_release(tlink);
	}

	pl = sp_playlist_create(g_session, plink);
	if(!apply_changes(pl, puw)) {
		// Changes applied directly, we're done
		sp_playlist_release(pl);
		sp_link_release(plink);
		return 1;
	}

	fprintf(stderr, "Playlist not yet loaded, waiting...\n");
	sp_playlist_add_callbacks(pl, &pl_update_callbacks, puw);
	sp_link_release(plink);
	return 0;
}
static void
ok_button_clicked_cb (GtkButton *button,
		      gpointer   user_data)
{
	GthFileToolGrayscale *self = user_data;

	self->priv->apply_to_original = TRUE;
	apply_changes (self);
}
Beispiel #8
0
static void pl_state_change(sp_playlist *pl, void *userdata)
{
	struct pl_update_work *puw = userdata;
	if(apply_changes(pl, puw))
		return;

	sp_playlist_remove_callbacks(pl, &pl_update_callbacks, puw);
	sp_playlist_release(pl);
	cmd_done();
}
Beispiel #9
0
static void
destroy_cb (GtkWidget *widget,
	    DialogData *data)
{
	apply_changes (data);
	gth_browser_set_dialog (data->browser, "preferences", NULL);

	g_object_unref (data->builder);
	g_free (data);
}
Beispiel #10
0
static int tostring(lua_State *L) {
    Lua_Hstore *strg = lua_touserdata(L, 1);
    apply_changes(L, strg);
    if (strg->issync){
        lua_pushstring(L, OutputFunctionCall(&hs_type.output, PointerGetDatum(strg->hstore)));
    }else{
        return luaL_error(L, "hstore apply changes failed");
    }
    return 1;
}
/** \brief Add or edit a rotor configuration.
 * \param conf Pointer to a rotator configuration.
 *
 * If conf->name is not NULL the widgets will be populated with the data.
 */
void sat_pref_rot_editor_run(rotor_conf_t * conf)
{
    gint            response;
    gboolean        finished = FALSE;

    /* crate dialog and add contents */
    dialog = gtk_dialog_new_with_buttons(_("Edit rotator configuration"),
                                         GTK_WINDOW(window),
                                         GTK_DIALOG_MODAL |
                                         GTK_DIALOG_DESTROY_WITH_PARENT,
                                         GTK_STOCK_CLEAR,
                                         GTK_RESPONSE_REJECT,
                                         GTK_STOCK_CANCEL,
                                         GTK_RESPONSE_CANCEL,
                                         GTK_STOCK_OK, GTK_RESPONSE_OK, NULL);

    /* disable OK button to begin with */
    gtk_dialog_set_response_sensitive(GTK_DIALOG(dialog),
                                      GTK_RESPONSE_OK, FALSE);

    gtk_container_add(GTK_CONTAINER
                      (gtk_dialog_get_content_area(GTK_DIALOG(dialog))),
                      create_editor_widgets(conf));

    /* this hacky-thing is to keep the dialog running in case the
       CLEAR button is plressed. OK and CANCEL will exit the loop
     */
    while (!finished)
    {

        response = gtk_dialog_run(GTK_DIALOG(dialog));

        switch (response)
        {
        case GTK_RESPONSE_OK:
            if (apply_changes(conf))
                finished = TRUE;
            else
                finished = FALSE;
            break;

        case GTK_RESPONSE_REJECT:
            /* CLEAR */
            clear_widgets();
            break;

        default:
            /* Everything else is considered CANCEL */
            finished = TRUE;
            break;
        }
    }

    gtk_widget_destroy(dialog);
}
static void
gth_file_tool_adjust_contrast_apply_options (GthFileTool *base)
{
	GthFileToolAdjustContrast *self;

	self = (GthFileToolAdjustContrast *) base;
	if (! self->priv->view_original) {
		self->priv->apply_to_original = TRUE;
		apply_changes (self);
	}
}
Beispiel #13
0
/* called when the preview button is clicked. */
static void
preview_cb (GtkWidget  *widget,
	    DialogData *data)
{
	GdkPixbuf *preview;

	preview = gdk_pixbuf_copy (data->image);
	apply_changes (data, preview, preview, FALSE, TRUE);
	g_object_unref (preview);

	data->modified = TRUE;
}
static void
image_task_completed_cb (GthTask  *task,
			 GError   *error,
			 gpointer  user_data)
{
	GthFileToolAdjustContrast *self = user_data;
	GthImage		  *destination_image;

	self->priv->image_task = NULL;

	if (self->priv->closing) {
		g_object_unref (task);
		gth_image_viewer_page_tool_reset_image (GTH_IMAGE_VIEWER_PAGE_TOOL (self));
		return;
	}

	if (error != NULL) {
		if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
			apply_changes (self);
		g_object_unref (task);
		return;
	}

	destination_image = gth_image_task_get_destination (GTH_IMAGE_TASK (task));
	if (destination_image == NULL) {
		g_object_unref (task);
		return;
	}

	cairo_surface_destroy (self->priv->destination);
	self->priv->destination = gth_image_get_cairo_surface (destination_image);
	self->priv->last_applied_method = self->priv->method;

	if (self->priv->apply_to_original) {
		if (self->priv->destination != NULL) {
			GtkWidget *window;
			GtkWidget *viewer_page;

			window = gth_file_tool_get_window (GTH_FILE_TOOL (self));
			viewer_page = gth_browser_get_viewer_page (GTH_BROWSER (window));
			gth_image_viewer_page_set_image (GTH_IMAGE_VIEWER_PAGE (viewer_page), self->priv->destination, TRUE);
		}

		gth_file_tool_hide_options (GTH_FILE_TOOL (self));
	}
	else {
		if (! self->priv->view_original)
			gth_preview_tool_set_image (GTH_PREVIEW_TOOL (self->priv->preview_tool), self->priv->destination);
	}

	g_object_unref (task);
}
static void
filter_grid_activated_cb (GthFilterGrid	*filter_grid,
			  int            filter_id,
			  gpointer       user_data)
{
	GthFileToolAdjustContrast *self = user_data;

	self->priv->view_original = (filter_id == GTH_FILTER_GRID_NO_FILTER);
	if (self->priv->view_original) {
		gth_preview_tool_set_image (GTH_PREVIEW_TOOL (self->priv->preview_tool), self->priv->preview);
	}
	else if (filter_id == self->priv->last_applied_method) {
		gth_preview_tool_set_image (GTH_PREVIEW_TOOL (self->priv->preview_tool), self->priv->destination);
	}
	else {
		self->priv->method = filter_id;
		apply_changes (self);
	}
}
Beispiel #16
0
void
edit_interface_rep::handle_keypress (string key, time_t t) {
  bool started= false;
#ifdef USE_EXCEPTIONS
  try {
#endif
    if (DEBUG_KEYBOARD) {
      //for (int i=0; i<N(key); i++)
      //  cout << ((int) (unsigned char) key[i]) << " ";
      //cout << "\n";
      debug_keyboard << "Pressed " << key << " at " << t << "\n";
    }
    //time_t t1= texmacs_time ();
    if (is_nil (eb)) apply_changes ();
    start_editing ();
    started= true;
    string zero= "a"; zero[0]= '\0';
    string gkey= replace (key, zero, "<#0>");
    call ("keyboard-press", object (gkey), object ((double) t));
    update_focus_loci ();
    if (!is_nil (focus_ids))
      call ("link-follow-ids", object (focus_ids), object ("focus"));
    notify_change (THE_DECORATIONS);
    end_editing ();
    //time_t t2= texmacs_time ();
    //if (t2 - t1 >= 10) cout << "handle_keypress took " << t2-t1 << "ms\n";
#ifdef USE_EXCEPTIONS
  }
  catch (string msg) {
    if (started) {
      cancel_editing ();
      interrupt_shortcut ();
    }
  }
  handle_exceptions ();
#endif
}
Beispiel #17
0
void
dlg_hue_saturation (GthWindow *window)
{
	DialogData *data;
	GtkWidget  *ok_button;
	GtkWidget  *reset_button;
	GtkWidget  *cancel_button;
	GtkWidget  *preview_button;
	GtkWidget  *hbox;
	GtkWidget  *reset_image;
	GdkPixbuf  *image;
	int         image_width, image_height;
	int         preview_width, preview_height;

	data = g_new0 (DialogData, 1);
	data->window = window;
	data->gui = glade_xml_new (GTHUMB_GLADEDIR "/" GLADE_FILE, NULL,
				   NULL);

	if (! data->gui) {
		g_warning ("Could not find " GLADE_FILE "\n");
		g_free (data);
		return;
	}

	/* Get the widgets. */

	data->dialog = glade_xml_get_widget (data->gui, "hue_saturation_dialog");
	data->bc_preview_image = glade_xml_get_widget (data->gui, "hl_preview_image");

	ok_button = glade_xml_get_widget (data->gui, "hl_ok_button");
	reset_button = glade_xml_get_widget (data->gui, "hl_reset_button");
	cancel_button = glade_xml_get_widget (data->gui, "hl_cancel_button");
	preview_button = glade_xml_get_widget (data->gui, "hl_preview_button");

	hbox = glade_xml_get_widget (data->gui, "hl_hue_hbox");
	data->bc_hue_hscale = gimp_scale_entry_new (hbox,
						    0.0, 
						    -180.0, 180.0,
						    1.0,
						    15.0);

	hbox = glade_xml_get_widget (data->gui, "hl_lightness_hbox");
	data->bc_lightness_hscale = gimp_scale_entry_new (hbox,
							  0.0, 
							  -100.0, 100.0,
							  1.0,
							  10.0);

	hbox = glade_xml_get_widget (data->gui, "hl_saturation_hbox");
	data->bc_saturation_hscale = gimp_scale_entry_new (hbox,
							   0.0, 
							   -100.0, 100.0,
							   1.0,
							   10.0);

	data->viewer = gth_window_get_image_viewer (window);

	reset_image = glade_xml_get_widget (data->gui, "hl_reset_image");
	gtk_image_set_from_stock (GTK_IMAGE (reset_image), GTHUMB_STOCK_RESET, GTK_ICON_SIZE_MENU);

	/**/

	image = image_viewer_get_current_pixbuf (data->viewer);
	data->image = gdk_pixbuf_copy (image);

	image_width = gdk_pixbuf_get_width (image);
	image_height = gdk_pixbuf_get_height (image);

	preview_width  = image_width;
	preview_height = image_height;
	scale_keepping_ratio (&preview_width, &preview_height, PREVIEW_SIZE, PREVIEW_SIZE);

	data->orig_pixbuf = gdk_pixbuf_scale_simple (image,
						     preview_width, 
						     preview_height,
						     GDK_INTERP_BILINEAR);
	data->new_pixbuf = gdk_pixbuf_copy (data->orig_pixbuf);

	gtk_image_set_from_pixbuf (GTK_IMAGE (data->bc_preview_image),
				   data->new_pixbuf);

	/* Set widgets data. */

	/* Set the signals handlers. */

	g_signal_connect (G_OBJECT (data->dialog),
			  "destroy",
			  G_CALLBACK (destroy_cb),
			  data);

	g_signal_connect (G_OBJECT (cancel_button),
			  "clicked",
			  G_CALLBACK (cancel_cb),
			  data);

	g_signal_connect (G_OBJECT (ok_button),
			  "clicked",
			  G_CALLBACK (ok_cb),
			  data);

	g_signal_connect (G_OBJECT (reset_button),
			  "clicked",
			  G_CALLBACK (reset_cb),
			  data);

	g_signal_connect (G_OBJECT (preview_button),
			  "clicked",
			  G_CALLBACK (preview_cb),
			  data);

	/* -- */

	g_signal_connect (G_OBJECT (data->bc_hue_hscale),
			  "value_changed",
			  G_CALLBACK (range_value_changed),
			  data);

	g_signal_connect (G_OBJECT (data->bc_lightness_hscale),
			  "value_changed",
			  G_CALLBACK (range_value_changed),
			  data);

	g_signal_connect (G_OBJECT (data->bc_saturation_hscale),
			  "value_changed",
			  G_CALLBACK (range_value_changed),
			  data);

	/* Run dialog. */

	gtk_window_set_transient_for (GTK_WINDOW (data->dialog),
				      GTK_WINDOW (window));
	gtk_window_set_modal (GTK_WINDOW (data->dialog), TRUE);
	gtk_widget_show (data->dialog);

	apply_changes (data, data->orig_pixbuf, data->new_pixbuf, TRUE, FALSE);
}
Beispiel #18
0
int
main(int argc, const char **argv)
{
	struct partition_metadata *md;
	const char *prompt;
	struct partedit_item *items = NULL;
	struct gmesh mesh;
	int i, op, nitems, nscroll;
	int error;

	if (strcmp(basename(argv[0]), "sade") == 0)
		sade_mode = 1;

	TAILQ_INIT(&part_metadata);

	init_fstab_metadata();

	init_dialog(stdin, stdout);
	if (!sade_mode)
		dialog_vars.backtitle = __DECONST(char *, "FreeBSD Installer");
	dialog_vars.item_help = TRUE;
	nscroll = i = 0;

	/* Revert changes on SIGINT */
	signal(SIGINT, sigint_handler);

	if (strcmp(basename(argv[0]), "autopart") == 0) { /* Guided */
		prompt = "Please review the disk setup. When complete, press "
		    "the Finish button.";
		/* Experimental ZFS autopartition support */
		if (argc > 1 && strcmp(argv[1], "zfs") == 0) {
			part_wizard("zfs");
		} else {
			part_wizard("ufs");
		}
	} else if (strcmp(basename(argv[0]), "scriptedpart") == 0) {
		error = scripted_editor(argc, argv);
		prompt = NULL;
		if (error != 0) {
			end_dialog();
			return (error);
		}
	} else {
		prompt = "Create partitions for FreeBSD. No changes will be "
		    "made until you select Finish.";
	}

	/* Show the part editor either immediately, or to confirm wizard */
	while (prompt != NULL) {
		dlg_clear();
		dlg_put_backtitle();

		error = geom_gettree(&mesh);
		if (error == 0)
			items = read_geom_mesh(&mesh, &nitems);
		if (error || items == NULL) {
			dialog_msgbox("Error", "No disks found. If you need to "
			    "install a kernel driver, choose Shell at the "
			    "installation menu.", 0, 0, TRUE);
			break;
		}
			
		get_mount_points(items, nitems);

		if (i >= nitems)
			i = nitems - 1;
		op = diskeditor_show("Partition Editor", prompt,
		    items, nitems, &i, &nscroll);

		switch (op) {
		case 0: /* Create */
			gpart_create((struct gprovider *)(items[i].cookie),
			    NULL, NULL, NULL, NULL, 1);
			break;
		case 1: /* Delete */
			gpart_delete((struct gprovider *)(items[i].cookie));
			break;
		case 2: /* Modify */
			gpart_edit((struct gprovider *)(items[i].cookie));
			break;
		case 3: /* Revert */
			gpart_revert_all(&mesh);
			while ((md = TAILQ_FIRST(&part_metadata)) != NULL) {
				if (md->fstab != NULL) {
					free(md->fstab->fs_spec);
					free(md->fstab->fs_file);
					free(md->fstab->fs_vfstype);
					free(md->fstab->fs_mntops);
					free(md->fstab->fs_type);
					free(md->fstab);
				}
				if (md->newfs != NULL)
					free(md->newfs);
				free(md->name);

				TAILQ_REMOVE(&part_metadata, md, metadata);
				free(md);
			}
			init_fstab_metadata();
			break;
		case 4: /* Auto */
			part_wizard("ufs");
			break;
		}

		error = 0;
		if (op == 5) { /* Finished */
			dialog_vars.ok_label = __DECONST(char *, "Commit");
			dialog_vars.extra_label =
			    __DECONST(char *, "Revert & Exit");
			dialog_vars.extra_button = TRUE;
			dialog_vars.cancel_label = __DECONST(char *, "Back");
			op = dialog_yesno("Confirmation", "Your changes will "
			    "now be written to disk. If you have chosen to "
			    "overwrite existing data, it will be PERMANENTLY "
			    "ERASED. Are you sure you want to commit your "
			    "changes?", 0, 0);
			dialog_vars.ok_label = NULL;
			dialog_vars.extra_button = FALSE;
			dialog_vars.cancel_label = NULL;

			if (op == 0 && validate_setup()) { /* Save */
				error = apply_changes(&mesh);
				if (!error)
					apply_workaround(&mesh);
				break;
			} else if (op == 3) { /* Quit */
				gpart_revert_all(&mesh);
				error =	-1;
				break;
			}
		}

		geom_deletetree(&mesh);
		free(items);
	}
Beispiel #19
0
/** Crée l'interface : boutons, intitulés, menus... */
void Ui_MainWindow::setupUi(QMainWindow *MainWindow) {
  if (MainWindow->objectName().isEmpty())
    MainWindow->setObjectName(QString::fromUtf8("MainWindow"));
  actionQuitter = new QAction(MainWindow);
  actionQuitter->setObjectName(QString::fromUtf8("actionQuitter"));
  actionFichier = new QAction(MainWindow);
  actionFichier->setObjectName(QString::fromUtf8("actionFichier"));
  actionWebcam = new QAction(MainWindow);
  actionWebcam->setObjectName(QString::fromUtf8("actionWebcam"));
  centralwidget = new QWidget(MainWindow);
  centralwidget->setObjectName(QString::fromUtf8("centralwidget"));
  listWidget = new QListWidget(centralwidget);
  new QListWidgetItem(listWidget);
  listWidget->setObjectName(QString::fromUtf8("listWidget"));
  listWidget->setDragDropMode(QAbstractItemView::InternalMove);
  cvwidget = new QOpenCVWidget(this);
  cvwidget->setObjectName(QString::fromUtf8("cvwidget"));
  label_2 = new QLabel(centralwidget);
  label_2->setObjectName(QString::fromUtf8("label_2"));
  label_6 = new QLabel(centralwidget);
  label_6->setObjectName(QString::fromUtf8("label_6"));
  comboBox_4 = new QComboBox(centralwidget);
  comboBox_4->setObjectName(QString::fromUtf8("comboBox_4"));
  buttonBox_2 = new QDialogButtonBox(centralwidget);
  buttonBox_2->setObjectName(QString::fromUtf8("buttonBox_2"));
  apply_button = new QPushButton(tr("Appliquer"));
  delete_button = new QPushButton(tr("Supprimer"));
  buttonBox_2->addButton(apply_button, QDialogButtonBox::AcceptRole);
  buttonBox_2->addButton(delete_button, QDialogButtonBox::RejectRole);
  comboBox = new QComboBox(centralwidget);
  comboBox->setObjectName(QString::fromUtf8("comboBox"));
  MainWindow->setCentralWidget(centralwidget);
  menubar = new QMenuBar(MainWindow);
  menubar->setObjectName(QString::fromUtf8("menubar"));
  menubar->setGeometry(QRect(0, 0, 540, 25));
  menuFichier = new QMenu(menubar);
  menuFichier->setObjectName(QString::fromUtf8("menuFichier"));
  menuOuvrir = new QMenu(menuFichier);
  menuOuvrir->setObjectName(QString::fromUtf8("menuOuvrir"));
  MainWindow->setMenuBar(menubar);
  statusbar = new QStatusBar(MainWindow);
  statusbar->setObjectName(QString::fromUtf8("statusbar"));
  MainWindow->setStatusBar(statusbar);

  menubar->addAction(menuFichier->menuAction());
  menuFichier->addAction(menuOuvrir->menuAction());
  menuFichier->addAction(actionQuitter);
  menuOuvrir->addAction(actionFichier);
  menuOuvrir->addAction(actionWebcam);

  may_the_force_be_with_you();

  retranslateUi(MainWindow);
  QObject::connect(actionQuitter, SIGNAL(triggered()), MainWindow, SLOT(close()));
  QObject::connect(actionFichier, SIGNAL(triggered()), MainWindow, SLOT(select_file()));
  QObject::connect(buttonBox_2, SIGNAL(accepted()), MainWindow, SLOT(apply_changes()));
  QObject::connect(buttonBox_2, SIGNAL(rejected()), MainWindow, SLOT(delete_filter()));
  QObject::connect(actionWebcam, SIGNAL(triggered()), MainWindow, SLOT(select_camera()));

  QMetaObject::connectSlotsByName(MainWindow);
}
static GtkWidget *
gth_file_tool_grayscale_get_options (GthFileTool *base)
{
	GthFileToolGrayscale *self;
	GtkWidget            *window;
	GtkWidget            *viewer_page;
	GtkWidget            *viewer;
	cairo_surface_t      *source;
	GtkWidget            *options;
	int                   width, height;
	GtkAllocation         allocation;

	self = (GthFileToolGrayscale *) base;

	window = gth_file_tool_get_window (base);
	viewer_page = gth_browser_get_viewer_page (GTH_BROWSER (window));
	if (! GTH_IS_IMAGE_VIEWER_PAGE (viewer_page))
		return NULL;

	cairo_surface_destroy (self->priv->destination);
	cairo_surface_destroy (self->priv->preview);

	viewer = gth_image_viewer_page_get_image_viewer (GTH_IMAGE_VIEWER_PAGE (viewer_page));
	source = gth_image_viewer_page_tool_get_source (GTH_IMAGE_VIEWER_PAGE_TOOL (self));
	if (source == NULL)
		return NULL;

	width = cairo_image_surface_get_width (source);
	height = cairo_image_surface_get_height (source);
	gtk_widget_get_allocation (GTK_WIDGET (viewer), &allocation);
	if (scale_keeping_ratio (&width, &height, PREVIEW_SIZE * allocation.width, PREVIEW_SIZE * allocation.height, FALSE))
		self->priv->preview = _cairo_image_surface_scale_bilinear (source, width, height);
	else
		self->priv->preview = cairo_surface_reference (source);

	self->priv->destination = cairo_surface_reference (self->priv->preview);
	self->priv->apply_to_original = FALSE;
	self->priv->closing = FALSE;

	self->priv->builder = _gtk_builder_new_from_file ("grayscale-options.ui", "file_tools");
	options = _gtk_builder_get_widget (self->priv->builder, "options");
	gtk_widget_show (options);

	g_signal_connect (GET_WIDGET ("ok_button"),
			  "clicked",
			  G_CALLBACK (ok_button_clicked_cb),
			  self);
	g_signal_connect_swapped (GET_WIDGET ("cancel_button"),
				  "clicked",
				  G_CALLBACK (gth_file_tool_cancel),
				  self);
	g_signal_connect (GET_WIDGET ("brightness_radiobutton"),
			  "clicked",
			  G_CALLBACK (method_changed_cb),
			  self);
	g_signal_connect (GET_WIDGET ("saturation_radiobutton"),
			  "clicked",
			  G_CALLBACK (method_changed_cb),
			  self);
	g_signal_connect (GET_WIDGET ("average_radiobutton"),
			  "clicked",
			  G_CALLBACK (method_changed_cb),
			  self);
	g_signal_connect (GET_WIDGET ("preview_checkbutton"),
			  "toggled",
			  G_CALLBACK (preview_checkbutton_toggled_cb),
			  self);

	self->priv->preview_tool = gth_preview_tool_new ();
	gth_preview_tool_set_image (GTH_PREVIEW_TOOL (self->priv->preview_tool), self->priv->preview);
	gth_image_viewer_set_tool (GTH_IMAGE_VIEWER (viewer), self->priv->preview_tool);
	apply_changes (self);

	return options;
}
Beispiel #21
0
/*------------------------------------------------*/
int main (int argc, char **argv)
{
  int cols, rows, iter, particles, x, y;
  int *pic;
  PartStr *p, *changes, *totalChanges;
  int rank, num, i, numChanges, numTotalChanges;
  int *changesPerNode, *buffDispl;
  MPI_Init (&argc, &argv);
  MPI_Comm_rank (MPI_COMM_WORLD, &rank);
  MPI_Comm_size (MPI_COMM_WORLD, &num);
  
  if (argc < 2)			// use default values if user does not specify anything
    {
      cols = PIC_SIZE + 2;
      rows = PIC_SIZE + 2;
      iter = MAX_ITER;
      particles = PARTICLES;
    }
  else
    {
      cols = atoi (argv[1]) + 2;
      rows = atoi (argv[2]) + 2;
      particles = atoi (argv[3]);
      iter = atoi (argv[4]);
    }

  // initialize the random number generator
  srand(rank);
  // srand(time(0)); // this should be used instead if the program runs on multiple hosts

    
  int particlesPerNode = particles / num;
  if (rank == num - 1)
    particlesPerNode = particles - particlesPerNode * (num - 1);	// in case particles cannot be split evenly
// printf("%i has %i\n", rank, particlesPerNode);
  pic = (int *) malloc (sizeof (int) * cols * rows);
  p = (PartStr *) malloc (sizeof (PartStr) * particlesPerNode);
  changes = (PartStr *) malloc (sizeof (PartStr) * particlesPerNode);
  totalChanges = (PartStr *) malloc (sizeof (PartStr) * particlesPerNode);
  changesPerNode = (int *) malloc (sizeof (int) * num);
  buffDispl = (int *) malloc (sizeof (int) * num);
  assert (pic != 0 && p != 0 && changes != 0 && totalChanges != 0
	  && changesPerNode != 0);



  // MPI user type declaration
  int lengths[2] = { 1, 1 };
  MPI_Datatype types[2] = { MPI_INT, MPI_INT };
  MPI_Aint add1, add2;
  MPI_Aint displ[2];
  MPI_Datatype Point;

  MPI_Address (p, &add1);
  MPI_Address (&(p[0].y), &add2);
  displ[0] = 0;
  displ[1] = add2 - add1;

  MPI_Type_struct (2, lengths, displ, types, &Point);
  MPI_Type_commit (&Point);


  dla_init_plist (pic, rows, cols, p, particlesPerNode, 1);
  while (--iter)
    {
      dla_evolve_plist (pic, rows, cols, p, &particlesPerNode, changes, &numChanges);      
//       printf("%i changed %i on iter %i : ",rank, numChanges, iter);
//       for(i=0;i<numChanges;i++) printf("(%i, %i) ", changes[i].x, changes[i].y);
//       printf("\n");
      
      //exchange information with other nodes
      MPI_Allgather (&numChanges, 1, MPI_INT, changesPerNode, 1, MPI_INT, MPI_COMM_WORLD);
      //calculate offsets
      numTotalChanges = 0;
      for (i = 0; i < num; i++)
	{
	  buffDispl[i] = numTotalChanges;
	  numTotalChanges += changesPerNode[i];
	}
//        if(rank==0)
//        {
//  	for(i=0;i<num;i++)
//  	  printf("%i tries to send %i\n",i,changesPerNode[i]);
//  	printf("-----------\n");
//        }
      if(numTotalChanges >0)
      {
      MPI_Allgatherv (changes, numChanges, Point,
		      totalChanges, changesPerNode, buffDispl, Point,
		      MPI_COMM_WORLD);
      apply_changes (pic, rows, cols, totalChanges, numTotalChanges);

	
//       if(rank==0)
//       {
//         printf("Total changes %i : ", numTotalChanges);
//         for(i=0;i<numTotalChanges;i++) printf("(%i, %i) ", totalChanges[i].x, totalChanges[i].y);
// 	
//         printf("\n");
// 	printf("-----------\n");
//       }
      }
    }

  /* Print to stdout a PBM picture of the simulation space */
  if (rank == 0)
    {
      printf ("P1\n%i %i\n", cols - 2, rows - 2);

      for (y = 1; y < rows - 1; y++)
	{
	  for (x = 1; x < cols - 1; x++)
	    {
	      if (pic[y * cols + x] < 0)
		printf ("1 ");
	      else
		printf ("0 ");
	    }
	  printf ("\n");
	}
    }
    
  MPI_Reduce(&particlesPerNode, &particles, 1, MPI_INT, MPI_SUM, 0, MPI_COMM_WORLD);  
  if(rank==0) fprintf(stderr, "Remaining particles %i\n", particles);
    
  free (pic);
  free (p);
  free (changes);
  free (changesPerNode);
  free (buffDispl);
  MPI_Finalize ();
  return 0;
}
Beispiel #22
0
int not_main(char *rom_name, char *offset, char *bytes, int apply_or_check) {

	FILE* file = fopen(rom_name, "rb");
	//printf("trying to open...\n");	

	if (file) {
		size_t size;

		//printf("file exists!\n");
		unsigned char *buf;

		get_data("rom.smc", &buf, file, &size);

		fclose(file);
		//printf("file closed!\n");

		//char input[30];
		char to_use[30];
		//printf("offset?\n");
		//scanf("%s", input);		//needed
		int num = strlen(bytes);	//needed
		
		int offset_to_apply, bytes_to_apply, new_offset;
		int c = 0;
		int check_tweak = 0;

		sscanf(offset, "%x", &offset_to_apply);
		//printf("bytes? (offset is: %d)\n", offset_to_apply);
		//scanf("%s", input);		//needed

		while (c < num) {
			//printf(">>>>>%d<<<<<<\n>>>>>%d<<<<<\n", c, num);
			strncpy(to_use, bytes+c, 2);
			sscanf(to_use, "%x", &bytes_to_apply);

			if ((make_changes(buf, offset_to_apply, bytes_to_apply, size, &check_tweak)==0)) {
				if (apply_or_check == 0) { //0 = apply
					/*switch(apply_changes(buf, rom_name, size)) {
						case 0: printf("success!\n"); break;
						case 1: printf("not success :(\n"); break;
					}*/
					apply_changes(buf, rom_name, size);
				}
			}	
			c += 2;
			offset_to_apply++;
		}
		
		free(buf);

		if (apply_or_check > 0)	//if this is checking stuff
			//printf("number of bytes in the tweak: %d\nnumber of bytes that were the same: %d\n", c/2, check_tweak);
			if (check_tweak == (c/2))
				return 1;
			else
				return 0;

		return 1;
	}

	else {
		fclose(file);
		printf("no such file???\n");
		return 0;
	}
}
Beispiel #23
0
Datum getHStoreDatum(lua_State *L, int index){
    Lua_Hstore *strg = lua_touserdata(L, index);
    apply_changes(L, strg);
    strg->havetodel = 1;
    return strg->datum;
}
Beispiel #24
0
static void
range_value_changed (GtkRange   *range,
		     DialogData *data)
{
	apply_changes (data, data->orig_pixbuf, data->new_pixbuf, TRUE, FALSE);
}