Ejemplo n.º 1
0
static void update_faction_menu()	// Populate menu
{
	int i, v, items = 0;
	char txt[64], *nm, *cm;
	void **slot;

	/* Show valid slots in menu */
	for (i = 1; i <= FACTION_PRESETS_TOTAL; i++)
	{
		sprintf(txt, faction_ini[0], i);
		nm = inifile_get(txt, "");

		sprintf(txt, faction_ini[1], i);
		cm = inifile_get(txt, "");

		slot = menu_slots[MENU_FACTION1 - 1 + i];

		if ((v = nm && nm[0] && (nm[0] != '#') &&
			cm && cm[0] && (cm[0] != '#')))
			cmd_setv(slot, nm, LABEL_VALUE);

		cmd_showhide(slot, v);	/* Hide by default */
		items += v;
	}

	/* Hide separator if no valid slots */
	cmd_showhide(menu_slots[MENU_FACTION_S], items);
}	
Ejemplo n.º 2
0
static void update_faction_menu()	// Populate menu
{
	int i, items = 0;
	char txt[64], *nm, *cm;
	GtkWidget *item;

	/* Show valid slots in menu */
	for (i = 1; i <= FACTION_PRESETS_TOTAL; i++)
	{
		item = menu_widgets[MENU_FACTION1 - 1 + i];
		gtk_widget_hide(item);		/* Hide by default */
		sprintf(txt, faction_ini[0], i);
		nm = inifile_get(txt, "");

		if (!nm || !nm[0] || (nm[0] == '#')) continue;
		sprintf(txt, faction_ini[1], i);
		cm = inifile_get(txt, "");

		if (!cm || !cm[0] || (cm[0] == '#')) continue;
		gtk_label_set_text(
			GTK_LABEL(GTK_MENU_ITEM(item)->item.bin.child), nm);
		gtk_widget_show(item);
		items++;
	}

	/* Hide separator if no valid slots */
	widget_showhide(menu_widgets[MENU_FACTION_S], items);
}	
Ejemplo n.º 3
0
void pressed_file_action(int item)
{
	char *comm, *dir, txt[64];

	sprintf(txt, faction_ini[1], item);
	comm = inifile_get(txt,"");
	sprintf(txt, faction_ini[2], item);
	dir = inifile_get(txt,"");

	spawn_expansion(comm, dir);
}
Ejemplo n.º 4
0
static void oss_preferences(void)
{
     GtkWidget *a,*b,*c,*d;
     struct oss_prefdlg *pd;
     gchar *q;
     pd = g_malloc(sizeof(struct oss_prefdlg));
     a = gtk_window_new(GTK_WINDOW_DIALOG);     
     gtk_window_set_modal(GTK_WINDOW(a),TRUE);
     gtk_window_set_title(GTK_WINDOW(a),_("OSS preferences"));
     gtk_window_set_position(GTK_WINDOW(a),GTK_WIN_POS_CENTER);
     gtk_container_set_border_width(GTK_CONTAINER(a),5);
     gtk_signal_connect_object(GTK_OBJECT(a),"destroy",GTK_SIGNAL_FUNC(g_free),
			       (GtkObject *)pd);
     pd->wnd = GTK_WINDOW(a);
     b = gtk_vbox_new(FALSE,5);
     gtk_container_add(GTK_CONTAINER(a),b);
     c = gtk_hbox_new(FALSE,3);
     gtk_container_add(GTK_CONTAINER(b),c);
     d = gtk_label_new(_("Playback device file:"));
     gtk_container_add(GTK_CONTAINER(c),d);
     d = gtk_entry_new();
     q = inifile_get(OSS_PCMFILE_PLAYBACK,OSS_PCMFILE_DEFAULT);
     gtk_entry_set_text(GTK_ENTRY(d),q);
     gtk_container_add(GTK_CONTAINER(c),d);
     pd->pcmdev_playback = GTK_ENTRY(d);
     c = gtk_hbox_new(FALSE,3);
     gtk_container_add(GTK_CONTAINER(b),c);
     d = gtk_label_new(_("Recording device file:"));
     gtk_container_add(GTK_CONTAINER(c),d);
     d = gtk_entry_new();
     gtk_entry_set_text(GTK_ENTRY(d),inifile_get(OSS_PCMFILE_RECORD,q));
     gtk_container_add(GTK_CONTAINER(c),d);
     pd->pcmdev_record = GTK_ENTRY(d);
     c = gtk_check_button_new_with_label(_("Avoid select calls (try this if "
					 "recording locks up)"));
     gtk_container_add(GTK_CONTAINER(b),c);
     oss_noselect = inifile_get_gboolean(OSS_NOSELECT,OSS_NOSELECT_DEFAULT);
     pd->noselect = GTK_TOGGLE_BUTTON(c);
     gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(c),oss_noselect);
     c = gtk_hseparator_new();
     gtk_container_add(GTK_CONTAINER(b),c);
     c = gtk_hbutton_box_new();
     gtk_container_add(GTK_CONTAINER(b),c);
     d = gtk_button_new_with_label(_("OK"));
     gtk_signal_connect(GTK_OBJECT(d),"clicked",
			GTK_SIGNAL_FUNC(oss_preferences_ok),pd);
     gtk_container_add(GTK_CONTAINER(c),d);
     d = gtk_button_new_with_label(_("Close"));
     gtk_signal_connect_object(GTK_OBJECT(d),"clicked",
			       GTK_SIGNAL_FUNC(gtk_widget_destroy),
			       GTK_OBJECT(a));
     gtk_container_add(GTK_CONTAINER(c),d);     
     gtk_widget_show_all(a);
}
Ejemplo n.º 5
0
void pressed_file_configure()
{
	spawn_dd tdata;
	spawn_row *rp;
	char txt[64], *s;
	int i, j;

	rp = tdata.strs = calloc(FACTION_ROWS_TOTAL, sizeof(spawn_row));
	if (!rp) return; // Not enough memory

	for (i = 1; i <= FACTION_ROWS_TOTAL; i++ , rp++)
	{
		for (j = 0; j < 3; j++)
		{
			sprintf(txt, faction_ini[j], i);
			s = inifile_get(txt, "");
			if (!j) strncpy0(rp->name, s, sizeof(rp->name));
			else if (j == 1) gtkuncpy(rp->cmd, s, sizeof(rp->cmd));
			else strncpy0(rp->dir, s, sizeof(rp->dir));
		}
	}

	tdata.name = tdata.cmd = "";
	tdata.dir[0] = '\0';
	tdata.idx = -1;
	tdata.nidx = 0;
	tdata.cnt = FACTION_ROWS_TOTAL;
	tdata.lock = FALSE;

	run_create(spawn_code, &tdata, sizeof(tdata));
}
Ejemplo n.º 6
0
int
inifile_getfmt(inifile_t *self, const char *sec, const char *key, const char *fmt, ...)
{
  const char *val = inifile_get(self, sec, key, "");
  int         res = 0;
  va_list     va;

  va_start(va, fmt);
  res = vsscanf(val, fmt, va);
  va_end(va);

  return res;
}
Ejemplo n.º 7
0
void init_factions()
{
#ifndef WIN32
	int i, j;
	static char *row_def[][3] = {
		{"View EXIF data (leafpad)", "exif %f | leafpad"},
		{"View filesystem data (xterm)", "xterm -hold -e ls -l %f"},
		{"Edit in Gimp", "gimp %f"},
		{"View in GQview", "gqview %f"},
		{"Print image", "kprinter %f"},
		{"Email image", "seamonkey -compose attachment=file://%f"},
		{"Send image to Firefox", "firefox %f"},
		{"Send image to OpenOffice", "soffice %f"},
		{"Edit Clipboards", "mtpaint ~/.clip*"},
		{"Time delayed screenshot", "sleep 10; mtpaint -s &"},
		{"View image information", "xterm -hold -sb -rightbar -geometry 100x100 -e identify -verbose %f"},
		{"#Create temp directory", "mkdir ~/images"},
		{"#Remove temp directory", "rm -rf ~/images"},
		{"#GIF to PNG conversion (in situ)", "mogrify -format png *.gif"},
		{"#ICO to PNG conversion (temp directory)", "ls --file-type *.ico | xargs -I FILE convert FILE ~/images/FILE.png"},
		{"Convert image to ICO file", "mogrify -format ico %f"},
		{"Create thumbnails in temp directory", "ls --file-type * | xargs -I FILE convert FILE -thumbnail 120x120 -sharpen 1 -quality 95 ~/images/th_FILE.jpg"},
		{"Create thumbnails (in situ)", "ls --file-type * | xargs -I FILE convert FILE -thumbnail 120x120 -sharpen 1 -quality 95 th_FILE.jpg"},
		{"Peruse temp images", "mtpaint ~/images/*"},
		{"Rename *.jpeg to *.jpg", "rename .jpeg .jpg *.jpeg"},
		{"Remove spaces from filenames", "for file in *\" \"*; do mv \"$file\" `echo $file | sed -e 's/ /_/g'`; done"},
		{"Remove extra .jpg. from filename", "rename .jpg. . *.jpg.jpg"},
//		{"", ""},
		{NULL, NULL, NULL}
		},
		txt[64];

	for (i = 0; row_def[i][0]; i++)		// Needed for first time usage - populate inifile list
	{
		for (j = 0; j < 3; j++)
		{
			sprintf(txt, faction_ini[j], i + 1);
			inifile_get(txt, row_def[i][j]);
		}
	}
#endif

	update_faction_menu();			// Prepare menu
}
Ejemplo n.º 8
0
static gint oss_try_format(Dataformat *format, gboolean input, gboolean silent)
{
     gchar *fname;
     int i,j;
     /* For now, we just refuse floating-point format. We should probably 
      * use a fallback format instead */
     if (format->type == DATAFORMAT_FLOAT) return -1;
     /* Determine the right format */
     oss_samplesize = format->samplesize;
     switch (oss_samplesize) {
     case 1:
	  oss_format = (format->sign) ? AFMT_S8 : AFMT_U8;
	  break;
     case 2:
	  if (!format->bigendian)
	       oss_format = (format->sign) ? AFMT_S16_LE : AFMT_U16_LE;
	  else
	       oss_format = (format->sign) ? AFMT_S16_BE : AFMT_U16_BE;
	  break;
     case 3:
     case 4:
	  if (!format->sign) return -1;
	  if (format->packing == 2) return -1;
	  /* This is really hairy, but the AFMT_S32-constants don't seem to be 
	   * defined in all soundcard.h files */
	  if (format->bigendian) {
#ifdef AFMT_S32_BE
	       oss_format = AFMT_S32_BE;
#else
	       return -1;
#endif
	  } else {
#ifdef AFMT_S32_LE
	  oss_format = AFMT_S32_LE;
#else
	  return -1;
#endif
	  }
	  break;
     default:
	  g_assert_not_reached();
     }
     /* Open the file */
     fname = inifile_get(OSS_PCMFILE_PLAYBACK,OSS_PCMFILE_DEFAULT);
     if (input)
	  fname = inifile_get(OSS_PCMFILE_RECORD, fname);
     oss_fd = oss_errdlg_open(fname, input ? O_RDONLY : O_WRONLY, silent);
     if (oss_fd == -1) return silent?-1:+1;
     /* Try to set the format */
     j = oss_format;
     i = oss_errdlg_ioctl(oss_fd, SNDCTL_DSP_SETFMT, &j, silent);
     if (i == -1 || j != oss_format) { 
	  close(oss_fd); 
	  oss_fd=-1; 
	  return (i != -1 || silent)?-1:+1; 
     }
     /* Try to set the number of channels */
     j = oss_channels = format->channels;
     i = oss_errdlg_ioctl(oss_fd, SNDCTL_DSP_CHANNELS, &j, silent);
     if (i==-1 || j != oss_channels) { 
	  close(oss_fd); 
	  oss_fd=-1; 
	  return (i != -1 || silent)?-1:+1; 
     }
     /* Try to set the sample rate */
     j = oss_samplerate = format->samplerate;
     i = oss_errdlg_ioctl(oss_fd, SNDCTL_DSP_SPEED, &j, silent);
     /* FIXME: Variable tolerance (esp. for input) */
     /* Currently tolerates 5% difference between requested/received samplerate
      */
     if (i==-1 || abs(j-oss_samplerate) > oss_samplerate/20) {
	  close(oss_fd); 
	  oss_fd=-1; 
	  return (i != -1 || silent)?-1:+1;
     }
     /* Everything went well! */
     oss_samplebytes_in = oss_samplebytes_out = oss_channels * oss_samplesize;     
     if (oss_samplesize == 3)
	  oss_samplebytes_out += oss_channels;
     return 0;
}
Ejemplo n.º 9
0
void pressed_preferences( GtkMenuItem *menu_item, gpointer user_data )
{
	int i;
#ifdef U_NLS
	int j;
	GSList *radio_group;
#endif


	GtkWidget *vbox3, *hbox4, *table3, *table4, *table5, *drawingarea_tablet, *frame;
	GtkWidget *button1, *button2, *notebook1, *vbox_1, *vbox_2, *vbox_3, *label;
	GtkAccelGroup* ag = gtk_accel_group_new();

	char *tab_tex[] = { _("Max memory used for undo (MB)"), _("Greyscale backdrop"),
		_("Selection nudge pixels"), _("Max Pan Window Size") };
	char *tab_tex2[] = { _("XPM/PNG transparency index"), _("XBM X hotspot"), _("XBM Y hotspot"),
		_("JPEG Save Quality (100=High)   "), _("Recently Used Files") };
	char *tab_tex3[] = { _("Minimum grid zoom"), _("Grid colour RGB") };
	char *stat_tex[] = { _("Colour A & B"), _("Canvas Geometry"), _("Cursor X,Y"),
		_("Pixel [I] {RGB}"), _("Zoom %"), _("Selection Geometry"), _("Continuous Mode"),
		_("Undo / Redo"), _("Opacity %"), _("Opacity Mode") },
		*tablet_txt[] = { _("Size"), _("Flow"), _("Opacity") };
	char txt[64];


	men_item_state( menu_prefs, FALSE );	// Make sure the user can only open 1 prefs window

	prefs_window = add_a_window( GTK_WINDOW_TOPLEVEL, _("Preferences"), GTK_WIN_POS_CENTER, FALSE );

	vbox3 = gtk_vbox_new (FALSE, 0);
	gtk_widget_show (vbox3);
	gtk_container_add (GTK_CONTAINER (prefs_window), vbox3);

///	SETUP NOTEBOOK

	notebook1 = gtk_notebook_new ();
	gtk_box_pack_start (GTK_BOX (vbox3), notebook1, TRUE, TRUE, 0);
	gtk_notebook_set_tab_pos (GTK_NOTEBOOK (notebook1), GTK_POS_TOP);
	gtk_widget_show (notebook1);

///	---- TAB1 - GENERAL

	vbox_1 = gtk_vbox_new (FALSE, 0);
	gtk_widget_show (vbox_1);
	gtk_container_add (GTK_CONTAINER (notebook1), vbox_1);

	label = gtk_label_new( _("General") );
	gtk_widget_show (label);
	gtk_notebook_set_tab_label(GTK_NOTEBOOK (notebook1),
		gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook1), 0), label);


	table3 = add_a_table( 3, 2, 10, vbox_1 );

