Exemplo n.º 1
0
GtkWidget*
saa_solid_display_new_with_visuel(SaaVisuel * visuel) {
	GObject * obj = g_object_new (SAA_TYPE_SOLID_DISPLAY, NULL);
	GdkColor c;
	double ts, tar;

	SAA_SOLID_DISPLAY(obj)->visuel = visuel;

	g_signal_handlers_block_by_func(SAA_SOLID_DISPLAY(obj)->rads1, saa_solid_display_s1, obj);
	g_signal_handlers_block_by_func(SAA_SOLID_DISPLAY(obj)->rads2, saa_solid_display_s2, obj);
	g_signal_handlers_block_by_func(SAA_SOLID_DISPLAY(obj)->rads3, saa_solid_display_s3, obj);
	switch(visuel->visuSommets) {
	case SAA_SOMMET_NON:
		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(SAA_SOLID_DISPLAY(obj)->rads1), TRUE);
		break;
	case SAA_SOMMET_MOLECULE:
		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(SAA_SOLID_DISPLAY(obj)->rads2), TRUE);
		break;
	case SAA_SOMMET_POINT:
		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(SAA_SOLID_DISPLAY(obj)->rads3), TRUE);
		break;
	}
	g_signal_handlers_unblock_by_func(SAA_SOLID_DISPLAY(obj)->rads1, saa_solid_display_s1, obj);
	g_signal_handlers_unblock_by_func(SAA_SOLID_DISPLAY(obj)->rads2, saa_solid_display_s2, obj);
	g_signal_handlers_unblock_by_func(SAA_SOLID_DISPLAY(obj)->rads3, saa_solid_display_s3, obj);

	g_signal_handlers_block_by_func(SAA_SOLID_DISPLAY(obj)->radar1, saa_solid_display_ar1, obj);
	g_signal_handlers_block_by_func(SAA_SOLID_DISPLAY(obj)->radar2, saa_solid_display_ar2, obj);
	g_signal_handlers_block_by_func(SAA_SOLID_DISPLAY(obj)->radar3, saa_solid_display_ar3, obj);
	switch(visuel->visuAretes) {
	case SAA_ARETE_NON:
		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(SAA_SOLID_DISPLAY(obj)->radar1), TRUE);
		break;
	case SAA_ARETE_MOLECULE:
		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(SAA_SOLID_DISPLAY(obj)->radar2), TRUE);
		break;
	case SAA_ARETE_LIGNE:
		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(SAA_SOLID_DISPLAY(obj)->radar3), TRUE);
		break;
	}
	g_signal_handlers_unblock_by_func(SAA_SOLID_DISPLAY(obj)->radar1, saa_solid_display_ar1, obj);
	g_signal_handlers_unblock_by_func(SAA_SOLID_DISPLAY(obj)->radar2, saa_solid_display_ar2, obj);
	g_signal_handlers_unblock_by_func(SAA_SOLID_DISPLAY(obj)->radar3, saa_solid_display_ar3, obj);

	g_signal_handlers_block_by_func(SAA_SOLID_DISPLAY(obj)->radai1, saa_solid_display_ai1, obj);
	g_signal_handlers_block_by_func(SAA_SOLID_DISPLAY(obj)->radai2, saa_solid_display_ai2, obj);
	g_signal_handlers_block_by_func(SAA_SOLID_DISPLAY(obj)->radai3, saa_solid_display_ai3, obj);
	switch(visuel->visuAiles) {
	case SAA_AILE_NON:
		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(SAA_SOLID_DISPLAY(obj)->radai1), TRUE);
		break;
	case SAA_AILE_TRIANGULATION:
		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(SAA_SOLID_DISPLAY(obj)->radai2), TRUE);
		break;
	case SAA_AILE_COULEUR:
		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(SAA_SOLID_DISPLAY(obj)->radai3), TRUE);
		break;
	}
	g_signal_handlers_unblock_by_func(SAA_SOLID_DISPLAY(obj)->radai1, saa_solid_display_ai1, obj);
	g_signal_handlers_unblock_by_func(SAA_SOLID_DISPLAY(obj)->radai2, saa_solid_display_ai2, obj);
	g_signal_handlers_unblock_by_func(SAA_SOLID_DISPLAY(obj)->radai3, saa_solid_display_ai3, obj);

	g_signal_handlers_block_by_func(SAA_SOLID_DISPLAY(obj)->chlight, saa_solid_display_light, obj);
	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(SAA_SOLID_DISPLAY(obj)->chlight), visuel->eclairage);
	g_signal_handlers_unblock_by_func(SAA_SOLID_DISPLAY(obj)->chlight, saa_solid_display_light, obj);

	g_signal_handlers_block_by_func(SAA_SOLID_DISPLAY(obj)->chtrans, saa_solid_display_trans, obj);
	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(SAA_SOLID_DISPLAY(obj)->chtrans), visuel->transparence);
	g_signal_handlers_unblock_by_func(SAA_SOLID_DISPLAY(obj)->chtrans, saa_solid_display_trans, obj);

	g_signal_handlers_block_by_func(SAA_SOLID_DISPLAY(obj)->chaxes, saa_solid_display_axes, obj);
	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(SAA_SOLID_DISPLAY(obj)->chaxes), visuel->axes);
	g_signal_handlers_unblock_by_func(SAA_SOLID_DISPLAY(obj)->chaxes, saa_solid_display_axes, obj);

	c.red = visuel->couleurFond[0]*65535;
	c.green = visuel->couleurFond[1]*65535;
	c.blue = visuel->couleurFond[2]*65535;
	g_signal_handlers_block_by_func(SAA_SOLID_DISPLAY(obj)->btbg, saa_solid_display_bgcolor, obj);
	gtk_color_button_set_color(GTK_COLOR_BUTTON(SAA_SOLID_DISPLAY(obj)->btbg), &c);
	g_signal_handlers_unblock_by_func(SAA_SOLID_DISPLAY(obj)->btbg, saa_solid_display_bgcolor, obj);

	c.red = visuel->couleurAretes[0]*65535;
	c.green = visuel->couleurAretes[1]*65535;
	c.blue = visuel->couleurAretes[2]*65535;
	g_signal_handlers_block_by_func(SAA_SOLID_DISPLAY(obj)->btar, saa_solid_display_arcolor, obj);
	gtk_color_button_set_color(GTK_COLOR_BUTTON(SAA_SOLID_DISPLAY(obj)->btar), &c);
	g_signal_handlers_unblock_by_func(SAA_SOLID_DISPLAY(obj)->btar, saa_solid_display_arcolor, obj);

	c.red = visuel->couleurSommets[0]*65535;
	c.green = visuel->couleurSommets[1]*65535;
	c.blue = visuel->couleurSommets[2]*65535;
	g_signal_handlers_block_by_func(SAA_SOLID_DISPLAY(obj)->bts, saa_solid_display_scolor, obj);
	gtk_color_button_set_color(GTK_COLOR_BUTTON(SAA_SOLID_DISPLAY(obj)->bts), &c);
	g_signal_handlers_unblock_by_func(SAA_SOLID_DISPLAY(obj)->bts, saa_solid_display_scolor, obj);

	ts = visuel->tailleSommets;
	g_signal_handlers_block_by_func(SAA_SOLID_DISPLAY(obj)->spins, saa_solid_display_ssize, obj);
	gtk_spin_button_set_value(GTK_SPIN_BUTTON(SAA_SOLID_DISPLAY(obj)->spins), ts);
	g_signal_handlers_unblock_by_func(SAA_SOLID_DISPLAY(obj)->spins, saa_solid_display_ssize, obj);

	tar = visuel->tailleAretes;
	g_signal_handlers_block_by_func(SAA_SOLID_DISPLAY(obj)->spinar, saa_solid_display_arsize, obj);
	gtk_spin_button_set_value(GTK_SPIN_BUTTON(SAA_SOLID_DISPLAY(obj)->spinar), tar);
	g_signal_handlers_unblock_by_func(SAA_SOLID_DISPLAY(obj)->spinar, saa_solid_display_arsize, obj);

	return GTK_WIDGET(obj);
}
Exemplo n.º 2
0
G_MODULE_EXPORT void
on_options_generate_go_clicked         (GtkButton       *button,
                                        gpointer         user_data)
{
#ifndef _WIN32
	GtkWidget *number = get_widget ("options_generate_number");
	int n = gtk_spin_button_get_value (GTK_SPIN_BUTTON (number));
	char nn[10];
	snprintf (nn, sizeof(nn), "%d", n);
	GtkWidget *view = get_widget ("options_generate_entry");
	GtkTextBuffer *buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
	GtkTextIter start, end;
	gtk_text_buffer_get_iter_at_offset (buffer, &start, 0);
	gtk_text_buffer_get_iter_at_offset (buffer, &end, -1);
	char *text = gtk_text_buffer_get_text (buffer, &start, &end, FALSE);

	int wfd[2], rfd[2];
	pid_t cpid;

	if (pipe(wfd) == -1 || pipe(rfd) == -1) {
		perror("pipe");
		exit(EXIT_FAILURE);
	}

	cpid = fork();
	if (cpid == -1) {
		perror("fork");
		exit(EXIT_FAILURE);
	}

	if (cpid == 0) {    /* Child reads from pipe */
		close (wfd[1]);          /* Close unused write end */
		close (rfd[0]);
		dup2 (0, wfd[0]);
		dup2 (1, rfd[1]);
		execlp ("dealer", "dealer", "-v", "-p", nn, NULL);
		perror ("execlp");
		_exit(EXIT_FAILURE);

	} else {
		close (wfd[0]);          /* Close unused read end */
		close (rfd[1]);
		if (write (wfd[1], text, strlen (text)) == -1) {
			perror ("write");
			return;
		}
		close (wfd[1]);          /* Reader will see EOF */
	}

	int i;
	do {
		char buf[100];
		i = read (rfd[0], buf, sizeof (buf));
		buf[i == sizeof (buf) ? sizeof (buf) - 1 : i] = '\0';
		puts (buf);
	} while (i > 0);
	close (rfd[0]);

	g_free (text);
#endif
}
Exemplo n.º 3
0
GdkWindow *wxSpinButton::GTKGetWindow(wxArrayGdkWindows& WXUNUSED(windows)) const
{
    return GTK_SPIN_BUTTON(m_widget)->panel;
}
/*
   ==============
   GetTexMods

   Reads the fields to get the current texdef (i.e. widgets -> MAP)
   in brush primitive mode, grab the fake shift scale rot and compute a new texture matrix
   ===============
 */
