Exemplo n.º 1
0
void on_about_button_clicked (GtkButton *button, gpointer user_data)
{
	gchar         *labeltext;
	GtkWidget     *label;
	GtkWidget     *credits_text;
	GtkWidget     *notes_text;
	GtkTextBuffer *textbuffer;
	GtkTextTag    *boldtag;
	GtkTextIter    start, end;
	
	if (aboutdialog != NULL)
	{
		gtk_window_present (GTK_WINDOW (aboutdialog));
		return;
	}
	
	aboutdialog = create_about_dialog ();
	labeltext = g_strdup_printf (_("<span weight=\"bold\" size=\"larger\">gcolor2 v%s</span>"), VERSION);
	label = lookup_widget (aboutdialog, "about_label");
	gtk_label_set_markup (GTK_LABEL (label), labeltext);
	g_free (labeltext);
	
	/* credits tab */
	credits_text = lookup_widget (aboutdialog, "about_credits_text");
	textbuffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (credits_text));
	gtk_text_buffer_set_text (textbuffer, _(ABOUT_CREDITS_TEXT), -1);
	
	/* make main sections bold */
	boldtag = gtk_text_buffer_create_tag (textbuffer, "bold", "weight", "bold", NULL);
	gtk_text_buffer_get_iter_at_line (textbuffer, &start, 0);
	gtk_text_buffer_get_iter_at_line (textbuffer, &end, 1);
	gtk_text_buffer_apply_tag (textbuffer, boldtag, &start, &end);
	
	gtk_text_buffer_get_iter_at_line (textbuffer, &start, 3);
	gtk_text_buffer_get_iter_at_line (textbuffer, &end, 4);
	gtk_text_buffer_apply_tag (textbuffer, boldtag, &start, &end);
	
	gtk_text_buffer_get_iter_at_line (textbuffer, &start, 10);
	gtk_text_buffer_get_iter_at_line (textbuffer, &end, 11);
	gtk_text_buffer_apply_tag (textbuffer, boldtag, &start, &end);
	
	
	/* release notes tab */
	notes_text = lookup_widget (aboutdialog, "about_notes_text");
	textbuffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (notes_text));
	gtk_text_buffer_set_text (textbuffer, _(ABOUT_NOTES_TEXT), -1);
	
	/* make main sections bold */
	boldtag = gtk_text_buffer_create_tag (textbuffer, "bold", "weight", "bold", NULL);
	gtk_text_buffer_get_iter_at_line (textbuffer, &start, 0);
	gtk_text_buffer_get_iter_at_line (textbuffer, &end, 1);
	gtk_text_buffer_apply_tag (textbuffer, boldtag, &start, &end);
	
	gtk_text_buffer_get_iter_at_line (textbuffer, &start, 3);
	gtk_text_buffer_get_iter_at_line (textbuffer, &end, 4);
	gtk_text_buffer_apply_tag (textbuffer, boldtag, &start, &end);
	
	
	gtk_window_present (GTK_WINDOW (aboutdialog));
}
Exemplo n.º 2
0
/*!
 * \brief The GTK GUI for the footprintwizard.
 *
 * \return 0 if successful.
 */
int
main
(
        int argc, /*!< : number of arguments.*/
        char *argv[] /*!< : array of argument variables.*/
)
{
        GtkWidget *pcb_gfpw;
        GtkWidget *about_dialog;
        gboolean debug = FALSE;
        /*!< Global for being verbose on debugging information. */
        gboolean silent = FALSE;
        /*!< Global for suppressing the logging of critical messages. */
        gboolean verbose = FALSE;
        /*!< Global for being verbose on logging of information. */
        gchar *fpw_filename;
        /*!< Filename of footprintwizard file. */
        gchar *footprint_filename = NULL;
        /*!< Filename of footprint file. */
        gchar *footprint_name = NULL;
        /*!< Name of the footprint. */
        int optc;
        /*!< Number of command line options. */

#ifdef ENABLE_NLS
        bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR);
        bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
        textdomain (GETTEXT_PACKAGE);