///	TABLE TEXT
	for ( i=0; i<4; i++ ) add_to_table( tab_tex[i], table3, i, 0, 0, GTK_JUSTIFY_LEFT, 0, 0.5 );

///	TABLE SPINBUTTONS
	spin_to_table( table3, &spinbutton_maxmem, 0, 1, 5, inifile_get_gint32("undoMBlimit", 32 ), 1, 1000 );
	spin_to_table( table3, &spinbutton_greys, 1, 1, 5, inifile_get_gint32("backgroundGrey", 180 ), 0, 255 );
	spin_to_table( table3, &spinbutton_nudge, 2, 1, 5, inifile_get_gint32("pixelNudge", 8 ), 2, 512 );
	spin_to_table( table3, &spinbutton_pan, 3, 1, 5, inifile_get_gint32("panSize", 128 ), 64, 256 );

	checkbutton_paste = add_a_toggle( _("Display clipboard while pasting"),
		vbox_1, inifile_get_gboolean("pasteToggle", TRUE) );
	checkbutton_cursor = add_a_toggle( _("Mouse cursor = Tool"),
		vbox_1, inifile_get_gboolean("cursorToggle", TRUE) );
	checkbutton_exit = add_a_toggle( _("Confirm Exit"),
		vbox_1, inifile_get_gboolean("exitToggle", FALSE) );
	checkbutton_quit = add_a_toggle( _("Q key quits mtPaint"),
		vbox_1, inifile_get_gboolean("quitToggle", TRUE) );
	checkbutton_commit = add_a_toggle( _("Changing tool commits paste"),
		vbox_1, inifile_get_gboolean("pasteCommit", FALSE) );