void SurfaceDlg::GetTexMods(){
	char buffer[1024];
	texdef_t *pt;

#ifdef DBG_SI
	Sys_Printf( "SurfaceDlg::GetTexMods\n" );
#endif

	if ( g_ptrSelectedFaces.GetSize() > 0 ) {
		//++timo just a test, we disable the undo when working on selected faces
		m_nUndoId = 0;
		face_t *selFace = reinterpret_cast<face_t*>( g_ptrSelectedFaces.GetAt( 0 ) );
		g_qeglobals.d_texturewin.texdef = selFace->texdef;
#ifdef DBG_SI
		Sys_Printf( "g_qeglobals.d_texturewin.texdef = selFace->texdef\n" );
#endif
	}
//  else
//  {
	pt = &g_qeglobals.d_texturewin.texdef;
#ifdef DBG_SI
	Sys_Printf( "pt = &g_qeglobals.d_texturewin.texdef\n" );
#endif
//  }

	const char* text = gtk_entry_get_text( GTK_ENTRY( GetDlgWidget( "texture" ) ) );

#ifdef DBG_SI
	Sys_Printf( "pt->SetName(%s)\n", text );
#endif

	// TTimo: detect and refuse invalid texture names (at least the ones with spaces)
	if ( text[0] <= ' ' || strchr( text, ' ' ) ) {
		Sys_FPrintf( SYS_WRN, "WARNING: spaces in shader names are not allowed, ignoring '%s'\n", text );
		pt->SetName( SHADER_NOT_FOUND );
		gtk_entry_set_text( GTK_ENTRY( GetDlgWidget( "texture" ) ), pt->GetName() );
	}
	else
	{
		strcpy( buffer, "textures/" );
		strcpy( buffer + 9, text );
		pt->SetName( buffer );
	}


	( g_qeglobals.m_bBrushPrimitMode ? m_shift[0] : pt->shift[0] ) =
		gtk_spin_button_get_value_as_float( GTK_SPIN_BUTTON( GetDlgWidget( "hshift" ) ) );
	( g_qeglobals.m_bBrushPrimitMode ? m_shift[1] : pt->shift[1] ) =
		gtk_spin_button_get_value_as_float( GTK_SPIN_BUTTON( GetDlgWidget( "vshift" ) ) );
	( g_qeglobals.m_bBrushPrimitMode ? m_scale[0] : pt->scale[0] ) =
		gtk_spin_button_get_value_as_float( GTK_SPIN_BUTTON( GetDlgWidget( "hscale" ) ) );
	( g_qeglobals.m_bBrushPrimitMode ? m_scale[1] : pt->scale[1] ) =
		gtk_spin_button_get_value_as_float( GTK_SPIN_BUTTON( GetDlgWidget( "vscale" ) ) );
	( g_qeglobals.m_bBrushPrimitMode ? m_rotate : pt->rotate ) =
		gtk_spin_button_get_value_as_float( GTK_SPIN_BUTTON( GetDlgWidget( "rotate" ) ) );

	// a local copy of the texture matrix, given for a qtexture_t with width=2 height=2
	brushprimit_texdef_t local_bp;
	brushprimit_texdef_t  *bpt;
	if ( g_qeglobals.m_bBrushPrimitMode ) {
		face_t *selFace = NULL;
		if ( g_ptrSelectedFaces.GetSize() > 0 ) {
			selFace = reinterpret_cast<face_t*>( g_ptrSelectedFaces.GetAt( 0 ) );
			bpt = &selFace->brushprimit_texdef;
		}
		else
		{
			bpt = &g_qeglobals.d_texturewin.brushprimit_texdef;
		}
		// compute texture matrix
		// the matrix returned must be understood as a qtexture_t with width=2 height=2
		FakeTexCoordsToTexMat( m_shift, m_rotate, m_scale, local_bp.coords );
		// copy the texture matrix in the global struct
		// fit the qtexture if we have a face selected, otherwise g_qeglobals.d_texturewin.brushprimit_texdef uses the basic qtexture_t with width=2 height=2

		ConvertTexMatWithQTexture( &local_bp, NULL, bpt, ( ( selFace ) ? selFace->d_texture : NULL ) );
	}
	// we are gonna do stuff, if we own the last do we undo it first
	if ( m_nUndoId != 0 ) {
		// check the do we're about to undo is the one we pushed earlier
		if ( m_nUndoId == Undo_GetUndoId() ) {
#ifdef DBG_SI
			Sys_Printf( "GetTexMods calling Undo_Undo (silent)\n" );
#endif
			g_bListenUpdate = false;
			Undo_Undo( true );
			g_bListenUpdate = true;
		}
	}
	Select_SetTexture( pt,&local_bp );
	m_nUndoId = Undo_GetUndoId();
}
Exemplo n.º 5
0
VikLayerParamData a_uibuilder_widget_get_value ( GtkWidget *widget, VikLayerParam *param )
{
  VikLayerParamData rv;
  switch ( param->widget_type )
  {
    case VIK_LAYER_WIDGET_COLOR:
      gtk_color_button_get_color ( GTK_COLOR_BUTTON(widget), &(rv.c) );
      break;
    case VIK_LAYER_WIDGET_CHECKBUTTON:
      rv.b = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
      break;
    case VIK_LAYER_WIDGET_COMBOBOX:
      if ( param->type == VIK_LAYER_PARAM_UINT )
      {
        rv.i = gtk_combo_box_get_active ( GTK_COMBO_BOX(widget) );
        if ( rv.i == -1 ) rv.i = 0;
        rv.u = rv.i;
        if ( param->extra_widget_data )
          rv.u = ((guint *)param->extra_widget_data)[rv.u];
      }
      if ( param->type == VIK_LAYER_PARAM_STRING)
      {
        if ( param->extra_widget_data )
        {
          /* Combobox displays labels and we want values from extra */
          int pos = gtk_combo_box_get_active ( GTK_COMBO_BOX(widget) );
          rv.s = ((const char **)param->extra_widget_data)[pos];
        }
        else
        {
          /* Return raw value */
#if GTK_CHECK_VERSION (2, 24, 0)
          rv.s = gtk_entry_get_text (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (widget))));
#else
          rv.s = gtk_combo_box_get_active_text ( GTK_COMBO_BOX(widget) );
#endif
        }
	g_debug("%s: %s", __FUNCTION__, rv.s);
      }
      break;
    case VIK_LAYER_WIDGET_RADIOGROUP:
    case VIK_LAYER_WIDGET_RADIOGROUP_STATIC:
      rv.u = vik_radio_group_get_selected(VIK_RADIO_GROUP(widget));
      if ( param->extra_widget_data )
        rv.u = GPOINTER_TO_UINT ( g_list_nth_data(param->extra_widget_data, rv.u) );
      break;
    case VIK_LAYER_WIDGET_SPINBUTTON:
      if ( param->type == VIK_LAYER_PARAM_UINT )
        rv.u = gtk_spin_button_get_value_as_int ( GTK_SPIN_BUTTON(widget) );
      else if ( param->type == VIK_LAYER_PARAM_INT )
        rv.i = gtk_spin_button_get_value_as_int ( GTK_SPIN_BUTTON(widget) );
      else
        rv.d = gtk_spin_button_get_value ( GTK_SPIN_BUTTON(widget) );
      break;
    case VIK_LAYER_WIDGET_ENTRY:
    case VIK_LAYER_WIDGET_PASSWORD:
      rv.s = gtk_entry_get_text ( GTK_ENTRY(widget) );
      break;
    case VIK_LAYER_WIDGET_FILEENTRY:
    case VIK_LAYER_WIDGET_FOLDERENTRY:
      rv.s = vik_file_entry_get_filename ( VIK_FILE_ENTRY(widget) );
      break;
    case VIK_LAYER_WIDGET_FILELIST:
      rv.sl = vik_file_list_get_files ( VIK_FILE_LIST(widget) );
      break;
    case VIK_LAYER_WIDGET_HSCALE:
      if ( param->type == VIK_LAYER_PARAM_UINT )
        rv.u = (guint32) gtk_range_get_value ( GTK_RANGE(widget) );
      else if ( param->type == VIK_LAYER_PARAM_INT )
        rv.i = (gint32) gtk_range_get_value ( GTK_RANGE(widget) );
      else
        rv.d = gtk_range_get_value ( GTK_RANGE(widget) );
      break;
    default: break;
  }

  // Perform conversion if necessary
  if ( param->convert_to_internal )
    rv = param->convert_to_internal ( rv );

  return rv;
}
Exemplo n.º 6
0
static void spamassassin_save_func(PrefsPage *_page)
{
	struct SpamAssassinPage *page = (struct SpamAssassinPage *) _page;
	SpamAssassinConfig *config;

	debug_print("Saving SpamAssassin Page\n");

	config = spamassassin_get_config();

	/* enable */
	config->enable = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->enable_sa_checkbtn));
	config->transport = page->trans;

	/* username */
	g_free(config->username);
	config->username = gtk_editable_get_chars(GTK_EDITABLE(page->username), 0, -1);
	spamassassin_check_username();

	/* hostname */
	g_free(config->hostname);
	config->hostname = gtk_editable_get_chars(GTK_EDITABLE(page->hostname), 0, -1);

	/* port */
	config->port = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(page->port));

	/* hostname */
	g_free(config->socket);
	config->socket = gtk_editable_get_chars(GTK_EDITABLE(page->socket), 0, -1);

	/* process_emails */
	config->process_emails = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->process_emails));

	/* receive_spam */
	config->receive_spam = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->receive_spam));

	/* save_folder */
	g_free(config->save_folder);
	config->save_folder = gtk_editable_get_chars(GTK_EDITABLE(page->save_folder), 0, -1);

	/* max_size */
	config->max_size = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(page->max_size));

	/* timeout */
	config->timeout = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(page->timeout));

	/* mark_as_read */
	config->mark_as_read = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->mark_as_read));

	/* whitelist_ab */
	config->whitelist_ab = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->whitelist_ab));
	g_free(config->whitelist_ab_folder);
	config->whitelist_ab_folder = gtk_editable_get_chars(
				GTK_EDITABLE(gtk_bin_get_child(GTK_BIN((page->whitelist_ab_folder_combo)))), 0, -1);
	/* store UNtranslated "Any" */
	if (g_utf8_collate(config->whitelist_ab_folder, _("Any")) == 0) {
		g_free(config->whitelist_ab_folder);
		config->whitelist_ab_folder = g_strdup("Any");
	}

	if (config->process_emails) {
		spamassassin_register_hook();
	} else {
		spamassassin_unregister_hook();
	}

	if (!config->enable) {
		procmsg_unregister_spam_learner(spamassassin_learn);
		procmsg_spam_set_folder(NULL, NULL);
	} else {
		if (config->transport == SPAMASSASSIN_TRANSPORT_TCP)
			debug_print("enabling learner with a remote spamassassin server requires spamc/spamd 3.1.x\n");
		procmsg_register_spam_learner(spamassassin_learn);
		procmsg_spam_set_folder(config->save_folder, spamassassin_get_spam_folder);
	}

	spamassassin_save_config();
}
void SurfaceDlg::BuildDialog() {
	GtkWidget *dlg, *vbox, *hbox2, *frame, *table, *label;
	GtkWidget *button, *entry, *spin;

	dlg = m_pWidget;

	load_window_pos( dlg, g_PrefsDlg.mWindowInfo.posSurfaceWnd );

	gtk_window_set_title( GTK_WINDOW( dlg ), _( "Surface inspector" ) );
	//g_signal_connect (G_OBJECT (dlg), "delete_event", G_CALLBACK (OnCancel), NULL);
	// we catch 'Enter' and interpret is as OnDone
	gtk_signal_connect( GTK_OBJECT( dlg ), "key_press_event", GTK_SIGNAL_FUNC( OnDialogKey ), NULL );
	gtk_window_set_transient_for( GTK_WINDOW( dlg ), GTK_WINDOW( g_pParentWnd->m_pWidget ) );

	// replaced by only the vbox:
	vbox = gtk_vbox_new( FALSE, 5 );
	gtk_widget_show( vbox );
	gtk_container_add( GTK_CONTAINER( dlg ), vbox );
	gtk_container_set_border_width( GTK_CONTAINER( vbox ), 5 );

	hbox2 = gtk_hbox_new( FALSE, 5 );
	gtk_widget_show( hbox2 );
	gtk_box_pack_start( GTK_BOX( vbox ), hbox2, FALSE, TRUE, 0 );

	label = gtk_label_new( _( "Texture" ) );
	gtk_widget_show( label );
	gtk_box_pack_start( GTK_BOX( hbox2 ), label, FALSE, TRUE, 0 );

	entry = gtk_entry_new();
	gtk_signal_connect( GTK_OBJECT( entry ), "key_press_event", GTK_SIGNAL_FUNC( OnTextureKey ), NULL );
	gtk_widget_show( entry );
	gtk_box_pack_start( GTK_BOX( hbox2 ), entry, TRUE, TRUE, 0 );
	g_object_set_data( G_OBJECT( m_pWidget ), "texture", entry );

//  table = gtk_table_new (5, 4, FALSE);
	table = gtk_table_new( 6, 4, FALSE );
	gtk_widget_show( table );
	gtk_box_pack_start( GTK_BOX( vbox ), table, FALSE, TRUE, 0 );
	gtk_table_set_row_spacings( GTK_TABLE( table ), 5 );
	gtk_table_set_col_spacings( GTK_TABLE( table ), 5 );

	label = gtk_label_new( _( "Horizontal shift" ) );
	gtk_widget_show( label );
	gtk_misc_set_alignment( GTK_MISC( label ), 0, 0 );
	gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 0, 1,
					  (GtkAttachOptions) ( GTK_FILL ),
					  (GtkAttachOptions) ( 0 ), 0, 0 );

	spin = gtk_spin_button_new( GTK_ADJUSTMENT( gtk_adjustment_new( 0, -8192, 8192, 2, 8, 0 ) ), 0, 0 );
	g_object_set_data( G_OBJECT( dlg ), "hshift", spin );
	gtk_signal_connect( GTK_OBJECT( gtk_spin_button_get_adjustment( GTK_SPIN_BUTTON( spin ) ) ), "value_changed",
						GTK_SIGNAL_FUNC( OnUpdate ), NULL );
	gtk_widget_show( spin );
	gtk_table_attach( GTK_TABLE( table ), spin, 1, 2, 0, 1,
					  (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
					  (GtkAttachOptions) ( 0 ), 0, 0 );
	gtk_widget_set_usize( spin, 60, -2 );

	label = gtk_label_new( _( "Step" ) );
	gtk_widget_show( label );
	gtk_misc_set_alignment( GTK_MISC( label ), 0, 0 );
	gtk_table_attach( GTK_TABLE( table ), label, 2, 3, 0, 1,
					  (GtkAttachOptions) ( GTK_FILL ),
					  (GtkAttachOptions) ( 0 ), 0, 0 );

	entry = gtk_entry_new();
	g_object_set_data( G_OBJECT( dlg ), "hshift_inc", entry );
	gtk_signal_connect( GTK_OBJECT( entry ), "changed",
						GTK_SIGNAL_FUNC( OnIncrementChanged ), NULL );
	gtk_widget_show( entry );
	gtk_table_attach( GTK_TABLE( table ), entry, 3, 4, 0, 1,
					  (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
					  (GtkAttachOptions) ( 0 ), 0, 0 );
	gtk_widget_set_usize( entry, 50, -2 );

	label = gtk_label_new( _( "Vertical shift" ) );
	gtk_widget_show( label );
	gtk_misc_set_alignment( GTK_MISC( label ), 0, 0 );
	gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 1, 2,
					  (GtkAttachOptions) ( GTK_FILL ),
					  (GtkAttachOptions) ( 0 ), 0, 0 );

	spin = gtk_spin_button_new( GTK_ADJUSTMENT( gtk_adjustment_new( 0, -8192, 8192, 2, 8, 0 ) ), 0, 0 );
	g_object_set_data( G_OBJECT( dlg ), "vshift", spin );
	gtk_signal_connect( GTK_OBJECT( gtk_spin_button_get_adjustment( GTK_SPIN_BUTTON( spin ) ) ), "value_changed",
						GTK_SIGNAL_FUNC( OnUpdate ), NULL );
	gtk_widget_show( spin );
	gtk_table_attach( GTK_TABLE( table ), spin, 1, 2, 1, 2,
					  (GtkAttachOptions) ( GTK_FILL ),
					  (GtkAttachOptions) ( 0 ), 0, 0 );
	gtk_widget_set_usize( spin, 60, -2 );

	label = gtk_label_new( _( "Step" ) );
	gtk_widget_show( label );
	gtk_misc_set_alignment( GTK_MISC( label ), 0, 0 );
	gtk_table_attach( GTK_TABLE( table ), label, 2, 3, 1, 2,
					  (GtkAttachOptions) ( GTK_FILL ),
					  (GtkAttachOptions) ( 0 ), 0, 0 );

	entry = gtk_entry_new();
	g_object_set_data( G_OBJECT( dlg ), "vshift_inc", entry );
	gtk_signal_connect( GTK_OBJECT( entry ), "changed",
						GTK_SIGNAL_FUNC( OnIncrementChanged ), NULL );
	gtk_widget_show( entry );
	gtk_table_attach( GTK_TABLE( table ), entry, 3, 4, 1, 2,
					  (GtkAttachOptions) ( GTK_FILL ),
					  (GtkAttachOptions) ( 0 ), 0, 0 );
	gtk_widget_set_usize( entry, 50, -2 );

	label = gtk_label_new( _( "Horizontal stretch" ) );
	gtk_widget_show( label );
	gtk_misc_set_alignment( GTK_MISC( label ), 0, 0 );
	gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 2, 3,
					  (GtkAttachOptions) ( GTK_FILL ),
					  (GtkAttachOptions) ( 0 ), 0, 0 );

	spin = gtk_spin_button_new( GTK_ADJUSTMENT( gtk_adjustment_new( 0, -1000, 1000, 1, 10, 0 ) ), 0, 0 );
	g_object_set_data( G_OBJECT( dlg ), "hscale", spin );
	gtk_signal_connect( GTK_OBJECT( gtk_spin_button_get_adjustment( GTK_SPIN_BUTTON( spin ) ) ), "value_changed",
						GTK_SIGNAL_FUNC( OnUpdate ), NULL );
	gtk_widget_show( spin );
	gtk_table_attach( GTK_TABLE( table ), spin, 1, 2, 2, 3,
					  (GtkAttachOptions) ( GTK_FILL ),
					  (GtkAttachOptions) ( 0 ), 0, 0 );
	gtk_widget_set_usize( spin, 60, -2 );

	label = gtk_label_new( _( "Step" ) );
	gtk_widget_show( label );
	gtk_misc_set_alignment( GTK_MISC( label ), 0, 0 );
	gtk_table_attach( GTK_TABLE( table ), label, 2, 3, 2, 3,
					  (GtkAttachOptions) ( GTK_FILL ),
					  (GtkAttachOptions) ( 0 ), 2, 3 );

	entry = gtk_entry_new();
	g_object_set_data( G_OBJECT( dlg ), "hscale_inc", entry );
	gtk_signal_connect( GTK_OBJECT( entry ), "changed",
						GTK_SIGNAL_FUNC( OnIncrementChanged ), NULL );
	gtk_widget_show( entry );
	gtk_table_attach( GTK_TABLE( table ), entry, 3, 4, 2, 3,
					  (GtkAttachOptions) ( GTK_FILL ),
					  (GtkAttachOptions) ( 0 ), 2, 3 );
	gtk_widget_set_usize( entry, 50, -2 );

	label = gtk_label_new( _( "Vertical stretch" ) );
	gtk_widget_show( label );
	gtk_misc_set_alignment( GTK_MISC( label ), 0, 0 );
	gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 3, 4,
					  (GtkAttachOptions) ( GTK_FILL ),
					  (GtkAttachOptions) ( 0 ), 0, 0 );

	spin = gtk_spin_button_new( GTK_ADJUSTMENT( gtk_adjustment_new( 0, -1000, 1000, 1, 10, 0 ) ), 0, 0 );
	g_object_set_data( G_OBJECT( dlg ), "vscale", spin );
	gtk_signal_connect( GTK_OBJECT( gtk_spin_button_get_adjustment( GTK_SPIN_BUTTON( spin ) ) ), "value_changed",
						GTK_SIGNAL_FUNC( OnUpdate ), NULL );
	gtk_widget_show( spin );
	gtk_table_attach( GTK_TABLE( table ), spin, 1, 2, 3, 4,
					  (GtkAttachOptions) ( GTK_FILL ),
					  (GtkAttachOptions) ( 0 ), 0, 0 );
	gtk_widget_set_usize( spin, 60, -2 );

	label = gtk_label_new( _( "Step" ) );
	gtk_widget_show( label );
	gtk_misc_set_alignment( GTK_MISC( label ), 0, 0 );
	gtk_table_attach( GTK_TABLE( table ), label, 2, 3, 3, 4,
					  (GtkAttachOptions) ( GTK_FILL ),
					  (GtkAttachOptions) ( 0 ), 0, 0 );

	entry = gtk_entry_new();
	g_object_set_data( G_OBJECT( dlg ), "vscale_inc", entry );
	gtk_signal_connect( GTK_OBJECT( entry ), "changed",
						GTK_SIGNAL_FUNC( OnIncrementChanged ), NULL );
	gtk_widget_show( entry );
	gtk_table_attach( GTK_TABLE( table ), entry, 3, 4, 3, 4,
					  (GtkAttachOptions) ( GTK_FILL ),
					  (GtkAttachOptions) ( 0 ), 0, 0 );
	gtk_widget_set_usize( entry, 50, -2 );

	label = gtk_label_new( _( "Rotate" ) );
	gtk_widget_show( label );
	gtk_misc_set_alignment( GTK_MISC( label ), 0, 0 );
	gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 4, 5,
					  (GtkAttachOptions) ( GTK_FILL ),
					  (GtkAttachOptions) ( 0 ), 0, 0 );

	spin = gtk_spin_button_new( GTK_ADJUSTMENT( gtk_adjustment_new( 0, -360, 360, 1, 10, 0 ) ), 1, 0 );
	g_object_set_data( G_OBJECT( dlg ), "rotate", spin );
	gtk_signal_connect( GTK_OBJECT( gtk_spin_button_get_adjustment( GTK_SPIN_BUTTON( spin ) ) ), "value_changed",
						GTK_SIGNAL_FUNC( OnUpdate ), NULL );
	gtk_widget_show( spin );
	gtk_table_attach( GTK_TABLE( table ), spin, 1, 2, 4, 5,
					  (GtkAttachOptions) ( GTK_FILL ),
					  (GtkAttachOptions) ( 0 ), 0, 0 );
	gtk_widget_set_usize( spin, 60, -2 );
	gtk_spin_button_set_wrap( GTK_SPIN_BUTTON( spin ), TRUE );

	label = gtk_label_new( _( "Step" ) );
	gtk_widget_show( label );
	gtk_misc_set_alignment( GTK_MISC( label ), 0, 0 );
	gtk_table_attach( GTK_TABLE( table ), label, 2, 3, 4, 5,
					  (GtkAttachOptions) ( GTK_FILL ),
					  (GtkAttachOptions) ( 0 ), 0, 0 );

	entry = gtk_entry_new();
	g_object_set_data( G_OBJECT( dlg ), "rotate_inc", entry );
	gtk_signal_connect( GTK_OBJECT( entry ), "changed",
						GTK_SIGNAL_FUNC( OnIncrementChanged ), NULL );
	gtk_widget_show( entry );
	gtk_table_attach( GTK_TABLE( table ), entry, 3, 4, 4, 5,
					  (GtkAttachOptions) ( GTK_FILL ),
					  (GtkAttachOptions) ( 0 ), 0, 0 );
	gtk_widget_set_usize( entry, 50, -2 );

	// match grid button
	button = gtk_button_new_with_label( _( "Match Grid" ) );
	gtk_widget_show( button );
	gtk_table_attach( GTK_TABLE( table ), button, 2, 4, 5, 6,
					  (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
					  (GtkAttachOptions) ( 0 ), 0, 0 );
	gtk_signal_connect( GTK_OBJECT( button ), "clicked",
						GTK_SIGNAL_FUNC( OnBtnMatchGrid ), NULL );

	frame = gtk_frame_new( _( "Texturing" ) );
	gtk_widget_show( frame );
	gtk_box_pack_start( GTK_BOX( vbox ), frame, FALSE, TRUE, 0 );

	table = gtk_table_new( 4, 4, FALSE );
	gtk_widget_show( table );
	gtk_container_add( GTK_CONTAINER( frame ), table );
	gtk_table_set_row_spacings( GTK_TABLE( table ), 5 );
	gtk_table_set_col_spacings( GTK_TABLE( table ), 5 );
	gtk_container_set_border_width( GTK_CONTAINER( table ), 5 );

	label = gtk_label_new( "Brush" );
	gtk_widget_show( label );
	gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 0, 1,
					  (GtkAttachOptions) ( GTK_FILL ),
					  (GtkAttachOptions) ( 0 ), 0, 0 );

	label = gtk_label_new( "Patch" );
	gtk_widget_show( label );
	gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 2, 3,
					  (GtkAttachOptions) ( GTK_FILL ),
					  (GtkAttachOptions) ( 0 ), 0, 0 );

	label = gtk_label_new( "Width" );
	gtk_widget_show( label );
	gtk_table_attach( GTK_TABLE( table ), label, 2, 3, 0, 1,
					  (GtkAttachOptions) ( GTK_FILL ),
					  (GtkAttachOptions) ( 0 ), 0, 0 );

	label = gtk_label_new( _( "Height" ) );
	gtk_widget_show( label );
	gtk_table_attach( GTK_TABLE( table ), label, 3, 4, 0, 1,
					  (GtkAttachOptions) ( GTK_FILL ),
					  (GtkAttachOptions) ( 0 ), 0, 0 );

	button = gtk_button_new_with_label( _( "Axial" ) );
	gtk_widget_show( button );
	gtk_table_attach( GTK_TABLE( table ), button, 0, 1, 1, 2,
					  (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
					  (GtkAttachOptions) ( 0 ), 0, 0 );
	gtk_signal_connect( GTK_OBJECT( button ), "clicked",
						GTK_SIGNAL_FUNC( OnBtnAxial ), NULL );
	gtk_widget_set_usize( button, 60, -2 );

	button = gtk_button_new_with_label( _( "Fit" ) );
	gtk_widget_show( button );
	gtk_table_attach( GTK_TABLE( table ), button, 1, 2, 1, 2,
					  (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
					  (GtkAttachOptions) ( 0 ), 0, 0 );
	gtk_signal_connect( GTK_OBJECT( button ), "clicked",
						GTK_SIGNAL_FUNC( OnBtnFaceFit ), NULL );
	gtk_widget_set_usize( button, 60, -2 );

	button = gtk_button_new_with_label( _( "CAP" ) );
	gtk_widget_show( button );
	gtk_table_attach( GTK_TABLE( table ), button, 0, 1, 3, 4,
					  (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
					  (GtkAttachOptions) ( 0 ), 0, 0 );
	gtk_signal_connect( GTK_OBJECT( button ), "clicked",
						GTK_SIGNAL_FUNC( OnBtnPatchdetails ), NULL );
	gtk_widget_set_usize( button, 60, -2 );

	button = gtk_button_new_with_label( _( "Set..." ) );
	gtk_widget_show( button );
	gtk_table_attach( GTK_TABLE( table ), button, 1, 2, 3, 4,
					  (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
					  (GtkAttachOptions) ( 0 ), 0, 0 );
	gtk_signal_connect( GTK_OBJECT( button ), "clicked",
						GTK_SIGNAL_FUNC( OnBtnPatchreset ), NULL );
	gtk_widget_set_usize( button, 60, -2 );

	button = gtk_button_new_with_label( _( "Natural" ) );
	gtk_widget_show( button );
	gtk_table_attach( GTK_TABLE( table ), button, 2, 3, 3, 4,
					  (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
					  (GtkAttachOptions) ( 0 ), 0, 0 );
	gtk_signal_connect( GTK_OBJECT( button ), "clicked",
						GTK_SIGNAL_FUNC( OnBtnPatchnatural ), NULL );
	gtk_widget_set_usize( button, 60, -2 );

	button = gtk_button_new_with_label( _( "Fit" ) );
	gtk_widget_show( button );
	gtk_table_attach( GTK_TABLE( table ), button, 3, 4, 3, 4,
					  (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
					  (GtkAttachOptions) ( 0 ), 0, 0 );
	gtk_signal_connect( GTK_OBJECT( button ), "clicked",
						GTK_SIGNAL_FUNC( OnBtnPatchFit ), NULL );
	gtk_widget_set_usize( button, 60, -2 );

	spin = gtk_spin_button_new( GTK_ADJUSTMENT( gtk_adjustment_new( 1, 1, 32, 1, 10, 0 ) ), 1, 0 );
	gtk_widget_show( spin );
	gtk_table_attach( GTK_TABLE( table ), spin, 2, 3, 1, 2,
					  (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
					  (GtkAttachOptions) ( 0 ), 0, 0 );
	gtk_widget_set_usize( spin, 60, -2 );
	AddDialogData( spin, &m_nWidth, DLG_SPIN_INT );

	spin = gtk_spin_button_new( GTK_ADJUSTMENT( gtk_adjustment_new( 1, 1, 32, 1, 10, 0 ) ), 1, 0 );
	gtk_widget_show( spin );
	gtk_table_attach( GTK_TABLE( table ), spin, 3, 4, 1, 2,
					  (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
					  (GtkAttachOptions) ( 0 ), 0, 0 );
	gtk_widget_set_usize( spin, 60, -2 );
	AddDialogData( spin, &m_nHeight, DLG_SPIN_INT );

	hbox2 = gtk_hbox_new( FALSE, 5 );
	gtk_widget_show( hbox2 );
	gtk_box_pack_start( GTK_BOX( vbox ), hbox2, FALSE, TRUE, 0 );

	button = gtk_button_new_with_label( _( "Done" ) );
	gtk_widget_show( button );
	gtk_box_pack_start( GTK_BOX( hbox2 ), button, FALSE, FALSE, 0 );
	gtk_signal_connect( GTK_OBJECT( button ), "clicked",
						GTK_SIGNAL_FUNC( OnDone ), NULL );
	gtk_widget_set_usize( button, 60, -2 );

	button = gtk_button_new_with_label( _( "Apply" ) );
	gtk_widget_show( button );
	gtk_box_pack_start( GTK_BOX( hbox2 ), button, FALSE, FALSE, 0 );
	gtk_signal_connect( GTK_OBJECT( button ), "clicked",
						GTK_SIGNAL_FUNC( OnApply ), NULL );
	gtk_widget_set_usize( button, 60, -2 );

	button = gtk_button_new_with_label( _( "Cancel" ) );
	gtk_widget_show( button );
	gtk_box_pack_start( GTK_BOX( hbox2 ), button, FALSE, FALSE, 0 );
	gtk_signal_connect( GTK_OBJECT( button ), "clicked",
						GTK_SIGNAL_FUNC( OnCancel ), NULL );
	gtk_widget_set_usize( button, 60, -2 );

	// that's a bit of trashy stuff from Textool-v2 branch
#ifdef _DEBUG
	// FIXME: testing only, scaling in BP mode
	button = gtk_button_new_with_label( _( "Test" ) );
	gtk_widget_show( button );
	gtk_box_pack_start( GTK_BOX( hbox2 ), button, FALSE, FALSE, 0 );
	gtk_signal_connect( GTK_OBJECT( button ), "clicked",
						GTK_SIGNAL_FUNC( OnTest ), NULL );
	gtk_widget_set_usize( button, 60, -2 );
#endif

	// Initialize
	SetTexMods();
}
Exemplo n.º 8
0
int main(int argc, char *argv[]) 
{
	GtkWidget *window;
	GtkWidget *canvas;
	GtkWidget *font_button;
	GtkWidget *g_button;
	GtkWidget *d_button;
	GtkWidget *str;
	GtkWidget *vbox;
	GtkWidget *hbox;
	GtkWidget *label1, *label2;
	GtkWidget *spin;
	PangoFontDescription *desc;

        if (argc == 2) {
            if (get_conf (argv[1]))
                printf ("Error reading configuration. Use defaults\n");
        }

	gtk_init(&argc, &argv);

	window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
	gtk_window_set_title (GTK_WINDOW(window), "Font converter");

	hbox = gtk_hbox_new (FALSE, 10);
	label1 = gtk_label_new ("Text: ");
	font_button = gtk_font_button_new_with_font (get_fontname());
	d_button = gtk_button_new_with_label ("Draw");
	g_button = gtk_button_new_with_label ("G Code");
	str = gtk_entry_new ();
	gtk_entry_set_max_length (GTK_ENTRY (str), 15);
	gtk_entry_set_text (GTK_ENTRY (str), get_string());
	label2 = gtk_label_new ("Width (inch): ");
	spin = gtk_spin_button_new_with_range (3, 120, 1);
	gtk_spin_button_set_digits (GTK_SPIN_BUTTON (spin), 2);
	gtk_spin_button_set_value (GTK_SPIN_BUTTON (spin), (double)10);

	gtk_box_pack_start (GTK_BOX (hbox), label1, FALSE, FALSE, 0);
	gtk_box_pack_start (GTK_BOX (hbox), str, FALSE, FALSE, 0);
	gtk_box_pack_start (GTK_BOX (hbox), font_button, TRUE, TRUE, 0);
	gtk_box_pack_start (GTK_BOX (hbox), d_button, TRUE, TRUE, 0);
	gtk_box_pack_start (GTK_BOX (hbox), g_button, TRUE, TRUE, 0);
	gtk_box_pack_start (GTK_BOX (hbox), label2, FALSE, FALSE, 0);
	gtk_box_pack_start (GTK_BOX (hbox), spin, FALSE, FALSE, 0);

	canvas = gtk_drawing_area_new();
	gtk_widget_set_size_request (canvas, 1200, 600);

	vbox = gtk_vbox_new (FALSE, 5);
	gtk_box_pack_start (GTK_BOX (vbox), canvas, TRUE, TRUE, 0);
	gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);

	g_object_set_data (G_OBJECT (g_button), "spin", spin);

	gtk_container_add (GTK_CONTAINER (window), vbox);

	g_signal_connect(window, "destroy",
		G_CALLBACK(gtk_main_quit), NULL);  

	g_signal_connect(G_OBJECT (canvas), "expose_event",
		G_CALLBACK(expose_event), str);  

	g_signal_connect(G_OBJECT (font_button), "font_set",
		G_CALLBACK(font_button_clicked), NULL);  

	g_signal_connect(G_OBJECT (g_button), "clicked",
		G_CALLBACK(g_button_clicked), str);  

	g_signal_connect(G_OBJECT (d_button), "clicked",
		G_CALLBACK(d_button_clicked), canvas);  

	gtk_widget_show_all(window);
	map = pango_ft2_font_map_new ();
	ctx = pango_font_map_create_context (map);
	desc = pango_font_description_from_string (get_fontname());
	set_font (desc);

	gtk_main();

	g_object_unref (map);
	g_object_unref (ctx);
	return 0;
}
Exemplo n.º 9
0
GtkWidget *
entry_create_widget (GtkWidget * dlg)
{
  GtkWidget *c, *l = NULL, *w = NULL;

#if !GTK_CHECK_VERSION(3,0,0)
  w = gtk_hbox_new (FALSE, 5);
#else
  w = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 5);
#endif

  if (options.entry_data.entry_label)
    {
      l = gtk_label_new (NULL);
      if (options.data.no_markup)
        gtk_label_set_text_with_mnemonic (GTK_LABEL (l), options.entry_data.entry_label);
      else
        gtk_label_set_markup_with_mnemonic (GTK_LABEL (l), options.entry_data.entry_label);
      gtk_widget_set_name (l, "yad-entry-label");
      gtk_box_pack_start (GTK_BOX (w), l, FALSE, FALSE, 1);
    }

  if (options.entry_data.numeric)
    {
      gdouble min, max, step, val;
      guint prec;

      min = 0.0;
      max = 65535.0;
      step = 1.0;
      prec = 0;
      val = 0.0;

      if (options.extra_data && options.extra_data[0])
        {
          min = g_ascii_strtod (options.extra_data[0], NULL);
          if (options.extra_data[1])
            max = g_ascii_strtod (options.extra_data[1], NULL);
          if (options.extra_data[2])
            step = g_ascii_strtod (options.extra_data[2], NULL);
          if (options.extra_data[3])
            {
              prec = (guint) g_ascii_strtoull (options.extra_data[3], NULL, 0);
              if (prec > 20)
                prec = 20;
            }
        }

      c = entry = gtk_spin_button_new_with_range (min, max, step);
      gtk_entry_set_alignment (GTK_ENTRY (c), 1.0);
      gtk_spin_button_set_digits (GTK_SPIN_BUTTON (c), prec);
      gtk_widget_set_name (entry, "yad-entry-spin");

      if (options.entry_data.entry_text)
        {
          val = g_ascii_strtod (options.entry_data.entry_text, NULL);

          if (min >= max)
            {
              g_printerr (_("Maximum value must be greater than minimum value.\n"));
              min = 0.0;
              max = 65535.0;
            }

          if (val < min)
            {
              g_printerr (_("Initial value less than minimal.\n"));
              val = min;
            }
          else if (val > max)
            {
              g_printerr (_("Initial value greater than maximum.\n"));
              val = max;
            }
        }

      gtk_spin_button_set_value (GTK_SPIN_BUTTON (c), val);
    }
  else if (!options.entry_data.completion && options.extra_data && *options.extra_data)
    {
      gint active, i;

      if (options.common_data.editable || settings.combo_always_editable)
        {
#if GTK_CHECK_VERSION(2,24,0)
          c = gtk_combo_box_text_new_with_entry ();
#else
          c = gtk_combo_box_entry_new_text ();
#endif
          gtk_widget_set_name (c, "yad-entry-edit-combo");
          entry = gtk_bin_get_child (GTK_BIN (c));
          if (options.entry_data.licon)
            {
              GdkPixbuf *pb = get_pixbuf (options.entry_data.licon, YAD_SMALL_ICON);

              if (pb)
                gtk_entry_set_icon_from_pixbuf (GTK_ENTRY (entry), GTK_ENTRY_ICON_PRIMARY, pb);
            }
          if (options.entry_data.ricon)
            {
              GdkPixbuf *pb = get_pixbuf (options.entry_data.ricon, YAD_SMALL_ICON);

              if (pb)
                gtk_entry_set_icon_from_pixbuf (GTK_ENTRY (entry), GTK_ENTRY_ICON_SECONDARY, pb);
            }
        }
      else
        {
#if GTK_CHECK_VERSION(2,24,0)
          c = entry = gtk_combo_box_text_new ();
#else
          c = entry = gtk_combo_box_new_text ();
#endif
          gtk_widget_set_name (c, "yad-entry-combo");
          is_combo = TRUE;
        }

      i = 0;
      active = -1;
      while (options.extra_data[i] != NULL)
        {
          if (options.entry_data.entry_text &&
              g_ascii_strcasecmp (options.extra_data[i], options.entry_data.entry_text) == 0)
            active = i;
#if GTK_CHECK_VERSION(2,24,0)
          gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (c), options.extra_data[i]);
#else
          gtk_combo_box_append_text (GTK_COMBO_BOX (c), options.extra_data[i]);
#endif
          i++;
        }

      if (options.entry_data.entry_text && active == -1)
        {
#if GTK_CHECK_VERSION(2,24,0)
          gtk_combo_box_text_prepend_text (GTK_COMBO_BOX_TEXT (c), options.entry_data.entry_text);
#else
          gtk_combo_box_prepend_text (GTK_COMBO_BOX (c), options.entry_data.entry_text);
#endif
        }

      /* set first iter active */
      if (!options.common_data.editable)
        gtk_combo_box_set_active (GTK_COMBO_BOX (c), (active != -1 ? active : 0));
    }
  else
    {
      c = entry = gtk_entry_new ();
      gtk_widget_set_name (c, "yad-entry-widget");

      gtk_entry_set_activates_default (GTK_ENTRY (entry), TRUE);

      if (options.entry_data.entry_text)
        gtk_entry_set_text (GTK_ENTRY (entry), options.entry_data.entry_text);

      if (options.entry_data.hide_text)
        g_object_set (G_OBJECT (entry), "visibility", FALSE, NULL);

      if (options.entry_data.completion)
        {
          GtkEntryCompletion *completion;
          GtkTreeModel *completion_model;

          completion = gtk_entry_completion_new ();
          gtk_entry_set_completion (GTK_ENTRY (entry), completion);

          completion_model = create_completion_model ();
          gtk_entry_completion_set_model (completion, completion_model);
          g_object_unref (completion_model);

          gtk_entry_completion_set_text_column (completion, 0);

          if (options.common_data.complete != YAD_COMPLETE_SIMPLE)
            gtk_entry_completion_set_match_func (completion, check_complete, NULL, NULL);

          g_object_unref (completion);
        }

      if (options.entry_data.licon)
        {
          GdkPixbuf *pb = get_pixbuf (options.entry_data.licon, YAD_SMALL_ICON);

          if (pb)
            gtk_entry_set_icon_from_pixbuf (GTK_ENTRY (entry), GTK_ENTRY_ICON_PRIMARY, pb);
        }
      if (options.entry_data.ricon)
        {
          GdkPixbuf *pb = get_pixbuf (options.entry_data.ricon, YAD_SMALL_ICON);

          if (pb)
            gtk_entry_set_icon_from_pixbuf (GTK_ENTRY (entry), GTK_ENTRY_ICON_SECONDARY, pb);
        }
    }

  if (l)
    gtk_label_set_mnemonic_widget (GTK_LABEL (l), entry);

  if (!is_combo)
    g_signal_connect (G_OBJECT (entry), "activate", G_CALLBACK (entry_activate_cb), dlg);
  else
    g_signal_connect (G_OBJECT (entry), "key-press-event", G_CALLBACK (combo_activate_cb), dlg);

  if (options.entry_data.licon || options.entry_data.ricon)
    g_signal_connect (G_OBJECT (entry), "icon-press", G_CALLBACK (icon_cb), NULL);

  gtk_box_pack_start (GTK_BOX (w), c, TRUE, TRUE, 1);

  return w;
}
Exemplo n.º 10
0
static gboolean
wshed_dialog(WshedArgs *args, GwyContainer *data)
{
    GtkWidget *dialog, *table, *label, *spin, *hbox;
    WshedControls controls;
    enum {
        RESPONSE_RESET = 1,
        RESPONSE_PREVIEW = 2
    };
    gint response;
    gdouble zoomval;
    GtkObject *layer;
    GwyDataField *dfield;
    gint row;

    dialog = gtk_dialog_new_with_buttons(_("Mark Grains by Watershed"),
                                         NULL, 0,
                                         _("_Update Preview"), RESPONSE_PREVIEW,
                                         _("_Reset"), RESPONSE_RESET,
                                         GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
                                         GTK_STOCK_OK, GTK_RESPONSE_OK,
                                         NULL);
    gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_OK);
    gtk_dialog_set_has_separator(GTK_DIALOG(dialog), FALSE);
    controls.dialog = dialog;

    hbox = gtk_hbox_new(FALSE, 2);

    gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), GTK_WIDGET(hbox),
                       FALSE, FALSE, 4);

    controls.mydata = GWY_CONTAINER(gwy_serializable_duplicate(G_OBJECT(data)));
    controls.view = gwy_data_view_new(controls.mydata);
    layer = gwy_layer_basic_new();
    gwy_data_view_set_base_layer(GWY_DATA_VIEW(controls.view),
                                 GWY_PIXMAP_LAYER(layer));
    dfield = GWY_DATA_FIELD(gwy_container_get_object_by_name(controls.mydata,
                                                             "/0/data"));

    if (gwy_data_field_get_xres(dfield) >= gwy_data_field_get_yres(dfield))
        zoomval = PREVIEW_SIZE/(gdouble)gwy_data_field_get_xres(dfield);
    else
        zoomval = PREVIEW_SIZE/(gdouble)gwy_data_field_get_yres(dfield);

    gwy_data_view_set_zoom(GWY_DATA_VIEW(controls.view), zoomval);

    gtk_box_pack_start(GTK_BOX(hbox), controls.view, FALSE, FALSE, 4);

    table = gtk_table_new(9, 4, FALSE);
    gtk_box_pack_start(GTK_BOX(hbox), table, TRUE, TRUE, 4);
    row = 0;

    label = gtk_label_new(NULL);
    gtk_label_set_markup(GTK_LABEL(label), _("<b>Grain Location</b>"));
    gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
    gtk_table_attach(GTK_TABLE(table), label,
                     0, 2, row, row+1, GTK_EXPAND | GTK_FILL, 0, 2, 2);
    row++;

    controls.locate_steps = gtk_adjustment_new(args->locate_steps,
                                               1.0, 100.0, 1, 5, 0);
    gwy_table_attach_hscale(table, row, _("_Number of steps:"), "",
                            controls.locate_steps, 0);
    g_signal_connect(controls.locate_steps, "value_changed",
                     G_CALLBACK(wshed_invalidate), &controls);
    row++;

    controls.locate_dropsize = gtk_adjustment_new(args->locate_dropsize,
                                                  0.01, 100.0, 0.1, 5, 0);
    spin = gwy_table_attach_hscale(table, row, _("_Drop size:"), "%",
                                   controls.locate_dropsize, 0);
    gtk_spin_button_set_digits(GTK_SPIN_BUTTON(spin), 2);
    g_signal_connect(controls.locate_dropsize, "value_changed",
                     G_CALLBACK(wshed_invalidate), &controls);

    row++;
    controls.locate_thresh = gtk_adjustment_new(args->locate_thresh,
                                                0.0, 100.0, 1, 5, 0);
    gwy_table_attach_hscale(table, row, _("_Threshold:"), "px<sup>2</sup>",
                            controls.locate_thresh, 0);
    g_signal_connect(controls.locate_thresh, "value_changed",
                     G_CALLBACK(wshed_invalidate), &controls);
    gtk_table_set_row_spacing(GTK_TABLE(table), row, 8);
    row++;

    label = gtk_label_new(NULL);
    gtk_label_set_markup(GTK_LABEL(label), _("<b>Segmentation</b>"));
    gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
    gtk_table_attach(GTK_TABLE(table), label,
                     0, 2, row, row+1, GTK_EXPAND | GTK_FILL, 0, 2, 2);
    row++;

    controls.wshed_steps = gtk_adjustment_new(args->wshed_steps,
                                              1.0, 1000.0, 1, 5, 0);
    gwy_table_attach_hscale(table, row, _("Num_ber of steps:"), "",
                            controls.wshed_steps, 0);
    g_signal_connect(controls.wshed_steps, "value_changed",
                     G_CALLBACK(wshed_invalidate), &controls);
    row++;

    controls.wshed_dropsize = gtk_adjustment_new(args->wshed_dropsize,
                                                 0.01, 100.0, 0.1, 5, 0);
    spin = gwy_table_attach_hscale(table, row, _("Dr_op size:"), "%",
                                   controls.wshed_dropsize, 0);
    gtk_spin_button_set_digits(GTK_SPIN_BUTTON(spin), 2);
    g_signal_connect(controls.wshed_dropsize, "value_changed",
                     G_CALLBACK(wshed_invalidate), &controls);
    gtk_table_set_row_spacing(GTK_TABLE(table), row, 8);
    row++;

    label = gtk_label_new(NULL);
    gtk_label_set_markup(GTK_LABEL(label), _("<b>Options</b>"));
    gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
    gtk_table_attach(GTK_TABLE(table), label, 0, 2, row, row+1,
                     GTK_EXPAND | GTK_FILL, 0, 2, 2);
    row++;

    controls.inverted = gtk_check_button_new_with_mnemonic(_("_Invert height"));
    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(controls.inverted),
                                 args->inverted);
    gtk_table_attach(GTK_TABLE(table), controls.inverted,
                     0, 4, row, row+1, GTK_EXPAND | GTK_FILL, 0, 2, 2);
    g_signal_connect(controls.inverted, "toggled",
                     G_CALLBACK(wshed_invalidate), &controls);
    row++;

    controls.color_button = gwy_color_button_new();
    gwy_color_button_set_use_alpha(GWY_COLOR_BUTTON(controls.color_button),
                                   TRUE);
    load_mask_color(controls.color_button,
                    gwy_data_view_get_data(GWY_DATA_VIEW(controls.view)));
    gwy_table_attach_hscale(table, row++, _("_Mask color:"), NULL,
                            GTK_OBJECT(controls.color_button),
                            GWY_HSCALE_WIDGET_NO_EXPAND);
    g_signal_connect(controls.color_button, "clicked",
                     G_CALLBACK(mask_color_change_cb), &controls);

    controls.computed = FALSE;

    gtk_widget_show_all(dialog);
    do {
        response = gtk_dialog_run(GTK_DIALOG(dialog));
        switch (response) {
            case GTK_RESPONSE_CANCEL:
            case GTK_RESPONSE_DELETE_EVENT:
            wshed_dialog_update_values(&controls, args);
            gtk_widget_destroy(dialog);
            case GTK_RESPONSE_NONE:
            g_object_unref(controls.mydata);
            return FALSE;
            break;

            case GTK_RESPONSE_OK:
            break;

            case RESPONSE_RESET:
            *args = wshed_defaults;
            wshed_dialog_update_controls(&controls, args);
            break;

            case RESPONSE_PREVIEW:
            wshed_dialog_update_values(&controls, args);
            preview(&controls, args);
            break;

            default:
            g_assert_not_reached();
            break;
        }
    } while (response != GTK_RESPONSE_OK);

    save_mask_color(controls.color_button, data);
    wshed_dialog_update_values(&controls, args);
    gtk_widget_destroy(dialog);
    wshed_ok(&controls, args, data);
    g_object_unref(controls.mydata);

    return controls.computed;
}
Exemplo n.º 11
0
static void 
intprop_set_from_widget(IntProperty *prop, WIDGET *widget) 
{
  prop->int_data = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(widget));
}
Exemplo n.º 12
0
int ExportDialog::getPngDpi()
{
	XOJ_CHECK_TYPE(ExportDialog);
	return gtk_spin_button_get_value(GTK_SPIN_BUTTON(get("spDpi")));
}
Exemplo n.º 13
0
GHashTable *
ppp_dialog_new_hash_from_dialog (GtkWidget *dialog, GError **error)
{
	GHashTable *hash;
	GtkWidget *widget;
	GtkBuilder *builder;
	GtkTreeModel *model;
	GtkTreeIter iter;
	gboolean valid;
	int mtu_num;
	int mru_num;

	g_return_val_if_fail (dialog != NULL, NULL);
	if (error)
		g_return_val_if_fail (*error == NULL, NULL);

	builder = g_object_get_data (G_OBJECT (dialog), "gtkbuilder-xml");
	g_return_val_if_fail (builder != NULL, NULL);

	hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);

	widget = GTK_WIDGET (gtk_builder_get_object (builder, "ppp_use_mppe"));
	if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget))) {

		widget = GTK_WIDGET (gtk_builder_get_object (builder, "ppp_mppe_security_combo"));
		switch (gtk_combo_box_get_active (GTK_COMBO_BOX (widget))) {
		case SEC_INDEX_MPPE_128:
			g_hash_table_insert (hash, g_strdup (NM_L2TP_KEY_REQUIRE_MPPE_128), g_strdup ("yes"));
			break;
		case SEC_INDEX_MPPE_40:
			g_hash_table_insert (hash, g_strdup (NM_L2TP_KEY_REQUIRE_MPPE_40), g_strdup ("yes"));
			break;
		default:
			g_hash_table_insert (hash, g_strdup (NM_L2TP_KEY_REQUIRE_MPPE), g_strdup ("yes"));
			break;
		}

		widget = GTK_WIDGET (gtk_builder_get_object (builder, "ppp_allow_stateful_mppe"));
		if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)))
			g_hash_table_insert (hash, g_strdup (NM_L2TP_KEY_MPPE_STATEFUL), g_strdup ("yes"));
	}

	widget = GTK_WIDGET (gtk_builder_get_object (builder, "ppp_allow_bsdcomp"));
	if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)))
		g_hash_table_insert (hash, g_strdup (NM_L2TP_KEY_NOBSDCOMP), g_strdup ("yes"));

	widget = GTK_WIDGET (gtk_builder_get_object (builder, "ppp_allow_deflate"));
	if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)))
		g_hash_table_insert (hash, g_strdup (NM_L2TP_KEY_NODEFLATE), g_strdup ("yes"));

	widget = GTK_WIDGET (gtk_builder_get_object (builder, "ppp_usevj"));
	if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)))
		g_hash_table_insert (hash, g_strdup (NM_L2TP_KEY_NO_VJ_COMP), g_strdup ("yes"));

	widget = GTK_WIDGET (gtk_builder_get_object (builder,"ppp_usepcomp"));
	if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)))
		g_hash_table_insert (hash, g_strdup (NM_L2TP_KEY_NO_PCOMP), g_strdup ("yes"));

	widget = GTK_WIDGET (gtk_builder_get_object (builder, "ppp_useaccomp"));
	if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)))
		g_hash_table_insert (hash, g_strdup (NM_L2TP_KEY_NO_ACCOMP), g_strdup ("yes"));

	widget = GTK_WIDGET (gtk_builder_get_object (builder, "ppp_send_echo_packets"));
	if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget))) {
		g_hash_table_insert (hash, g_strdup (NM_L2TP_KEY_LCP_ECHO_FAILURE), g_strdup_printf ("%d", 5));
		g_hash_table_insert (hash, g_strdup (NM_L2TP_KEY_LCP_ECHO_INTERVAL), g_strdup_printf ("%d", 30));
	}

	widget = GTK_WIDGET (gtk_builder_get_object (builder, "ppp_auth_methods"));
	model = gtk_tree_view_get_model (GTK_TREE_VIEW (widget));
	valid = gtk_tree_model_get_iter_first (model, &iter);
	while (valid) {
		gboolean allowed;
		guint32 tag;

		gtk_tree_model_get (model, &iter, COL_VALUE, &allowed, COL_TAG, &tag, -1);
		switch (tag) {
		case TAG_PAP:
			if (!allowed)
				g_hash_table_insert (hash, g_strdup (NM_L2TP_KEY_REFUSE_PAP), g_strdup ("yes"));
			break;
		case TAG_CHAP:
			if (!allowed)
				g_hash_table_insert (hash, g_strdup (NM_L2TP_KEY_REFUSE_CHAP), g_strdup ("yes"));
			break;
		case TAG_MSCHAP:
			if (!allowed)
				g_hash_table_insert (hash, g_strdup (NM_L2TP_KEY_REFUSE_MSCHAP), g_strdup ("yes"));
			break;
		case TAG_MSCHAPV2:
			if (!allowed)
				g_hash_table_insert (hash, g_strdup (NM_L2TP_KEY_REFUSE_MSCHAPV2), g_strdup ("yes"));
			break;
		case TAG_EAP:
			if (!allowed)
				g_hash_table_insert (hash, g_strdup (NM_L2TP_KEY_REFUSE_EAP), g_strdup ("yes"));
			break;
		default:
			break;
		}

		valid = gtk_tree_model_iter_next (model, &iter);
	}

	widget = GTK_WIDGET (gtk_builder_get_object (builder, "ppp_mtu_spinbutton"));
	mtu_num = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (widget));
	g_hash_table_insert (hash, g_strdup (NM_L2TP_KEY_MTU),
	                     g_strdup_printf ("%d", mtu_num));

	widget = GTK_WIDGET (gtk_builder_get_object (builder, "ppp_mru_spinbutton"));
	mru_num = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (widget));
	g_hash_table_insert (hash, g_strdup (NM_L2TP_KEY_MRU),
	                     g_strdup_printf ("%d", mru_num));

	return hash;
}
Exemplo n.º 14
0
GtkWidget *
ppp_dialog_new (GHashTable *hash)
{
	GtkBuilder *builder;
	GtkWidget *dialog = NULL;
	GtkWidget *widget;
	const char *value;
	gboolean mppe = FALSE;
	GError *error = NULL;

	g_return_val_if_fail (hash != NULL, NULL);

	builder = gtk_builder_new ();
	gtk_builder_set_translation_domain (builder, GETTEXT_PACKAGE);
	if (!gtk_builder_add_from_resource (builder, "/org/freedesktop/network-manager-l2tp/nm-l2tp-dialog.ui", &error)) {
		g_warning ("Couldn't load builder file: %s",
				   error ? error->message : "(unknown)");
		g_clear_error (&error);
		g_object_unref (G_OBJECT (builder));
		return NULL;
	}

	dialog = GTK_WIDGET (gtk_builder_get_object (builder, "l2tp-ppp-dialog"));
	if (!dialog) {
		g_object_unref (G_OBJECT (builder));
		return NULL;
	}
	gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);

	g_object_set_data_full (G_OBJECT (dialog), "gtkbuilder-xml",
	                        builder, (GDestroyNotify) g_object_unref);

	setup_security_combo (builder, hash);

	value = g_hash_table_lookup (hash, NM_L2TP_KEY_REQUIRE_MPPE);
	if (value && !strcmp (value, "yes"))
		mppe = TRUE;

	value = g_hash_table_lookup (hash, NM_L2TP_KEY_REQUIRE_MPPE_40);
	if (value && !strcmp (value, "yes"))
		mppe = TRUE;

	value = g_hash_table_lookup (hash, NM_L2TP_KEY_REQUIRE_MPPE_128);
	if (value && !strcmp (value, "yes"))
		mppe = TRUE;

	widget = GTK_WIDGET (gtk_builder_get_object (builder, "ppp_use_mppe"));
	if (mppe)
		gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), TRUE);

	widget = GTK_WIDGET (gtk_builder_get_object (builder, "ppp_allow_stateful_mppe"));
	value = g_hash_table_lookup (hash, NM_L2TP_KEY_MPPE_STATEFUL);
	if (value && !strcmp (value, "yes"))
		gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), TRUE);

	widget = GTK_WIDGET (gtk_builder_get_object (builder, "ppp_allow_bsdcomp"));
	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), TRUE);
	value = g_hash_table_lookup (hash, NM_L2TP_KEY_NOBSDCOMP);
	if (value && !strcmp (value, "yes"))
		gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), FALSE);

	widget = GTK_WIDGET (gtk_builder_get_object (builder, "ppp_allow_deflate"));
	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), TRUE);
	value = g_hash_table_lookup (hash, NM_L2TP_KEY_NODEFLATE);
	if (value && !strcmp (value, "yes"))
		gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), FALSE);

	widget = GTK_WIDGET (gtk_builder_get_object (builder, "ppp_usevj"));
	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), TRUE);
	value = g_hash_table_lookup (hash, NM_L2TP_KEY_NO_VJ_COMP);
	if (value && !strcmp (value, "yes"))
		gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), FALSE);

	widget = GTK_WIDGET (gtk_builder_get_object (builder,"ppp_usepcomp"));
	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), TRUE);
	value = g_hash_table_lookup (hash, NM_L2TP_KEY_NO_PCOMP);
	if (value && !strcmp (value, "yes"))
		gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), FALSE);

	widget = GTK_WIDGET (gtk_builder_get_object (builder, "ppp_useaccomp"));
	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), TRUE);
	value = g_hash_table_lookup (hash, NM_L2TP_KEY_NO_ACCOMP);
	if (value && !strcmp (value, "yes"))
		gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), FALSE);

	widget = GTK_WIDGET (gtk_builder_get_object (builder, "ppp_send_echo_packets"));
	value = g_hash_table_lookup (hash, NM_L2TP_KEY_LCP_ECHO_INTERVAL);
	if (value && strlen (value)) {
		long int tmp_int;

		errno = 0;
		tmp_int = strtol (value, NULL, 10);
		if (errno == 0 && tmp_int > 0)
			gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), TRUE);
	}

	auth_methods_setup (builder, hash);

	widget = GTK_WIDGET (gtk_builder_get_object (builder,"ppp_use_mppe"));
	handle_mppe_changed (widget, TRUE, builder);
	g_signal_connect (G_OBJECT (widget), "toggled", G_CALLBACK (mppe_toggled_cb), builder);

	widget = GTK_WIDGET (gtk_builder_get_object (builder,"ppp_mtu_spinbutton"));
	value = g_hash_table_lookup (hash, NM_L2TP_KEY_MTU);
	if (value && *value) {
		long int tmp_int;

		errno = 0;
		tmp_int = strtol (value, NULL, 10);
		if (errno == 0 && tmp_int >= 575 && tmp_int <= 1500) {
			gtk_spin_button_set_value (GTK_SPIN_BUTTON (widget), (gdouble) tmp_int);
		}
	} else {
		gtk_spin_button_set_value (GTK_SPIN_BUTTON (widget), 1400);
	}

	widget = GTK_WIDGET (gtk_builder_get_object (builder,"ppp_use_mppe"));
	handle_mppe_changed (widget, TRUE, builder);
	g_signal_connect (G_OBJECT (widget), "toggled", G_CALLBACK (mppe_toggled_cb), builder);

	widget = GTK_WIDGET (gtk_builder_get_object (builder,"ppp_mru_spinbutton"));
	value = g_hash_table_lookup (hash, NM_L2TP_KEY_MRU);
	if (value && *value) {
		long int tmp_int;

		errno = 0;
		tmp_int = strtol (value, NULL, 10);
		if (errno == 0 && tmp_int >= 575 && tmp_int <= 1500) {
			gtk_spin_button_set_value (GTK_SPIN_BUTTON (widget), (gdouble) tmp_int);
		}
	} else {
		gtk_spin_button_set_value (GTK_SPIN_BUTTON (widget), 1400);
	}

	return dialog;
}
Exemplo n.º 15
0
static void mp3_configure(void)
{
    gint i;

    if (!configure_win) {
        configure_win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
        gtk_window_set_type_hint(GTK_WINDOW(configure_win), GDK_WINDOW_TYPE_HINT_DIALOG);

        g_signal_connect (configure_win, "destroy", (GCallback)
         gtk_widget_destroyed, & configure_win);
        gtk_window_set_title(GTK_WINDOW(configure_win),
                             _("MP3 Configuration"));
        gtk_window_set_position(GTK_WINDOW(configure_win),
                                GTK_WIN_POS_MOUSE);
        gtk_container_set_border_width(GTK_CONTAINER(configure_win), 5);

        vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 5);
        gtk_container_add(GTK_CONTAINER(configure_win), vbox);

        notebook = gtk_notebook_new();
        gtk_box_pack_start(GTK_BOX(vbox), notebook, TRUE, TRUE, 0);


        /* Quality */

        quality_vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 5);
        gtk_container_set_border_width(GTK_CONTAINER(quality_vbox), 5);

        quality_hbox1 = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 5);
        gtk_box_pack_start(GTK_BOX(quality_vbox), quality_hbox1, FALSE,
                           FALSE, 0);

        /* Algorithm Quality */

        alg_quality_frame = gtk_frame_new(_("Algorithm Quality:"));
        gtk_container_set_border_width(GTK_CONTAINER(alg_quality_frame),
                                       5);
        gtk_box_pack_start(GTK_BOX(quality_hbox1), alg_quality_frame,
                           FALSE, FALSE, 0);

        alg_quality_hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 5);
        gtk_container_set_border_width(GTK_CONTAINER(alg_quality_hbox),
                                       10);
        gtk_container_add(GTK_CONTAINER(alg_quality_frame),
                          alg_quality_hbox);

        alg_quality_adj = (GtkAdjustment *) gtk_adjustment_new (5, 0, 9, 1, 1, 0);
        alg_quality_spin =
            gtk_spin_button_new(GTK_ADJUSTMENT(alg_quality_adj), 8, 0);
        gtk_box_pack_start(GTK_BOX(alg_quality_hbox), alg_quality_spin,
                           TRUE, TRUE, 0);
        g_signal_connect (alg_quality_adj, "value-changed", (GCallback)
         algo_qual, NULL);

        gtk_spin_button_set_value(GTK_SPIN_BUTTON(alg_quality_spin),
                                  algo_quality_val);

        /* Output Samplerate */

        samplerate_frame = gtk_frame_new(_("Output Samplerate:"));
        gtk_container_set_border_width(GTK_CONTAINER(samplerate_frame), 5);
        gtk_box_pack_start(GTK_BOX(quality_hbox1), samplerate_frame, FALSE,
                           FALSE, 0);

        samplerate_hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 5);
        gtk_container_set_border_width(GTK_CONTAINER(samplerate_hbox), 10);
        gtk_container_add(GTK_CONTAINER(samplerate_frame),
                          samplerate_hbox);

        GtkWidget * combo = gtk_combo_box_text_new ();
        gtk_combo_box_text_append_text ((GtkComboBoxText *) combo, _("Auto"));
        if (! out_samplerate_val)
            gtk_combo_box_set_active ((GtkComboBox *) combo, 0);

        for (i = 0; i < G_N_ELEMENTS (available_samplerates); i ++)
        {
            gchar buf[10];
            snprintf (buf, sizeof buf, "%d", available_samplerates[i]);
            gtk_combo_box_text_append_text ((GtkComboBoxText *) combo, buf);

            if (out_samplerate_val == available_samplerates[i])
                gtk_combo_box_set_active ((GtkComboBox *) combo, 1 + i);
        }

        gtk_box_pack_start ((GtkBox *) samplerate_hbox, combo, FALSE, FALSE, 0);
        g_signal_connect (combo, "changed", (GCallback) samplerate_changed, NULL);

        samplerate_label = gtk_label_new(_("(Hz)"));
        gtk_misc_set_alignment(GTK_MISC(samplerate_label), 0, 0.5);
        gtk_box_pack_start(GTK_BOX(samplerate_hbox), samplerate_label,
                           FALSE, FALSE, 0);

        /* Encoder Quality */

        enc_quality_frame = gtk_frame_new(_("Bitrate / Compression ratio:"));
        gtk_container_set_border_width(GTK_CONTAINER(enc_quality_frame),
                                       5);
        gtk_box_pack_start(GTK_BOX(quality_vbox), enc_quality_frame, FALSE,
                           FALSE, 0);

        // vbox sorrounding hbox1 and hbox2
        enc_quality_vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 5);
        gtk_container_set_border_width(GTK_CONTAINER(enc_quality_vbox), 10);

        // pack vbox to frame
        gtk_container_add(GTK_CONTAINER(enc_quality_frame), enc_quality_vbox);

        // hbox1 for bitrate
        hbox1 = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 5);
        gtk_container_add(GTK_CONTAINER(enc_quality_vbox), hbox1);

        // radio 1
        enc_radio1 = gtk_radio_button_new(NULL);
        if (enc_toggle_val == 0)
            gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(enc_radio1), TRUE);
        gtk_box_pack_start(GTK_BOX(hbox1), enc_radio1, FALSE, FALSE, 0);

        // label 1
        enc_quality_label1 = gtk_label_new(_("Bitrate (kbps):"));
        gtk_box_pack_start(GTK_BOX(hbox1), enc_quality_label1, FALSE, FALSE, 0);

        // bitrate menu

        combo = gtk_combo_box_text_new ();

        for (i = 0; i < G_N_ELEMENTS (available_bitrates); i ++)
        {
            gchar buf[10];
            snprintf (buf, sizeof buf, "%d", available_bitrates[i]);
            gtk_combo_box_text_append_text ((GtkComboBoxText *) combo, buf);

            if (bitrate_val == available_bitrates[i])
                gtk_combo_box_set_active ((GtkComboBox *) combo, i);
        }

        gtk_box_pack_start ((GtkBox *) hbox1, combo, FALSE, FALSE, 0);
        g_signal_connect (combo, "changed", (GCallback) bitrate_changed, NULL);

        // hbox2 for compression ratio
        hbox2 = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 5);
        gtk_container_add(GTK_CONTAINER(enc_quality_vbox), hbox2);

        // radio 2
        enc_radio2 = gtk_radio_button_new_from_widget(GTK_RADIO_BUTTON(enc_radio1));
        if (enc_toggle_val == 1)
            gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(enc_radio2),
                                         TRUE);
        // pack radio 2
        gtk_box_pack_start(GTK_BOX(hbox2), enc_radio2, FALSE, FALSE, 0);

        // label
        enc_quality_label2 = gtk_label_new(_("Compression ratio:"));
        gtk_box_pack_start(GTK_BOX(hbox2), enc_quality_label2, FALSE, FALSE, 0);

        // comp-ratio spin
        compression_adj = (GtkAdjustment *) gtk_adjustment_new (11, 0, 100, 1,
         1, 0);
        compression_spin =
            gtk_spin_button_new(GTK_ADJUSTMENT(compression_adj), 8, 0);
        gtk_box_pack_end(GTK_BOX(hbox2), compression_spin, FALSE, FALSE, 0);

        g_signal_connect (compression_adj, "value-changed", (GCallback)
         compression_change, NULL);

        gtk_spin_button_set_value(GTK_SPIN_BUTTON(compression_spin),
                                  compression_val);

        // radio button signale connect
        g_signal_connect (enc_radio1, "toggled", (GCallback) encoding_toggle,
         GINT_TO_POINTER (0));
        g_signal_connect (enc_radio2, "toggled", (GCallback) encoding_toggle,
         GINT_TO_POINTER (1));

        /* Audio Mode */

        mode_frame = gtk_frame_new(_("Audio Mode:"));
        gtk_container_set_border_width(GTK_CONTAINER(mode_frame), 5);
        gtk_box_pack_start(GTK_BOX(quality_vbox), mode_frame, FALSE, FALSE,
                           0);

        mode_hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 10);
        gtk_container_set_border_width(GTK_CONTAINER(mode_hbox), 10);
        gtk_container_add(GTK_CONTAINER(mode_frame), mode_hbox);

        combo = gtk_combo_box_text_new ();

        for (i = 0; i < MODES; i ++)
        {
            gtk_combo_box_text_append_text ((GtkComboBoxText *) combo,
             _(mode_names[i]));

            if (audio_mode_val == modes[i])
                gtk_combo_box_set_active ((GtkComboBox *) combo, i);
        }

        gtk_box_pack_start ((GtkBox *) mode_hbox, combo, FALSE, FALSE, 0);
        g_signal_connect (combo, "changed", (GCallback) mode_changed, NULL);

        /* Misc */

        misc_frame = gtk_frame_new(_("Misc:"));
        gtk_container_set_border_width(GTK_CONTAINER(misc_frame), 5);
        gtk_box_pack_start(GTK_BOX(quality_vbox), misc_frame, FALSE, FALSE,
                           0);

        misc_vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 5);
        gtk_container_set_border_width(GTK_CONTAINER(misc_vbox), 5);
        gtk_container_add(GTK_CONTAINER(misc_frame), misc_vbox);

        enforce_iso_toggle =
            gtk_check_button_new_with_label
            (_("Enforce strict ISO complience"));
        gtk_box_pack_start(GTK_BOX(misc_vbox), enforce_iso_toggle, TRUE,
                           TRUE, 2);
        g_signal_connect (enforce_iso_toggle, "toggled", (GCallback)
         toggle_enforce_iso, NULL);

        if (enforce_iso_val == 1)
            gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON
                                         (enforce_iso_toggle), TRUE);

        error_protection_toggle =
            gtk_check_button_new_with_label(_("Error protection"));
        gtk_box_pack_start(GTK_BOX(misc_vbox), error_protection_toggle,
                           TRUE, TRUE, 2);
        g_signal_connect (error_protection_toggle, "toggled", (GCallback)
         toggle_error_protect, NULL);

        if (error_protect_val == 1)
            gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON
                                         (error_protection_toggle), TRUE);

        /* Add the Notebook */
        gtk_notebook_append_page(GTK_NOTEBOOK(notebook), quality_vbox,
                                 gtk_label_new(_("Quality")));


        /* VBR/ABR */

        vbr_vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 5);
        gtk_container_set_border_width(GTK_CONTAINER(vbr_vbox), 5);

        /* Toggle VBR */

        vbr_toggle = gtk_check_button_new_with_label(_("Enable VBR/ABR"));
        gtk_box_pack_start(GTK_BOX(vbr_vbox), vbr_toggle, FALSE, FALSE, 2);
        g_signal_connect (vbr_toggle, "toggled", (GCallback) toggle_vbr, NULL);

        vbr_options_vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
        gtk_container_add(GTK_CONTAINER(vbr_vbox), vbr_options_vbox);
        gtk_widget_set_sensitive(vbr_options_vbox, FALSE);

        /* Choose VBR/ABR */

        vbr_type_frame = gtk_frame_new(_("Type:"));
        gtk_container_set_border_width(GTK_CONTAINER(vbr_type_frame), 5);
        gtk_box_pack_start(GTK_BOX(vbr_options_vbox), vbr_type_frame,
                           FALSE, FALSE, 2);

        vbr_type_hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 5);
        gtk_container_set_border_width(GTK_CONTAINER(vbr_type_hbox), 5);
        gtk_container_add(GTK_CONTAINER(vbr_type_frame), vbr_type_hbox);

        vbr_type_radio1 = gtk_radio_button_new_with_label(NULL, "VBR");
        gtk_box_pack_start(GTK_BOX(vbr_type_hbox), vbr_type_radio1, TRUE,
                           TRUE, 2);
        if (vbr_type == 0)
            gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON
                                         (vbr_type_radio1), TRUE);

        vbr_type_radio2 =
            gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON
                                                        (vbr_type_radio1),
                                                        "ABR");
        gtk_box_pack_start(GTK_BOX(vbr_type_hbox), vbr_type_radio2, TRUE,
                           TRUE, 2);
        if (vbr_type == 1)
            gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON
                                         (vbr_type_radio2), TRUE);

        g_signal_connect (vbr_type_radio1, "toggled", (GCallback)
         vbr_abr_toggle, "VBR");
        g_signal_connect (vbr_type_radio2, "toggled", (GCallback)
         vbr_abr_toggle, "ABR");

        /* VBR Options */

        vbr_frame = gtk_frame_new(_("VBR Options:"));
        gtk_container_set_border_width(GTK_CONTAINER(vbr_frame), 5);
        gtk_box_pack_start(GTK_BOX(vbr_options_vbox), vbr_frame, FALSE,
                           FALSE, 2);

        vbr_options_vbox2 = gtk_box_new(GTK_ORIENTATION_VERTICAL, 5);
        gtk_container_set_border_width(GTK_CONTAINER(vbr_options_vbox2),
                                       5);
        gtk_container_add(GTK_CONTAINER(vbr_frame), vbr_options_vbox2);

        vbr_options_hbox1 = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 5);
        gtk_container_set_border_width(GTK_CONTAINER(vbr_options_hbox1),
                                       5);
        gtk_container_add(GTK_CONTAINER(vbr_options_vbox2),
                          vbr_options_hbox1);

        vbr_min_label = gtk_label_new(_("Minimum bitrate (kbps):"));
        gtk_misc_set_alignment(GTK_MISC(vbr_min_label), 0, 0.5);
        gtk_box_pack_start(GTK_BOX(vbr_options_hbox1), vbr_min_label, TRUE,
                           TRUE, 0);

        combo = gtk_combo_box_text_new ();

        for (i = 0; i < G_N_ELEMENTS (available_bitrates); i ++)
        {
            gchar buf[10];
            snprintf (buf, sizeof buf, "%d", available_bitrates[i]);
            gtk_combo_box_text_append_text ((GtkComboBoxText *) combo, buf);

            if (vbr_min_val == available_bitrates[i])
                gtk_combo_box_set_active ((GtkComboBox *) combo, i);
        }

        gtk_box_pack_start ((GtkBox *) vbr_options_hbox1, combo, FALSE, FALSE,
         0);
        g_signal_connect (combo, "changed", (GCallback) vbr_min_changed, NULL);

        vbr_options_hbox2 = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 5);
        gtk_container_set_border_width(GTK_CONTAINER(vbr_options_hbox2),
                                       5);
        gtk_container_add(GTK_CONTAINER(vbr_options_vbox2),
                          vbr_options_hbox2);

        vbr_max_label = gtk_label_new(_("Maximum bitrate (kbps):"));
        gtk_misc_set_alignment(GTK_MISC(vbr_max_label), 0, 0.5);
        gtk_box_pack_start(GTK_BOX(vbr_options_hbox2), vbr_max_label, TRUE,
                           TRUE, 0);

        combo = gtk_combo_box_text_new ();

        for (i = 0; i < G_N_ELEMENTS (available_bitrates); i ++)
        {
            gchar buf[10];
            snprintf (buf, sizeof buf, "%d", available_bitrates[i]);
            gtk_combo_box_text_append_text ((GtkComboBoxText *) combo, buf);

            if (vbr_max_val == available_bitrates[i])
                gtk_combo_box_set_active ((GtkComboBox *) combo, i);
        }

        gtk_box_pack_start ((GtkBox *) vbr_options_hbox2, combo, FALSE, FALSE,
         0);
        g_signal_connect (combo, "changed", (GCallback) vbr_max_changed, NULL);

        enforce_min_toggle =
            gtk_check_button_new_with_label
            (_("Strictly enforce minimum bitrate"));
        gtk_box_pack_start(GTK_BOX(vbr_options_vbox2), enforce_min_toggle,
                           FALSE, FALSE, 2);
        g_signal_connect (enforce_min_toggle, "toggled", (GCallback)
         toggle_enforce_min, NULL);

        if (enforce_min_val == 1)
            gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON
                                         (enforce_min_toggle), TRUE);

        /* ABR Options */

        abr_frame = gtk_frame_new(_("ABR Options:"));
        gtk_container_set_border_width(GTK_CONTAINER(abr_frame), 5);
        gtk_box_pack_start(GTK_BOX(vbr_options_vbox), abr_frame, FALSE,
                           FALSE, 2);
        gtk_widget_set_sensitive(abr_frame, FALSE);

        abr_hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 5);
        gtk_container_set_border_width(GTK_CONTAINER(abr_hbox), 5);
        gtk_container_add(GTK_CONTAINER(abr_frame), abr_hbox);

        abr_label = gtk_label_new(_("Average bitrate (kbps):"));
        gtk_misc_set_alignment(GTK_MISC(abr_label), 0, 0.5);
        gtk_box_pack_start(GTK_BOX(abr_hbox), abr_label, TRUE, TRUE, 0);

        combo = gtk_combo_box_text_new ();

        for (i = 0; i < G_N_ELEMENTS (available_bitrates); i ++)
        {
            gchar buf[10];
            snprintf (buf, sizeof buf, "%d", available_bitrates[i]);
            gtk_combo_box_text_append_text ((GtkComboBoxText *) combo, buf);

            if (abr_val == available_bitrates[i])
                gtk_combo_box_set_active ((GtkComboBox *) combo, i);
        }

        gtk_box_pack_start ((GtkBox *) abr_hbox, combo, FALSE, FALSE,
         0);
        g_signal_connect (combo, "changed", (GCallback) abr_changed, NULL);

        /* Quality Level */

        vbr_options_hbox3 = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 5);
        gtk_container_set_border_width(GTK_CONTAINER(vbr_options_hbox3),
                                       5);
        gtk_container_add(GTK_CONTAINER(vbr_options_vbox),
                          vbr_options_hbox3);

        vbr_quality_label = gtk_label_new(_("VBR quality level:"));
        gtk_misc_set_alignment(GTK_MISC(vbr_quality_label), 0, 0.5);
        gtk_box_pack_start(GTK_BOX(vbr_options_hbox3), vbr_quality_label,
                           TRUE, TRUE, 0);

        vbr_quality_adj = (GtkAdjustment *) gtk_adjustment_new (4, 0, 9, 1, 1, 0);
        vbr_quality_spin =
            gtk_spin_button_new(GTK_ADJUSTMENT(vbr_quality_adj), 8, 0);
        gtk_box_pack_start(GTK_BOX(vbr_options_hbox3), vbr_quality_spin,
                           TRUE, TRUE, 0);
        g_signal_connect (vbr_quality_adj, "value-changed", (GCallback)
         vbr_qual, NULL);

        gtk_spin_button_set_value(GTK_SPIN_BUTTON(vbr_quality_spin),
                                  vbr_quality_val);

        /* Xing Header */

        xing_header_toggle =
            gtk_check_button_new_with_label(_("Don't write Xing VBR header"));
        gtk_box_pack_start(GTK_BOX(vbr_options_vbox), xing_header_toggle,
                           FALSE, FALSE, 2);
        g_signal_connect (xing_header_toggle, "toggled", (GCallback)
         toggle_xing, NULL);

        if (toggle_xing_val == 0)
            gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON
                                         (xing_header_toggle), TRUE);


        /* Add the Notebook */

        gtk_notebook_append_page(GTK_NOTEBOOK(notebook), vbr_vbox,
                                 gtk_label_new(_("VBR/ABR")));


        /* Tags */

        tags_vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 5);
        gtk_container_set_border_width(GTK_CONTAINER(tags_vbox), 5);

        /* Frame Params */

        tags_frames_frame = gtk_frame_new(_("Frame params:"));
        gtk_container_set_border_width(GTK_CONTAINER(tags_frames_frame),
                                       5);
        gtk_box_pack_start(GTK_BOX(tags_vbox), tags_frames_frame, FALSE,
                           FALSE, 2);

        tags_frames_hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 5);
        gtk_container_set_border_width(GTK_CONTAINER(tags_frames_hbox), 5);
        gtk_container_add(GTK_CONTAINER(tags_frames_frame),
                          tags_frames_hbox);

        tags_copyright_toggle =
            gtk_check_button_new_with_label(_("Mark as copyright"));
        gtk_box_pack_start(GTK_BOX(tags_frames_hbox),
                           tags_copyright_toggle, FALSE, FALSE, 2);
        g_signal_connect (tags_copyright_toggle, "toggled", (GCallback)
         toggle_copyright, NULL);

        if (mark_copyright_val == 1)
            gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON
                                         (tags_copyright_toggle), TRUE);

        tags_original_toggle =
            gtk_check_button_new_with_label(_("Mark as original"));
        gtk_box_pack_start(GTK_BOX(tags_frames_hbox), tags_original_toggle,
                           FALSE, FALSE, 2);
        g_signal_connect (tags_original_toggle, "toggled", (GCallback)
         toggle_original, NULL);

        if (mark_original_val == 1)
            gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON
                                         (tags_original_toggle), TRUE);

        /* ID3 Params */

        tags_id3_frame = gtk_frame_new(_("ID3 params:"));
        gtk_container_set_border_width(GTK_CONTAINER(tags_id3_frame), 5);
        gtk_box_pack_start(GTK_BOX(tags_vbox), tags_id3_frame, FALSE,
                           FALSE, 2);

        tags_id3_vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 5);
        gtk_container_set_border_width(GTK_CONTAINER(tags_id3_vbox), 5);
        gtk_container_add(GTK_CONTAINER(tags_id3_frame), tags_id3_vbox);

        tags_force_id3v2_toggle =
            gtk_check_button_new_with_label
            (_("Force addition of version 2 tag"));
        gtk_box_pack_start(GTK_BOX(tags_id3_vbox), tags_force_id3v2_toggle,
                           FALSE, FALSE, 2);
        g_signal_connect (tags_force_id3v2_toggle, "toggled", (GCallback)
         force_v2_toggle, NULL);

        tags_id3_hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 5);
        gtk_container_add(GTK_CONTAINER(tags_id3_vbox), tags_id3_hbox);

        tags_only_v1_toggle =
            gtk_check_button_new_with_label(_("Only add v1 tag"));
        gtk_box_pack_start(GTK_BOX(tags_id3_hbox), tags_only_v1_toggle,
                           FALSE, FALSE, 2);
        g_signal_connect (tags_only_v1_toggle, "toggled", (GCallback)
         id3_only_version, "v1");

        tags_only_v2_toggle =
            gtk_check_button_new_with_label(_("Only add v2 tag"));
        gtk_box_pack_start(GTK_BOX(tags_id3_hbox), tags_only_v2_toggle,
                           FALSE, FALSE, 2);
        g_signal_connect (tags_only_v2_toggle, "toggled", (GCallback)
         id3_only_version, "v2");

        if (force_v2_val == 1)
            gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON
                                         (tags_force_id3v2_toggle), TRUE);

        if (only_v1_val == 1)
            gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON
                                         (tags_only_v1_toggle), TRUE);

        if (only_v2_val == 1)
            gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON
                                         (tags_only_v2_toggle), TRUE);

        /* Add the Notebook */

        gtk_notebook_append_page(GTK_NOTEBOOK(notebook), tags_vbox,
                                 gtk_label_new(_("Tags")));




        /* The Rest */

        /* Buttons */

        configure_bbox = gtk_button_box_new(GTK_ORIENTATION_HORIZONTAL);
        gtk_button_box_set_layout(GTK_BUTTON_BOX(configure_bbox),
                                  GTK_BUTTONBOX_END);
        gtk_box_pack_start(GTK_BOX(vbox), configure_bbox, FALSE, FALSE, 0);

        configure_cancel = gtk_button_new_from_stock(GTK_STOCK_CANCEL);
        g_signal_connect_swapped (configure_cancel, "clicked", (GCallback)
         gtk_widget_destroy, configure_win);
        gtk_box_pack_start(GTK_BOX(configure_bbox), configure_cancel, TRUE,
                           TRUE, 0);

        configure_ok = gtk_button_new_from_stock(GTK_STOCK_OK);
        g_signal_connect (configure_ok, "clicked", (GCallback) configure_ok_cb,
         NULL);
        gtk_box_pack_start(GTK_BOX(configure_bbox), configure_ok, TRUE,
                           TRUE, 0);
        gtk_widget_show(configure_ok);

        /* Set States */

        if (vbr_on == 1)
            gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(vbr_toggle),
                                         TRUE);
        else
            gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(vbr_toggle),
                                         FALSE);

        /* Show it! */

        gtk_widget_show_all(configure_win);

    }
}
Exemplo n.º 16
0
// Creation de l'application FiguRE
void FIGUREGUI_create_app()
{
  guchar * txt = NULL;
  gint i;

  ptr_window = (Window*) g_malloc(sizeof(Window));

  /* Création de la fenêtre */
  ptr_window->win = gtk_window_new(GTK_WINDOW_TOPLEVEL);

  gtk_window_set_title(GTK_WINDOW(ptr_window->win), WTITLE);
  gtk_window_set_icon_from_file(GTK_WINDOW(ptr_window->win),WICON,NULL);
  gtk_window_set_default_size(GTK_WINDOW(ptr_window->win), WWIDTH, WHEIGHT);
  gtk_window_set_resizable(GTK_WINDOW(ptr_window->win),FALSE);
  gtk_window_set_position(GTK_WINDOW(ptr_window->win),GTK_WIN_POS_CENTER);
  g_signal_connect(G_OBJECT(ptr_window->win),"delete-event", G_CALLBACK(window_quitte),NULL);

  /* vbox qui contiendra notre interface */
  ptr_window->vbox = gtk_vbox_new(FALSE, 0);
  gtk_container_add(GTK_CONTAINER(ptr_window->win), ptr_window->vbox);

  /* barre menu */
  window_barre_menu();
  gtk_box_pack_start(GTK_BOX(ptr_window->vbox), ptr_window->menu_bar, FALSE, TRUE, 0);


  /* barre d'outils */
  window_barre_outils();
  gtk_box_pack_start(GTK_BOX(ptr_window->vbox), ptr_window->toolbar, FALSE, TRUE, 0);

  /* Création de la barre de progression */
  ptr_window->progress_bar = gtk_progress_bar_new();
  gtk_container_add(GTK_CONTAINER(ptr_window->vbox), ptr_window->progress_bar);

  // HBOX : contiendra les 2 cadres apprentissage et reconnaissance
  ptr_window->hbox = gtk_hbox_new(TRUE, 0);
  gtk_box_pack_start(GTK_BOX(ptr_window->vbox), ptr_window->hbox, TRUE, TRUE, 0);
  
  ptr_window->draw = gtk_frame_new("Zone d'ecriture");
  gtk_frame_set_shadow_type(GTK_FRAME(ptr_window->draw), GTK_SHADOW_IN);
  gtk_box_pack_start(GTK_BOX(ptr_window->hbox), ptr_window->draw, TRUE, TRUE, 0);
  
  ptr_window->result = gtk_frame_new("Informations");
  gtk_frame_set_shadow_type(GTK_FRAME(ptr_window->result), GTK_SHADOW_IN);
  gtk_box_pack_start(GTK_BOX(ptr_window->hbox), ptr_window->result, FALSE, TRUE, 0);

  
  // 
  ptr_window->infos_txt = gtk_label_new(NULL);
  gtk_container_add(GTK_CONTAINER(ptr_window->result),ptr_window->infos_txt);
  maj_infos();

  /* On crée la zone de dessin 256x256  */
  creation_zone_dessin();

  /* Creation buffer pre-traitement */
  creation_buffer_pretraitement();

  /* Creation de la zone de saisie */
  ptr_window->hbox_saisie = gtk_hbox_new(FALSE, 0);
  gtk_box_pack_start(GTK_BOX(ptr_window->vbox), ptr_window->hbox_saisie, TRUE, TRUE, 0);

  ptr_window->lbl_saisie_chiffre = gtk_label_new("Chiffre : ");
  gtk_box_pack_start(GTK_BOX(ptr_window->hbox_saisie), ptr_window->lbl_saisie_chiffre, FALSE, TRUE, 0);
  ptr_window->saisie_chiffre = gtk_spin_button_new_with_range(0,9,1);
  gtk_box_pack_start(GTK_BOX(ptr_window->hbox_saisie), ptr_window->saisie_chiffre, FALSE, TRUE, 0);
 

  ptr_window->lbl_saisie_pas = gtk_label_new(" Pas d'apprentissage : ");
  gtk_box_pack_start(GTK_BOX(ptr_window->hbox_saisie), ptr_window->lbl_saisie_pas, FALSE, TRUE, 0);
  ptr_window->saisie_pas = gtk_spin_button_new_with_range(0,1,0.1);
  gtk_spin_button_set_value(GTK_SPIN_BUTTON(ptr_window->saisie_pas),0.7);
  gtk_box_pack_start(GTK_BOX(ptr_window->hbox_saisie), ptr_window->saisie_pas, FALSE, TRUE, 0);

  ptr_window->lbl_saisie_period = gtk_label_new(" Periodes : ");
  gtk_box_pack_start(GTK_BOX(ptr_window->hbox_saisie), ptr_window->lbl_saisie_period, FALSE, TRUE, 0);
  ptr_window->saisie_period = gtk_spin_button_new_with_range(100,100000,1);
  gtk_spin_button_set_value(GTK_SPIN_BUTTON(ptr_window->saisie_period),10000.0);
  gtk_box_pack_start(GTK_BOX(ptr_window->hbox_saisie), ptr_window->saisie_period, FALSE, TRUE, 0);
  

  /* Création des boutons */
  ptr_window->hbox_btn = gtk_hbox_new(FALSE, 0);
  gtk_box_pack_start(GTK_BOX(ptr_window->vbox), ptr_window->hbox_btn, TRUE, TRUE, 0);
  
  ptr_window->btn_aj = gtk_button_new_with_label("Ajouter l'exemple");
  g_signal_connect(G_OBJECT(ptr_window->btn_aj), "clicked", G_CALLBACK(ajouter_un_exemple), NULL);
  gtk_box_pack_start(GTK_BOX(ptr_window->hbox_btn), ptr_window->btn_aj, FALSE, TRUE, 0);
  
  ptr_window->btn_del = gtk_button_new_with_label("Effacer le dessin");
  g_signal_connect(G_OBJECT(ptr_window->btn_del), "clicked", G_CALLBACK(zone_dessin_effacer), NULL);
  gtk_box_pack_start(GTK_BOX(ptr_window->hbox_btn), ptr_window->btn_del, FALSE, TRUE, 0);

  ptr_window->btn_app = gtk_button_new_with_label("Lancer l'apprentissage");
  g_signal_connect(G_OBJECT(ptr_window->btn_app), "clicked", G_CALLBACK(lancer_apprentissage), NULL);
  gtk_box_pack_start(GTK_BOX(ptr_window->hbox_btn), ptr_window->btn_app, FALSE, TRUE, 0);
  
  ptr_window->btn_ana = gtk_button_new_with_label("Reconnaitre le chiffre");
  g_signal_connect(G_OBJECT(ptr_window->btn_ana), "clicked", G_CALLBACK(reconnaitre_chiffre), NULL);
  gtk_box_pack_start(GTK_BOX(ptr_window->hbox_btn), ptr_window->btn_ana, FALSE, TRUE, 0);

  
  /* Affiche tout */
  gtk_widget_show_all(ptr_window->win);
 
  /* Creation du perceptron de 16x16 = 256 entrées avec 10 neurones*/
  pm = PERCEPTRONMONO_new(10,256);
  
}
Exemplo n.º 17
0
static void spamassassin_create_widget_func(PrefsPage * _page,
					    GtkWindow * window,
					    gpointer data)
{
	struct SpamAssassinPage *page = (struct SpamAssassinPage *) _page;
	SpamAssassinConfig *config;
	guint i, active;

	GtkWidget *vbox1, *vbox2;
	GtkWidget *frame_transport, *table_transport, *vbox_transport;
	GtkWidget *hbox_spamd, *hbox_max_size, *hbox_timeout;
	GtkWidget *hbox_process_emails, *hbox_save_spam;
	GtkWidget *hbox_mark_as_read, *hbox_whitelist;
	GtkWidget *whitelist_ab_checkbtn;
	GtkWidget *whitelist_ab_folder_combo;
	GtkWidget *whitelist_ab_select_btn;

	GtkWidget *enable_sa_checkbtn;

	GtkWidget *transport_label;
	GtkWidget *transport_optmenu;

	GtkWidget *user_label;
	GtkWidget *user_entry;

	GtkWidget *spamd_label;
	GtkWidget *spamd_hostname_entry;
	GtkWidget *spamd_colon_label;
	GtkAdjustment *spamd_port_spinbtn_adj;
	GtkWidget *spamd_port_spinbtn;
	GtkWidget *spamd_socket_entry;

	GtkWidget *max_size_label;
	GtkAdjustment *max_size_spinbtn_adj;
	GtkWidget *max_size_spinbtn;
	GtkWidget *max_size_kb_label;

	GtkWidget *timeout_label;
	GtkAdjustment *timeout_spinbtn_adj;
	GtkWidget *timeout_spinbtn;
	GtkWidget *timeout_seconds_label;

	GtkWidget *process_emails_checkbtn;

	GtkWidget *save_spam_checkbtn;
	GtkWidget *save_spam_folder_entry;
	GtkWidget *save_spam_folder_select;

	GtkWidget *mark_as_read_checkbtn;

	GtkListStore *store;
	GtkCellRenderer *renderer;
	GtkTreeIter iter;

	vbox1 = gtk_vbox_new (FALSE, VSPACING);
	gtk_widget_show (vbox1);
	gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);

	vbox2 = gtk_vbox_new (FALSE, 4);
	gtk_widget_show (vbox2);
	gtk_box_pack_start (GTK_BOX (vbox1), vbox2, FALSE, FALSE, 0);

	enable_sa_checkbtn = gtk_check_button_new_with_label(_("Enable SpamAssassin plugin"));
	gtk_widget_show(enable_sa_checkbtn);
	gtk_box_pack_start(GTK_BOX(vbox2), enable_sa_checkbtn, TRUE, TRUE, 0);

	vbox_transport = gtkut_get_options_frame(vbox2, &frame_transport, _("Transport"));

	table_transport = gtk_table_new (3, 3, FALSE);
	gtk_widget_show (table_transport);
	gtk_box_pack_start(GTK_BOX(vbox_transport), table_transport, TRUE, TRUE, 0);
	gtk_table_set_row_spacings (GTK_TABLE (table_transport), 4);
	gtk_table_set_col_spacings (GTK_TABLE (table_transport), 8);

	transport_label = gtk_label_new(_("Type of transport"));
	gtk_widget_show(transport_label);
	gtk_table_attach (GTK_TABLE (table_transport), transport_label, 0, 1, 0, 1,
			(GtkAttachOptions) (GTK_FILL),
			(GtkAttachOptions) (0), 0, 0);
	gtk_label_set_justify(GTK_LABEL(transport_label), GTK_JUSTIFY_RIGHT);
	gtk_misc_set_alignment(GTK_MISC(transport_label), 1, 0.5);

	store = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_POINTER);
	transport_optmenu = gtk_combo_box_new_with_model(GTK_TREE_MODEL(store));
	renderer = gtk_cell_renderer_text_new();
	gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(transport_optmenu),
				   renderer, TRUE);
	gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(transport_optmenu),
				       renderer, "text", 0, NULL);
	gtk_widget_show(transport_optmenu);

	gtk_table_attach (GTK_TABLE (table_transport), transport_optmenu, 1, 2, 0, 1,
			(GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
			(GtkAttachOptions) (0), 0, 0);

	user_label = gtk_label_new(_("User"));
	gtk_widget_show(user_label);
	gtk_table_attach (GTK_TABLE (table_transport), user_label, 0, 1, 1, 2,
			(GtkAttachOptions) (GTK_FILL),
			(GtkAttachOptions) (0), 0, 0);
	gtk_label_set_justify(GTK_LABEL(user_label), GTK_JUSTIFY_RIGHT);
	gtk_misc_set_alignment(GTK_MISC(user_label), 1, 0.5);

	user_entry = gtk_entry_new();
	gtk_widget_show(user_entry);
	gtk_table_attach (GTK_TABLE (table_transport), user_entry, 1, 2, 1, 2,
			(GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
			(GtkAttachOptions) (0), 0, 0);
	CLAWS_SET_TIP(user_entry, _("User to use with spamd server"));

	spamd_label = gtk_label_new(_("spamd"));
	gtk_widget_show(spamd_label);
	gtk_table_attach (GTK_TABLE (table_transport), spamd_label, 0, 1, 2, 3,
			(GtkAttachOptions) (GTK_FILL),
			(GtkAttachOptions) (0), 0, 0);
	gtk_label_set_justify(GTK_LABEL(spamd_label), GTK_JUSTIFY_RIGHT);
	gtk_misc_set_alignment(GTK_MISC(spamd_label), 1, 0.5);

	hbox_spamd = gtk_hbox_new(FALSE, 8);
	gtk_widget_show(hbox_spamd);
	gtk_table_attach (GTK_TABLE (table_transport), hbox_spamd, 1, 2, 2, 3,
			(GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
			(GtkAttachOptions) (0), 0, 0);

	spamd_hostname_entry = gtk_entry_new();
	gtk_widget_show(spamd_hostname_entry);
	gtk_box_pack_start(GTK_BOX(hbox_spamd), spamd_hostname_entry, TRUE, TRUE, 0);
	CLAWS_SET_TIP(spamd_hostname_entry,
			_("Hostname or IP address of spamd server"));

	spamd_colon_label = gtk_label_new(":");
	gtk_widget_show(spamd_colon_label);
	gtk_box_pack_start(GTK_BOX(hbox_spamd), spamd_colon_label, FALSE, FALSE, 0);

	spamd_port_spinbtn_adj = GTK_ADJUSTMENT(gtk_adjustment_new(783, 1, 65535, 1, 10, 0));
	spamd_port_spinbtn = gtk_spin_button_new(GTK_ADJUSTMENT(spamd_port_spinbtn_adj), 1, 0);
	gtk_widget_show(spamd_port_spinbtn);
	gtk_box_pack_start(GTK_BOX(hbox_spamd), spamd_port_spinbtn, FALSE, FALSE, 0);
	CLAWS_SET_TIP(spamd_port_spinbtn,
			_("Port of spamd server"));
	gtk_spin_button_set_numeric(GTK_SPIN_BUTTON(spamd_port_spinbtn), TRUE);

	spamd_socket_entry = gtk_entry_new();
	gtk_widget_show(spamd_socket_entry);
	gtk_box_pack_start(GTK_BOX(hbox_spamd), spamd_socket_entry, TRUE, TRUE, 0);
	CLAWS_SET_TIP(spamd_socket_entry, _("Path of Unix socket"));

	hbox_max_size = gtk_hbox_new(FALSE, 8);
	gtk_widget_show(hbox_max_size);
	gtk_box_pack_start (GTK_BOX (vbox2), hbox_max_size, TRUE, TRUE, 0);

	max_size_label = gtk_label_new(_("Maximum size"));
	gtk_widget_show(max_size_label);
	gtk_box_pack_start(GTK_BOX(hbox_max_size), max_size_label, FALSE, FALSE, 0);

	max_size_spinbtn_adj = GTK_ADJUSTMENT(gtk_adjustment_new(250, 0, 10000, 10, 10, 0));
	max_size_spinbtn = gtk_spin_button_new(GTK_ADJUSTMENT(max_size_spinbtn_adj), 1, 0);
	gtk_widget_show(max_size_spinbtn);
	gtk_box_pack_start(GTK_BOX(hbox_max_size), max_size_spinbtn, FALSE, FALSE, 0);
	CLAWS_SET_TIP(max_size_spinbtn,
			_("Messages larger than this will not be checked"));
	gtk_spin_button_set_numeric(GTK_SPIN_BUTTON(max_size_spinbtn), TRUE);

	max_size_kb_label = gtk_label_new(_("KB"));
	gtk_widget_show(max_size_kb_label);
	gtk_box_pack_start(GTK_BOX(hbox_max_size), max_size_kb_label, FALSE, FALSE, 0);

	hbox_timeout = gtk_hbox_new(FALSE, 8);
	gtk_widget_show(hbox_timeout);
	gtk_box_pack_start (GTK_BOX (vbox2), hbox_timeout, TRUE, TRUE, 0);

	timeout_label = gtk_label_new(_("Timeout"));
	gtk_widget_show(timeout_label);
	gtk_box_pack_start(GTK_BOX(hbox_timeout), timeout_label, FALSE, FALSE, 0);

	timeout_spinbtn_adj = GTK_ADJUSTMENT(gtk_adjustment_new(60, 0, 10000, 10, 10, 0));
	timeout_spinbtn = gtk_spin_button_new(GTK_ADJUSTMENT(timeout_spinbtn_adj), 1, 0);
	gtk_widget_show(timeout_spinbtn);
	gtk_box_pack_start(GTK_BOX(hbox_timeout), timeout_spinbtn, FALSE, FALSE, 0);
	CLAWS_SET_TIP(timeout_spinbtn,
			_("Maximum time allowed for checking. If the check takes longer "
				"it will be aborted."));
	gtk_spin_button_set_numeric(GTK_SPIN_BUTTON(timeout_spinbtn), TRUE);

	timeout_seconds_label = gtk_label_new(_("seconds"));
	gtk_widget_show(timeout_seconds_label);
	gtk_box_pack_start(GTK_BOX(hbox_timeout), timeout_seconds_label, FALSE, FALSE, 0);

	hbox_process_emails = gtk_hbox_new(FALSE, 8);
	gtk_widget_show(hbox_process_emails);
	gtk_box_pack_start (GTK_BOX (vbox2), hbox_process_emails, TRUE, TRUE, 0);

	process_emails_checkbtn = gtk_check_button_new_with_label(
			_("Process messages on receiving"));
	gtk_widget_show(process_emails_checkbtn);
	gtk_box_pack_start(GTK_BOX(hbox_process_emails), process_emails_checkbtn, TRUE, TRUE, 0);

	hbox_save_spam = gtk_hbox_new(FALSE, 8);
	gtk_widget_show(hbox_save_spam);
	gtk_box_pack_start (GTK_BOX (vbox2), hbox_save_spam, TRUE, TRUE, 0);

	save_spam_checkbtn = gtk_check_button_new_with_label(_("Save spam in"));
	gtk_widget_show(save_spam_checkbtn);
	gtk_box_pack_start(GTK_BOX(hbox_save_spam), save_spam_checkbtn, FALSE, FALSE, 0);

	save_spam_folder_entry = gtk_entry_new();
	gtk_widget_show (save_spam_folder_entry);
	gtk_box_pack_start (GTK_BOX (hbox_save_spam), save_spam_folder_entry, TRUE, TRUE, 0);
	CLAWS_SET_TIP(save_spam_folder_entry,
			_("Folder for storing identified spam. Leave empty to use the trash folder."));

	save_spam_folder_select = gtkut_get_browse_directory_btn(_("_Browse"));
	gtk_widget_show (save_spam_folder_select);
	gtk_box_pack_start (GTK_BOX (hbox_save_spam), save_spam_folder_select, FALSE, FALSE, 0);
	CLAWS_SET_TIP(save_spam_folder_select,
			_("Click this button to select a folder for storing spam"));

	hbox_mark_as_read = gtk_hbox_new(FALSE, 8);
	gtk_widget_show(hbox_mark_as_read);
	gtk_box_pack_start (GTK_BOX (vbox2), hbox_mark_as_read, TRUE, TRUE, 0);

	mark_as_read_checkbtn = gtk_check_button_new_with_label(
			_("Mark spam as read"));
	gtk_widget_show(mark_as_read_checkbtn);
	gtk_box_pack_start(GTK_BOX(hbox_mark_as_read), mark_as_read_checkbtn, TRUE, TRUE, 0);

	hbox_whitelist = gtk_hbox_new(FALSE, 8);
	gtk_widget_show(hbox_whitelist);
	gtk_box_pack_start (GTK_BOX (vbox2), hbox_whitelist, TRUE, TRUE, 0);

	whitelist_ab_checkbtn = gtk_check_button_new_with_label(_("Whitelist senders found in address book/folder"));
	gtk_widget_show(whitelist_ab_checkbtn);
	gtk_box_pack_start(GTK_BOX(hbox_whitelist), whitelist_ab_checkbtn, FALSE, FALSE, 0);
	CLAWS_SET_TIP(whitelist_ab_checkbtn,
			_("Messages coming from your address book contacts will be received in the normal folder even if detected as spam"));

	whitelist_ab_folder_combo = combobox_text_new(TRUE, _("Any"), NULL);
	gtk_widget_set_size_request(whitelist_ab_folder_combo, 100, -1);
	gtk_box_pack_start (GTK_BOX (hbox_whitelist), whitelist_ab_folder_combo, TRUE, TRUE, 0);

	whitelist_ab_select_btn = gtk_button_new_with_label(_("Select..."));
	gtk_widget_show (whitelist_ab_select_btn);
	gtk_box_pack_start (GTK_BOX (hbox_whitelist), whitelist_ab_select_btn, FALSE, FALSE, 0);
	CLAWS_SET_TIP(whitelist_ab_select_btn,
			_("Click this button to select a book or folder in the address book"));

	SET_TOGGLE_SENSITIVITY(enable_sa_checkbtn, frame_transport);
	SET_TOGGLE_SENSITIVITY(enable_sa_checkbtn, hbox_max_size);
	SET_TOGGLE_SENSITIVITY(enable_sa_checkbtn, hbox_timeout);
	SET_TOGGLE_SENSITIVITY(enable_sa_checkbtn, hbox_save_spam);
	SET_TOGGLE_SENSITIVITY(save_spam_checkbtn, save_spam_folder_entry);
	SET_TOGGLE_SENSITIVITY(save_spam_checkbtn, save_spam_folder_select);
	SET_TOGGLE_SENSITIVITY(enable_sa_checkbtn, hbox_process_emails);
	SET_TOGGLE_SENSITIVITY(save_spam_checkbtn, mark_as_read_checkbtn);
	SET_TOGGLE_SENSITIVITY(whitelist_ab_checkbtn, whitelist_ab_folder_combo);
#ifndef USE_NEW_ADDRBOOK
	SET_TOGGLE_SENSITIVITY(whitelist_ab_checkbtn, whitelist_ab_select_btn);
#endif
	config = spamassassin_get_config();

	g_signal_connect(G_OBJECT(save_spam_folder_select), "clicked",
			G_CALLBACK(foldersel_cb), page);
#ifndef USE_NEW_ADDRBOOK
	g_signal_connect(G_OBJECT (whitelist_ab_select_btn), "clicked",
			 G_CALLBACK(spamassassin_whitelist_ab_select_cb), page);
#else
	gtk_widget_set_sensitive(GTK_WIDGET(whitelist_ab_select_btn), FALSE);
#endif

	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(enable_sa_checkbtn), config->enable);
	if (config->username != NULL)
		gtk_entry_set_text(GTK_ENTRY(user_entry), config->username);
	if (config->hostname != NULL)
		gtk_entry_set_text(GTK_ENTRY(spamd_hostname_entry), config->hostname);
	if (config->socket != NULL)
		gtk_entry_set_text(GTK_ENTRY(spamd_socket_entry), config->socket);
	if (config->whitelist_ab_folder != NULL) {
		/* translate "Any" (stored UNtranslated) */
		if (strcasecmp(config->whitelist_ab_folder, "Any") == 0)
			gtk_entry_set_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN((whitelist_ab_folder_combo)))),
					config->whitelist_ab_folder);
		else
		/* backward compatibility (when translated "Any" was stored) */
		if (g_utf8_collate(config->whitelist_ab_folder, _("Any")) == 0)
			gtk_entry_set_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN((whitelist_ab_folder_combo)))),
					config->whitelist_ab_folder);
		else
			gtk_entry_set_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN((whitelist_ab_folder_combo)))),
					config->whitelist_ab_folder);
	}
	gtk_spin_button_set_value(GTK_SPIN_BUTTON(spamd_port_spinbtn), (float) config->port);
	gtk_spin_button_set_value(GTK_SPIN_BUTTON(max_size_spinbtn), (float) config->max_size);
	gtk_spin_button_set_value(GTK_SPIN_BUTTON(timeout_spinbtn), (float) config->timeout);
	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(process_emails_checkbtn), config->process_emails);
	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(save_spam_checkbtn), config->receive_spam);
	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(whitelist_ab_checkbtn), config->whitelist_ab);
	if (config->save_folder != NULL)
		gtk_entry_set_text(GTK_ENTRY(save_spam_folder_entry), config->save_folder);
	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(mark_as_read_checkbtn), config->mark_as_read);

	page->enable_sa_checkbtn = enable_sa_checkbtn;
	page->transport_label = transport_label;
	page->transport_optmenu = transport_optmenu;
	page->username = user_entry;
	page->hostname = spamd_hostname_entry;
	page->colon = spamd_colon_label;
	page->port = spamd_port_spinbtn;
	page->socket = spamd_socket_entry;
	page->max_size = max_size_spinbtn;
	page->timeout = timeout_spinbtn;
	page->process_emails = process_emails_checkbtn;
	page->receive_spam = save_spam_checkbtn;
	page->save_folder = save_spam_folder_entry;
	page->save_folder_select = save_spam_folder_select;
	page->mark_as_read = mark_as_read_checkbtn;
	page->whitelist_ab = whitelist_ab_checkbtn;
	page->whitelist_ab_folder_combo = whitelist_ab_folder_combo;

	active = 0;
	for (i = 0; i < (sizeof(transports) / sizeof(struct Transport)); i++) {
		
		gtk_list_store_append(store, &iter);
		gtk_list_store_set(store, &iter,
				   0, gettext(transports[i].name),
				   1, &transports[i], -1);

		if (config->transport == transports[i].transport) {
			show_transport(page, &transports[i]);
			active = i;
		} else if (config->transport == SPAMASSASSIN_DISABLED 
			&& transports[i].transport == SPAMASSASSIN_TRANSPORT_LOCALHOST) {
			show_transport(page, &transports[i]);
			active = i;
			/* and disable via new way */
			config->enable = FALSE;
			gtk_toggle_button_set_active(
				GTK_TOGGLE_BUTTON(enable_sa_checkbtn), 
				config->enable);
		}
	}
	gtk_combo_box_set_active(GTK_COMBO_BOX(transport_optmenu), active);
	g_signal_connect(G_OBJECT(transport_optmenu), "changed",
			 G_CALLBACK(transport_sel_cb), page);

	page->page.widget = vbox1;
}
Exemplo n.º 18
0
/* 
   Appellée si on clique sur "Ajouter l'exemple"

   L'ajout d'un exemple se fait en plusieurs étapes :

   1) On applique la fonction de pré-traitement sur l'image, on stocke la nouvelle image dans un buffer. (buf_pre)

   2) A partir cette image, on récupère le vecteur caractéristique qui correspond en fait à la matrice de l'image.

   3) Ensuite on récupère la valeur numérique du chiffre saisie, on en déduit alors le vecteur de sortie.

   4) On sauvegarde alors l'exemple (vecteur caractéristique + vecteur de sortie) dans la base de connaissances.

*/
gboolean ajouter_un_exemple(GtkWidget *w, GdkEventMotion *e, gpointer data)
{
  Exemple * ex = NULL;
  gint i,j,k = 0;

  gdouble s = 0.0;
  gint chiffre = 0;
  guchar * txt = NULL;

  printf("<AJOUTER>\n");

  if(BASECONNAISSANCE_est_pleine(pm->bc) == FALSE)
    {
      ex = EXEMPLE_new(buf_pre->width * buf_pre->height,pm->nb_neurone);
      if(ex==NULL) { printf("erreur\n"); return FALSE; }
  
      maj_barre_progression(0.2);

      // Pré-traitement : échantillonage
      IMAGE_echantillonnage(ptr_draw_area->buffer,buf_pre);

      maj_barre_progression(0.4);
      
      // Recupération du vecteur caractéristique et affichage
      printf("Vecteur caractéristique:\n");
      for(i=0;i<buf_pre->width;i++)
	{
	  for(j=0;j<buf_pre->height;j++)
	    {
	      s = (gdouble) 1.0 - (buf_pre->mat[(j*(buf_pre->width)+i)]/255);
	      printf("%.1f ",s);
	      ex->vecCarac->c[k] = s;
	      k++;
	    }
	  printf("\n");
	}
      
      maj_barre_progression(0.6);
      
      // Récupération de la valeur du chiffre écrit
      printf("Vecteur de sortie:\n");
      chiffre = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(ptr_window->saisie_chiffre));
      ex->vecSortie->c[chiffre] = 1.0;

      VECTEUR_afficher(ex->vecSortie);

      maj_barre_progression(0.8);
      
      // Sauvegarde de l'exemple dans la base
      BASECONNAISSANCE_ajouter(pm->bc,ex);
      
      // Mise a jour des informations
      nb_exemples_par_chiffre[chiffre]++;
      maj_infos();

      maj_barre_progression(1.0);
      maj_barre_progression(0.0);
      
      return TRUE;
    }
  else
    {
      printf("Base de connaissances pleine\n");
    }
}
Exemplo n.º 19
0
static void rssyl_gtk_prop_store(RFolderItem *ritem)
{
	gchar *url, *auth_user, *auth_pass;
	gint x, old_ri, old_fetch_comments;
	gboolean use_default_ri = FALSE, keep_old = FALSE;
	FolderItem *item;

	g_return_if_fail(ritem != NULL);
	g_return_if_fail(ritem->feedprop != NULL);

	url = (gchar *)gtk_entry_get_text(GTK_ENTRY(ritem->feedprop->url));

	if( strlen(url) ) {
		if( ritem->url ) {
			g_free(ritem->url);
		}
		ritem->url = g_strdup(url);
	}

	ritem->auth->type = gtk_combo_box_get_active(GTK_COMBO_BOX(ritem->feedprop->auth_type));

	auth_user = (gchar *)gtk_entry_get_text(GTK_ENTRY(ritem->feedprop->auth_username));
	if (auth_user != NULL) {
		if (ritem->auth->username) {
			g_free(ritem->auth->username);
		}
		ritem->auth->username = g_strdup(auth_user);
	}

	auth_pass = (gchar *)gtk_entry_get_text(GTK_ENTRY(ritem->feedprop->auth_password));
	if (auth_pass != NULL) {
		if (ritem->auth->password) {
			g_free(ritem->auth->password);
		}
		ritem->auth->password = g_strdup(auth_pass);
	}

	use_default_ri = gtk_toggle_button_get_active(
			GTK_TOGGLE_BUTTON(ritem->feedprop->default_refresh_interval));
	ritem->default_refresh_interval = use_default_ri;
	debug_print("store: default refresh interval is %s\n",
			( use_default_ri ? "ON" : "OFF" ) );

	/* Use default if checkbutton is set */
	if( use_default_ri )
		x = rssyl_prefs_get()->refresh;
	else
		x = gtk_spin_button_get_value_as_int(
				GTK_SPIN_BUTTON(ritem->feedprop->refresh_interval) );

	old_ri = ritem->refresh_interval;
	ritem->refresh_interval = x;

	/* Set timer for next automatic refresh, if needed. */
	if( x > 0 ) {
		if( old_ri != x || ritem->refresh_id == 0 ) {
			debug_print("RSSyl: GTK - refresh interval changed to %d , updating "
					"timeout\n", ritem->refresh_interval);
			rssyl_feed_start_refresh_timeout(ritem);
		}
	} else
		ritem->refresh_id = 0;

	old_fetch_comments = ritem->fetch_comments;
	ritem->fetch_comments = gtk_toggle_button_get_active(
			GTK_TOGGLE_BUTTON(ritem->feedprop->fetch_comments));

	if (!old_fetch_comments && ritem->fetch_comments) {
		/* reset the RFolderItem's mtime to be sure we get all 
		 * available comments */
		 ritem->item.mtime = 0;
	}
	
	ritem->fetch_comments_max_age = gtk_spin_button_get_value_as_int(
			GTK_SPIN_BUTTON(ritem->feedprop->fetch_comments_max_age));

	keep_old = gtk_toggle_button_get_active(
			GTK_TOGGLE_BUTTON(ritem->feedprop->keep_old));
	ritem->keep_old = keep_old;

	ritem->silent_update =
		gtk_combo_box_get_active(GTK_COMBO_BOX(ritem->feedprop->silent_update));

	ritem->write_heading = gtk_toggle_button_get_active(
			GTK_TOGGLE_BUTTON(ritem->feedprop->write_heading));

	ritem->ignore_title_rename = gtk_toggle_button_get_active(
			GTK_TOGGLE_BUTTON(ritem->feedprop->ignore_title_rename));

	ritem->ssl_verify_peer = gtk_toggle_button_get_active(
			GTK_TOGGLE_BUTTON(ritem->feedprop->ssl_verify_peer));

	/* Store updated properties */
	item = &ritem->item;
	item->folder->klass->item_get_xml(item->folder, item);
}
Exemplo n.º 20
0
/*
  Pour un descriptif détaillé de l'algorithme voir le rapport
*/
gboolean lancer_apprentissage(GtkWidget *w, GdkEventMotion *e, gpointer data)
{
  gint i,j,k;
  gint erreurs = 1;
  gint nb_essais = 0;
  gint egaux = 0;
  gint max_periode = 10000;

  gdouble nouveau_poids = 0.0;
  gdouble pas = 0.7;
  gdouble pourcentage_effectue = 0.0,pour_pas = .0;
  
  Exemple * exemple_courant = NULL;
  Vecteur * sortie_desiree = NULL;
  Vecteur * vecteur_carac = NULL;
  Vecteur * sortie_obtenue = NULL;

  printf("<APPRENTISSAGE EN COURS>\n");
  fflush(stdout);

  max_periode = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(ptr_window->saisie_period));
  pas = gtk_spin_button_get_value(GTK_SPIN_BUTTON(ptr_window->saisie_pas));

  printf("pas = %f , period = %d\n",pas,max_periode);
  fflush(stdout);
  
  while((erreurs == 1) && (nb_essais<max_periode))
    {
      pourcentage_effectue = (gdouble) nb_essais/max_periode;

      if(pourcentage_effectue >= pour_pas)
	{
	  maj_barre_progression(pourcentage_effectue);
	  pour_pas += .1;
	}

      // On envoie au réseau tous les exemples contenus dans la base
      for(i=0;i<pm->bc->nb;i++)
	{
	  exemple_courant = pm->bc->exs[i];
	  
	  sortie_desiree = exemple_courant->vecSortie;
	  vecteur_carac = exemple_courant->vecCarac;

	  sortie_obtenue = PERCEPTRONMONO_calculer_sortie(pm,vecteur_carac);

	  VECTEUR_egaux(sortie_obtenue,sortie_desiree,&egaux);

	  if(egaux == 0)
	    {
	      // Pour chaque neurone du perceptron
	      for(j=0;j<pm->nb_neurone;j++)
		{
		  // On modifie ses poids
		  for(k=0;k<pm->neurones[j]->nb_poids;k++)
		    {
		      nouveau_poids = pm->neurones[j]->poids->c[k] + pas * (sortie_desiree->c[j] - sortie_obtenue->c[j]) * vecteur_carac->c[k];
		      pm->neurones[j]->poids->c[k] = nouveau_poids;
		    }
		}

	      erreurs = 1;
	    }

	  VECTEUR_free(sortie_obtenue);
	}

      nb_essais++;
    }
  

  printf("<TERMINE>\n");
  maj_barre_progression(0.0);

  return TRUE;
}
void SurfaceDlg::SetTexMods(){
	texdef_t *pt;
	brushprimit_texdef_t  *bpt;
	// local copy if a width=2 height=2 qtetxture_t is needed
	brushprimit_texdef_t local_bp;

#ifdef DBG_SI
	Sys_Printf( "SurfaceDlg::SetTexMods\n" );
#endif

	if ( !g_surfwin ) {
		return;
	}

	if ( g_ptrSelectedFaces.GetSize() > 0 ) {
		face_t *selFace = reinterpret_cast<face_t*>( g_ptrSelectedFaces.GetAt( 0 ) );
		pt = &selFace->texdef;
		if ( g_qeglobals.m_bBrushPrimitMode ) {
			// compute a texture matrix related to the default matrix width=2 height=2
			ConvertTexMatWithQTexture( &selFace->brushprimit_texdef, selFace->d_texture, &local_bp, NULL );
			bpt = &local_bp;
		}
	}
	else
	{
		pt = &g_qeglobals.d_texturewin.texdef;
		if ( g_qeglobals.m_bBrushPrimitMode ) {
			bpt = &g_qeglobals.d_texturewin.brushprimit_texdef;
		}
	}
	// brush primitive mode : compute fake shift scale rot representation
	if ( g_qeglobals.m_bBrushPrimitMode ) {
		TexMatToFakeTexCoords( bpt->coords, m_shift, &m_rotate, m_scale );
	}

	g_bListenChanged = false;

	if ( strncmp( pt->GetName(), "textures/", 9 ) != 0 ) {
		pt->SetName( SHADER_NOT_FOUND );
	}
	gtk_entry_set_text( GTK_ENTRY( GetDlgWidget( "texture" ) ), pt->GetName() + 9 );

	GtkSpinButton *spin;
	spin = GTK_SPIN_BUTTON( GetDlgWidget( "hshift" ) );
	gtk_spin_button_set_digits( spin, 2 );
	if ( g_qeglobals.m_bBrushPrimitMode ) {
		gtk_spin_button_set_value( spin, m_shift[0] );
	}
	else{
		gtk_spin_button_set_value( spin, pt->shift[0] );
	}
	GtkAdjustment *adjust = gtk_spin_button_get_adjustment( GTK_SPIN_BUTTON( spin ) );
	adjust->step_increment = l_pIncrement->shift[0];
	char buf[10]; // got into snprintf paranoia after BoundChecker detected a stack overrun
#ifdef _WIN32
	// TTimo: THIS IS UGLY
#define snprintf _snprintf
#endif
	snprintf( buf, 10, "%g", l_pIncrement->shift[0] );
	gtk_entry_set_text( GTK_ENTRY( GetDlgWidget( "hshift_inc" ) ), buf );

	spin = GTK_SPIN_BUTTON( GetDlgWidget( "vshift" ) );
	gtk_spin_button_set_digits( spin, 2 );
	if ( g_qeglobals.m_bBrushPrimitMode ) {
		gtk_spin_button_set_value( spin, m_shift[1] );
	}
	else{
		gtk_spin_button_set_value( spin, pt->shift[1] );
	}
	adjust = gtk_spin_button_get_adjustment( GTK_SPIN_BUTTON( spin ) );
	adjust->step_increment = l_pIncrement->shift[1];
	snprintf( buf, 10, "%g", l_pIncrement->shift[1] );
	gtk_entry_set_text( GTK_ENTRY( GetDlgWidget( "vshift_inc" ) ), buf );

	spin = GTK_SPIN_BUTTON( GetDlgWidget( "hscale" ) );
	gtk_spin_button_set_digits( spin, 5 );
	gtk_spin_button_set_value( spin, g_qeglobals.m_bBrushPrimitMode ? m_scale[0] : pt->scale[0] );

	adjust = gtk_spin_button_get_adjustment( GTK_SPIN_BUTTON( spin ) );
	adjust->step_increment = l_pIncrement->scale[0];
	snprintf( buf, 10, "%g", l_pIncrement->scale[0] );
	gtk_entry_set_text( GTK_ENTRY( GetDlgWidget( "hscale_inc" ) ), buf );

	spin = GTK_SPIN_BUTTON( GetDlgWidget( "vscale" ) );
	gtk_spin_button_set_digits( spin, 5 );
	gtk_spin_button_set_value( spin, g_qeglobals.m_bBrushPrimitMode ? m_scale[1] : pt->scale[1] );

	adjust = gtk_spin_button_get_adjustment( GTK_SPIN_BUTTON( spin ) );
	adjust->step_increment = l_pIncrement->scale[1];
	snprintf( buf, 10, "%g", l_pIncrement->scale[1] );
	gtk_entry_set_text( GTK_ENTRY( GetDlgWidget( "vscale_inc" ) ), buf );

	//++timo compute BProtate as int ..
	spin = GTK_SPIN_BUTTON( GetDlgWidget( "rotate" ) );
	gtk_spin_button_set_digits( spin, 2 );
	gtk_spin_button_set_value( spin, g_qeglobals.m_bBrushPrimitMode ? m_rotate : pt->rotate );

	adjust = gtk_spin_button_get_adjustment( GTK_SPIN_BUTTON( spin ) );
	adjust->step_increment = l_pIncrement->rotate;
	snprintf( buf, 10, "%g", l_pIncrement->rotate );
	gtk_entry_set_text( GTK_ENTRY( GetDlgWidget( "rotate_inc" ) ), buf );

	g_bListenChanged = true;

	// undo tricks: set the undo id to zero so we don't attempt to undo something that does not belong to us
	m_nUndoId = 0;
	// store the current texdef as our escape route if user hits OnCancel
	g_old_texdef = g_qeglobals.d_texturewin.texdef;
	// reset the Enter key behaviour flag
	m_bEditingTextureWidget = false;
}
Exemplo n.º 22
0
static GtkWidget *
bezierline_get_properties(Bezierline *bezierline)
{
    GtkWidget *vbox;
    GtkWidget *hbox;
    GtkWidget *label;
    GtkWidget *color;
    GtkWidget *linestyle;
    GtkWidget *arrow;
    GtkWidget *line_width;
    GtkWidget *align;
    GtkAdjustment *adj;

    if (bezierline_properties_dialog == NULL) {
        bezierline_properties_dialog = g_new(BezierlinePropertiesDialog, 1);

        vbox = gtk_vbox_new(FALSE, 5);
        bezierline_properties_dialog->vbox = vbox;

        hbox = gtk_hbox_new(FALSE, 5);
        label = gtk_label_new(_("Line width:"));
        gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, TRUE, 0);
        gtk_widget_show (label);
        adj = (GtkAdjustment *) gtk_adjustment_new(0.1, 0.00, 10.0, 0.01, 0.0, 0.0);
        line_width = gtk_spin_button_new(adj, 1.0, 2);
        gtk_spin_button_set_wrap(GTK_SPIN_BUTTON(line_width), TRUE);
        gtk_spin_button_set_numeric(GTK_SPIN_BUTTON(line_width), TRUE);
        bezierline_properties_dialog->line_width = GTK_SPIN_BUTTON(line_width);
        gtk_box_pack_start(GTK_BOX (hbox), line_width, TRUE, TRUE, 0);
        gtk_widget_show (line_width);
        gtk_widget_show(hbox);
        gtk_box_pack_start (GTK_BOX(vbox), hbox, TRUE, TRUE, 0);

        hbox = gtk_hbox_new(FALSE, 5);
        label = gtk_label_new(_("Color:"));
        gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, TRUE, 0);
        gtk_widget_show (label);
        color = dia_color_selector_new();
        bezierline_properties_dialog->color = DIACOLORSELECTOR(color);
        gtk_box_pack_start (GTK_BOX (hbox), color, TRUE, TRUE, 0);
        gtk_widget_show (color);
        gtk_widget_show(hbox);
        gtk_box_pack_start (GTK_BOX(vbox), hbox, TRUE, TRUE, 0);

        hbox = gtk_hbox_new(FALSE, 5);
        label = gtk_label_new(_("Line style:"));
        gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, TRUE, 0);
        gtk_widget_show (label);
        linestyle = dia_line_style_selector_new();
        bezierline_properties_dialog->line_style = DIALINESTYLESELECTOR(linestyle);
        gtk_box_pack_start (GTK_BOX (hbox), linestyle, TRUE, TRUE, 0);
        gtk_widget_show (linestyle);
        gtk_widget_show(hbox);
        gtk_box_pack_start (GTK_BOX(vbox), hbox, TRUE, TRUE, 0);

        hbox = gtk_hbox_new(FALSE, 5);
        label = gtk_label_new(_("Start arrow:"));
        align = gtk_alignment_new(0.0,0.0,0.0,0.0);
        gtk_container_add(GTK_CONTAINER(align), label);
        gtk_box_pack_start (GTK_BOX (hbox), align, FALSE, TRUE, 0);
        gtk_widget_show (label);
        gtk_widget_show(align);
        arrow = dia_arrow_selector_new();
        bezierline_properties_dialog->start_arrow = DIAARROWSELECTOR(arrow);
        gtk_box_pack_start (GTK_BOX (hbox), arrow, TRUE, TRUE, 0);
        gtk_widget_show (arrow);
        gtk_widget_show(hbox);
        gtk_box_pack_start (GTK_BOX(vbox), hbox, TRUE, TRUE, 0);

        hbox = gtk_hbox_new(FALSE, 5);
        label = gtk_label_new(_("End arrow:"));
        align = gtk_alignment_new(0.0,0.0,0.0,0.0);
        gtk_container_add(GTK_CONTAINER(align), label);
        gtk_box_pack_start (GTK_BOX (hbox), align, FALSE, TRUE, 0);
        gtk_widget_show (label);
        gtk_widget_show(align);
        arrow = dia_arrow_selector_new();
        bezierline_properties_dialog->end_arrow = DIAARROWSELECTOR(arrow);
        gtk_box_pack_start (GTK_BOX (hbox), arrow, TRUE, TRUE, 0);
        gtk_widget_show (arrow);
        gtk_widget_show(hbox);
        gtk_box_pack_start (GTK_BOX(vbox), hbox, TRUE, TRUE, 0);

        gtk_widget_show (vbox);
    }

    bezierline_properties_dialog->bezierline = bezierline;

    gtk_spin_button_set_value(bezierline_properties_dialog->line_width,
                              bezierline->line_width);
    dia_color_selector_set_color(bezierline_properties_dialog->color,
                                 &bezierline->line_color);
    dia_line_style_selector_set_linestyle(bezierline_properties_dialog->line_style,
                                          bezierline->line_style,
                                          bezierline->dashlength);
    dia_arrow_selector_set_arrow(bezierline_properties_dialog->start_arrow,
                                 bezierline->start_arrow);
    dia_arrow_selector_set_arrow(bezierline_properties_dialog->end_arrow,
                                 bezierline->end_arrow);

    return bezierline_properties_dialog->vbox;
}
static GtkContainer *
maildir_get_setup_page( XfceMailwatchMailbox *mailbox )
{
    XfceMailwatchMaildirMailbox *maildir = XFCE_MAILWATCH_MAILDIR_MAILBOX( mailbox );
    GtkWidget                   *vbox, *hbox;
    GtkWidget                   *label;
    GtkWidget                   *button;
    GtkWidget                   *spin;
    GtkSizeGroup                *sg;

    DBG( "-->>" );

    vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, BORDER / 2 );
    gtk_widget_show( vbox );

    hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, BORDER );
    gtk_widget_show( hbox );
    gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 );

    sg = gtk_size_group_new( GTK_SIZE_GROUP_HORIZONTAL );

    label = gtk_label_new_with_mnemonic( _( "Maildir _Path:" ) );
    gtk_widget_show( label );
    gtk_box_pack_start( GTK_BOX( hbox ), label, FALSE, FALSE, 0 );
    gtk_size_group_add_widget( sg, label );

    button = gtk_file_chooser_button_new( _("Select Maildir Folder"),
                                          GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER );
    g_mutex_lock( maildir->mutex );
    if ( maildir->path ) {
        gtk_file_chooser_set_filename( GTK_FILE_CHOOSER( button ), maildir->path );
    }
    g_mutex_unlock( maildir->mutex );
    gtk_widget_show( button );
    gtk_box_pack_start( GTK_BOX( hbox ), button, TRUE, TRUE, 0 );
    g_signal_connect( G_OBJECT( button ), "file-set",
            G_CALLBACK( maildir_folder_set_cb ), maildir );

    gtk_label_set_mnemonic_widget( GTK_LABEL( label ), button );

    hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, BORDER );
    gtk_widget_show( hbox );
    gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 );

    label = gtk_label_new_with_mnemonic( _( "_Interval:" ) );
    gtk_widget_show( label );
    gtk_widget_set_halign(label, GTK_ALIGN_CENTER);
    gtk_box_pack_start( GTK_BOX( hbox ), label, FALSE, FALSE, 0 );
    gtk_size_group_add_widget( sg, label );

    spin = gtk_spin_button_new_with_range( 1.0, 1440.0, 1.0 );
    gtk_spin_button_set_numeric( GTK_SPIN_BUTTON( spin ), TRUE );
    gtk_spin_button_set_wrap( GTK_SPIN_BUTTON( spin ), FALSE );
    gtk_spin_button_set_value( GTK_SPIN_BUTTON( spin ), maildir->interval / 60 );
    gtk_widget_show( spin );
    gtk_box_pack_start( GTK_BOX( hbox ), spin, FALSE, FALSE, 0 );
    g_signal_connect( G_OBJECT( spin ), "value-changed",
            G_CALLBACK( maildir_interval_changed_cb ), maildir );
    gtk_label_set_mnemonic_widget( GTK_LABEL( label ), spin );

    label = gtk_label_new( _( "minute(s)." ) );
    gtk_widget_show( label );
    gtk_box_pack_start( GTK_BOX( hbox ), label, FALSE, FALSE, 0 );
    
    DBG( "<<--" );
    
    return ( GTK_CONTAINER( vbox ) );
}
Exemplo n.º 24
0
static void
time_out_configure (XfcePanelPlugin *plugin,
                    TimeOutPlugin   *time_out)
{
  GtkWidget *dialog;
  GtkWidget *framebox;
  GtkWidget *timebin;
  GtkWidget *behaviourbin;
  GtkWidget *appearancebin;
  GtkWidget *table;
  GtkWidget *vbox;
  GtkWidget *label;
  GtkWidget *spin;
  GtkWidget *checkbutton;

  g_return_if_fail (plugin != NULL);
  g_return_if_fail (time_out != NULL);

  /* Pause break timer for the time we're configuring */
  if (G_LIKELY (time_out_countdown_get_running (time_out->break_countdown)))
    time_out_countdown_pause (time_out->break_countdown);

  /* Block plugin context menu */
  xfce_panel_plugin_block_menu (plugin);

  /* Create properties dialog */
  dialog = xfce_titled_dialog_new_with_buttons (_("Time Out"),
                                                GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (plugin))),
                                                GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_NO_SEPARATOR,
                                                GTK_STOCK_CLOSE, GTK_RESPONSE_OK,
                                                NULL);

  /* Set dialog property */
  g_object_set_data (G_OBJECT (plugin), "dialog", dialog);

  /* Be notified when the properties dialog is closed */
  g_signal_connect (dialog, "response", G_CALLBACK (time_out_end_configure), time_out);

  /* Basic dialog window setup */
  gtk_window_set_icon_name (GTK_WINDOW (dialog), "xfce4-time-out-plugin");
  gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_CENTER);

  /* Create time settings section */
  framebox = xfce_gtk_frame_box_new (_("Time settings"), &timebin);
  gtk_container_set_border_width (GTK_CONTAINER (framebox), 6);
  gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), framebox, TRUE, TRUE, 0);
  gtk_widget_show (framebox);

  /* Create time settings table */
  table = gtk_table_new (3, 3, FALSE);
  gtk_table_set_row_spacings (GTK_TABLE (table), 6);
  gtk_table_set_col_spacings (GTK_TABLE (table), 12);
  gtk_container_add (GTK_CONTAINER (timebin), table);
  gtk_widget_show (table);

  /* Create the labels for the minutes and seconds spins */
  label = gtk_label_new (_("Minutes"));
  gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
  gtk_table_attach (GTK_TABLE (table), label, 1, 2, 0, 1, GTK_SHRINK, GTK_FILL, 1.0, 0.5);
  gtk_widget_show (label);

  label = gtk_label_new (_("Seconds"));
  gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
  gtk_table_attach (GTK_TABLE (table), label, 2, 3, 0, 1, GTK_SHRINK, GTK_FILL, 1.0, 0.5);
  gtk_widget_show (label);

  /* Create break countdown time label */
  label = gtk_label_new (_("Time between breaks:"));
  gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
  gtk_table_attach (GTK_TABLE (table), label, 0, 1, 1, 2, GTK_FILL, GTK_FILL, 1.0, 0.5);
  gtk_widget_show (label);

  /* Create break countdown time minute spin */
  spin = gtk_spin_button_new_with_range (1, 24 * 60, 1);
  gtk_spin_button_set_value (GTK_SPIN_BUTTON (spin), time_out->break_countdown_seconds / 60);
  gtk_table_attach (GTK_TABLE (table), spin, 1, 2, 1, 2, GTK_EXPAND | GTK_FILL, GTK_FILL, 0.0, 0.5);
  gtk_widget_show (spin);

  /* Store reference on the spin button in the plugin */
  g_object_set_data (G_OBJECT (time_out->plugin), "break-countdown-minutes-spin", spin);

  /* Create break countdown time minute spin */
  spin = gtk_spin_button_new_with_range (0, 59, 1);
  gtk_spin_button_set_value (GTK_SPIN_BUTTON (spin), time_out->break_countdown_seconds % 60);
  gtk_table_attach (GTK_TABLE (table), spin, 2, 3, 1, 2, GTK_EXPAND | GTK_FILL, GTK_FILL, 0.0, 0.5);
  gtk_widget_show (spin);

  /* Store reference on the spin button in the plugin */
  g_object_set_data (G_OBJECT (time_out->plugin), "break-countdown-seconds-spin", spin);

  /* Create lock countdown time label */
  label = gtk_label_new (_("Break length:"));
  gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
  gtk_table_attach (GTK_TABLE (table), label, 0, 1, 2, 3, GTK_FILL, GTK_FILL, 1.0, 0.5);
  gtk_widget_show (label);

  /* Create lock countdown time spins */
  spin = gtk_spin_button_new_with_range (0, 24 * 60, 1);
  gtk_spin_button_set_value (GTK_SPIN_BUTTON (spin), time_out->lock_countdown_seconds / 60);
  g_signal_connect (spin, "value-changed", G_CALLBACK (time_out_lock_countdown_minutes_changed), time_out);
  gtk_table_attach (GTK_TABLE (table), spin, 1, 2, 2, 3, GTK_EXPAND | GTK_FILL, GTK_FILL, 0.0, 0.5);
  gtk_widget_show (spin);
  spin = gtk_spin_button_new_with_range (0, 59, 1);
  gtk_spin_button_set_value (GTK_SPIN_BUTTON (spin), time_out->lock_countdown_seconds % 60);
  g_signal_connect (spin, "value-changed", G_CALLBACK (time_out_lock_countdown_seconds_changed), time_out);
  gtk_table_attach (GTK_TABLE (table), spin, 2, 3, 2, 3, GTK_EXPAND | GTK_FILL, GTK_FILL, 0.0, 0.5);
  gtk_widget_show (spin);

  /* Create postpone countdown time label */
  label = gtk_label_new (_("Postpone length:"));
  gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
  gtk_table_attach (GTK_TABLE (table), label, 0, 1, 3, 4, GTK_FILL, GTK_FILL, 1.0, 0.5);
  gtk_widget_show (label);

  /* Create postpone countdown time spins */
  spin = gtk_spin_button_new_with_range (0, 24 * 60, 1);
  gtk_spin_button_set_value (GTK_SPIN_BUTTON (spin), time_out->postpone_countdown_seconds / 60);
  g_signal_connect (spin, "value-changed", G_CALLBACK (time_out_postpone_countdown_minutes_changed), time_out);
  gtk_table_attach (GTK_TABLE (table), spin, 1, 2, 3, 4, GTK_EXPAND | GTK_FILL, GTK_FILL, 0.0, 0.5);
  gtk_widget_show (spin);
  spin = gtk_spin_button_new_with_range (0, 59, 1);
  gtk_spin_button_set_value (GTK_SPIN_BUTTON (spin), time_out->postpone_countdown_seconds % 60);
  g_signal_connect (spin, "value-changed", G_CALLBACK (time_out_postpone_countdown_seconds_changed), time_out);
  gtk_table_attach (GTK_TABLE (table), spin, 2, 3, 3, 4, GTK_EXPAND | GTK_FILL, GTK_FILL, 0.0, 0.5);
  gtk_widget_show (spin);

  /* Create behaviour section */
  framebox = xfce_gtk_frame_box_new (_("Behaviour"), &behaviourbin);
  gtk_container_set_border_width (GTK_CONTAINER (framebox), 6);
  gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), framebox, TRUE, TRUE, 0);
  gtk_widget_show (framebox);

  /* Create behaviour box */
  vbox = gtk_vbox_new (FALSE, 6);
  gtk_container_add (GTK_CONTAINER (behaviourbin), vbox);
  gtk_widget_show (vbox);

  /* Create postpone check button */
  checkbutton = gtk_check_button_new_with_label (_("Allow postpone"));
  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (checkbutton), time_out->allow_postpone);
  g_signal_connect (checkbutton, "toggled", G_CALLBACK (time_out_allow_postpone_toggled), time_out);
  gtk_container_add (GTK_CONTAINER (vbox), checkbutton);
  gtk_widget_show (checkbutton);

  /* Create resume check button */
  checkbutton = gtk_check_button_new_with_label (_("Resume automatically"));
  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (checkbutton), time_out->auto_resume);
  g_signal_connect (checkbutton, "toggled", G_CALLBACK (time_out_auto_resume_toggled), time_out);
  gtk_container_add (GTK_CONTAINER (vbox), checkbutton);
  gtk_widget_show (checkbutton);

  /* Create appearance section */
  framebox = xfce_gtk_frame_box_new (_("Appearance"), &appearancebin);
  gtk_container_set_border_width (GTK_CONTAINER (framebox), 6);
  gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), framebox, TRUE, TRUE, 0);
  gtk_widget_show (framebox);

  /* Create appearance box */
  vbox = gtk_vbox_new (FALSE, 6);
  gtk_container_add (GTK_CONTAINER (appearancebin), vbox);
  gtk_widget_show (vbox);

  /* Create note label */
  label = gtk_label_new(_("Note: Icon and time cannot be hidden simultaneously."));
  gtk_container_add (GTK_CONTAINER (vbox), label);
  gtk_widget_show(label);

  /* Create display icon check button */
  checkbutton = gtk_check_button_new_with_label (_("Display icon"));
  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (checkbutton), time_out->display_icon);
  g_signal_connect (checkbutton, "toggled", G_CALLBACK (time_out_display_icon_toggled), time_out);
  gtk_container_add (GTK_CONTAINER (vbox), checkbutton);
  gtk_widget_show (checkbutton);

  /* Create display time check button */
  checkbutton = gtk_check_button_new_with_label (_("Display remaining time in the panel"));
  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (checkbutton), time_out->display_time);
  g_signal_connect (checkbutton, "toggled", G_CALLBACK (time_out_display_time_toggled), time_out);
  gtk_container_add (GTK_CONTAINER (vbox), checkbutton);
  gtk_widget_show (checkbutton);

  /* Create display hours check button */
  checkbutton = gtk_check_button_new_with_label (_("Display hours"));
  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (checkbutton), time_out->display_hours);
  g_signal_connect (checkbutton, "toggled", G_CALLBACK (time_out_display_hours_toggled), time_out);
  gtk_container_add (GTK_CONTAINER (vbox), checkbutton);
  gtk_widget_show (checkbutton);

  /* Create display seconds check button */
  checkbutton = gtk_check_button_new_with_label (_("Display seconds"));
  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (checkbutton), time_out->display_seconds);
  g_signal_connect (checkbutton, "toggled", G_CALLBACK (time_out_display_seconds_toggled), time_out);
  gtk_container_add (GTK_CONTAINER (vbox), checkbutton);
  gtk_widget_show (checkbutton);

  /* Show the entire dialog */
  gtk_widget_show (dialog);
}
Exemplo n.º 25
0
/* create options window and fill it */
G_MODULE_EXPORT void
on_options1_activate                   (GtkMenuItem     *menuitem,
                                        gpointer         user_data)
{
	if (window_options)
		return;

	window_options = get_widget ("window_options");
	gtk_widget_show (window_options);

	/* Tab 1: Card display */
	GtkWidget *w = get_widget ("show_played_cards");
	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (w), win->show_played_cards);

	w = get_widget (win->hand_display_style == HAND_DISPLAY_STYLE_CARDS ?
			"show_as_cards" : "show_as_text");
	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (w), TRUE);

	w = get_widget ("svg_file");
	if (win->svg)
		gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (w), win->svg);

	w = get_widget ("spinbutton_card_width");
	GtkAdjustment *adj = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (w));
	gtk_adjustment_configure (adj, win->card_width,
			10, 10000, 10, 100, 0);

	/* Tab 2: Hands */
	switch (win->show_hands) {
		case seat_none: /* not yet implemented - is this useful? */
			w = get_widget ("show_hand_none");
			break;
		case east_west:
			w = get_widget ("show_hand_ew");
			break;
		case north_south:
			w = get_widget ("show_hand_ns");
			break;
		default:
			w = get_widget ("show_hand_all");
	}
	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (w), TRUE);

	switch (win->show_dd_scores) {
		case seat_none:
			w = get_widget ("show_dd_none");
			break;
		case east_west:
			w = get_widget ("show_dd_ew");
			break;
		case north_south:
			w = get_widget ("show_dd_ns");
			break;
		default:
			w = get_widget ("show_dd_all");
	}
	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (w), TRUE);

	/* Tab 3: Current board */
	window_options_board_populate ();

	/* Tab 4: Board list */
	if (! board_store) {
		board_store = gtk_list_store_new (2,
			G_TYPE_INT, G_TYPE_STRING);
	}

	w = get_widget ("board_list");
	gtk_tree_view_set_model (GTK_TREE_VIEW (w), GTK_TREE_MODEL (board_store));

	GtkCellRenderer *renderer;
	GtkTreeViewColumn *column;
	renderer = gtk_cell_renderer_text_new ();
	column = gtk_tree_view_column_new_with_attributes (
			_("#"), renderer, "markup", 0, NULL);
	gtk_tree_view_append_column (GTK_TREE_VIEW (w), column);

	renderer = gtk_cell_renderer_text_new ();
	column = gtk_tree_view_column_new_with_attributes (
			_("Title"), renderer, "markup", 1, NULL);
	gtk_tree_view_append_column (GTK_TREE_VIEW (w), column);

	/* Tab 5: Generate */
	w = get_widget ("options_generate_number");
	adj = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (w));
	gtk_adjustment_configure (adj, 1, 1, 10000, 1, 10, 0);

	window_options_board_list_populate ();
}
Exemplo n.º 26
0
static void 
start_recording (Viewer *self)
{
    if (self->is_recording) {
        err ("viewer: already recording!!\n");
        return;
    }

#ifndef USE_ZMOV
    assert (self->fb_area == NULL);
#endif
    assert (self->movie_buffer == NULL);

    int window_width = GTK_WIDGET (self->gl_area)->allocation.width;
    int window_height = GTK_WIDGET (self->gl_area)->allocation.height;

    self->movie_width = window_width - (window_width % 4);
    self->movie_height = window_height;
    self->movie_stride = self->movie_width * 3;
    self->movie_buffer = (uint8_t*) malloc (self->movie_stride * self->movie_height);
    self->movie_desired_fps = 1000.0 / gtk_spin_button_get_value (GTK_SPIN_BUTTON (self->fps_spin));
    self->movie_actual_fps = self->movie_desired_fps;
    self->movie_frame_last_utime = 0;

/*
    int wwidth, wheight;
    gtk_window_get_size(GTK_WINDOW(self->window), &wwidth, &wheight);
    printf("%5d, %5d\n", self->movie_width, self->movie_height);
    gtk_widget_set_size_request(GTK_WIDGET(self->gl_area), self->movie_width, self->movie_height);
    gtk_window_set_default_size(GTK_WINDOW(self->window), wwidth, wheight);
    gtk_widget_set_size_request(GTK_WIDGET(self->gl_area), self->movie_width, self->movie_height);
    gtk_window_set_resizable(GTK_WINDOW(self->window), FALSE);
*/

#ifdef USE_ZMOV

    self->movie_path = get_unique_filename(NULL, "viewer", 1, "ppms.gz");
    self->movie_gzf = gzopen(self->movie_path, "w");
    gzsetparams(self->movie_gzf, Z_BEST_SPEED, Z_DEFAULT_STRATEGY);

    if (self->movie_gzf == NULL)
        goto abort_recording;
    
    viewer_set_status_bar_message (self, "Recording to: %s", self->movie_path);

#else
    self->fb_area = fb_gl_drawing_area_new (FALSE, mov_width, mov_height, GL_BGR);
    if (!self->fb_area) {
        err ("Couldn't create FramebufferObject offscreen plugin\n");
        gtk_toggle_tool_button_set_active (
                GTK_TOGGLE_TOOL_BUTTON (self->record_button), FALSE);
        free (self->mov_bgr_buf);
        return;
    }

    assert(self->ezavi == NULL);

    ezavi_params_t avi_params = {
        .path = NULL,
        .file_prefix = "viewer",
        .date_in_file = 1,
        .codec = "raw",
        .width = mov_width,
        .height = mov_height,
        .src_stride = mov_width * 3,
        .frame_rate = 30,
        .split_point = 4000000000UL
    };

    self->ezavi = ezavi_new (&avi_params);
    if (!self->ezavi) { 
        err ("Couldn't create AVI file\n");
        goto abort_recording;
    }

    g_signal_connect (G_OBJECT(self->fb_area), "buffer-ready",
            G_CALLBACK (on_fb_ready), self->ezavi);

    viewer_set_status_bar_message (self, "Recording to: %s",
            ezavi_get_filename (self->ezavi));

#endif

    self->render_timer_id = g_timeout_add (1000 /
            gtk_spin_button_get_value (GTK_SPIN_BUTTON (self->fps_spin)),
            (GSourceFunc) on_render_timer, self);
    self->is_recording = 1;
    return;

abort_recording:
#ifndef USE_ZMOV
    g_object_unref (self->fb_area);
#endif
    gtk_toggle_tool_button_set_active (
            GTK_TOGGLE_TOOL_BUTTON (self->record_button),
            FALSE);
    free (self->mov_bgr_buf);
}