#endif
        gtk_set_locale ();
        gtk_init (&argc, &argv);
        add_pixmap_directory (PACKAGE_DATA_DIR "/" PACKAGE "/pixmaps");
        /* Find out how we are called today. */
        program_name = argv[0];
        /* Recognise long options. */
        static const struct option opts[] =
        {
                {"debug", no_argument, NULL, 'd'},
                {"help", no_argument, NULL, 'h'},
                {"version", no_argument, NULL, 'V'},
                {"verbose", no_argument, NULL, 'v'},
                {"quiet", no_argument, NULL, 'q'},
                {"silent", no_argument, NULL, 'q'},
                {"format", required_argument, NULL, 'f'},
                {"output", required_argument, NULL, 'o'},
                {0, 0, 0, 0}
        };
        while ((optc = getopt_long (argc, argv, "dhVvqqf:o:", opts, NULL)) != -1)
        {
                switch (optc)
                {
                        case 'd':
                                debug = TRUE;
                                break;
                        case 'h':
                                gfpw_print_usage ();
                                exit (EXIT_SUCCESS);
                        case 'V':
                                gfpw_print_version ();
                                exit (EXIT_SUCCESS);
                        case 'v':
                                verbose = TRUE;
                                break;
                        case 'q':
                                silent = TRUE;
                                verbose = FALSE; /* Just to be sure. */
                                break;
                        case 'f':
                                fpw_filename = strdup (optarg);
                                if (debug)
                                        fprintf (stderr, "fpw filename = %s\n", fpw_filename);
                                break;
                        case 'o':
                                footprint_name = strdup (optarg);
                                if (debug)
                                        fprintf (stderr, "footprint name = %s\n", footprint_name);
                                break;
                        case '?':
                                gfpw_print_usage ();
                                exit (EXIT_FAILURE);
                        default:
                                g_log ("", G_LOG_LEVEL_WARNING,
                                        _("unknown command line option encountered.\n"));
                                gfpw_print_usage ();
                                exit (EXIT_FAILURE);
                }
        }
        /*
         * The following code was added by Glade to create one of each
         * component (except popup menus), just so that you see something
         * after building the project.
         * Delete any components that you don't want shown initially.
         */
        /* Create and show the about dialog as a splash screen. */
        about_dialog = create_about_dialog ();
        gtk_widget_show (about_dialog);
        /* Now create the main dialog. */
        pcb_gfpw = create_pcb_gfpw ();
        /* Set the "Add license to footprint" checkbutton initially to
         * TRUE */
        GtkWidget *add_license_checkbutton = lookup_widget (GTK_WIDGET (pcb_gfpw),
                "add_license_checkbutton");
        gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (add_license_checkbutton),
                TRUE);
        /* Set the initial state of the total pins and pads entry to
         * sensitive. The entry is to be used as a label for most packages
         * as the total amount of pins and pads can be caluculated.
         * However for some packages it might be needed to set a value here.
         */
        GtkWidget *number_total_pins_entry = lookup_widget (GTK_WIDGET (pcb_gfpw),
                "number_total_pins_entry");
        gtk_widget_set_sensitive (number_total_pins_entry, TRUE);
        GtkWidget *pin_pad_exceptions_button = lookup_widget (GTK_WIDGET (pcb_gfpw),
                "pin_pad_exceptions_button");
        gtk_widget_set_sensitive (pin_pad_exceptions_button, FALSE);
        /* Set the initial state of the checkbutton for the thermal pad to false,
         * set the "length" entry for the thermal pad to insensitive,
         * set the "width" entry for the thermal pad to insensitive,
         * set the "clearance" entry for the thermal pad to insensitive,
         * and set the "solder mask clearance" entry for the thermal pad to insensitive.
         */
        GtkWidget *thermal_checkbutton = lookup_widget (GTK_WIDGET (pcb_gfpw),
                "thermal_checkbutton");
        gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (thermal_checkbutton), FALSE);
        GtkWidget *thermal_nopaste_checkbutton = lookup_widget (GTK_WIDGET (pcb_gfpw),
                "thermal_nopaste_checkbutton");
        gtk_widget_set_sensitive (GTK_WIDGET (thermal_nopaste_checkbutton), FALSE);
        GtkWidget *thermal_length_entry = lookup_widget (GTK_WIDGET (pcb_gfpw),
                "thermal_length_entry");
        gtk_widget_set_sensitive (thermal_length_entry, FALSE);
        GtkWidget *thermal_width_entry = lookup_widget (GTK_WIDGET (pcb_gfpw),
                "thermal_width_entry");
        gtk_widget_set_sensitive (thermal_width_entry, FALSE);
        GtkWidget *thermal_clearance_entry = lookup_widget (GTK_WIDGET (pcb_gfpw),
                "thermal_clearance_entry");
        gtk_widget_set_sensitive (thermal_clearance_entry, FALSE);
        GtkWidget *thermal_solder_mask_clearance_entry = lookup_widget (GTK_WIDGET (pcb_gfpw),
                "thermal_solder_mask_clearance_entry");
        gtk_widget_set_sensitive (thermal_solder_mask_clearance_entry, FALSE);
        /* Set the initial state of the checkbutton for the fiducial pads to
         * false, set the "fiducial pad diameter" entry to insensitive,
         * and set the "fiducial pad clearance" entry to insensitive,
         * and set the "fiducial pad solder mask clearance" entry to insensitive.
         */
        GtkWidget *fiducial_checkbutton = lookup_widget (GTK_WIDGET (pcb_gfpw),
                "fiducial_checkbutton");
        gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (fiducial_checkbutton), FALSE);
        GtkWidget *fiducial_pad_diameter_entry = lookup_widget
                (GTK_WIDGET (pcb_gfpw),
                "fiducial_pad_diameter_entry");
        gtk_widget_set_sensitive (fiducial_pad_diameter_entry, FALSE);
        GtkWidget *fiducial_pad_clearance_entry = lookup_widget
                (GTK_WIDGET (pcb_gfpw),
                "fiducial_pad_clearance_entry");
        gtk_widget_set_sensitive (fiducial_pad_clearance_entry, FALSE);
        GtkWidget *fiducial_pad_solder_mask_clearance_entry = lookup_widget
                (GTK_WIDGET (pcb_gfpw),
                "fiducial_pad_solder_mask_clearance_entry");
        gtk_widget_set_sensitive (fiducial_pad_solder_mask_clearance_entry,
                FALSE);
        /* Set the initial state of the checkbutton for the silkscreen to true,
         * set the "linewidth" entry for the silkscreen to sensitive.
         */
        GtkWidget *silkscreen_package_outline = lookup_widget (GTK_WIDGET (pcb_gfpw),
                "silkscreen_package_outline_checkbutton");
        gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (silkscreen_package_outline), TRUE);
        GtkWidget *silkscreen_line_width_entry = lookup_widget (GTK_WIDGET (pcb_gfpw),
                "silkscreen_line_width_entry");
        gtk_widget_set_sensitive (silkscreen_line_width_entry, TRUE);
        /* Set the state of the check button for the courtyard to false,
         * set the "length" entry for the courtyard to insensitive,
         * set the "width" entry for the courtyard to insensitive,
         * set the "linewidth" entry for the courtyard to insensitive,
         * and set the "clearance to package" entry for the courtyard to
         * insensitive.
         */
        GtkWidget *courtyard_checkbutton = lookup_widget (GTK_WIDGET (pcb_gfpw),
                "courtyard_checkbutton");
        gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (courtyard_checkbutton), FALSE);
        GtkWidget *courtyard_length_entry = lookup_widget (GTK_WIDGET (pcb_gfpw),
                "courtyard_length_entry");
        gtk_widget_set_sensitive (courtyard_length_entry, FALSE);
        GtkWidget *courtyard_width_entry = lookup_widget (GTK_WIDGET (pcb_gfpw),
                "courtyard_width_entry");
        gtk_widget_set_sensitive (courtyard_width_entry, FALSE);
        GtkWidget *courtyard_line_width_entry = lookup_widget (GTK_WIDGET (pcb_gfpw),
                "courtyard_line_width_entry");
        gtk_widget_set_sensitive (courtyard_line_width_entry, FALSE);
        GtkWidget *courtyard_clearance_with_package_entry = lookup_widget (GTK_WIDGET (pcb_gfpw),
                "courtyard_clearance_with_package_entry");
        gtk_widget_set_sensitive (courtyard_clearance_with_package_entry, FALSE);
        /* Set the initial state of the entries adjacent to the radiobuttons in
         * the notebook tab  "Heel & Toe goals".
         * These entries are for entering the C1, C2, G1, G2, Z1 and Z2
         * variables.
         */
        GtkWidget *C1_entry = lookup_widget (GTK_WIDGET (pcb_gfpw), "C1_entry");
        gtk_widget_set_sensitive (C1_entry, TRUE);
        GtkWidget *C2_entry = lookup_widget (GTK_WIDGET (pcb_gfpw), "C2_entry");
        gtk_widget_set_sensitive (C2_entry, TRUE);
        GtkWidget *G1_entry = lookup_widget (GTK_WIDGET (pcb_gfpw), "G1_entry");
        gtk_widget_set_sensitive (G1_entry, FALSE);
        GtkWidget *G2_entry = lookup_widget (GTK_WIDGET (pcb_gfpw), "G2_entry");
        gtk_widget_set_sensitive (G2_entry, FALSE);
        GtkWidget *Z1_entry = lookup_widget (GTK_WIDGET (pcb_gfpw), "Z1_entry");
        gtk_widget_set_sensitive (Z1_entry, FALSE);
        GtkWidget *Z2_entry = lookup_widget (GTK_WIDGET (pcb_gfpw), "Z2_entry");
        gtk_widget_set_sensitive (Z2_entry, FALSE);
        /* Now show the main dialog. */
        gtk_widget_show (pcb_gfpw);
        /* Now enter the main loop */
        gtk_main ();
        return 0;
}