///	---- TAB2 - FILES

	vbox_2 = gtk_vbox_new (FALSE, 0);
	gtk_widget_show (vbox_2);
	gtk_container_add (GTK_CONTAINER (notebook1), vbox_2);

	label = gtk_label_new( _("Files") );
	gtk_widget_show (label);
	gtk_notebook_set_tab_label(GTK_NOTEBOOK (notebook1),
		gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook1), 1), label);

	table4 = add_a_table( 5, 2, 10, vbox_2 );

	for ( i=0; i<5; i++ ) add_to_table( tab_tex2[i], table4, i, 0, 0, GTK_JUSTIFY_LEFT, 0, 0.5 );

	spin_to_table( table4, &spinbutton_trans, 0, 1, 5, mem_xpm_trans, -1, mem_cols-1 );
	spin_to_table( table4, &spinbutton_hotx, 1, 1, 5, mem_xbm_hot_x, -1, mem_width-1 );
	spin_to_table( table4, &spinbutton_hoty, 2, 1, 5, mem_xbm_hot_y, -1, mem_height-1 );
	spin_to_table( table4, &spinbutton_jpeg, 3, 1, 5, mem_jpeg_quality, 0, 100 );
	spin_to_table( table4, &spinbutton_recent, 4, 1, 5, recent_files, 0, MAX_RECENT );

	add_hseparator( vbox_2, -2, 10 );
	label = gtk_label_new( _("Clipboard Files") );
	gtk_widget_show( label );
	gtk_box_pack_start( GTK_BOX(vbox_2), label, FALSE, FALSE, 0 );

	clipboard_entry = gtk_entry_new();
	gtk_widget_show( clipboard_entry );
	gtk_box_pack_start( GTK_BOX(vbox_2), clipboard_entry, FALSE, FALSE, 0 );
	gtk_entry_set_text( GTK_ENTRY(clipboard_entry), mem_clip_file[0] );
	strncpy( mem_clip_file[1], mem_clip_file[0], 250 );

	button1 = add_a_button( _("Browse"), 4, vbox_2, FALSE );
	gtk_signal_connect(GTK_OBJECT(button1), "clicked",
		GTK_SIGNAL_FUNC(clip_file_browse), NULL);