static void 
stop_recording (Viewer *self)
{
#ifndef USE_ZMOV
    if (!self->fb_area)
        return;
#endif

    free(self->movie_buffer);
    self->movie_buffer = NULL;

    dbg ("\nRecording stopped\n");
    viewer_set_status_bar_message (self, "Recording stopped");

#ifdef USE_ZMOV
    gzclose(self->movie_gzf);
    self->movie_gzf = NULL;
    free(self->movie_path);
    self->movie_draw_pending = 0;
#else
    fb_gl_drawing_area_flush (self->fb_area);
    ezavi_finish (self->ezavi);
    ezavi_destroy (self->ezavi);
    self->ezavi = NULL;
    g_object_unref (self->fb_area);
    self->fb_area = NULL;
#endif

    g_source_remove (self->render_timer_id);

    self->is_recording = 0;
    gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (self->record_button),
                                       FALSE);
//    gtk_window_set_resizable(GTK_WINDOW(self->window), TRUE);
}

static void update_status_bar(Viewer *viewer)
{
    char buf[1024];
    
    if (viewer->picking_handler && !viewer->picking_handler->picking)
        viewer->picking_handler = NULL;

    int vp[4] = {0,0,0,0};
    if (viewer->gl_area &&
            gtku_gl_drawing_area_set_context (viewer->gl_area) == 0) {
        glGetIntegerv(GL_VIEWPORT, vp);
    }
    int width = vp[2], height = vp[3];

    if (viewer->picking_handler)
        snprintf(buf, sizeof (buf), "%s%d x %d [%s]  %s", 
                (viewer->simulation_flag?"[SIM ENABLED] ":""), width, height, 
                 viewer->picking_handler->name,  viewer->status_bar_message);
    else
        snprintf(buf, sizeof (buf), "%s%d x %d [Idle] %s", 
                (viewer->simulation_flag?"[SIM ENABLED] ":""), width, height,
                 viewer->status_bar_message);

    gtk_statusbar_push(GTK_STATUSBAR(viewer->status_bar), 
                       gtk_statusbar_get_context_id(
                           GTK_STATUSBAR(viewer->status_bar),"info"), buf);
}
Exemplo n.º 27
0
/* set program data from options window */
static void
apply_options (GtkWidget *window_options)
{
	/* Card display */
	GtkWidget *w = get_widget ("show_played_cards");
	win->show_played_cards = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (w));

	w = get_widget ("show_as_cards");
	int style = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (w)) ?
		HAND_DISPLAY_STYLE_CARDS : HAND_DISPLAY_STYLE_TEXT;
	window_card_set_style (style);
	w = get_widget ("svg_file");
	gchar *fname = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (w));
	if (fname && strcmp (win->svg, fname)) { /* svg file changed */
		if (win->svg)
			g_free (win->svg);
		win->svg = fname;
	}
	w = get_widget ("spinbutton_card_width");
	int card_width = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (w));
	board_window_set_style (win, style, card_width);
	board_window_apply_style (win);

	/* Hands */
	if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON
		(get_widget ("show_dd_all"))))
	{
		win->show_dd_scores = seat_all;
	} else if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON
		(get_widget ("show_dd_ns"))))
	{
		win->show_dd_scores = north_south;
	} else if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON
		(get_widget ("show_dd_ew"))))
	{
		win->show_dd_scores = east_west;
	} else {
		win->show_dd_scores = seat_none;
	}

	if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON
		(get_widget ("show_hand_all"))))
	{
		win->show_hands = seat_all;
	} else if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON
		(get_widget ("show_hand_ns"))))
	{
		win->show_hands = north_south;
	} else {
		win->show_hands = east_west;
	}

	/* Current board */
	board *b = CUR_BOARD;
	w = get_widget ("entry_title");
	g_string_printf (b->name, "%s", gtk_entry_get_text (GTK_ENTRY (w)));
	int i;
	for (i = 0; i < 4; i++) {
		w = get_widget (entry_name[i]);
		g_string_printf (b->hand_name[i],
			"%s", gtk_entry_get_text (GTK_ENTRY (w)));
	}

	/* Board list */
	board **new_boards = malloc (win->n_boards_alloc * sizeof (board *));
	//int new_cur = 0;
	i = 0;
	GtkTreeIter iter;
	gtk_tree_model_get_iter_first (GTK_TREE_MODEL (board_store), &iter);
	do {
		GValue val = { 0 };
		gtk_tree_model_get_value (GTK_TREE_MODEL (board_store), &iter, 0, &val);
		int n = g_value_get_int (&val) - 1;
		assert (0 <= n && n < win->n_boards);
		new_boards[i] = win->boards[n];
		/*if (n == win->cur)
			new_cur = i;*/
		i++;
	} while (gtk_tree_model_iter_next (GTK_TREE_MODEL (board_store), &iter));
	free (win->boards);
	win->boards = new_boards;

	show_board(CUR_BOARD, REDRAW_HANDS | REDRAW_NAMES | REDRAW_CONTRACT |
			REDRAW_BOARD_LIST);
}
FormatDialog::FormatDialog(GladeSearchpath* gladeSearchPath, Settings* settings, double width, double heigth) :
		GladeGui(gladeSearchPath, "pagesize.glade", "pagesizeDialog")
{

	XOJ_INIT_TYPE(FormatDialog);

	this->orientation = ORIENTATION_NOT_DEFINED;
	this->selectedScale = 0;
	this->settings = settings;

	SElement& format = settings->getCustomElement("format");
	string unit;

	if (format.getString("unit", unit))
	{
		for (int i = 0; i < XOJ_UNIT_COUNT; i++)
		{
			if (unit == XOJ_UNITS[i].name)
			{
				this->selectedScale = i;
				break;
			}
		}
	}

	this->scale = XOJ_UNITS[this->selectedScale].scale;
	this->origHeight = heigth;
	this->origWidth = width;

	this->width = -1;
	this->height = -1;

	gtk_spin_button_set_value(GTK_SPIN_BUTTON(get("spinWidth")), this->origWidth / this->scale);
	gtk_spin_button_set_value(GTK_SPIN_BUTTON(get("spinHeight")), this->origHeight / this->scale);

	GtkWidget* cbUnit = get("cbUnit");
	GtkListStore* store = gtk_list_store_new(1, G_TYPE_STRING);
	gtk_combo_box_set_model(GTK_COMBO_BOX(cbUnit), GTK_TREE_MODEL(store));
	g_object_unref(store);

	GtkCellRenderer* cell = gtk_cell_renderer_text_new();
	gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(cbUnit), cell, TRUE);
	gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(cbUnit), cell, "text", 0, NULL);

	for (int i = 0; i < XOJ_UNIT_COUNT; i++)
	{
		gtk_combo_box_append_text(GTK_COMBO_BOX(cbUnit), XOJ_UNITS[i].name);
	}
	gtk_combo_box_set_active(GTK_COMBO_BOX(cbUnit), this->selectedScale);

	GtkWidget* cbTemplate = get("cbTemplate");
	store = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_POINTER);
	gtk_combo_box_set_model(GTK_COMBO_BOX(cbTemplate), GTK_TREE_MODEL(store));
	g_object_unref(store);

	cell = gtk_cell_renderer_text_new();
	gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(cbTemplate), cell, TRUE);
	gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(cbTemplate), cell, "text", 0, NULL);

	int selectedFormat = -1;

	string formatlist = settings->getVisiblePageFormats();

	if (heigth < width)
	{
		double tmp = width;
		width = heigth;
		heigth = tmp;
	}

	this->list = gtk_paper_size_get_paper_sizes(false);
	int i = 0;
	GList* next = NULL;
	for (GList* l = list; l != NULL; l = next)
	{
		GtkPaperSize* s = (GtkPaperSize*) l->data;
		next = l->next;

		double w = gtk_paper_size_get_width(s, GTK_UNIT_POINTS);
		double h = gtk_paper_size_get_height(s, GTK_UNIT_POINTS);

		bool visible = false;

		if (((int) (w - width) * 10) == 0 && ((int) (h - heigth) * 10) == 0)
		{
			selectedFormat = i;
			visible = true;
		}

		if (formatlist.find(gtk_paper_size_get_name(s)) != string::npos)
		{
			visible = true;
		}

		if (visible)
		{
			GtkTreeIter iter;
			gtk_list_store_append(store, &iter);
			gtk_list_store_set(store, &iter, 0, gtk_paper_size_get_display_name(s), -1);
			gtk_list_store_set(store, &iter, 1, s, -1);
			i++;
		}
		else
		{
			gtk_paper_size_free(s);
			this->list = g_list_delete_link(this->list, l);

		}
	}

	GtkTreeIter iter;
	gtk_list_store_append(store, &iter);
	gtk_list_store_set(store, &iter, 0, _C("Custom"), -1);
	gtk_list_store_set(store, &iter, 1, NULL, -1);

	// not found, select custom format
	if (selectedFormat == -1)
	{
		selectedFormat = i;
	}

	gtk_combo_box_set_active(GTK_COMBO_BOX(cbTemplate), selectedFormat);

	spinValueChangedCb(NULL, this);

	g_signal_connect(get("btLandscape"), "toggled", G_CALLBACK(landscapeSelectedCb), this);
	g_signal_connect(get("btPortrait"), "toggled", G_CALLBACK(portraitSelectedCb), this);
	g_signal_connect(cbTemplate, "changed", G_CALLBACK(cbFormatChangedCb), this);
	g_signal_connect(cbUnit, "changed", G_CALLBACK(cbUnitChanged), this);

	g_signal_connect(get("spinWidth"), "value-changed", G_CALLBACK(spinValueChangedCb), this);
	g_signal_connect(get("spinHeight"), "value-changed", G_CALLBACK(spinValueChangedCb), this);
}
Exemplo n.º 29
0
GtkWidget *
range_widget_create()
{
	GtkWidget *range_dialog;
	GtkWidget *dialog_vbox4;
	GtkWidget *vbox7;
	GtkWidget *hbox46;
	GtkWidget *label43;
	GtkWidget *label44;
	GtkWidget *hbox42;
	GtkWidget *hbox43;
	GtkWidget *hbox44;
	GtkObject *start_hours_adj;
	GtkObject *start_minutes_adj;
	GtkObject *start_seconds_adj;
	GtkWidget *hbox45;
	GtkObject *end_hours_adj;
	GtkObject *end_minutes_adj;
	GtkObject *end_seconds_adj;
	GtkWidget *dialog_action_area4;
	GtkWidget *cancel_button;
	GtkWidget *ok_button;
	GtkWidget *alignment55;
	GtkWidget *hbox341;
	GtkWidget *image49;
	GtkWidget *label97;
	gchar *val;

	range_dialog = gtk_dialog_new();
	gtk_window_set_title(GTK_WINDOW(range_dialog), TIMELOG_TITLE);
	gtk_window_set_modal(GTK_WINDOW(range_dialog), FALSE);
	gtk_window_set_type_hint(GTK_WINDOW(range_dialog), GDK_WINDOW_TYPE_HINT_DIALOG);

	dialog_vbox4 = GTK_DIALOG(range_dialog)->vbox;
	gtk_widget_show(dialog_vbox4);

	vbox7 = gtk_vbox_new(FALSE, 0);
	gtk_widget_show(vbox7);
	gtk_box_pack_start(GTK_BOX(dialog_vbox4), vbox7, TRUE, TRUE, 0);

	hbox46 = gtk_hbox_new(FALSE, 20);
	gtk_widget_show(hbox46);
	gtk_box_pack_start(GTK_BOX(vbox7), hbox46, FALSE, FALSE, 5);

	label43 = gtk_label_new(_("Start Time"));
	gtk_widget_show(label43);
	gtk_box_pack_start(GTK_BOX(hbox46), label43, TRUE, TRUE, 0);

	label44 = gtk_label_new(_("End Time"));
	gtk_widget_show(label44);
	gtk_box_pack_start(GTK_BOX(hbox46), label44, TRUE, TRUE, 0);

	hbox42 = gtk_hbox_new(FALSE, 20);
	gtk_widget_show(hbox42);
	gtk_box_pack_start(GTK_BOX(vbox7), hbox42, TRUE, TRUE, 0);

	start_calendar = gtk_calendar_new();
	gtk_widget_show(start_calendar);
	gtk_box_pack_start(GTK_BOX(hbox42), start_calendar, TRUE, TRUE, 0);
	gtk_calendar_display_options(GTK_CALENDAR(start_calendar),
			GTK_CALENDAR_SHOW_HEADING | GTK_CALENDAR_SHOW_DAY_NAMES);

	end_calendar = gtk_calendar_new();
	gtk_widget_show(end_calendar);
	gtk_box_pack_start(GTK_BOX(hbox42), end_calendar, TRUE, TRUE, 0);
	gtk_calendar_display_options(GTK_CALENDAR(end_calendar),
			GTK_CALENDAR_SHOW_HEADING | GTK_CALENDAR_SHOW_DAY_NAMES);

	hbox43 = gtk_hbox_new(FALSE, 20);
	gtk_widget_show(hbox43);
	gtk_box_pack_start(GTK_BOX(vbox7), hbox43, FALSE, TRUE, 10);

	hbox44 = gtk_hbox_new(FALSE, 0);
	gtk_widget_show(hbox44);
	gtk_box_pack_start(GTK_BOX(hbox43), hbox44, TRUE, TRUE, 0);

	start_hours_adj = gtk_adjustment_new(0, -100, 100, 1, 10, 10);
	start_hours = gtk_spin_button_new(GTK_ADJUSTMENT(start_hours_adj), 1, 0);
	gtk_widget_show(start_hours);
	gtk_box_pack_start(GTK_BOX(hbox44), start_hours, TRUE, TRUE, 0);
	gtk_spin_button_set_numeric(GTK_SPIN_BUTTON(start_hours), TRUE);
	gtk_spin_button_set_snap_to_ticks(GTK_SPIN_BUTTON(start_hours), TRUE);

	start_minutes_adj = gtk_adjustment_new(0, -100, 100, 1, 10, 10);
	start_minutes = gtk_spin_button_new(GTK_ADJUSTMENT(start_minutes_adj), 1, 0);
	gtk_widget_show(start_minutes);
	gtk_box_pack_start(GTK_BOX(hbox44), start_minutes, TRUE, TRUE, 0);
	gtk_spin_button_set_numeric(GTK_SPIN_BUTTON(start_minutes), TRUE);
	gtk_spin_button_set_snap_to_ticks(GTK_SPIN_BUTTON(start_minutes), TRUE);

	start_seconds_adj = gtk_adjustment_new(0, -100, 100, 1, 10, 10);
	start_seconds = gtk_spin_button_new(GTK_ADJUSTMENT(start_seconds_adj), 1, 0);
	gtk_widget_show(start_seconds);
	gtk_box_pack_start(GTK_BOX(hbox44), start_seconds, TRUE, TRUE, 0);
	gtk_spin_button_set_numeric(GTK_SPIN_BUTTON(start_seconds), TRUE);
	gtk_spin_button_set_snap_to_ticks(GTK_SPIN_BUTTON(start_seconds), TRUE);

	hbox45 = gtk_hbox_new(FALSE, 0);
	gtk_widget_show(hbox45);
	gtk_box_pack_start(GTK_BOX(hbox43), hbox45, TRUE, TRUE, 0);

	end_hours_adj = gtk_adjustment_new(0, -100, 100, 1, 10, 10);
	end_hours = gtk_spin_button_new(GTK_ADJUSTMENT(end_hours_adj), 1, 0);
	gtk_widget_show(end_hours);
	gtk_box_pack_start(GTK_BOX(hbox45), end_hours, TRUE, TRUE, 0);
	gtk_spin_button_set_numeric(GTK_SPIN_BUTTON(end_hours), TRUE);
	gtk_spin_button_set_snap_to_ticks(GTK_SPIN_BUTTON(end_hours), TRUE);

	end_minutes_adj = gtk_adjustment_new(0, -100, 100, 1, 10, 10);
	end_minutes = gtk_spin_button_new(GTK_ADJUSTMENT(end_minutes_adj), 1, 0);
	gtk_widget_show(end_minutes);
	gtk_box_pack_start(GTK_BOX(hbox45), end_minutes, TRUE, TRUE, 0);
	gtk_spin_button_set_numeric(GTK_SPIN_BUTTON(end_minutes), TRUE);
	gtk_spin_button_set_snap_to_ticks(GTK_SPIN_BUTTON(end_minutes), TRUE);

	end_seconds_adj = gtk_adjustment_new(0, -100, 100, 1, 10, 10);
	end_seconds = gtk_spin_button_new(GTK_ADJUSTMENT(end_seconds_adj), 1, 0);
	gtk_widget_show(end_seconds);
	gtk_box_pack_start(GTK_BOX(hbox45), end_seconds, TRUE, TRUE, 0);
	gtk_spin_button_set_numeric(GTK_SPIN_BUTTON(end_seconds), TRUE);
	gtk_spin_button_set_snap_to_ticks(GTK_SPIN_BUTTON(end_seconds), TRUE);

	dialog_action_area4 = GTK_DIALOG(range_dialog)->action_area;
	gtk_widget_show(dialog_action_area4);
	gtk_button_box_set_layout(GTK_BUTTON_BOX(dialog_action_area4), GTK_BUTTONBOX_END);

	cancel_button = gtk_button_new_from_stock("gtk-cancel");
	gtk_widget_show(cancel_button);
	gtk_dialog_add_action_widget(GTK_DIALOG(range_dialog), cancel_button, GTK_RESPONSE_CANCEL);
	GTK_WIDGET_SET_FLAGS(cancel_button, GTK_CAN_DEFAULT);

	ok_button = gtk_button_new();
	gtk_widget_show(ok_button);
	gtk_dialog_add_action_widget(GTK_DIALOG(range_dialog), ok_button, GTK_RESPONSE_OK);
	GTK_WIDGET_SET_FLAGS(ok_button, GTK_CAN_DEFAULT);

	alignment55 = gtk_alignment_new(0.5, 0.5, 0, 0);
	gtk_widget_show(alignment55);
	gtk_container_add(GTK_CONTAINER(ok_button), alignment55);

	hbox341 = gtk_hbox_new(FALSE, 2);
	gtk_widget_show(hbox341);
	gtk_container_add(GTK_CONTAINER(alignment55), hbox341);

	image49 = gtk_image_new_from_stock("gtk-ok", GTK_ICON_SIZE_BUTTON);
	gtk_widget_show(image49);
	gtk_box_pack_start(GTK_BOX(hbox341), image49, FALSE, FALSE, 0);

	label97 = gtk_label_new_with_mnemonic(_("Select Time Range"));
	gtk_widget_show(label97);
	gtk_box_pack_start(GTK_BOX(hbox341), label97, FALSE, FALSE, 0);

	g_signal_connect((gpointer) start_hours, "value_changed", 
			G_CALLBACK(cb_time_value_changed), NULL);
	g_signal_connect((gpointer) start_minutes, "value_changed", 
			G_CALLBACK(cb_time_value_changed), NULL);
	g_signal_connect((gpointer) start_seconds, "value_changed",
			G_CALLBACK(cb_time_value_changed), NULL);
	g_signal_connect((gpointer) end_hours, "value_changed",
			G_CALLBACK(cb_time_value_changed), NULL);
	g_signal_connect((gpointer) end_minutes, "value_changed",
			G_CALLBACK(cb_time_value_changed), NULL);
	g_signal_connect((gpointer) end_seconds, "value_changed",
			G_CALLBACK(cb_time_value_changed), NULL);

	val = g_strdup_printf("%02d", 0);
	gtk_entry_set_text(GTK_ENTRY(start_hours), val);
	gtk_entry_set_text(GTK_ENTRY(start_minutes), val);
	gtk_entry_set_text(GTK_ENTRY(start_seconds), val);
	gtk_entry_set_text(GTK_ENTRY(end_hours), val);
	gtk_entry_set_text(GTK_ENTRY(end_minutes), val);
	gtk_entry_set_text(GTK_ENTRY(end_seconds), val);
	g_free(val);

	gtk_widget_grab_default(ok_button);

	return range_dialog;
}
Exemplo n.º 30
0
gint display_loglink_dbox()
{
    GladeXML *xml;
    GtkWidget *dbox;
    GtkWidget *text;
    gpointer data, data2;
    int i, j;

    xml = glade_xml_new
          (tilp_paths_build_glade("log_link-2.glade"), "linklog_dbox", PACKAGE);
    if (!xml)
        g_error(_("%s: GUI loading failed!\n"), __FILE__);
    glade_xml_signal_autoconnect(xml);

    text = glade_xml_get_widget(xml, "textview1");
    txtbuf = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text));

    data = glade_xml_get_widget(xml, "spinbutton1");
    gtk_spin_button_set_value(GTK_SPIN_BUTTON(data), logger.link_size >> 10);

    data = glade_xml_get_widget(xml, "checkbutton1");
    gtk_toggle_button_set_active(data, logger.link_mask & 1);

    data = glade_xml_get_widget(xml, "checkbutton2");
    gtk_toggle_button_set_active(data, logger.link_mask & 2);

    data = glade_xml_get_widget(xml, "button10");
    data2 = glade_xml_get_widget(xml, "spinbutton1");
    udpate_widgets(data, data2);

    if(logger.link_buf)
    {
        int old_flags;
        char *str;
        char *tmp;
        int meaningful_length;
        int offset;

        if (logger.link_ptr <= logger.link_size)
        {
            // No data of the circular buffer was overwritten.
            meaningful_length = logger.link_ptr;
            offset = 0;
        }
        else
        {
            // Some data of the circular buffer was overwritten:
            // * show only the meaningful part of it;
            // * prevent reading past the bounds of logger.link_buf.
            meaningful_length = logger.link_size;
            offset = logger.link_ptr % logger.link_size;
        }

        old_flags = MSB((logger.link_buf)[offset]);

        if((logger.link_buf)[offset] & (1 << 8))
            str = g_strdup("S: ");
        else
            str = g_strdup("R: ");


        for(i = j = 0; i < meaningful_length; i++)
        {
            uint16_t word = (logger.link_buf)[(i + offset) % logger.link_size];
            uint8_t byte = LSB(word);
            uint8_t flags = MSB(word);
            int s = flags & 1;
            int r = flags & 2;

            if(flags != old_flags)
            {
                old_flags = flags;

                tmp = g_strdup_printf("(%i bytes)\n", j);
                str = g_strconcat(str, tmp, NULL);
                g_free(tmp);
                gtk_text_buffer_insert_at_cursor(txtbuf, str, strlen(str));

                j = 0;
                g_free(str);
                str = g_strdup_printf("%c: ", s ? 'S' : 'R');

            }

            // Wrap every 16 characters.
            if((i != 0) && !(i & 15))
            {
                tmp = g_strdup("\n");
                str = g_strconcat(str, tmp, NULL);
                gtk_text_buffer_insert_at_cursor(txtbuf, str, strlen(str));
                g_free(str);
                str = g_strdup("   ");
            }

            tmp = g_strdup_printf("%02X ", byte);
            str = g_strconcat(str, tmp, NULL);
            g_free(tmp);
            j++;
        }

        tmp = g_strdup_printf("(%i bytes)\n", j);
        str = g_strconcat(str, tmp, NULL);
        gtk_text_buffer_insert_at_cursor(txtbuf, str, strlen(str));

        g_free(str);
    }

    dbox = glade_xml_get_widget(xml, "linklog_dbox");
    gtk_widget_show(dbox);

    return 0;
}