///	---- TAB3 - STATUS BAR

	hbox4 = gtk_hbox_new (FALSE, 0);
	gtk_widget_show (hbox4);
	gtk_container_add (GTK_CONTAINER (notebook1), hbox4);

	vbox_3 = gtk_vbox_new (FALSE, 0);
	gtk_widget_show (vbox_3);
	gtk_box_pack_start (GTK_BOX (hbox4), vbox_3, FALSE, FALSE, 0);

	label = gtk_label_new( _("Status Bar") );
	gtk_widget_show (label);
	gtk_notebook_set_tab_label(GTK_NOTEBOOK (notebook1),
		gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook1), 2), label);

	for ( i=0; i<STATUS_ITEMS; i++ )
	{
		if (i==5)
		{
			vbox_3 = gtk_vbox_new (FALSE, 0);
			gtk_widget_show (vbox_3);
			gtk_box_pack_start (GTK_BOX (hbox4), vbox_3, FALSE, FALSE, 0);
		}
		sprintf(txt, "status%iToggle", i);
		prefs_status[i] = add_a_toggle( stat_tex[i], vbox_3, inifile_get_gboolean(txt, TRUE) );
	}

///	---- TAB4 - ZOOM

	hbox4 = gtk_hbox_new (FALSE, 0);
	gtk_widget_show (hbox4);
	gtk_container_add (GTK_CONTAINER (notebook1), hbox4);

	vbox_3 = gtk_vbox_new (FALSE, 0);
	gtk_widget_show (vbox_3);
	gtk_box_pack_start (GTK_BOX (hbox4), vbox_3, FALSE, FALSE, 0);

	label = gtk_label_new( _("Zoom") );
	gtk_widget_show (label);
	gtk_notebook_set_tab_label(GTK_NOTEBOOK (notebook1),
		gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook1), 3), label);
	table5 = add_a_table( 2, 4, 10, vbox_3 );

///	TABLE TEXT
	for ( i=0; i<2; i++ ) add_to_table( tab_tex3[i], table5, i, 0, 0, GTK_JUSTIFY_LEFT, 0, 0.5 );

///	TABLE SPINBUTTONS
	spin_to_table( table5, &spinbutton_grid[0], 0, 1, 5, mem_grid_min, 2, 12 );
	spin_to_table( table5, &spinbutton_grid[1], 1, 1, 5, mem_grid_rgb[0], 0, 255 );
	spin_to_table( table5, &spinbutton_grid[2], 1, 2, 5, mem_grid_rgb[1], 0, 255 );
	spin_to_table( table5, &spinbutton_grid[3], 1, 3, 5, mem_grid_rgb[2], 0, 255 );

	checkbutton_zoom = add_a_toggle( _("New image sets zoom to 100%"),
		vbox_3, inifile_get_gboolean("zoomToggle", FALSE) );
#if GTK_MAJOR_VERSION == 2
	checkbutton_wheel = add_a_toggle( _("Mouse Scroll Wheel = Zoom"),
		vbox_3, inifile_get_gboolean("scrollwheelZOOM", TRUE) );
#endif



///	---- TAB5 - TABLET

	hbox4 = gtk_hbox_new (FALSE, 0);
	gtk_widget_show (hbox4);
	gtk_container_add (GTK_CONTAINER (notebook1), hbox4);

	vbox_3 = gtk_vbox_new (FALSE, 0);
	gtk_widget_show (vbox_3);
	gtk_box_pack_start (GTK_BOX (hbox4), vbox_3, FALSE, FALSE, 0);

	label = gtk_label_new( _("Tablet") );
	gtk_widget_show (label);
	gtk_notebook_set_tab_label(GTK_NOTEBOOK (notebook1),
		gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook1), 4), label);



	frame = gtk_frame_new (_("Device Settings"));
	gtk_widget_show (frame);
	gtk_box_pack_start (GTK_BOX (vbox_3), frame, FALSE, FALSE, 0);
	gtk_container_set_border_width (GTK_CONTAINER (frame), 5);

	vbox_2 = gtk_vbox_new (FALSE, 0);
	gtk_widget_show (vbox_2);
	gtk_container_add (GTK_CONTAINER (frame), vbox_2);
	gtk_container_set_border_width (GTK_CONTAINER (vbox_2), 5);

	label_tablet_device = gtk_label_new ("");
	gtk_widget_show (label_tablet_device);
	gtk_box_pack_start (GTK_BOX (vbox_2), label_tablet_device, FALSE, FALSE, 0);
	gtk_misc_set_alignment (GTK_MISC (label_tablet_device), 0, 0.5);
	gtk_misc_set_padding (GTK_MISC (label_tablet_device), 5, 5);

	button1 = add_a_button( _("Configure Device"), 0, vbox_2, FALSE );
	gtk_signal_connect(GTK_OBJECT(button1), "clicked", GTK_SIGNAL_FUNC(conf_tablet), NULL);

	table3 = gtk_table_new (4, 2, FALSE);
	gtk_widget_show (table3);
	gtk_box_pack_start (GTK_BOX (vbox_2), table3, TRUE, TRUE, 0);

	label = add_to_table( _("Tool Variable"), table3, 0, 0, 0, 0, 0, 0 );
	gtk_misc_set_padding (GTK_MISC (label), 5, 5);
	label = add_to_table( _("Factor"), table3, 0, 1, 0, 0, 0, 0 );
	gtk_misc_set_padding (GTK_MISC (label), 5, 5);
	gtk_misc_set_alignment (GTK_MISC (label), 0.4, 0.5);

	for ( i=0; i<3; i++ )
	{
		check_tablet[i] = gtk_check_button_new_with_label (tablet_txt[i]);
		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check_tablet[i]),
			tablet_tool_use[i] );
		gtk_widget_show (check_tablet[i]);
		gtk_table_attach (GTK_TABLE (table3), check_tablet[i], 0, 1, i+1, i+2,
			(GtkAttachOptions) (GTK_FILL),
			(GtkAttachOptions) (0), 0, 0);

//	Size/Flow/Opacity sliders

		hscale_tablet[i] = add_slider2table( 0, -1, 1, table3, 1+i, 1, 200, -2 );
		gtk_adjustment_set_value( GTK_HSCALE(hscale_tablet[i])->scale.range.adjustment,
			tablet_tool_factor[i] );
		gtk_scale_set_value_pos (GTK_SCALE (hscale_tablet[i]), GTK_POS_RIGHT);
		gtk_scale_set_digits (GTK_SCALE (hscale_tablet[i]), 2);
		gtk_scale_set_draw_value (GTK_SCALE (hscale_tablet[i]), TRUE);
	}


	frame = gtk_frame_new (_("Test Area"));
	gtk_widget_show (frame);
	gtk_box_pack_start (GTK_BOX (vbox_3), frame, FALSE, FALSE, 0);
	gtk_container_set_border_width (GTK_CONTAINER (frame), 5);

	vbox_2 = gtk_vbox_new (FALSE, 0);
	gtk_widget_show (vbox_2);
	gtk_container_add (GTK_CONTAINER (frame), vbox_2);
	gtk_container_set_border_width (GTK_CONTAINER (vbox_2), 5);

	drawingarea_tablet = gtk_drawing_area_new ();
	gtk_widget_show (drawingarea_tablet);
	gtk_box_pack_start (GTK_BOX (vbox_2), drawingarea_tablet, TRUE, TRUE, 0);
	gtk_widget_set_usize (drawingarea_tablet, 128, 64);
	gtk_signal_connect( GTK_OBJECT(drawingarea_tablet), "expose_event",
		GTK_SIGNAL_FUNC (expose_tablet_preview), (gpointer) drawingarea_tablet );

	gtk_signal_connect (GTK_OBJECT (drawingarea_tablet), "motion_notify_event",
		GTK_SIGNAL_FUNC (tablet_preview_motion), NULL);
	gtk_signal_connect (GTK_OBJECT (drawingarea_tablet), "button_press_event",
		GTK_SIGNAL_FUNC (tablet_preview_button), NULL);

	gtk_widget_set_events (drawingarea_tablet, GDK_EXPOSURE_MASK
		| GDK_LEAVE_NOTIFY_MASK
		| GDK_BUTTON_PRESS_MASK
		| GDK_POINTER_MOTION_MASK
		| GDK_POINTER_MOTION_HINT_MASK);

	gtk_widget_set_extension_events (drawingarea_tablet, GDK_EXTENSION_EVENTS_CURSOR);



	label_tablet_pressure = gtk_label_new ("");
	gtk_widget_show (label_tablet_pressure);
	gtk_box_pack_start (GTK_BOX (vbox_2), label_tablet_pressure, FALSE, FALSE, 0);
	gtk_misc_set_alignment (GTK_MISC (label_tablet_pressure), 0, 0.5);



///	---- TAB6 - LANGUAGE

#ifdef U_NLS

	pref_lang_ini[1] = _("Default System Language");
	pref_lang_ini[3] = _("Czech");
	pref_lang_ini[5] = _("English (UK)");
	pref_lang_ini[7] = _("French");
	pref_lang_ini[9] = _("Portuguese");
	pref_lang_ini[11] = _("Portuguese (Brazilian)");
	pref_lang_ini[13] = _("Spanish");

	vbox_2 = gtk_vbox_new (FALSE, 0);
	gtk_widget_show (vbox_2);
	gtk_container_add (GTK_CONTAINER (notebook1), vbox_2);
	gtk_container_set_border_width( GTK_CONTAINER(vbox_2), 10 );

	label = gtk_label_new( _("Language") );
	gtk_widget_show (label);
	gtk_notebook_set_tab_label(GTK_NOTEBOOK (notebook1),
		gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook1), 5), label);

	add_hseparator( vbox_2, 200, 10 );
	label = gtk_label_new( _("Select preferred language translation\n\n"
				"You will need to restart mtPaint\nfor this to take full effect") );
	pref_lang_label = label;
	gtk_widget_show (label);
	gtk_box_pack_start( GTK_BOX(vbox_2), label, FALSE, FALSE, 0 );
	add_hseparator( vbox_2, 200, 10 );

	pref_lang_radio[0] = add_radio_button( pref_lang_ini[1], NULL,  NULL, vbox_2, 0 );
	radio_group = gtk_radio_button_group( GTK_RADIO_BUTTON(pref_lang_radio[0]) );
	pref_lang_radio[1] = add_radio_button( pref_lang_ini[3], radio_group, NULL, vbox_2, 1 );
	for ( i=2; i<PREF_LANGS; i++ )
		pref_lang_radio[i] = add_radio_button(
					pref_lang_ini[i*2+1], NULL, pref_lang_radio[1], vbox_2, i );

	for ( i=0; i<PREF_LANGS; i++ )
		gtk_container_set_border_width( GTK_CONTAINER(pref_lang_radio[i]), 5 );

	j = 0;
	for ( i = PREF_LANGS - 1; i>0; i-- )
	{
		if ( strcmp( pref_lang_ini[i*2], inifile_get( "languageSETTING", "system" ) ) == 0 )
			j = i;
	}
	gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(pref_lang_radio[j]), TRUE );

#endif



///	Bottom of Prefs window

	hbox4 = gtk_hbox_new (FALSE, 0);
	gtk_widget_show (hbox4);
	gtk_box_pack_start (GTK_BOX (vbox3), hbox4, FALSE, FALSE, 0);

	button1 = add_a_button(_("Cancel"), 5, hbox4, TRUE);
	gtk_signal_connect(GTK_OBJECT(button1), "clicked", GTK_SIGNAL_FUNC(delete_prefs), NULL);
	gtk_widget_add_accelerator (button1, "clicked", ag, GDK_Escape, 0, (GtkAccelFlags) 0);

	button1 = add_a_button(_("Apply"), 5, hbox4, TRUE);
	gtk_signal_connect(GTK_OBJECT(button1), "clicked", GTK_SIGNAL_FUNC(prefs_apply), NULL);

	button2 = add_a_button(_("OK"), 5, hbox4, TRUE);
	gtk_signal_connect(GTK_OBJECT(button2), "clicked", GTK_SIGNAL_FUNC(prefs_ok), NULL);
	gtk_widget_add_accelerator (button2, "clicked", ag, GDK_Return, 0, (GtkAccelFlags) 0);
	gtk_widget_add_accelerator (button2, "clicked", ag, GDK_KP_Enter, 0, (GtkAccelFlags) 0);


	gtk_signal_connect_object (GTK_OBJECT (prefs_window), "delete_event",
		GTK_SIGNAL_FUNC (delete_prefs), NULL);

	gtk_window_set_transient_for( GTK_WINDOW(prefs_window), GTK_WINDOW(main_window) );
	gtk_widget_show (prefs_window);
	gtk_window_add_accel_group(GTK_WINDOW (prefs_window), ag);

	if ( tablet_working )
	{
		tablet_update_device( tablet_device->name );
	} else	tablet_update_device( "NONE" );
}
Ejemplo n.º 10
0
static const char *custom_(const char *profile, const char *key)
{
  return inifile_get(database_custom, profile, key, NULL);
}
Ejemplo n.º 11
0
static const char *config_(const char *profile, const char *key)
{
  return inifile_get(database_static, profile, key, NULL);
}
Ejemplo n.º 12
0
static const char *override_(const char *key)
{
  return inifile_get(database_static, OVERRIDE, key, NULL);
}
Ejemplo n.º 13
0
static const char *fallback_(const char *key)
{
  return inifile_get(database_static, FALLBACK, key, NULL);
}
Ejemplo n.º 14
0
static const char *datatype_(const char *key)
{
  return inifile_get(database_static, DATATYPE, key, NULL);
}
Ejemplo n.º 15
0
void init_tablet()				// Set up variables
{
	int i;
	char *devname, txt[32];

	gboolean use_tablet;
	GList *dlist;

#if GTK_MAJOR_VERSION == 1
	GdkDeviceInfo *device = NULL;
	gint use;
#endif
#if GTK_MAJOR_VERSION == 2
	GdkDevice *device = NULL;
	GdkAxisUse use;
#endif

	use_tablet = inifile_get_gboolean( "tablet_USE", FALSE );

	if ( use_tablet )		// User has got tablet working in past so try to initialize it
	{
		devname = inifile_get( tablet_ini3[0], "?" );	// Device name last used
#if GTK_MAJOR_VERSION == 1
		dlist = gdk_input_list_devices();
#endif
#if GTK_MAJOR_VERSION == 2
		dlist = gdk_devices_list();
#endif
		while ( dlist != NULL )
		{
			device = dlist->data;
			if ( strcmp(device->name, devname ) == 0 )
			{		// Previously used device was found

#if GTK_MAJOR_VERSION == 1
				gdk_input_set_mode(device->deviceid,
					inifile_get_gint32( tablet_ini3[1], 0 ) );
#endif
#if GTK_MAJOR_VERSION == 2
				gdk_device_set_mode(device, inifile_get_gint32( tablet_ini3[1], 0 ) );
#endif
				for ( i=0; i<device->num_axes; i++ )
				{
					sprintf(txt, "%s%i", tablet_ini3[2], i);
					use = inifile_get_gint32( txt, GDK_AXIS_IGNORE );
#if GTK_MAJOR_VERSION == 1
					device->axes[i] = use;
					gdk_input_set_axes(device->deviceid, device->axes);
#endif
#if GTK_MAJOR_VERSION == 2
					gdk_device_set_axis_use(device, i, use);
#endif
				}
				tablet_device = device;
				tablet_working = TRUE;		// Success!
				break;
			}
			dlist = dlist->next;		// Not right device so look for next one
		}
	}

	for ( i=0; i<3; i++ )
	{
		tablet_tool_use[i] = inifile_get_gboolean( tablet_ini2[i], FALSE );
		tablet_tool_factor[i] = ((float) inifile_get_gint32( tablet_ini[i], 100 )) / 100;
	}
}
Ejemplo n.º 16
0
//****************************************************************************************
// Challenge menu
//*****************************************************************************************
bool addChallenges()
{
    char			sPath[PATH_MAX];
    const char *sSearchPath	= "challenges";
    UDWORD			slotCount;
    static char		sSlotCaps[totalslots][totalslotspace];
    static char		sSlotTips[totalslots][totalslotspace];
    static char		sSlotFile[totalslots][totalslotspace];
    char **i, **files;

    (void) PHYSFS_mkdir(sSearchPath); // just in case

    psRequestScreen = widgCreateScreen(); // init the screen
    widgSetTipFont(psRequestScreen, font_regular);

    /* add a form to place the tabbed form on */
    W_FORMINIT sFormInit;
    sFormInit.formID = 0;				//this adds the blue background, and the "box" behind the buttons -Q
    sFormInit.id = CHALLENGE_FORM;
    sFormInit.style = WFORM_PLAIN;
    sFormInit.x = (SWORD) CHALLENGE_X;
    sFormInit.y = (SWORD) CHALLENGE_Y;
    sFormInit.width = CHALLENGE_W;
    // we need the form to be long enough for all resolutions, so we take the total number of items * height
    // and * the gaps, add the banner, and finally, the fudge factor ;)
    sFormInit.height = (slotsInColumn * CHALLENGE_ENTRY_H + CHALLENGE_HGAP * slotsInColumn) + CHALLENGE_BANNER_DEPTH + 20;
    sFormInit.disableChildren = true;
    sFormInit.pDisplay = intOpenPlainForm;
    widgAddForm(psRequestScreen, &sFormInit);

    // Add Banner
    sFormInit.formID = CHALLENGE_FORM;
    sFormInit.id = CHALLENGE_BANNER;
    sFormInit.x = CHALLENGE_HGAP;
    sFormInit.y = CHALLENGE_VGAP;
    sFormInit.width = CHALLENGE_W - (2 * CHALLENGE_HGAP);
    sFormInit.height = CHALLENGE_BANNER_DEPTH;
    sFormInit.disableChildren = false;
    sFormInit.pDisplay = displayLoadBanner;
    sFormInit.UserData = 0;
    widgAddForm(psRequestScreen, &sFormInit);

    // Add Banner Label
    W_LABINIT sLabInit;
    sLabInit.formID		= CHALLENGE_BANNER;
    sLabInit.id		= CHALLENGE_LABEL;
    sLabInit.style		= WLAB_ALIGNCENTRE;
    sLabInit.x		= 0;
    sLabInit.y		= 3;
    sLabInit.width		= CHALLENGE_W - (2 * CHALLENGE_HGAP);	//CHALLENGE_W;
    sLabInit.height		= CHALLENGE_BANNER_DEPTH;		//This looks right -Q
    sLabInit.pText		= "Challenge";
    widgAddLabel(psRequestScreen, &sLabInit);

    // add cancel.
    W_BUTINIT sButInit;
    sButInit.formID = CHALLENGE_BANNER;
    sButInit.x = 8;
    sButInit.y = 8;
    sButInit.width		= iV_GetImageWidth(IntImages, IMAGE_NRUTER);
    sButInit.height		= iV_GetImageHeight(IntImages, IMAGE_NRUTER);
    sButInit.UserData	= PACKDWORD_TRI(0, IMAGE_NRUTER , IMAGE_NRUTER);

    sButInit.id = CHALLENGE_CANCEL;
    sButInit.pTip = _("Close");
    sButInit.pDisplay = intDisplayImageHilight;
    widgAddButton(psRequestScreen, &sButInit);

    // add slots
    sButInit = W_BUTINIT();
    sButInit.formID		= CHALLENGE_FORM;
    sButInit.width		= CHALLENGE_ENTRY_W;
    sButInit.height		= CHALLENGE_ENTRY_H;
    sButInit.pDisplay	= displayLoadSlot;

    for (slotCount = 0; slotCount < totalslots; slotCount++)
    {
        sButInit.id		= slotCount + CHALLENGE_ENTRY_START;

        if (slotCount < slotsInColumn)
        {
            sButInit.x	= 22 + CHALLENGE_HGAP;
            sButInit.y	= (SWORD)((CHALLENGE_BANNER_DEPTH + (2 * CHALLENGE_VGAP)) + (
                                      slotCount * (CHALLENGE_VGAP + CHALLENGE_ENTRY_H)));
        }
        else if (slotCount >= slotsInColumn && (slotCount < (slotsInColumn *2)))
        {
            sButInit.x	= 22 + (2 * CHALLENGE_HGAP + CHALLENGE_ENTRY_W);
            sButInit.y	= (SWORD)((CHALLENGE_BANNER_DEPTH + (2 * CHALLENGE_VGAP)) + (
                                      (slotCount % slotsInColumn) * (CHALLENGE_VGAP + CHALLENGE_ENTRY_H)));
        }
        else
        {
            sButInit.x	= 22 + (3 * CHALLENGE_HGAP + (2 * CHALLENGE_ENTRY_W));
            sButInit.y	= (SWORD)((CHALLENGE_BANNER_DEPTH + (2 * CHALLENGE_VGAP)) + (
                                      (slotCount % slotsInColumn) * (CHALLENGE_VGAP + CHALLENGE_ENTRY_H)));
        }
        widgAddButton(psRequestScreen, &sButInit);
    }

    // fill slots.
    slotCount = 0;

    sstrcpy(sPath, sSearchPath);
    sstrcat(sPath, "/*.ini");

    debug(LOG_SAVE, "Searching \"%s\" for challenges", sPath);

    // add challenges to buttons
    files = PHYSFS_enumerateFiles(sSearchPath);
    for (i = files; *i != NULL; ++i)
    {
        W_BUTTON *button;
        char description[totalslotspace];
        char highscore[totalslotspace];
        const char *name, *difficulty, *map, *givendescription;
        inifile *inif;

        // See if this filename contains the extension we're looking for
        if (!strstr(*i, ".ini"))
        {
            // If it doesn't, move on to the next filename
            continue;
        }

        /* First grab any high score associated with this challenge */
        inif = inifile_load(CHALLENGE_SCORES);
        sstrcpy(sPath, *i);
        sPath[strlen(sPath) - 4] = '\0';	// remove .ini
        sstrcpy(highscore, "no score");
        if (inif)
        {
            char key[64];
            bool victory;
            int seconds;

            ssprintf(key, "%s:Player", sPath);
            name = inifile_get(inif, key, "NO NAME");
            ssprintf(key, "%s:Victory", sPath);
            victory = inifile_get_as_bool(inif, key, false);
            ssprintf(key, "%s:Seconds", sPath);
            seconds = inifile_get_as_int(inif, key, -1);
            if (seconds > 0)
            {
                getAsciiTime(key, seconds * GAME_TICKS_PER_SEC);
                ssprintf(highscore, "%s by %s (%s)", key, name, victory ? "Victory" : "Survived");
            }
            inifile_delete(inif);
        }

        ssprintf(sPath, "%s/%s", sSearchPath, *i);
        inif = inifile_load(sPath);
        inifile_set_current_section(inif, "challenge");
        if (!inif)
        {
            debug(LOG_ERROR, "Could not open \"%s\"", sPath);
            continue;
        }
        name = inifile_get(inif, "Name", "BAD NAME");
        map = inifile_get(inif, "Map", "BAD MAP");
        difficulty = inifile_get(inif, "difficulty", "BAD DIFFICULTY");
        givendescription = inifile_get(inif, "description", "");
        ssprintf(description, "%s, %s, %s. %s", map, difficulty, highscore, givendescription);

        button = (W_BUTTON*)widgGetFromID(psRequestScreen, CHALLENGE_ENTRY_START + slotCount);

        debug(LOG_SAVE, "We found [%s]", *i);

        /* Set the button-text */
        sstrcpy(sSlotCaps[slotCount], name);		// store it!
        sstrcpy(sSlotTips[slotCount], description);	// store it, too!
        sstrcpy(sSlotFile[slotCount], sPath);		// store filename
        inifile_delete(inif);

        /* Add button */
        button->pTip = sSlotTips[slotCount];
        button->pText = sSlotCaps[slotCount];
        button->pUserData = (void *)sSlotFile[slotCount];
        slotCount++;		// go to next button...
        if (slotCount == totalslots)
        {
            break;
        }
    }
    PHYSFS_freeList(files);

    challengesUp = true;

    return true;
}
Ejemplo n.º 17
0
int main( int argc, char *argv[] )
{
	glob_t globdata;
	int i, j, l, file_arg_start, new_empty = TRUE, get_screenshot = FALSE;

	if (argc > 1)
	{
		if ( strcmp(argv[1], "--version") == 0 )
		{
			printf("%s\n\n", MT_VERSION);
			exit(0);
		}
		if ( strcmp(argv[1], "--help") == 0 )
		{
			printf("%s\n\n"
				"Usage: mtpaint [option] [imagefile ... ]\n\n"
				"Options:\n"
				"  --help          Output this help\n"
				"  --version       Output version information\n"
				"  -s              Grab screenshot\n"
				"  -v              Start in viewer mode\n\n"
			, MT_VERSION);
			exit(0);
		}
	}

	putenv( "G_BROKEN_FILENAMES=1" );	// Needed to read non ASCII filenames in GTK+2

#if GTK2VERSION >= 4
	/* Tablet handling in GTK+ 2.18+ is broken beyond repair if this mode
	 * is set; so unset it, if g_unsetenv() is present */
	g_unsetenv("GDK_NATIVE_WINDOWS");
#endif

#ifdef U_THREADS
	/* Enable threading for GLib, but NOT for GTK+ (at least, not yet) */
	g_thread_init(NULL);
#endif
	inifile_init("/etc/mtpaint/mtpaintrc", "~/.mtpaint");

#ifdef U_NLS
#if GTK_MAJOR_VERSION == 1
	/* !!! GTK+1 needs locale set up before gtk_init(); GTK+2, *QUITE*
	 * the opposite - WJ */
	setup_language();
#endif
#endif

#ifdef U_THREADS
	/* !!! Uncomment to allow GTK+ calls from other threads */
	/* gdk_threads_init(); */
#endif
	gtk_init( &argc, &argv );
	gtk_init_bugfixes();
#if GTK_MAJOR_VERSION == 2
	{
		char *theme = inifile_get(DEFAULT_THEME_INI, "");
		if (theme[0]) gtk_rc_parse(theme);
	}
#endif

#ifdef U_NLS
#if GTK_MAJOR_VERSION == 2
	/* !!! GTK+2 starts acting up if this is before gtk_init() - WJ */
	setup_language();
#endif
	bindtextdomain("mtpaint", MT_LANG_DEST);
	textdomain("mtpaint");
#if GTK_MAJOR_VERSION == 2
	bind_textdomain_codeset("mtpaint", "UTF-8");
#endif
#endif

	file_arg_start = 1;
	if (argc > 1)		// Argument received, so assume user is trying to load a file
	{
		if ( strcmp(argv[1], "-g") == 0 )	// Loading GIF animation frames
		{
			file_arg_start+=2;
			sscanf(argv[2], "%i", &preserved_gif_delay);
		}
		if ( strcmp(argv[1], "-v") == 0 )	// Viewer mode
		{
			file_arg_start++;
			viewer_mode = TRUE;
		}
		if ( strcmp(argv[1], "-s") == 0 )	// Screenshot
		{
			file_arg_start++;
			get_screenshot = TRUE;
		}
		if ( strstr(argv[0], "mtv") != NULL ) viewer_mode = TRUE;
	}

	/* Something else got passed in */
	l = argc - file_arg_start;
	while (l)
	{
		/* First, process wildcarded args */
		memset(&globdata, 0, sizeof(globdata));
/* !!! I avoid GLOB_DOOFFS here, because glibc before version 2.2 mishandled it,
 * and quite a few copycats had cloned those buggy versions, some libc
 * implementors among them. So it is possible to encounter a broken function
 * in the wild, and playing it safe doesn't cost all that much - WJ */
		for (i = file_arg_start , j = 0; i < argc; i++)
		{
			if (strcmp(argv[i], "-w")) continue; j++;
			if (++i >= argc) break; j++;
			// Ignore errors - be glad for whatever gets returned
			glob(argv[i], (j > 2 ? GLOB_APPEND : 0), NULL, &globdata);
		}
		files_passed = l - j + globdata.gl_pathc;

		/* If no wildcarded args */
		file_args = argv + file_arg_start;
		if (!j) break;
		/* If no normal args */
		file_args = globdata.gl_pathv;
		if (l <= j) break;

		/* Allocate space for both kinds of args together */
		file_args = calloc(files_passed + 1, sizeof(char *));
		// !!! Die by SIGSEGV if this allocation fails

		/* Copy normal args if any */
		for (i = file_arg_start , j = 0; i < argc; i++)
		{
			if (!strcmp(argv[i], "-w")) i++; // Skip the pair
			else file_args[j++] = argv[i];
		}

		/* Copy globbed args after them */
		if (globdata.gl_pathc) memcpy(file_args + j, globdata.gl_pathv,
			globdata.gl_pathc * sizeof(char *));
		break;
	}

	string_init();				// Translate static strings
	var_init();				// Load INI variables
	mem_init();				// Set up memory & back end
	layers_init();
	init_cols();

	if ( get_screenshot )
	{
		if (load_image(NULL, FS_PNG_LOAD, FT_PIXMAP) == 1)
			new_empty = FALSE;	// Successfully grabbed so no new empty
		else get_screenshot = FALSE;	// Screenshot failed
	}
	main_init();					// Create main window

	if ( get_screenshot )
	{
		do_new_chores(FALSE);
		notify_changed();
	}
	else
	{
		if ((files_passed > 0) && !do_a_load(file_args[0], FALSE))
			new_empty = FALSE;
	}

	if ( new_empty )		// If no file was loaded, start with a blank canvas
	{
		create_default_image();
	}

	update_menus();

	THREADS_ENTER();
	gtk_main();
	THREADS_LEAVE();

	spawn_quit();
	inifile_quit();

	return 0;
}