Ejemplo n.º 1
0
int
main (int argc, char *argv[])
{
	GtkWidget *window, *box, *w;
	GogChart *chart;
	GogGraph *graph;
	GogLabel *label;
	GogPlot *pie;
	GogSeries *series;
	GOStyle *style;
	GOData *data;
	GError *error;
	PangoFontDescription *desc;
	char const *title = "Some statistics";
	char const * const legends[] = {"first", "second", "third", "fourth"};
	double values[] = {10., 20., 30., 40.};

	gtk_init (&argc, &argv);
	/* Initialize libgoffice */
	libgoffice_init ();
	/* Initialize plugins manager */
	go_plugins_init (NULL, NULL, NULL, NULL, TRUE, GO_TYPE_PLUGIN_LOADER_MODULE);

	window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
	gtk_window_resize (GTK_WINDOW (window), 300, 340);
	gtk_window_set_title (GTK_WINDOW (window), "pie demo");
	g_signal_connect (window, "destroy", gtk_main_quit, NULL);

	box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
	w = gtk_button_new_from_stock (GTK_STOCK_QUIT);
	g_signal_connect_swapped (w, "clicked", G_CALLBACK (on_quit), window);
	gtk_box_pack_end (GTK_BOX (box), w, FALSE, FALSE, 0);

	w = gtk_separator_new (GTK_ORIENTATION_HORIZONTAL);
	gtk_box_pack_end (GTK_BOX (box), w, FALSE, FALSE, 2);

	/* Create a graph widget and add it to the GtkVBox */
	w = go_graph_widget_new (NULL);
	gtk_box_pack_end (GTK_BOX (box), w, TRUE, TRUE, 0);
	/* Get the embedded graph */
	graph = go_graph_widget_get_graph (GO_GRAPH_WIDGET (w));
	/* Add a title */
	label = (GogLabel *) g_object_new (GOG_TYPE_LABEL, NULL);
	data = go_data_scalar_str_new (title, FALSE);
	gog_dataset_set_dim (GOG_DATASET (label), 0, data, NULL);
	gog_object_add_by_name (GOG_OBJECT (graph), "Title", GOG_OBJECT (label));
	/* Change the title font */
	style = go_styled_object_get_style (GO_STYLED_OBJECT (label));
	desc = pango_font_description_from_string ("Sans bold 16");
	go_style_set_font_desc (style, desc);
	/* Get the chart created by the widget initialization */
	chart = go_graph_widget_get_chart (GO_GRAPH_WIDGET (w));
	/* Create a pie plot and add it to the chart */
	pie = (GogPlot *) gog_plot_new_by_name ("GogPiePlot");
	gog_object_add_by_name (GOG_OBJECT (chart), "Plot", GOG_OBJECT (pie));
	/* Create a series for the plot and populate it with some simple data */
	series = gog_plot_new_series (pie);
	data = go_data_vector_str_new (legends, 4, NULL);
	gog_series_set_dim (series, 0, data, &error);
	data = go_data_vector_val_new (values, 4, NULL);
	gog_series_set_dim (series, 1, data, &error);
	/* Add a legend to the chart */
	gog_object_add_by_name (GOG_OBJECT (chart), "Legend", NULL);

	gtk_container_add (GTK_CONTAINER (window), box);
	gtk_widget_show_all (GTK_WIDGET (window));

	w = gtk_separator_new (GTK_ORIENTATION_HORIZONTAL);
	gtk_box_pack_start (GTK_BOX (box), w, FALSE, FALSE, 0);

	gtk_main ();

	/* Clean libgoffice stuff */
	libgoffice_shutdown ();
	return 0;
}
Ejemplo n.º 2
0
static void file_configure(void)
{
    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)
         configure_destroy, NULL);
        g_signal_connect (configure_win, "destroy", (GCallback)
         gtk_widget_destroyed, & configure_win);

        gtk_window_set_title(GTK_WINDOW(configure_win),
                             _("File Writer Configuration"));
        gtk_window_set_position(GTK_WINDOW(configure_win), GTK_WIN_POS_MOUSE);

        gtk_container_set_border_width(GTK_CONTAINER(configure_win), 10);

        configure_vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 10);
        gtk_container_add(GTK_CONTAINER(configure_win), configure_vbox);


        fileext_hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 5);
        gtk_box_pack_start(GTK_BOX(configure_vbox), fileext_hbox, FALSE, FALSE, 0);

        fileext_label = gtk_label_new(_("Output file format:"));
        gtk_box_pack_start(GTK_BOX(fileext_hbox), fileext_label, FALSE, FALSE, 0);

        fileext_combo = gtk_combo_box_text_new ();
        gtk_combo_box_text_append_text ((GtkComboBoxText *) fileext_combo, "WAV");
#ifdef FILEWRITER_MP3
        gtk_combo_box_text_append_text ((GtkComboBoxText *) fileext_combo, "MP3");
#endif
#ifdef FILEWRITER_VORBIS
        gtk_combo_box_text_append_text ((GtkComboBoxText *) fileext_combo, "Vorbis");
#endif
#ifdef FILEWRITER_FLAC
        gtk_combo_box_text_append_text ((GtkComboBoxText *) fileext_combo, "FLAC");
#endif
        gtk_box_pack_start(GTK_BOX(fileext_hbox), fileext_combo, FALSE, FALSE, 0);
        gtk_combo_box_set_active(GTK_COMBO_BOX(fileext_combo), fileext);
        g_signal_connect(G_OBJECT(fileext_combo), "changed", G_CALLBACK(fileext_cb), NULL);

        plugin_button = gtk_button_new_with_label(_("Configure"));
        gtk_widget_set_sensitive(plugin_button, plugin->configure != NULL);
        g_signal_connect(G_OBJECT(plugin_button), "clicked", G_CALLBACK(plugin_configure_cb), NULL);
        gtk_box_pack_end(GTK_BOX(fileext_hbox), plugin_button, FALSE, FALSE, 0);




        gtk_box_pack_start(GTK_BOX(configure_vbox), gtk_separator_new(GTK_ORIENTATION_HORIZONTAL), FALSE, FALSE, 0);



        saveplace_hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 5);
        gtk_container_add(GTK_CONTAINER(configure_vbox), saveplace_hbox);

        saveplace = gtk_radio_button_new_with_label(NULL, _("Save into original directory"));
        g_signal_connect(G_OBJECT(saveplace), "toggled", G_CALLBACK(saveplace_original_cb), NULL);
        gtk_box_pack_start(GTK_BOX(saveplace_hbox), saveplace, FALSE, FALSE, 0);

        saveplace = gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(saveplace),
                                                                _("Save into custom directory"));
        if (!save_original)
            gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(saveplace), TRUE);

        g_signal_connect(G_OBJECT(saveplace), "toggled", G_CALLBACK(saveplace_custom_cb), NULL);
        gtk_box_pack_start(GTK_BOX(saveplace_hbox), saveplace, FALSE, FALSE, 0);

        path_hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 5);
        gtk_box_pack_start(GTK_BOX(configure_vbox), path_hbox, FALSE, FALSE, 0);

        path_label = gtk_label_new(_("Output file folder:"));
        gtk_box_pack_start(GTK_BOX(path_hbox), path_label, FALSE, FALSE, 0);

        path_dirbrowser =
            gtk_file_chooser_button_new (_("Pick a folder"),
                                         GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER);
        gtk_file_chooser_set_uri ((GtkFileChooser *) path_dirbrowser, file_path);
        gtk_box_pack_start(GTK_BOX(path_hbox), path_dirbrowser, TRUE, TRUE, 0);

        if (save_original)
            gtk_widget_set_sensitive(path_hbox, FALSE);




        gtk_box_pack_start(GTK_BOX(configure_vbox), gtk_separator_new(GTK_ORIENTATION_HORIZONTAL), FALSE, FALSE, 0);




        filenamefrom_hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 5);
        gtk_container_add(GTK_CONTAINER(configure_vbox), filenamefrom_hbox);

        filenamefrom_label = gtk_label_new(_("Get filename from:"));
        gtk_box_pack_start(GTK_BOX(filenamefrom_hbox), filenamefrom_label, FALSE, FALSE, 0);

        filenamefrom_toggle = gtk_radio_button_new_with_label(NULL, _("original file tags"));
        g_signal_connect(G_OBJECT(filenamefrom_toggle), "toggled", G_CALLBACK(filenamefromtags_cb), NULL);
        gtk_box_pack_start(GTK_BOX(filenamefrom_hbox), filenamefrom_toggle, FALSE, FALSE, 0);

        filenamefrom_toggle =
            gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(filenamefrom_toggle),
                                                        _("original filename"));
        g_signal_connect(G_OBJECT(filenamefrom_toggle), "toggled", G_CALLBACK(filenamefromfilename_cb), NULL);
        gtk_box_pack_start(GTK_BOX(filenamefrom_hbox), filenamefrom_toggle, FALSE, FALSE, 0);

        if (!filenamefromtags)
            gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(filenamefrom_toggle), TRUE);




        use_suffix_toggle = gtk_check_button_new_with_label(_("Don't strip file name extension"));
        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(use_suffix_toggle), use_suffix);
        gtk_box_pack_start(GTK_BOX(configure_vbox), use_suffix_toggle, FALSE, FALSE, 0);

        if (filenamefromtags)
            gtk_widget_set_sensitive(use_suffix_toggle, FALSE);




        gtk_box_pack_start(GTK_BOX(configure_vbox), gtk_separator_new(GTK_ORIENTATION_HORIZONTAL), FALSE, FALSE, 0);




        prependnumber_toggle = gtk_check_button_new_with_label(_("Prepend track number to filename"));
        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(prependnumber_toggle), prependnumber);
        gtk_box_pack_start(GTK_BOX(configure_vbox), prependnumber_toggle, FALSE, FALSE, 0);



        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(configure_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_all(configure_win);
    }
}
Ejemplo n.º 3
0
Archivo: dialog.c Proyecto: 3v1n0/gtk
GtkWidget *
do_dialog (GtkWidget *do_widget)
{
  GtkWidget *frame;
  GtkWidget *vbox;
  GtkWidget *vbox2;
  GtkWidget *hbox;
  GtkWidget *button;
  GtkWidget *table;
  GtkWidget *label;

  if (!window)
    {
      window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
      gtk_window_set_screen (GTK_WINDOW (window),
                             gtk_widget_get_screen (do_widget));
      gtk_window_set_title (GTK_WINDOW (window), "Dialogs");

      g_signal_connect (window, "destroy", G_CALLBACK (gtk_widget_destroyed), &window);
      gtk_container_set_border_width (GTK_CONTAINER (window), 8);

      frame = gtk_frame_new ("Dialogs");
      gtk_container_add (GTK_CONTAINER (window), frame);

      vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 8);
      gtk_container_set_border_width (GTK_CONTAINER (vbox), 8);
      gtk_container_add (GTK_CONTAINER (frame), vbox);

      /* Standard message dialog */
      hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 8);
      gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
      button = gtk_button_new_with_mnemonic ("_Message Dialog");
      g_signal_connect (button, "clicked",
                        G_CALLBACK (message_dialog_clicked), NULL);
      gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);

      gtk_box_pack_start (GTK_BOX (vbox), gtk_separator_new (GTK_ORIENTATION_HORIZONTAL),
                          FALSE, FALSE, 0);

      /* Interactive dialog*/
      hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 8);
      gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
      vbox2 = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);

      button = gtk_button_new_with_mnemonic ("_Interactive Dialog");
      g_signal_connect (button, "clicked",
                        G_CALLBACK (interactive_dialog_clicked), NULL);
      gtk_box_pack_start (GTK_BOX (hbox), vbox2, FALSE, FALSE, 0);
      gtk_box_pack_start (GTK_BOX (vbox2), button, FALSE, FALSE, 0);

      table = gtk_grid_new ();
      gtk_grid_set_row_spacing (GTK_GRID (table), 4);
      gtk_grid_set_column_spacing (GTK_GRID (table), 4);
      gtk_box_pack_start (GTK_BOX (hbox), table, FALSE, FALSE, 0);

      label = gtk_label_new_with_mnemonic ("_Entry 1");
      gtk_grid_attach (GTK_GRID (table), label, 0, 0, 1, 1);

      entry1 = gtk_entry_new ();
      gtk_grid_attach (GTK_GRID (table), entry1, 1, 0, 1, 1);
      gtk_label_set_mnemonic_widget (GTK_LABEL (label), entry1);

      label = gtk_label_new_with_mnemonic ("E_ntry 2");
      gtk_grid_attach (GTK_GRID (table), label, 0, 1, 1, 1);

      entry2 = gtk_entry_new ();
      gtk_grid_attach (GTK_GRID (table), entry2, 1, 1, 1, 1);
    }

  if (!gtk_widget_get_visible (window))
    {
      gtk_widget_show_all (window);
    }
  else
    {
      gtk_widget_destroy (window);
      window = NULL;
    }

  return window;
}
Ejemplo n.º 4
0
UgSettingDialog*	ug_setting_dialog_new (const gchar* title, GtkWindow* parent)
{
	UgSettingDialog*	dialog;
	GtkWidget*			widget;
	GtkBox*				vbox;

	dialog = g_malloc0 (sizeof (UgSettingDialog));
	dialog->self = (GtkDialog*) gtk_dialog_new_with_buttons (title, parent,
			GTK_DIALOG_DESTROY_WITH_PARENT,
			GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
			GTK_STOCK_OK,     GTK_RESPONSE_OK,
			NULL);
	gtk_dialog_set_default_response (dialog->self, GTK_RESPONSE_OK);
	widget = gtk_notebook_new ();
	gtk_widget_set_size_request (widget, 430, 320);
	vbox = (GtkBox*) gtk_dialog_get_content_area (dialog->self);
	gtk_box_pack_start (vbox, widget, FALSE, FALSE, 0);
	dialog->notebook = (GtkNotebook*) widget;

	// ------------------------------------------------------------------------
	// UI settings page
	vbox = (GtkBox*) gtk_box_new (GTK_ORIENTATION_VERTICAL, 2);
	gtk_container_set_border_width (GTK_CONTAINER (vbox), 2);
	gtk_notebook_append_page (dialog->notebook, (GtkWidget*) vbox,
			gtk_label_new (_("UI Settings")));
	ug_user_interface_form_init (&dialog->ui);
	gtk_box_pack_start (vbox, dialog->ui.self, FALSE, FALSE, 2);

	// ------------------------------------------------------------------------
	// Clipboard settings page
	ug_clipboard_setting_form_init (&dialog->clipboard);
	gtk_container_set_border_width (GTK_CONTAINER (dialog->clipboard.self), 2);
	gtk_notebook_append_page (dialog->notebook, dialog->clipboard.self,
			gtk_label_new (_("Clipboard")));

	// ------------------------------------------------------------------------
	// Scheduler settings page
	ug_schedule_form_init (&dialog->scheduler);
	gtk_container_set_border_width (GTK_CONTAINER (dialog->scheduler.self), 2);
	gtk_notebook_append_page (dialog->notebook, dialog->scheduler.self,
			gtk_label_new (_("Scheduler")));

#ifdef HAVE_PLUGIN_ARIA2
	// ------------------------------------------------------------------------
	// Plugin settings page
	ug_plugin_setting_form_init (&dialog->plugin);
	gtk_container_set_border_width (GTK_CONTAINER (dialog->plugin.self), 2);
	gtk_notebook_append_page (dialog->notebook, dialog->plugin.self,
			gtk_label_new (_("Plug-in")));
#endif	// HAVE_PLUGIN_ARIA2

	// ------------------------------------------------------------------------
	// Others settings page
	vbox = (GtkBox*) gtk_box_new (GTK_ORIENTATION_VERTICAL, 2);
	gtk_container_set_border_width (GTK_CONTAINER (vbox), 2);
	gtk_notebook_append_page (dialog->notebook, (GtkWidget*) vbox,
			gtk_label_new (_("Others")));
	ug_commandline_setting_form_init (&dialog->commandline);
	gtk_box_pack_start (vbox, dialog->commandline.self, FALSE, FALSE, 2);
	gtk_box_pack_start (vbox, gtk_separator_new (GTK_ORIENTATION_HORIZONTAL), FALSE, FALSE, 2);
	ug_auto_save_form_init (&dialog->auto_save);
	gtk_box_pack_start (vbox, dialog->auto_save.self, FALSE, FALSE, 2);
	gtk_box_pack_start (vbox, gtk_separator_new (GTK_ORIENTATION_HORIZONTAL), FALSE, FALSE, 2);
	ug_launch_setting_form_init (&dialog->launch);
	gtk_box_pack_start (vbox, dialog->launch.self, FALSE, FALSE, 2);

	gtk_widget_show_all ((GtkWidget*) dialog->notebook);
//	gtk_container_set_focus_child (GTK_CONTAINER (dialog->self), dialog->pattern_entry);
//	g_signal_connect (dialog->pattern_entry, "key-press-event", G_CALLBACK (on_key_press_event), dialog);

	return dialog;
}
Ejemplo n.º 5
0
/**
 * create the page 2 of the assistant to make the link between marked transactions and reconciles
 * that page propose to :
 * 	create new reconciles
 * 	automatically associate transactions to known reconciles
 * 	associate transactions to a reconcile, by hand
 * a change to that menu will change the next page, according to it
 *
 * \param assistant the GtkWidget assistant
 *
 * \return a GtkWidget containing the page
 * */
static GtkWidget *gsb_assistant_reconcile_config_page_menu ( GtkWidget *assistant )
{
    GtkWidget *page;
    GtkWidget *separator;
    GtkWidget *label;
    GtkWidget *button;
	gchar* tmpstr;

    page = gtk_box_new ( GTK_ORIENTATION_VERTICAL, 5);
    gtk_container_set_border_width ( GTK_CONTAINER(page), 12 );

    tmpstr = g_strdup_printf (_("Still %d transactions to link with a reconciliation."),
								   transactions_to_link);
    label_transactions_to_link_1 = gtk_label_new (tmpstr );
    g_free ( tmpstr );
    gtk_misc_set_alignment ( GTK_MISC (label_transactions_to_link_1),
			     0, 0.5 );

    gtk_box_pack_start ( GTK_BOX (page),
			 label_transactions_to_link_1,
			 FALSE, FALSE, 0 );

    separator = gtk_separator_new ( GTK_ORIENTATION_HORIZONTAL );
    gtk_box_pack_start ( GTK_BOX (page),
			 separator,
			 FALSE, FALSE, 0 );

    /* set up the menu */
    label = gtk_label_new (_("Choose the next operation to do: "));
    gtk_misc_set_alignment ( GTK_MISC (label),
			     0, 0.5 );
    gtk_box_pack_start ( GTK_BOX (page),
			 label,
			 FALSE, FALSE, 0 );

    /* create a new reconcile */
    button = gtk_radio_button_new_with_label ( NULL,
					       _("Manually create a new reconciliation"));
    g_object_set_data ( G_OBJECT (button),
			"next_page", GINT_TO_POINTER (RECONCILE_ASSISTANT_NEW_RECONCILE));
    g_signal_connect ( G_OBJECT (button),
		       "toggled",
		       G_CALLBACK (gsb_assistant_reconcile_config_page_menu_toggled),
		       assistant );
    gtk_box_pack_start ( GTK_BOX (page),
			 button,
			 FALSE, FALSE, 0 );

    label = gtk_label_new (_("	After a long use, some transactions may be before the first known reconciliation.\n"
			     "	You can create all the previous needed reconciliations here."));
    gtk_misc_set_alignment ( GTK_MISC (label),
			     0, 0.5 );
    gtk_box_pack_start ( GTK_BOX (page),
			 label,
			 FALSE, FALSE, 0 );

    /* automatically associate the transactions without reconcile number */
    button = gtk_radio_button_new_with_label ( gtk_radio_button_get_group (GTK_RADIO_BUTTON (button)),
					       _("Automatically associate transactions without reconciliation number with the known reconciliations"));
    g_object_set_data ( G_OBJECT (button),
			"next_page", GINT_TO_POINTER (RECONCILE_ASSISTANT_AUTOMATICALLY_ASSOCIATE));
    g_signal_connect ( G_OBJECT (button),
		       "toggled",
		       G_CALLBACK (gsb_assistant_reconcile_config_page_menu_toggled),
		       assistant );
    gtk_box_pack_start ( GTK_BOX (page),
			 button,
			 FALSE, FALSE, 0 );

    label = gtk_label_new (_("	This will make all the work for you if you create "
                        "previously all the needed reconciliations\n"
                        "	and adjust the date of the known reconciliations."));
    gtk_misc_set_alignment ( GTK_MISC (label),
			     0, 0.5 );
    gtk_box_pack_start ( GTK_BOX (page),
			 label,
			 FALSE, FALSE, 0 );

    /* associate the transactions without reconcile number by hand */
    button = gtk_radio_button_new_with_label ( gtk_radio_button_get_group (GTK_RADIO_BUTTON (button)),
                        _("Associate by hands the transactions without "
                        "reconciliation number with the known reconciliation"));
    g_object_set_data ( G_OBJECT (button),
			"next_page", GINT_TO_POINTER (RECONCILE_ASSISTANT_MANUALLY_ASSOCIATE));
    g_signal_connect ( G_OBJECT (button),
		       "toggled",
		       G_CALLBACK (gsb_assistant_reconcile_config_page_menu_toggled),
		       assistant );
    gtk_box_pack_start ( GTK_BOX (page),
			 button,
			 FALSE, FALSE, 0 );

    label = gtk_label_new (_("	You control all and have a lot of time to spend on your computer !\n"
			     "	(you will be able to choose a reconciliation for each orphan transaction)."));
    gtk_misc_set_alignment ( GTK_MISC (label),
			     0, 0.5 );
    gtk_box_pack_start ( GTK_BOX (page),
			 label,
			 FALSE, FALSE, 0 );




    gtk_widget_show_all (page);
    return page;
}
Ejemplo n.º 6
0
/* Create transponder table. */
static GtkWidget *create_transponder_table(guint catnum)
{
    GtkWidget      *vbox, *label, *swin;
    GSList         *trsplist = NULL;
    trsp_t         *trsp = NULL;
    guint           i, n;
    gchar          *text;


    trsplist = read_transponders(catnum);
    if (trsplist == NULL)
    {
        swin = gtk_label_new(_("No transponders"));
    }
    else
    {
        vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 3);
        gtk_box_set_homogeneous(GTK_BOX(vbox), FALSE);
        gtk_container_set_border_width(GTK_CONTAINER(vbox), 10);

        /* Add each transponder to vbox */
        n = g_slist_length(trsplist);
        for (i = 0; i < n; i++)
        {
            gtk_box_pack_start(GTK_BOX(vbox), gtk_label_new(" "), FALSE, FALSE,
                               0);

            trsp = (trsp_t *) g_slist_nth_data(trsplist, i);

            /* transponder name */
            text = g_strdup_printf("<b>%s</b>", trsp->name);
            label = gtk_label_new(NULL);
            g_object_set(label, "xalign", 0.0, "yalign", 0.5, NULL);
            gtk_label_set_markup(GTK_LABEL(label), text);
            g_free(text);
            gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
            gtk_box_pack_start(GTK_BOX(vbox),
                               gtk_separator_new(GTK_ORIENTATION_HORIZONTAL),
                               FALSE, FALSE, 0);

            /* uplink */
            if (trsp->uplow > 0.0)
            {
                if (trsp->uphigh > trsp->uplow)
                {
                    /* we have a range */
                    text =
                        g_strdup_printf(_
                                        ("Uplink: %.4f \342\200\222 %.4f MHz"),
                                        trsp->uplow / 1.0e6,
                                        trsp->uphigh / 1.0e6);
                }
                else
                {
                    text =
                        g_strdup_printf(_("Uplink: %.4f MHz"),
                                        trsp->uplow / 1.0e6);
                }
                label = gtk_label_new(text);
                g_object_set(label, "xalign", 0.0, "yalign", 0.5, NULL);
                gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
                g_free(text);
            }

            /* downlink */
            if (trsp->downlow > 0.0)
            {
                if (trsp->downhigh > trsp->downlow)
                {
                    /* we have a range */
                    text =
                        g_strdup_printf(_
                                        ("Downlink: %.4f \342\200\222 %.4f MHz"),
                                        trsp->downlow / 1.0e6,
                                        trsp->downhigh / 1.0e6);
                }
                else
                {
                    text =
                        g_strdup_printf(_("Downlink: %.4f MHz"),
                                        trsp->downlow / 1.0e6);
                }
                label = gtk_label_new(text);
                g_object_set(label, "xalign", 0.0, "yalign", 0.5, NULL);
                gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
                g_free(text);
            }

            /* inverting */
            if ((trsp->downhigh > trsp->downlow) &&
                (trsp->uphigh > trsp->uplow))
            {
                text =
                    g_strdup_printf(_("Inverting: %s"),
                                    trsp->invert ? "YES" : "NO");
                label = gtk_label_new(text);
                g_object_set(label, "xalign", 0.0, "yalign", 0.5, NULL);
                g_free(text);
                gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
            }

            /* mode string */
            if (trsp->mode)
            {
                text = g_strdup_printf(_("Mode: %s"), trsp->mode);
                label = gtk_label_new(text);
                g_object_set(label, "xalign", 0.0, "yalign", 0.5, NULL);
                g_free(text);
                gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
            }
            if (trsp->baud)
            {
                text = g_strdup_printf(_("Baudrate: %9.2f"), trsp->baud);
                label = gtk_label_new(text);
                g_object_set(label, "xalign", 0.0, "yalign", 0.5, NULL);
                g_free(text);
                gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
            }
        }
        free_transponders(trsplist);

        /* pack into a scrolled window */
        swin = gtk_scrolled_window_new(NULL, NULL);
        gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(swin),
                                       GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
        gtk_container_add (GTK_CONTAINER (swin), vbox);
    }

    return swin;
}
static gboolean
set_tooltip_widget_from_marks (GtkSourceView *view,
                               GtkTooltip    *tooltip,
                               GSList        *marks)
{
	GtkGrid *grid = NULL;
	gint row_num = 0;
	gint icon_size;

	gtk_icon_size_lookup (GTK_ICON_SIZE_MENU, NULL, &icon_size);

	for (; marks; marks = g_slist_next (marks))
	{
		const gchar *category;
		GtkSourceMark *mark;
		GtkSourceMarkAttributes *attrs;
		gchar *text;
		gboolean ismarkup = FALSE;
		GtkWidget *label;
		const GdkPixbuf *pixbuf;

		mark = marks->data;
		category = gtk_source_mark_get_category (mark);

		attrs = gtk_source_view_get_mark_attributes (view, category, NULL);

		if (attrs == NULL)
		{
			continue;
		}

		text = gtk_source_mark_attributes_get_tooltip_markup (attrs, mark);

		if (text == NULL)
		{
			text = gtk_source_mark_attributes_get_tooltip_text (attrs, mark);
		}
		else
		{
			ismarkup = TRUE;
		}

		if (text == NULL)
		{
			continue;
		}

		if (grid == NULL)
		{
			grid = GTK_GRID (gtk_grid_new ());
			gtk_grid_set_column_spacing (grid, 4);
			gtk_widget_show (GTK_WIDGET (grid));
		}

		label = gtk_label_new (NULL);

		if (ismarkup)
		{
			gtk_label_set_markup (GTK_LABEL (label), text);
		}
		else
		{
			gtk_label_set_text (GTK_LABEL (label), text);
		}

		gtk_widget_set_halign (label, GTK_ALIGN_START);
		gtk_widget_set_valign (label, GTK_ALIGN_START);
		gtk_widget_show (label);

		pixbuf = gtk_source_mark_attributes_render_icon (attrs,
		                                                 GTK_WIDGET (view),
		                                                 icon_size);

		if (pixbuf == NULL)
		{
			gtk_grid_attach (grid, label, 0, row_num, 2, 1);
		}
		else
		{
			GtkWidget *image;
			GdkPixbuf *copy;

			/* FIXME why a copy is needed? */
			copy = gdk_pixbuf_copy (pixbuf);
			image = gtk_image_new_from_pixbuf (copy);
			g_object_unref (copy);

			gtk_widget_set_halign (image, GTK_ALIGN_START);
			gtk_widget_set_valign (image, GTK_ALIGN_START);
			gtk_widget_show (image);

			gtk_grid_attach (grid, image, 0, row_num, 1, 1);
			gtk_grid_attach (grid, label, 1, row_num, 1, 1);
		}

		row_num++;

		if (marks->next != NULL)
		{
			GtkWidget *separator;

			separator = gtk_separator_new (GTK_ORIENTATION_HORIZONTAL);

			gtk_widget_show (separator);

			gtk_grid_attach (grid, separator, 0, row_num, 2, 1);
			row_num++;
		}

		g_free (text);
	}

	if (grid == NULL)
	{
		return FALSE;
	}

	gtk_tooltip_set_custom (tooltip, GTK_WIDGET (grid));

	return TRUE;
}
static gboolean
set_tooltip_widget_from_marks (GtkSourceView *view,
                               GtkTooltip    *tooltip,
                               GSList        *marks)
{
	GtkWidget *vbox = NULL;

	for (; marks; marks = g_slist_next (marks))
	{
		const gchar *category;
		GtkSourceMark *mark;
		GtkSourceMarkAttributes *attrs;
		gchar *text;
		gboolean ismarkup = FALSE;
		GtkWidget *label;
		GtkWidget *hbox;
		const GdkPixbuf *pixbuf;
		gint size;

		mark = marks->data;
		category = gtk_source_mark_get_category (mark);

		attrs = gtk_source_view_get_mark_attributes (view,
		                                             category,
		                                             NULL);

		if (attrs == NULL)
		{
			continue;
		}

		text = gtk_source_mark_attributes_get_tooltip_markup (attrs,
		                                                      mark);

		if (text == NULL)
		{
			text = gtk_source_mark_attributes_get_tooltip_text (attrs,
			                                                    mark);
		}
		else
		{
			ismarkup = TRUE;
		}

		if (text == NULL)
		{
			continue;
		}

		if (vbox == NULL)
		{
			vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
			gtk_widget_show (vbox);
		}

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

		label = gtk_label_new (NULL);

		if (ismarkup)
		{
			gtk_label_set_markup (GTK_LABEL (label), text);
		}
		else
		{
			gtk_label_set_text (GTK_LABEL (label), text);
		}

		gtk_misc_set_alignment (GTK_MISC (label), 0, 0);
		gtk_widget_show (label);

		gtk_icon_size_lookup (GTK_ICON_SIZE_MENU, NULL, &size);
		pixbuf = gtk_source_mark_attributes_render_icon (attrs,
		                                                 GTK_WIDGET (view),
		                                                 size);

		if (pixbuf != NULL)
		{
			GtkWidget *image;
			PangoLayoutLine *line;
			PangoRectangle rect;
			GtkWidget *align;
			GdkPixbuf *copy;

			align = gtk_alignment_new (0, 0, 0, 0);
			gtk_widget_show (align);

			copy = gdk_pixbuf_copy (pixbuf);
			image = gtk_image_new_from_pixbuf (copy);
			g_object_unref (copy);

			gtk_misc_set_alignment (GTK_MISC (image), 0, 0);
			gtk_widget_show (image);

			/* Measure up to align exact */
			line = pango_layout_get_line (gtk_label_get_layout (GTK_LABEL (label)), 0);
			pango_layout_line_get_pixel_extents (line, NULL, &rect);

			gtk_alignment_set_padding (GTK_ALIGNMENT (align),
				                   (rect.height > size ? rect.height - size : size - rect.height) - 1,
				                   0, 0, 0);
			if (rect.height > size)
			{
				gtk_container_add (GTK_CONTAINER (align),
				                   image);

				image = align;
			}
			else if (size > rect.height)
			{
				gtk_container_add (GTK_CONTAINER (align),
				                   label);
				label = align;
			}
			else
			{
				gtk_widget_destroy (align);
			}

			gtk_box_pack_start (GTK_BOX (hbox),
			                    image,
			                    FALSE,
			                    FALSE,
			                    0);
		}

		gtk_box_pack_end (GTK_BOX (hbox),
		                  label,
		                  TRUE,
		                  TRUE,
		                  0);

		if (g_slist_length (marks) != 1)
		{
			GtkWidget *separator;

			separator = gtk_separator_new (GTK_ORIENTATION_HORIZONTAL);

			gtk_widget_show (separator);

			gtk_box_pack_start (GTK_BOX (vbox),
			                    separator,
			                    FALSE,
			                    FALSE,
			                    0);
		}

		g_free (text);
	}

	if (vbox == NULL)
	{
		return FALSE;
	}

	gtk_tooltip_set_custom (tooltip, vbox);

	return TRUE;
}
Ejemplo n.º 9
0
void doPrefs(void)
{
	GtkWidget*	vbox;
	GtkWidget*	hbox;
	GtkWidget*	item;

	prefswin=gtk_window_new(GTK_WINDOW_TOPLEVEL);
	gtk_window_set_title((GtkWindow*)prefswin,"Preferences");
	vbox=creatNewBox(NEWVBOX,false,8);

//wraplines
	item=gtk_check_button_new_with_label("Wrap Lines");
	gtk_widget_set_name(item,"wrap");
	gtk_toggle_button_set_active((GtkToggleButton*)item,lineWrap);
	gtk_box_pack_start(GTK_BOX(vbox),item,true,true,0);
	g_signal_connect(G_OBJECT(item),"toggled",G_CALLBACK(setPrefs),(void*)item);

//highlite
	item=gtk_check_button_new_with_label("Highlight Current Line");
	gtk_widget_set_name(item,"high");
	gtk_toggle_button_set_active((GtkToggleButton*)item,highLight);
	gtk_box_pack_start(GTK_BOX(vbox),item,true,true,0);
	g_signal_connect(G_OBJECT(item),"toggled",G_CALLBACK(setPrefs),(void*)item);

//use underline
	item=gtk_check_button_new_with_label("Use Underline");
	gtk_widget_set_name(item,"underline");
	gtk_toggle_button_set_active((GtkToggleButton*)item,useUnderline);
	gtk_box_pack_start(GTK_BOX(vbox),item,true,true,0);
	g_signal_connect(G_OBJECT(item),"toggled",G_CALLBACK(setPrefs),(void*)item);

//gzip manpages
	item=gtk_check_button_new_with_label("GZip Man Pages");
	gtk_widget_set_name(item,"gzip");
	gtk_toggle_button_set_active((GtkToggleButton*)item,gzipPages);
	gtk_box_pack_start(GTK_BOX(vbox),item,true,true,0);
	g_signal_connect(G_OBJECT(item),"toggled",G_CALLBACK(setPrefs),(void*)item);

//show live search in toolbar
	item=gtk_check_button_new_with_label("Show 'Live Search' in toolbar");
	gtk_widget_set_name(item,"livesearch");
	gtk_toggle_button_set_active((GtkToggleButton*)item,showLiveSearch);
	gtk_box_pack_start(GTK_BOX(vbox),item,true,true,0);
	g_signal_connect(G_OBJECT(item),"toggled",G_CALLBACK(setPrefs),(void*)item);

//tabwidth
#if 1
#ifdef _USEGTK3_
	GtkAdjustment*	adj=gtk_adjustment_new(tmpTabWidth,1,64,1,1,0);
#else
	GtkObject*	adj=gtk_adjustment_new(tmpTabWidth,1,64,1,1,0);
#endif
	hbox=creatNewBox(NEWHBOX,true,0);
	item=gtk_spin_button_new((GtkAdjustment*)adj,1,0);
	gtk_widget_set_name(item,"tabs");
	gtk_box_pack_start(GTK_BOX(hbox),gtk_label_new("Tab width: "),true,true,0);
	gtk_container_add(GTK_CONTAINER(hbox),item);
	gtk_box_pack_start(GTK_BOX(vbox),hbox,true,true,0);
	g_signal_connect(G_OBJECT(item),"value-changed",G_CALLBACK(setPrefs),(void*)item);
#endif
//font
	fontBox=gtk_entry_new();
	hbox=creatNewBox(NEWHBOX,true,0);

	gtk_box_pack_start(GTK_BOX(hbox),gtk_label_new("Font And Size: "),true,true,0);
	gtk_container_add(GTK_CONTAINER(hbox),fontBox);
	gtk_box_pack_start(GTK_BOX(vbox),hbox,true,true,0);
	gtk_entry_set_text((GtkEntry*)fontBox,fontAndSize);

//terminalcommand
	terminalBox=gtk_entry_new();
	hbox=creatNewBox(NEWHBOX,true,0);

	gtk_box_pack_start(GTK_BOX(hbox),gtk_label_new("Terminal Command: "),true,true,0);
	gtk_container_add(GTK_CONTAINER(hbox),terminalBox);
	gtk_box_pack_start(GTK_BOX(vbox),hbox,true,true,0);
	gtk_entry_set_text((GtkEntry*)terminalBox,terminalCommand);
	gtk_widget_show_all(hbox);

//buttons
#ifdef _USEGTK3_
	gtk_box_pack_start(GTK_BOX(vbox),gtk_separator_new(GTK_ORIENTATION_HORIZONTAL),true,true,0);
#else
	gtk_box_pack_start(GTK_BOX(vbox),gtk_hseparator_new(),true,true,0);
#endif

	hbox=creatNewBox(NEWHBOX,true,4);

#ifdef _USEGTK3_
	item=gtk_button_new_with_label("Apply");
#else
	item=gtk_button_new_from_stock(GTK_STOCK_APPLY);
#endif
	gtk_box_pack_start(GTK_BOX(hbox),item,true,false,2);
	gtk_widget_set_name(item,"apply");
	g_signal_connect(G_OBJECT(item),"clicked",G_CALLBACK(setPrefs),(void*)item);

#ifdef _USEGTK3_
	item=gtk_button_new_with_label("Cancel");
#else
	item=gtk_button_new_from_stock(GTK_STOCK_CANCEL);
#endif
	gtk_box_pack_start(GTK_BOX(hbox),item,true,false,2);
	gtk_widget_set_name(item,"cancel");
	g_signal_connect(G_OBJECT(item),"clicked",G_CALLBACK(setPrefs),(void*)item);
	gtk_box_pack_start(GTK_BOX(vbox),hbox,true,true,2);

//show it
	gtk_container_add(GTK_CONTAINER(prefswin),(GtkWidget*)vbox);
	gtk_widget_show_all(prefswin);
}
Ejemplo n.º 10
0
static void
box_comparison (void)
{
  GtkWidget *window;
  GtkWidget *vbox;
  GtkWidget *box;
  GtkWidget *label;
  GtkWidget *grid;

  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_window_set_title (GTK_WINDOW (window), "Grid vs. Box");
  vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5);
  gtk_container_add (GTK_CONTAINER (window), vbox);

  gtk_container_add (GTK_CONTAINER (vbox), gtk_label_new ("Above"));
  gtk_container_add (GTK_CONTAINER (vbox), gtk_separator_new (GTK_ORIENTATION_HORIZONTAL));

  box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
  gtk_container_add (GTK_CONTAINER (vbox), box);

  gtk_box_pack_start (GTK_BOX (box), test_widget ("1", "white"), FALSE, FALSE, 0);

  label = gtk_label_new ("Some ellipsizing text");
  gtk_label_set_ellipsize (GTK_LABEL (label), PANGO_ELLIPSIZE_END);
  gtk_label_set_width_chars (GTK_LABEL (label), 10);
  gtk_box_pack_start (GTK_BOX (box), label, TRUE, FALSE, 0);

  gtk_box_pack_start (GTK_BOX (box), test_widget ("2", "green"), FALSE, FALSE, 0);

  label = gtk_label_new ("Some text that may wrap if needed");
  gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
  gtk_label_set_width_chars (GTK_LABEL (label), 10);
  gtk_box_pack_start (GTK_BOX (box), label, TRUE, FALSE, 0);

  gtk_box_pack_start (GTK_BOX (box), test_widget ("3", "red"), FALSE, FALSE, 0);

  grid = gtk_grid_new ();
  gtk_orientable_set_orientation (GTK_ORIENTABLE (grid), GTK_ORIENTATION_VERTICAL);
  gtk_container_add (GTK_CONTAINER (vbox), gtk_separator_new (GTK_ORIENTATION_HORIZONTAL));
  gtk_container_add (GTK_CONTAINER (vbox), grid);

  gtk_grid_attach (GTK_GRID (grid), test_widget ("1", "white"), 0, 0, 1, 1);

  label = gtk_label_new ("Some ellipsizing text");
  gtk_label_set_ellipsize (GTK_LABEL (label), PANGO_ELLIPSIZE_END);
  gtk_label_set_width_chars (GTK_LABEL (label), 10);
  gtk_grid_attach (GTK_GRID (grid), label, 1, 0, 1, 1);
  gtk_widget_set_hexpand (label, TRUE);

  gtk_grid_attach (GTK_GRID (grid), test_widget ("2", "green"), 2, 0, 1, 1);

  label = gtk_label_new ("Some text that may wrap if needed");
  gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
  gtk_label_set_width_chars (GTK_LABEL (label), 10);
  gtk_grid_attach (GTK_GRID (grid), label, 3, 0, 1, 1);
  gtk_widget_set_hexpand (label, TRUE);

  gtk_grid_attach (GTK_GRID (grid), test_widget ("3", "red"), 4, 0, 1, 1);

  gtk_container_add (GTK_CONTAINER (vbox), gtk_separator_new (GTK_ORIENTATION_HORIZONTAL));
  gtk_container_add (GTK_CONTAINER (vbox), gtk_label_new ("Below"));

  gtk_widget_show_all (window);
}
Ejemplo n.º 11
0
static void
create_colors (void)
{
   static GtkWidget *window = NULL;
   GtkWidget *box1 = NULL;
   GtkWidget *box2 = NULL;
   GtkWidget *close_button = NULL;
   GtkWidget *box = NULL;
   GtkWidget *separator;
   GtkWidget *label;
   GtkWidget *menu;
   GtkWidget *root_menu;
   GtkWidget *menu_bar;
   gfloat *X = NULL;
   gfloat *Y = NULL;
   gint i, j;
   GtkDataboxGraph *graph;
   GdkRGBA color;

   window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
   gtk_widget_set_size_request (window, 500, 300);

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

   gtk_window_set_title (GTK_WINDOW (window), "GtkDatabox: Colors");
   gtk_container_set_border_width (GTK_CONTAINER (window), 0);

   box1 = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
   gtk_container_add (GTK_CONTAINER (window), box1);

   box = gtk_databox_new ();
   gtk_databox_set_enable_selection (GTK_DATABOX (box), FALSE);
   gtk_databox_set_enable_zoom (GTK_DATABOX (box), FALSE);

   color.red = 0;
   color.green = 0;
   color.blue = 0;
   color.alpha = 1;

   gtk_widget_override_background_color (box, GTK_STATE_FLAG_NORMAL, &color);

   menu = gtk_menu_new ();
   root_menu = gtk_menu_item_new_with_label ("Color Menu");
   gtk_menu_item_set_submenu (GTK_MENU_ITEM (root_menu), menu);
   menu_bar = gtk_menu_bar_new ();
   gtk_menu_shell_append (GTK_MENU_SHELL (menu_bar), root_menu);
   gtk_box_pack_start (GTK_BOX (box1), menu_bar, FALSE, TRUE, 0);


   label =
      gtk_label_new
      ("You can change the colors of the shown datasets via the menu.\n\n");
   gtk_box_pack_start (GTK_BOX (box1), label, FALSE, FALSE, 0);
   separator = gtk_separator_new (GTK_ORIENTATION_HORIZONTAL);
   gtk_box_pack_start (GTK_BOX (box1), separator, FALSE, FALSE, 0);

   g_signal_connect (G_OBJECT (box), "destroy",
		     G_CALLBACK (gtk_main_quit), NULL);


   for (i = 0; i < NO_OF_DATASETS; i++)
   {
      if (!i)
	 X = g_new0 (gfloat, POINTS);
      Y = g_new0 (gfloat, POINTS);
      for (j = 0; j < POINTS; j++)
      {
	 X[j] = j;
	 Y[j] = 100. * sin ((i + 1) * 2 * j * G_PI / POINTS);
      }
      color.red = 1 * ((i + 1) % 2);
      color.green = (1 / 2) * ((i + 1) % 3);
      color.blue = (1 / 3) * ((i + 1) % 4);
      graph = gtk_databox_points_new (POINTS, X, Y, &color, 1);
      gtk_databox_graph_add (GTK_DATABOX (box), graph);
      create_menu_entry (menu, i, box, graph);
   }

   gtk_databox_auto_rescale (GTK_DATABOX (box), 0.05);

   gtk_box_pack_start (GTK_BOX (box1), box, TRUE, TRUE, 0);

   separator = gtk_separator_new (GTK_ORIENTATION_HORIZONTAL);
   gtk_box_pack_start (GTK_BOX (box1), separator, FALSE, TRUE, 0);

   box2 = gtk_box_new (GTK_ORIENTATION_VERTICAL, 10);
   gtk_container_set_border_width (GTK_CONTAINER (box2), 10);
   gtk_box_pack_end (GTK_BOX (box1), box2, FALSE, TRUE, 0);
   close_button = gtk_button_new_with_label ("close");
   g_signal_connect (G_OBJECT (close_button), "clicked",
		     G_CALLBACK (gtk_main_quit), (gpointer) NULL);
   gtk_box_pack_start (GTK_BOX (box2), close_button, TRUE, TRUE, 0);
   gtk_widget_set_can_default(close_button, TRUE);
   gtk_widget_grab_default (close_button);





   gtk_widget_show_all (window);

}
Ejemplo n.º 12
0
void i_configure_gui( void )
{
  static GtkWidget *configwin = NULL;
  GdkGeometry cw_hints;
  GtkWidget *configwin_vbox;
  GtkWidget *hseparator, *hbuttonbox, *button_ok, *button_cancel, *button_apply;

  GtkWidget *configwin_notebook;

  GtkWidget *ap_page_alignment, *ap_pagelabel_alignment; /* amidi-plug */
  GtkWidget *alsa_page_alignment, *alsa_pagelabel_alignment; /* alsa */
  GtkWidget *fsyn_page_alignment, *fsyn_pagelabel_alignment; /* fluidsynth */

  GSList *backend_list = NULL, *backend_list_h = NULL;

  if ( configwin != NULL )
  {
    DEBUGMSG( "config window is already open!\n" );
    return;
  }

  /* get configuration information for backends */
  i_configure_cfg_backend_alloc();
  i_configure_cfg_backend_read();

  configwin = gtk_window_new( GTK_WINDOW_TOPLEVEL );
  gtk_window_set_type_hint( GTK_WINDOW(configwin), GDK_WINDOW_TYPE_HINT_DIALOG );
  gtk_window_set_title( GTK_WINDOW(configwin), _("AMIDI-Plug - configuration") );
  gtk_container_set_border_width( GTK_CONTAINER(configwin), 10 );
  g_signal_connect( G_OBJECT(configwin) , "destroy" ,
                    G_CALLBACK(gtk_widget_destroyed) , &configwin );
  button_ok = gtk_button_new_from_stock( GTK_STOCK_OK );

  if (! g_signal_lookup ("ap-commit", G_OBJECT_TYPE (button_ok)))
    g_signal_new ("ap-commit", G_OBJECT_TYPE (button_ok), G_SIGNAL_ACTION, 0,
     NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);

  g_signal_connect (button_ok, "clicked", (GCallback) commit_cb, NULL);

  cw_hints.min_width = 480; cw_hints.min_height = -1;
  gtk_window_set_geometry_hints( GTK_WINDOW(configwin) , GTK_WIDGET(configwin) ,
                                 &cw_hints , GDK_HINT_MIN_SIZE );

  configwin_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0 );
  gtk_container_add( GTK_CONTAINER(configwin) , configwin_vbox );

  configwin_notebook = gtk_notebook_new();
  gtk_notebook_set_tab_pos( GTK_NOTEBOOK(configwin_notebook) , GTK_POS_LEFT );
  gtk_box_pack_start( GTK_BOX(configwin_vbox) , configwin_notebook , TRUE , TRUE , 2 );

  /* GET A LIST OF BACKENDS */
  backend_list = i_backend_list_lookup(); /* get a list of available backends */;
  backend_list_h = backend_list;

  /* AMIDI-PLUG PREFERENCES TAB */
  ap_pagelabel_alignment = gtk_alignment_new( 0.5 , 0.5 , 1 , 1 );
  ap_page_alignment = gtk_alignment_new( 0.5 , 0.5 , 1 , 1 );
  gtk_alignment_set_padding( GTK_ALIGNMENT(ap_page_alignment) , 3 , 3 , 8 , 3 );
  i_configure_gui_tab_ap( ap_page_alignment , backend_list , button_ok );
  i_configure_gui_tablabel_ap( ap_pagelabel_alignment , backend_list , button_ok );
  gtk_notebook_append_page( GTK_NOTEBOOK(configwin_notebook) ,
                            ap_page_alignment , ap_pagelabel_alignment );

  /* ALSA BACKEND CONFIGURATION TAB */
  alsa_pagelabel_alignment = gtk_alignment_new( 0.5 , 0.5 , 1 , 1 );
  alsa_page_alignment = gtk_alignment_new( 0.5 , 0.5 , 1 , 1 );
  gtk_alignment_set_padding( GTK_ALIGNMENT(alsa_page_alignment) , 3 , 3 , 8 , 3 );
  i_configure_gui_tab_alsa( alsa_page_alignment , backend_list , button_ok );
  i_configure_gui_tablabel_alsa( alsa_pagelabel_alignment , backend_list , button_ok );
  gtk_notebook_append_page( GTK_NOTEBOOK(configwin_notebook) ,
                            alsa_page_alignment , alsa_pagelabel_alignment );

  /* FLUIDSYNTH BACKEND CONFIGURATION TAB */
  fsyn_pagelabel_alignment = gtk_alignment_new( 0.5 , 0.5 , 1 , 1 );
  fsyn_page_alignment = gtk_alignment_new( 0.5 , 0.5 , 1 , 1 );
  gtk_alignment_set_padding( GTK_ALIGNMENT(fsyn_page_alignment) , 3 , 3 , 8 , 3 );
  i_configure_gui_tab_fsyn( fsyn_page_alignment , backend_list , button_ok );
  i_configure_gui_tablabel_fsyn( fsyn_pagelabel_alignment , backend_list , button_ok );
  gtk_notebook_append_page( GTK_NOTEBOOK(configwin_notebook) ,
                            fsyn_page_alignment , fsyn_pagelabel_alignment );

  i_backend_list_free( backend_list_h ); /* done, free the list of available backends */

  /* horizontal separator and buttons */
  hseparator = gtk_separator_new (GTK_ORIENTATION_HORIZONTAL);
  gtk_box_pack_start( GTK_BOX(configwin_vbox) , hseparator , FALSE , FALSE , 4 );
  hbuttonbox = gtk_button_box_new (GTK_ORIENTATION_HORIZONTAL);
  gtk_button_box_set_layout( GTK_BUTTON_BOX(hbuttonbox) , GTK_BUTTONBOX_END );
  button_apply = gtk_button_new_from_stock( GTK_STOCK_APPLY );
  gtk_container_add( GTK_CONTAINER(hbuttonbox) , button_apply );
  button_cancel = gtk_button_new_from_stock( GTK_STOCK_CANCEL );
  g_signal_connect_swapped( G_OBJECT(button_cancel) , "clicked" ,
                            G_CALLBACK(i_configure_ev_bcancel) , configwin );
  gtk_container_add( GTK_CONTAINER(hbuttonbox) , button_cancel );
  /* button_ok = gtk_button_new_from_stock( GTK_STOCK_OK ); created above */
  g_object_set_data( G_OBJECT(button_ok) , "bapply_pressed" , GUINT_TO_POINTER(0) );
  g_object_set_data( G_OBJECT(button_apply) , "bok" , button_ok );
  g_signal_connect( G_OBJECT(button_ok) , "ap-commit" ,
                    G_CALLBACK(i_configure_ev_bok) , configwin );
  g_signal_connect( G_OBJECT(button_apply) , "clicked" ,
                    G_CALLBACK(i_configure_ev_bapply) , configwin );
  gtk_container_add( GTK_CONTAINER(hbuttonbox) , button_ok );
  gtk_box_pack_start( GTK_BOX(configwin_vbox) , hbuttonbox , FALSE , FALSE , 0 );

  gtk_widget_show_all( configwin );
}
Ejemplo n.º 13
0
// Основная функция построения класса, в которой происходит заполнение окна виджетами.
void cMainWin::Create()
{
	// Создаём объект, если ранее он был не создан или был уничтожен.
	if(mbIsCreated)
		return;


	// Общие виджеты. Будут использованы несколько раз.
	GtkWidget *awHBox;		// Горизонтальный бокс.
	GtkWidget *awVBox;		// Вертикальный бокс.
	GtkWidget *awLabel;		// Заголовок.
	GtkWidget *awFrame;		// Фрейм для виджетов.

	GtkWidget *awMenuBar;		// Виджет для основного меню.
	GtkWidget *awSubmenu;		// Подменю.
	GtkWidget *awMenuitem;		// Пункт основного меню.
	GtkWidget *awSubMenuitem;	// Пункт подменю.

	GtkWidget *awOpenFileButton;	// Кнопка открытия файла.
	GtkWidget *awAdditionButton;	// Кнопка доп. настроек.
	GtkWidget *awConvertButton;		// Кнопка конвертации.


	// Настраиваем виджет главного окна.
	mwWindow = gtk_window_new(GTK_WINDOW_TOPLEVEL);
	gtk_window_set_default_size ((GtkWindow *)mwWindow, 800, 400);	// Задаём размер.
	gtk_window_move((GtkWindow *)mwWindow, 50, 50);					// Перемещаем окно.
	gtk_window_set_title((GtkWindow *)mwWindow, msTitle.c_str());	// Задаём имя.

	// Устанавливаем обработчик события уничтожения окна.
	g_signal_connect(
			G_OBJECT(mwWindow), "delete_event",
			G_CALLBACK(gtk_main_quit), this);



	// Создаём новый вертикальный бокс и забиваем его в основное окно.
	mwMainBox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
	gtk_container_add((GtkContainer *)mwWindow, mwMainBox);



	// Создаём новый виджет основного меню.
	awMenuBar = gtk_menu_bar_new ();
    gtk_box_pack_start (GTK_BOX (mwMainBox), awMenuBar, FALSE, TRUE, 0);	// Забиваем меню в главный бокс.


    // Создаём новый пункт меню Справка и заполняем его подменю.
    awMenuitem = gtk_menu_item_new_with_label ("Справка");
    awSubmenu = gtk_menu_new();


    // Добавляем в подменю новый пункт.
    awSubMenuitem = gtk_menu_item_new_with_label ("О программе");
    gtk_menu_shell_append (GTK_MENU_SHELL (awSubmenu), awSubMenuitem);	// Не забываем связать этот пункт с подменю.

    // Устанавливаем обработчик нажатия на пункт подменю.
    g_signal_connect(awSubMenuitem, "activate",
                                    G_CALLBACK(OnAbout), this);

    gtk_menu_item_set_submenu (GTK_MENU_ITEM (awMenuitem), awSubmenu);	// Связываем подменю с главным.
    gtk_menu_shell_append (GTK_MENU_SHELL (awMenuBar), awMenuitem);		// И добавляем пунтк меню в главное меню.


    // Добавляем в главный бокс разделитель виджетов(простая длинная линия).
    gtk_box_pack_start (GTK_BOX (mwMainBox), gtk_separator_new(GTK_ORIENTATION_HORIZONTAL), FALSE, TRUE, 5);


    // Задаём вертикальный бокс для первого пункта процесса конвертации и забиваем его в главный бокс.
	awVBox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
	gtk_box_pack_start(GTK_BOX(mwMainBox), awVBox, FALSE, FALSE, 1);

	// Задаём горизонтальный бокс для первого пункта процесса конвертации и забиваем его в предыдущий вертикальный бокс.
	awHBox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
	gtk_box_pack_start(GTK_BOX(awVBox), awHBox, FALSE, FALSE, 1);

	// Задаём виджет для отображения текста и добавляем в горизонтальный бокс.
	awLabel = gtk_label_new ("1.");
	//gtk_widget_set_halign (awLabel, GTK_ALIGN_START); // Выравнивание. Не нужно, если использовать горизонтальный бокс.
	gtk_box_pack_start(GTK_BOX(awHBox), awLabel, FALSE, FALSE, 5);

	// Создаём кнопку Открыть файл и добавляем в горизонтальный бокс.
	awOpenFileButton = gtk_button_new_with_label ("Открыть файл");
	gtk_box_pack_start(GTK_BOX(awHBox), awOpenFileButton, FALSE, FALSE, 10);

	// Устанавливаем обработчик нажатия на кнопку Открыть файл.
    g_signal_connect(awOpenFileButton, "clicked",
    									G_CALLBACK(OnOpenFile), this);


    // Создаём бокс для списка всех записей и добавляем в горизонтальный бокс.
    mwTrackNameBox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
    gtk_box_pack_start(GTK_BOX(awHBox), mwTrackNameBox, FALSE, FALSE, 5);


    // Переходим ко второму пункту меню
    // Задаём вертикальный бокс для второго пункта процесса конвертации и забиваем его в главный бокс.
	awVBox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
	gtk_box_pack_start(GTK_BOX(mwMainBox), awVBox, FALSE, FALSE, 10);

	// Задаём горизонтальный бокс для второго пункта процесса конвертации и забиваем его в предыдущий вертикальный бокс.
	awHBox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
	gtk_box_pack_start(GTK_BOX(awVBox), awHBox, FALSE, FALSE, 1);

	// Задаём виджет для отображения текста и добавляем в горизонтальный бокс.
	awLabel = gtk_label_new ("2. ");
	gtk_box_pack_start(GTK_BOX(awHBox), awLabel, FALSE, FALSE, 5);


	// Создаём комбо бокс для выбора формата конвертации.
	mwFormat = gtk_combo_box_text_new ();
	for(int i = eFormat_MP3; i < eFormat_Unknown; i++)
	{
		// Для каждого пункта из enum добавляем пункт в комбо боксе со своим текстом из asFormat.
		gtk_combo_box_text_insert_text ((GtkComboBoxText *)mwFormat, -1, asFormat[i].c_str());
	}
	gtk_combo_box_set_active((GtkComboBox *)mwFormat, 0);	// Устанавливаем активный элемент на первый в списке.

	// Задаём обработчик события смены формата.
	g_signal_connect (mwFormat, "changed",
								G_CALLBACK (OnChangeFormat), this);

	gtk_box_pack_start(GTK_BOX(awHBox), mwFormat, FALSE, FALSE, 5);		// Добавляем комбо бокс в горизонтальный бокс.


	// Теперь настроим виджеты, которые будут соответствовать формату конвертации из комбо бокса.
	// Виджеты, соответствующие формату, будут показываться, только при выборе этого формата в комбо боксе.
	// Задаём горизонтальный бокс для настроек под определённый формат и добавляем его в вертикальный бокс.
	awHBox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
	gtk_box_pack_start(GTK_BOX(awVBox), awHBox, FALSE, FALSE, 10);

	// Настроим MP3 виджеты.
	// Задаём слайдер качества с определённым количеством меток.
	mMP3Widgets.mwQuality = gtk_scale_new_with_range (GTK_ORIENTATION_HORIZONTAL, 0, eMP3Quality_count-1, 1);
	gtk_scale_set_draw_value ((GtkScale *)mMP3Widgets.mwQuality, FALSE);	// Не будем рисовать текущее значение.

	// Добавим метки на шкалу слайдера для визуализации.
	for(int i = 0; i < eMP3Quality_count; i++)
	{
		std::string asQ = asMP3Quality[i] +"kbps";	// Значения мток берём из asMP3Quality массива.
		gtk_scale_add_mark ((GtkScale *)mMP3Widgets.mwQuality, i, GTK_POS_TOP, asQ.c_str());
	}

	gtk_box_pack_start(GTK_BOX(awHBox), mMP3Widgets.mwQuality, TRUE, TRUE, 30);			// Добавляем слайдер в горизонтальный бокс.
	gtk_range_set_show_fill_level ((GtkRange *)mMP3Widgets.mwQuality, TRUE);			// Заполняем слайдер другим цветом.
	gtk_range_set_restrict_to_fill_level ((GtkRange *)mMP3Widgets.mwQuality, TRUE);		// Устанавливаем указатель слайдера до уровня заполнения слайдера.
	gtk_range_set_fill_level ((GtkRange *)mMP3Widgets.mwQuality, eMP3Quality_count-1);	// Полностью заполняем слайдер цветом.
	gtk_range_set_value ((GtkRange *)mMP3Widgets.mwQuality, eMP3Quality_count-1);		// Ставим значение слайдера на последнее из массива значений.

	// Указатель теперь связан с уровнем заполнения, но указатель всё ещё можно двигать, не меняя уровень заполнения.
	// Для этого необходимо ввести 2 обработчика событий - изменение значение слайдера и изменение границ указателя, для перемещения уровня заполнения.
	g_signal_connect (mMP3Widgets.mwQuality, "value-changed", G_CALLBACK (OnQualityChanged), this);
	g_signal_connect (mMP3Widgets.mwQuality, "adjust-bounds", G_CALLBACK (OnAdjustBoundsQuality), this);

	gtk_widget_show(mMP3Widgets.mwQuality);	// Показываем виджеты страницы MP3 конвертера.


	// Настраиваем OGG виджеты.
	// Задаём слайдер качества с определённым количеством меток.
	mOGGWidgets.mwQuality = gtk_scale_new_with_range (GTK_ORIENTATION_HORIZONTAL, 0, eOGGQuality_count-1, 1);
	gtk_scale_set_draw_value ((GtkScale *)mOGGWidgets.mwQuality, FALSE);

	// Добавим метки на шкалу слайдера для визуализации.
	for(int i = 0; i < eOGGQuality_count; i++)
	{
		std::string asQ = asOGGQuality[i] +"kbps";	// Значения мток берём из asOGGQuality массива.
		gtk_scale_add_mark ((GtkScale *)mOGGWidgets.mwQuality, i, GTK_POS_TOP, asQ.c_str());
	}

	gtk_box_pack_start(GTK_BOX(awHBox), mOGGWidgets.mwQuality, TRUE, TRUE, 30);			// Добавляем слайдер в горизонтальный бокс.
	gtk_range_set_show_fill_level ((GtkRange *)mOGGWidgets.mwQuality, TRUE);			// Заполняем слайдер другим цветом.
	gtk_range_set_restrict_to_fill_level ((GtkRange *)mOGGWidgets.mwQuality, TRUE);		// Устанавливаем указатель слайдера до уровня заполнения слайдера.
	gtk_range_set_fill_level ((GtkRange *)mOGGWidgets.mwQuality, eOGGQuality_count-1);	// Полностью заполняем слайдер цветом.
	gtk_range_set_value ((GtkRange *)mOGGWidgets.mwQuality, eOGGQuality_count-1);		// Ставим значение слайдера на последнее из массива значений.

	// Снова вводим 2 обработчика событий, один на изменение значения слайдера и друго для изменения границ указателя, для перемещения уровня заполнения.
	g_signal_connect (mOGGWidgets.mwQuality, "value-changed", G_CALLBACK (OnQualityChanged), this);
	g_signal_connect (mOGGWidgets.mwQuality, "adjust-bounds", G_CALLBACK (OnAdjustBoundsQuality), this);


	// Добавим новую кнопку Дополнительно для отображения дополнительных параметров и добавим его в горизонтальный бокс.
	awAdditionButton = gtk_button_new_with_label ("Дополнительно");
	gtk_box_pack_end(GTK_BOX(awHBox), awAdditionButton, FALSE, FALSE, 30);

	// Введём обработчик нажатия на кнопку Дополнительно.
    g_signal_connect(awAdditionButton, "clicked",
    									G_CALLBACK(OnShowAdditionalSettings), this);


    // Переходим к третьему пункту меню.
    // Задаём вертикальный бокс для третьего пункта процесса конвертации и забиваем его в главный бокс.
	awVBox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
	gtk_box_pack_start(GTK_BOX(mwMainBox), awVBox, FALSE, FALSE, 1);

	// Задаём горизонтальный бокс для третьего пункта процесса конвертации и забиваем его в предыдущий вертикальный бокс.
	awHBox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
	gtk_box_pack_start(GTK_BOX(awVBox), awHBox, FALSE, FALSE, 10);

	// Задаём виджет для отображения текста и добавляем в горизонтальный бокс.
	awLabel = gtk_label_new ("3.");
	gtk_box_pack_start(GTK_BOX(awHBox), awLabel, FALSE, FALSE, 5);


	// Добавим кнопку Конвертировать - для начала процесса конвертации ваших аудио файлов. Добавим кнопку в горизонтальный бокс.
	awConvertButton = gtk_button_new_with_label ("Конвертировать");
	gtk_box_pack_start(GTK_BOX(awHBox), awConvertButton, FALSE, FALSE, 10);

	// Создадим спиннер для визуального отображения процесса конвертации.
	// Это просто необходимо, т.к. программа как бы подвисает, из-за того что мы конвертируем в одном потоке с программой.
	// Серъёзно нагружает процессор =(
	mwSpinner = gtk_spinner_new ();
	gtk_box_pack_start(GTK_BOX(awHBox), mwSpinner, FALSE, FALSE, 5);


	// Обработчик события нажатие на кнопку Конвертация.
	g_signal_connect(awConvertButton, "clicked",
										G_CALLBACK(OnConvert), this);


	gtk_widget_show_all (mwWindow);	// Покажем все виджеты в окне.

	gtk_widget_hide(mOGGWidgets.mwQuality);	// Скроем виджеты со страницы OGG. По умолчанию отображаем конвертацию в MP3.
	gtk_widget_hide(mwSpinner);				// Скроем спиннер, т.к. мы хотим его показать только в момент конвертации файлов.


	mbIsCreated = true;	// Объект создан.
}
Ejemplo n.º 14
0
int music_build_element_widgets () {
	int i = 0;
	for (i = 0; i < 9; i++) {
		label_music_info[i] = gtk_label_new(NULL);
		gtk_label_set_width_chars(GTK_LABEL(label_music_info[i]), 15);
		gtk_label_set_max_width_chars(GTK_LABEL(label_music_info[i]), 150);
		gtk_label_set_line_wrap(GTK_LABEL(label_music_info[i]), TRUE);
	}
	separator_music_info = gtk_separator_new(GTK_ORIENTATION_VERTICAL);
	
	for (i = 0; i < 9; i++) {
		label_music_lyric[i] = gtk_label_new(NULL);
		gtk_label_set_max_width_chars(GTK_LABEL(label_music_lyric[i]), 305);
// 		gtk_label_set_line_wrap(GTK_LABEL(label_music_lyric[i]), TRUE);
	}
	gtk_label_set_selectable(GTK_LABEL(label_music_lyric[4]), TRUE);
	gtk_label_set_use_underline (GTK_LABEL(label_music_lyric[4]), TRUE);
	gtk_label_set_use_markup (GTK_LABEL(label_music_lyric[4]), TRUE);
	gtk_label_set_pattern (GTK_LABEL(label_music_lyric[4]), "________");
	separator_music_lyric1 =  gtk_separator_new (GTK_ORIENTATION_HORIZONTAL);
	separator_music_lyric2 =  gtk_separator_new (GTK_ORIENTATION_HORIZONTAL);

	button_music_start_server = gtk_button_new_with_label("启动服务器");
// 	set_button_music_start_server(button_music_start_server);
	
	button_music_exit_server = gtk_button_new_with_label("关闭服务器");
// 	set_button_music_exit_server(button_music_exit_server);
	
	
	button_music_play = gtk_button_new();
// 	box_music_play = button_with_image("/usr/share/raspi_remote_control/ui_images/ui_images_music/play.png");
// 	box_music_pause = button_with_image("/usr/share/raspi_remote_control/ui_images/ui_images_music/pause.png");
	image_music_play = gtk_image_new_from_file("/usr/share/raspi_remote_control/ui_images/ui_images_music/play.png");
	image_music_play_light = gtk_image_new_from_file("/usr/share/raspi_remote_control/ui_images/ui_images_music/play_light.png");
	image_music_pause = gtk_image_new_from_file ("/usr/share/raspi_remote_control/ui_images/ui_images_music/pause.png");
	image_music_pause_light = gtk_image_new_from_file ("/usr/share/raspi_remote_control/ui_images/ui_images_music/pause_light.png");
	gtk_button_set_relief(GTK_BUTTON(button_music_play), GTK_RELIEF_NONE);
	set_button_music_play(button_music_play);
	
	button_music_pause = gtk_button_new_with_label("暂停");
// 	set_button_music_pause(button_music_pause);
	
	button_music_unpause = gtk_button_new_with_label("取消暂停");
// 	set_button_music_unpause(button_music_unpause);
	
// 	button_music_stop = gtk_button_new_with_label("停止");
	button_music_stop = gtk_button_new();
	image_music_stop = gtk_image_new_from_file ("/usr/share/raspi_remote_control/ui_images/ui_images_music/stop.png");
	image_music_stop_light = gtk_image_new_from_file ("/usr/share/raspi_remote_control/ui_images/ui_images_music/stop_light.png");
	gtk_button_set_image(GTK_BUTTON(button_music_stop), image_music_stop);
	gtk_button_set_relief(GTK_BUTTON(button_music_stop), GTK_RELIEF_NONE);
	set_button_music_stop(button_music_stop);
	
// 	button_music_next = gtk_button_new_with_label("下一首");
	button_music_next = gtk_button_new();
	image_music_next = gtk_image_new_from_file("/usr/share/raspi_remote_control/ui_images/ui_images_music/next.png");
	image_music_next_light = gtk_image_new_from_file("/usr/share/raspi_remote_control/ui_images/ui_images_music/next_light.png");
	gtk_button_set_image(GTK_BUTTON(button_music_next), image_music_next);
	gtk_button_set_relief(GTK_BUTTON(button_music_next), GTK_RELIEF_NONE);
	set_button_music_next(button_music_next);
	
// 	button_music_pre = gtk_button_new_with_label("上一首");
	button_music_pre = gtk_button_new();
	image_music_pre = gtk_image_new_from_file("/usr/share/raspi_remote_control/ui_images/ui_images_music/pre.png");
	image_music_pre_light = gtk_image_new_from_file("/usr/share/raspi_remote_control/ui_images/ui_images_music/pre_light.png");
	gtk_button_set_image (GTK_BUTTON(button_music_pre), image_music_pre);
	gtk_button_set_relief(GTK_BUTTON(button_music_pre), GTK_RELIEF_NONE);
	set_button_music_pre(button_music_pre);
	

	
	
// 	button_music_volume_up = gtk_button_new_with_label("音量+");
// 	set_button_music_volume_up(button_music_volume_up);
	
// 	button_music_volume_silence = gtk_button_new_with_label("静音");
	button_music_silence = gtk_button_new();
	image_music_silence = gtk_image_new_from_file("/usr/share/raspi_remote_control/ui_images/ui_images_music/silence.png");
	image_music_silence_light = gtk_image_new_from_file("/usr/share/raspi_remote_control/ui_images/ui_images_music/silence_light.png");
	image_music_unsilence = gtk_image_new_from_file("/usr/share/raspi_remote_control/ui_images/ui_images_music/unsilence.png");
	image_music_unsilence_light = gtk_image_new_from_file("/usr/share/raspi_remote_control/ui_images/ui_images_music/unsilence_light.png");
	gtk_button_set_image (GTK_BUTTON(button_music_silence), image_music_silence);
	gtk_button_set_relief(GTK_BUTTON(button_music_silence), GTK_RELIEF_NONE);
	set_button_music_silence(button_music_silence);
	
	button_music_volume = gtk_volume_button_new();
	set_button_music_volume( button_music_volume);
	
	button_music_reset_list = gtk_button_new_with_label("重设列表");
	set_button_music_reset_list(button_music_reset_list);
	
// 	button_music_choose_path = gtk_button_new_with_label("添加路径");
// 	set_button_music_choose_path(button_music_choose_path);
// 	music_path_dialog = gtk_file_chooser_widget_new(GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER);
	music_path_dialog = gtk_file_chooser_dialog_new ("test_title", NULL, GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER, "test_button_text", NULL);
	button_music_choose_path = gtk_file_chooser_button_new_with_dialog (music_path_dialog);
	gtk_file_chooser_button_set_title (GTK_FILE_CHOOSER_BUTTON(button_music_choose_path), "添加路径");
// 	gtk_file_chooser_set_select_multiple (music_path_dialog, TRUE);
	
	
	button_music_delete_path = gtk_button_new_with_label("删除当前路径");
	set_button_music_delete_path(button_music_delete_path);
	
	scale_music_process = gtk_scale_new_with_range (GTK_ORIENTATION_HORIZONTAL, 0, 100, 1);
	set_scale_music_process(scale_music_process);
	
	label_music_cur_time = gtk_label_new ("--:--:--");
	label_music_total_time = gtk_label_new ("--:--:--");
	
	switch_music_autonext = gtk_switch_new ();
	set_switch_music_autonext ();
	label_music_autonext = gtk_label_new ("AutoNext: ");
	
	switch_music_repeat = gtk_switch_new ();
	set_switch_music_repeat ();
	label_music_repeat = gtk_label_new ("Repeat: ");
	
	switch_music_shuffle = gtk_switch_new ();
	set_switch_music_shuffle ();
	label_music_shuffle = gtk_label_new ("Shuffle: ");
	
	radio_button_music_mode_shuffle = gtk_radio_button_new (NULL);
	label_music_mode_shuffle = gtk_label_new ("随机:");
	radio_button_music_mode_loop_list = gtk_radio_button_new_from_widget (GTK_RADIO_BUTTON (radio_button_music_mode_shuffle));
	label_music_mode_loop_list = gtk_label_new ("列表循环:");
	radio_button_music_mode_play_list = gtk_radio_button_new_from_widget (GTK_RADIO_BUTTON (radio_button_music_mode_shuffle));
	label_music_mode_play_list = gtk_label_new ("播放列表:");
	radio_button_music_mode_loop_one = gtk_radio_button_new_from_widget (GTK_RADIO_BUTTON (radio_button_music_mode_shuffle));
	label_music_mode_loop_one = gtk_label_new ("单曲:");
	spinner_music_mode_changing = gtk_spinner_new ();
	
	set_radio_button_music_mode ();
	
	
	store_music_dir_list = gtk_tree_store_new(dir_n_columns, G_TYPE_STRING);
	tree_view_music_dir_list = gtk_tree_view_new_with_model (GTK_TREE_MODEL(store_music_dir_list));
	text_renderer_music_dir_list = gtk_cell_renderer_text_new ();
	column_music_dir_list = gtk_tree_view_column_new_with_attributes (NULL, text_renderer_music_dir_list, "text", dir_name, NULL);
	gtk_tree_view_column_set_fixed_width(column_music_dir_list, 100);
	gtk_tree_view_append_column (GTK_TREE_VIEW (tree_view_music_dir_list), column_music_dir_list);
	music_dir_list_sw_adj_h = gtk_adjustment_new(100, 0, 100, 1, 1, 50);
	music_dir_list_sw = gtk_scrolled_window_new(NULL, music_dir_list_sw_adj_h);
	gtk_scrolled_window_set_min_content_height(GTK_SCROLLED_WINDOW(music_dir_list_sw), 330);
	gtk_scrolled_window_set_min_content_width(GTK_SCROLLED_WINDOW(music_dir_list_sw), 100);
	gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(music_dir_list_sw), GTK_SHADOW_NONE);
// 	gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(music_dir_list_sw), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
	gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(music_dir_list_sw), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
	gtk_container_add(GTK_CONTAINER(music_dir_list_sw), tree_view_music_dir_list);
	
	selection_music_dir_list = gtk_tree_view_get_selection (GTK_TREE_VIEW (tree_view_music_dir_list));
	set_tree_view_music_dir_list ();
	

	store_music_list = gtk_tree_store_new(list_n_columns, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING);
// 	char file_index[BUFSIZ];
// 	printf("music_list_num is: %s\n", music_list_num);
// 	while (i < music_list_num) {
// // 		printf("%d: %s\n", i, music_list[i]);
// 		sprintf(file_index, "%d", i + 1);
// 		gtk_tree_store_append(store_music_list, &iter_music_list, NULL);
// 		gtk_tree_store_set (store_music_list, &iter_music_list, list_index, file_index, list_title, music_list[i], list_total_sec, "03:00", -1);
// 		i++;
// 	}
// 	
	tree_view_music_list = gtk_tree_view_new_with_model (GTK_TREE_MODEL(store_music_list));
	
	text_renderer_music_list = gtk_cell_renderer_text_new ();
	column_music_list = gtk_tree_view_column_new_with_attributes (NULL, text_renderer_music_list, "text", list_index, NULL);
	gtk_tree_view_append_column (GTK_TREE_VIEW (tree_view_music_list), column_music_list);
	
	gtk_tree_view_column_set_title(column_music_list, "序号");
	
	text_renderer_music_list = gtk_cell_renderer_text_new ();
	column_music_list = gtk_tree_view_column_new_with_attributes (NULL, text_renderer_music_list, "text", list_title, NULL);
	gtk_tree_view_column_set_fixed_width(column_music_list, 100);
	gtk_tree_view_append_column (GTK_TREE_VIEW (tree_view_music_list), column_music_list);
	
// 	text_renderer_music_list = gtk_cell_renderer_text_new ();
// 	column_music_list = gtk_tree_view_column_new_with_attributes (NULL, text_renderer_music_list, "text", list_total_sec, NULL);
// 	gtk_tree_view_append_column (GTK_TREE_VIEW (tree_view_music_list), column_music_list);
	
	
	
	music_list_sw_adj_h = gtk_adjustment_new(100, 0, 100, 1, 1, 50);
	music_list_sw = gtk_scrolled_window_new(NULL, music_list_sw_adj_h);
	gtk_scrolled_window_set_min_content_height(GTK_SCROLLED_WINDOW(music_list_sw), 370);
	gtk_scrolled_window_set_min_content_width(GTK_SCROLLED_WINDOW(music_list_sw), 200);
	gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(music_list_sw), GTK_SHADOW_NONE);
// 	gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(music_list_sw), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
	gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(music_list_sw), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
	gtk_container_add(GTK_CONTAINER(music_list_sw), tree_view_music_list);
	
	selection_music_list = gtk_tree_view_get_selection (GTK_TREE_VIEW (tree_view_music_list));
	set_tree_view_music_list ();
	return 1;
}
Ejemplo n.º 15
0
/**
 * g_paste_settings_ui_panel_add_separator:
 * @self: a #GPasteSettingsUiPanel instance
 *
 * Add a new separator to the current pane
 *
 * Returns:
 */
G_PASTE_VISIBLE void
g_paste_settings_ui_panel_add_separator (GPasteSettingsUiPanel *self)
{
    gtk_grid_attach (GTK_GRID (self), gtk_separator_new (GTK_ORIENTATION_HORIZONTAL), 0, self->priv->current_line++, 2, 1);
}
Ejemplo n.º 16
0
static void
gctt_init (GncCombott *combott)
{
    GtkWidget *hbox;
    GtkWidget *label;
    GtkWidget *arrow;
    GtkWidget *button;
    GtkWidget *sep;

    GncCombottPrivate *priv = GNC_COMBOTT_GET_PRIVATE (combott);

    gtk_orientable_set_orientation (GTK_ORIENTABLE(combott), GTK_ORIENTATION_HORIZONTAL);

    // Set the style context for this widget so it can be easily manipulated with css
    gnc_widget_set_style_context (GTK_WIDGET(combott), "GncCombott");

    priv->active = 0;
    priv->text_col = 0;
    priv->tip_col = 1;

    hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
    gtk_box_set_homogeneous (GTK_BOX(hbox), FALSE);

    arrow = gtk_image_new_from_icon_name ("go-down", GTK_ICON_SIZE_BUTTON);

    g_signal_connect (G_OBJECT (arrow), "draw",
                      G_CALLBACK (gnc_draw_arrow_cb), GINT_TO_POINTER(1));

#if GTK_CHECK_VERSION(3,12,0)
    gtk_widget_set_margin_start (GTK_WIDGET(arrow), 5);
#else
    gtk_widget_set_margin_left (GTK_WIDGET(arrow), 5);
#endif
    gtk_box_pack_end (GTK_BOX (hbox), arrow, FALSE, FALSE, 0);

    sep = gtk_separator_new (GTK_ORIENTATION_VERTICAL);
    gtk_box_pack_end (GTK_BOX (hbox), sep, FALSE, FALSE, 0);

    label = gtk_label_new(NULL);
    gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
    priv->label = label;

    button = gtk_button_new();
    gtk_container_add(GTK_CONTAINER(button), GTK_WIDGET(hbox));
    priv->button = button;

    gtk_container_add(GTK_CONTAINER(combott), GTK_WIDGET(button));

    g_signal_connect (button, "event",
                      G_CALLBACK (button_press_cb), combott);

    gtk_widget_set_has_tooltip (GTK_WIDGET(combott), TRUE);

    g_signal_connect(G_OBJECT(combott), "query-tooltip",
                     G_CALLBACK(which_tooltip_cb), combott);

    g_signal_connect(G_OBJECT(combott), "size-allocate",
                     G_CALLBACK(button_getsize_cb), combott);

    gtk_widget_show(GTK_WIDGET(priv->button));
}
Ejemplo n.º 17
0
/**
 * Show satellite info in a dialog
 *
 * @param sat Pointer to the sat info.
 * @param data Pointer to parent window or NULL.
 *
 * FIXME: see nice drawing at http://www.amsat.org/amsat-new/tools/keps_tutorial.php
 */
void show_sat_info(sat_t * sat, gpointer data)
{
    GtkWidget      *dialog;
    GtkWidget      *notebook;
    GtkWidget      *table;
    GtkWidget      *label;
    GtkWindow      *toplevel = NULL;
    gchar          *str;


    if (data != NULL)
        toplevel = GTK_WINDOW(data);

    /* create table */
    table = gtk_grid_new();
    gtk_grid_set_column_spacing(GTK_GRID(table), 5);
    gtk_grid_set_row_spacing(GTK_GRID(table), 5);
    gtk_container_set_border_width(GTK_CONTAINER(table), 10);

    /* satellite name */
    label = gtk_label_new(NULL);
    gtk_label_set_markup(GTK_LABEL(label), _("<b>Satellite name:</b>"));
    g_object_set(label, "xalign", 0.0, "yalign", 0.5, NULL);
    gtk_grid_attach(GTK_GRID(table), label, 0, 0, 1, 1);

    label = gtk_label_new(NULL);
    str = g_markup_printf_escaped(_("<b>%s</b>"), sat->nickname);
    gtk_label_set_markup(GTK_LABEL(label), str);
    g_object_set(label, "xalign", 0.0, "yalign", 0.5, NULL);
    gtk_grid_attach(GTK_GRID(table), label, 1, 0, 1, 1);
    g_free(str);

    /* operational status */
    label = gtk_label_new(_("Operational Status:"));
    g_object_set(label, "xalign", 0.0, "yalign", 0.5, NULL);
    gtk_grid_attach(GTK_GRID(table), label, 0, 1, 1, 1);

    switch (sat->tle.status)
    {

    case OP_STAT_OPERATIONAL:
        label = gtk_label_new(_("Operational"));
        break;

    case OP_STAT_NONOP:
        label = gtk_label_new(_("Non-operational"));
        break;

    case OP_STAT_PARTIAL:
        label = gtk_label_new(_("Partially operational"));
        break;

    case OP_STAT_STDBY:
        label = gtk_label_new(_("Backup/Standby"));
        break;

    case OP_STAT_SPARE:
        label = gtk_label_new(_("Spare"));
        break;

    case OP_STAT_EXTENDED:
        label = gtk_label_new(_("Extended Mission"));
        break;

    default:
        label = gtk_label_new(_("Unknown"));
        break;

    }

    g_object_set(label, "xalign", 0.0, "yalign", 0.5, NULL);
    gtk_grid_attach(GTK_GRID(table), label, 1, 1, 1, 1);

    /* Catnum */
    label = gtk_label_new(_("Catalogue number:"));
    g_object_set(label, "xalign", 0.0, "yalign", 0.5, NULL);
    gtk_grid_attach(GTK_GRID(table), label, 0, 2, 1, 1);

    str = g_strdup_printf("%d", sat->tle.catnr);
    label = gtk_label_new(str);
    g_object_set(label, "xalign", 0.0, "yalign", 0.5, NULL);
    gtk_grid_attach(GTK_GRID(table), label, 1, 2, 1, 1);
    g_free(str);

    /* international designator */
    label = gtk_label_new(_("International designator:"));
    g_object_set(label, "xalign", 0.0, "yalign", 0.5, NULL);
    gtk_grid_attach(GTK_GRID(table), label, 0, 3, 1, 1);

    label = gtk_label_new(sat->tle.idesg);
    g_object_set(label, "xalign", 0.0, "yalign", 0.5, NULL);
    gtk_grid_attach(GTK_GRID(table), label, 1, 3, 1, 1);

    /* elset number */
    label = gtk_label_new(_("Element set number:"));
    g_object_set(label, "xalign", 0.0, "yalign", 0.5, NULL);
    gtk_grid_attach(GTK_GRID(table), label, 0, 4, 1, 1);

    str = g_strdup_printf("%d", sat->tle.elset);
    label = gtk_label_new(str);
    g_object_set(label, "xalign", 0.0, "yalign", 0.5, NULL);
    gtk_grid_attach(GTK_GRID(table), label, 1, 4, 1, 1);
    g_free(str);

    /* elset epoch */
    label = gtk_label_new(_("Epoch time:"));
    g_object_set(label, "xalign", 0.0, "yalign", 0.5, NULL);
    gtk_grid_attach(GTK_GRID(table), label, 0, 5, 1, 1);

    str = epoch_to_str(sat);
    label = gtk_label_new(str);
    g_object_set(label, "xalign", 0.0, "yalign", 0.5, NULL);
    gtk_grid_attach(GTK_GRID(table), label, 1, 5, 1, 1);
    g_free(str);

    /* Revolution Number @ Epoch */
    label = gtk_label_new(_("Orbit number @ epoch:"));
    g_object_set(label, "xalign", 0.0, "yalign", 0.5, NULL);
    gtk_grid_attach(GTK_GRID(table), label, 0, 6, 1, 1);

    str = g_strdup_printf("%d", sat->tle.revnum);
    label = gtk_label_new(str);
    g_object_set(label, "xalign", 0.0, "yalign", 0.5, NULL);
    gtk_grid_attach(GTK_GRID(table), label, 1, 6, 1, 1);
    g_free(str);

    /* ephermis type left out, since it is always 0 */

    /* separator */
    gtk_grid_attach(GTK_GRID(table),
                    gtk_separator_new(GTK_ORIENTATION_HORIZONTAL),
                    0, 7, 2, 1); 

    /* Orbit inclination */
    label = gtk_label_new(_("Inclination:"));
    g_object_set(label, "xalign", 0.0, "yalign", 0.5, NULL);
    gtk_grid_attach(GTK_GRID(table), label, 0, 8, 1, 1);

    str = g_strdup_printf("%.4f\302\260", sat->tle.xincl / de2ra);
    label = gtk_label_new(str);
    g_object_set(label, "xalign", 0.0, "yalign", 0.5, NULL);
    gtk_grid_attach(GTK_GRID(table), label, 1, 8, 1, 1);
    g_free(str);

    /* RAAN */
    label = gtk_label_new(_("RAAN:"));
    g_object_set(label, "xalign", 0.0, "yalign", 0.5, NULL);
    gtk_grid_attach(GTK_GRID(table), label, 0, 9, 1, 1);

    str = g_strdup_printf("%.4f\302\260", sat->tle.xnodeo / de2ra);
    label = gtk_label_new(str);
    g_object_set(label, "xalign", 0.0, "yalign", 0.5, NULL);
    gtk_grid_attach(GTK_GRID(table), label, 1, 9, 1, 1);
    g_free(str);

    /* Eccentricity */
    label = gtk_label_new(_("Eccentricity:"));
    g_object_set(label, "xalign", 0.0, "yalign", 0.5, NULL);
    gtk_grid_attach(GTK_GRID(table), label, 0, 10, 1, 1);

    str = g_strdup_printf("%.7f", sat->tle.eo);
    label = gtk_label_new(str);
    g_object_set(label, "xalign", 0.0, "yalign", 0.5, NULL);
    gtk_grid_attach(GTK_GRID(table), label, 1, 10, 1, 1);
    g_free(str);

    /* Argument of perigee */
    label = gtk_label_new(_("Arg. of perigee:"));
    g_object_set(label, "xalign", 0.0, "yalign", 0.5, NULL);
    gtk_grid_attach(GTK_GRID(table), label, 0, 11, 1, 1);

    str = g_strdup_printf("%.4f\302\260", sat->tle.omegao / de2ra);
    label = gtk_label_new(str);
    g_object_set(label, "xalign", 0.0, "yalign", 0.5, NULL);
    gtk_grid_attach(GTK_GRID(table), label, 1, 11, 1, 1);
    g_free(str);

    /* Mean Anomaly */
    label = gtk_label_new(_("Mean anomaly:"));
    g_object_set(label, "xalign", 0.0, "yalign", 0.5, NULL);
    gtk_grid_attach(GTK_GRID(table), label, 0, 12, 1, 1);

    str = g_strdup_printf("%.4f\302\260", sat->tle.xmo / de2ra);
    label = gtk_label_new(str);
    g_object_set(label, "xalign", 0.0, "yalign", 0.5, NULL);
    gtk_grid_attach(GTK_GRID(table), label, 1, 12, 1, 1);
    g_free(str);

    /* Mean Motion */
    label = gtk_label_new(_("Mean motion:"));
    g_object_set(label, "xalign", 0.0, "yalign", 0.5, NULL);
    gtk_grid_attach(GTK_GRID(table), label, 0, 13, 1, 1);

    str = g_strdup_printf("%.8f [rev/day]", sat->meanmo);
    label = gtk_label_new(str);
    g_object_set(label, "xalign", 0.0, "yalign", 0.5, NULL);
    gtk_grid_attach(GTK_GRID(table), label, 1, 13, 1, 1);
    g_free(str);

    /* one half of the first time derivative of mean motion */
    label = gtk_label_new(_("\302\275 d/dt (mean motion):"));
    g_object_set(label, "xalign", 0.0, "yalign", 0.5, NULL);
    gtk_grid_attach(GTK_GRID(table), label, 0, 14, 1, 1);

    str = g_strdup_printf("%.5e [rev/day<sup>2</sup>]",
                          sat->tle.xndt2o / (twopi / xmnpda / xmnpda));
    label = gtk_label_new(NULL);
    gtk_label_set_markup(GTK_LABEL(label), str);
    g_object_set(label, "xalign", 0.0, "yalign", 0.5, NULL);
    gtk_grid_attach(GTK_GRID(table), label, 1, 14, 1, 1);
    g_free(str);

    /* one sixth of the second time derivative of mean motion */
    label = gtk_label_new(NULL);
    gtk_label_set_markup(GTK_LABEL(label),
                         _("1/6 d<sup>2</sup>/dt<sup>2</sup> (mean motion):"));
    g_object_set(label, "xalign", 0.0, "yalign", 0.5, NULL);
    gtk_grid_attach(GTK_GRID(table), label, 0, 15, 1, 1);

    str = g_strdup_printf("%.5e [rev/day<sup>3</sup>]",
                          sat->tle.xndd6o * xmnpda / (twopi / xmnpda / xmnpda));
    label = gtk_label_new(NULL);
    gtk_label_set_markup(GTK_LABEL(label), str);
    g_object_set(label, "xalign", 0.0, "yalign", 0.5, NULL);
    gtk_grid_attach(GTK_GRID(table), label, 1, 15, 1, 1);
    g_free(str);

    /* B* drag term */
    label = gtk_label_new(_("B* drag term:"));
    g_object_set(label, "xalign", 0.0, "yalign", 0.5, NULL);
    gtk_grid_attach(GTK_GRID(table), label, 0, 16, 1, 1);

    str = g_strdup_printf("%.5e [R<sub>E</sub><sup>-1</sup>]",
                          sat->tle.bstar * ae);
    label = gtk_label_new(NULL);
    gtk_label_set_markup(GTK_LABEL(label), str);
    g_object_set(label, "xalign", 0.0, "yalign", 0.5, NULL);
    gtk_grid_attach(GTK_GRID(table), label, 1, 16, 1, 1);
    g_free(str);

    /* Orbit type */

    /* Next Event */

    gtk_widget_show_all(table);

    notebook = gtk_notebook_new();
    gtk_notebook_append_page(GTK_NOTEBOOK(notebook), table,
                             gtk_label_new(_("Orbit Info")));
    gtk_notebook_append_page(GTK_NOTEBOOK(notebook),
                             create_transponder_table(sat->tle.catnr),
                             gtk_label_new(_("Transponders")));

    /* create dialog window with NULL parent */
    dialog = gtk_dialog_new_with_buttons(_("Satellite Info"),
                                         toplevel,
                                         GTK_DIALOG_DESTROY_WITH_PARENT,
                                         "_OK",
                                         GTK_RESPONSE_ACCEPT, NULL);

    /* allow interaction with other windows */
    gtk_window_set_modal(GTK_WINDOW(dialog), FALSE);

    g_signal_connect(dialog, "response", G_CALLBACK(gtk_widget_destroy), NULL);

    GtkWidget *content_area = gtk_dialog_get_content_area(GTK_DIALOG(dialog));
    gtk_box_pack_start(GTK_BOX(content_area), notebook, TRUE, TRUE, 0);

    gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_ACCEPT);

    gtk_widget_show_all(dialog);
}
Ejemplo n.º 18
0
static GtkWidget* parametrs_widget_new() {
    GtkWidget *vbox;
    GtkWidget *function_name_label;
    GtkWidget *interval_label;
    GtkWidget *interval_hbox;
    GtkWidget *parametrs_label;
    GtkWidget *draw_button_image;
    GtkWidget *draw_button;
    GtkWidget *separator_0;
    GtkWidget *separator_1;
    GtkWidget *separator_2;
    GtkWidget *parametrs_grid;
    
    /* Создание виджетов окна параметров */
    vbox                = gtk_box_new(GTK_ORIENTATION_VERTICAL, 5);
    function_name_label = gtk_label_new(FUNCTION_NAME);
    separator_0         = gtk_separator_new(GTK_ORIENTATION_HORIZONTAL);
    interval_label      = gtk_label_new("Выберите интервал");
    interval_hbox       = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 5);
    entry[LEFT_BOUND]   = gtk_entry_new();
    entry[RIGHT_BOUND]  = gtk_entry_new();
    separator_1         = gtk_separator_new(GTK_ORIENTATION_HORIZONTAL);
    parametrs_label     = gtk_label_new("Введите параметры");
    parametrs_grid      = gtk_grid_new();
    entry[PARAMETR_A]   = gtk_entry_new();
    entry[PARAMETR_B]   = gtk_entry_new();
    entry[PARAMETR_C]   = gtk_entry_new();
    entry[PARAMETR_D]   = gtk_entry_new();
    separator_2         = gtk_separator_new(GTK_ORIENTATION_HORIZONTAL);
    draw_button_image   = gtk_image_new_from_file(DRAW_BUTTON_IMAGE);
    draw_button         = gtk_button_new_with_label("Отрисовать");
    
    /* Настройка виджетов окна параметров */
    gtk_label_set_use_markup(GTK_LABEL(function_name_label), TRUE);
    gtk_grid_set_row_spacing(GTK_GRID(parametrs_grid), 5);
    gtk_grid_set_column_spacing(GTK_GRID(parametrs_grid), 5);
    gtk_container_set_border_width(GTK_CONTAINER(vbox), 5);
    gtk_entry_set_placeholder_text(GTK_ENTRY(entry[LEFT_BOUND]),  "α");
    gtk_entry_set_placeholder_text(GTK_ENTRY(entry[RIGHT_BOUND]), "β");
    gtk_entry_set_placeholder_text(GTK_ENTRY(entry[PARAMETR_A]),  "a");
    gtk_entry_set_placeholder_text(GTK_ENTRY(entry[PARAMETR_B]),  "b");
    gtk_entry_set_placeholder_text(GTK_ENTRY(entry[PARAMETR_C]),  "c");
    gtk_entry_set_placeholder_text(GTK_ENTRY(entry[PARAMETR_D]),  "d");
    gtk_button_set_image(GTK_BUTTON(draw_button), draw_button_image);
    
    /* Упаковка окна параметров */
    gtk_box_pack_start(GTK_BOX(vbox), function_name_label,  FALSE, TRUE, 0);
    gtk_box_pack_start(GTK_BOX(vbox), separator_0,          FALSE, TRUE, 5);
    gtk_box_pack_start(GTK_BOX(interval_hbox), entry[LEFT_BOUND],  FALSE, TRUE, 0);    
    gtk_box_pack_start(GTK_BOX(interval_hbox), entry[RIGHT_BOUND], FALSE, TRUE, 0);
    gtk_grid_attach(GTK_GRID(parametrs_grid),  entry[PARAMETR_A], 0, 0, 1, 1);
    gtk_grid_attach(GTK_GRID(parametrs_grid),  entry[PARAMETR_B], 1, 0, 1, 1);
    gtk_grid_attach(GTK_GRID(parametrs_grid),  entry[PARAMETR_C], 0, 1, 1, 1);
    gtk_grid_attach(GTK_GRID(parametrs_grid),  entry[PARAMETR_D], 1, 1, 1, 1);
    gtk_box_pack_start(GTK_BOX(vbox), interval_label,  FALSE, TRUE, 0);
    gtk_box_pack_start(GTK_BOX(vbox), interval_hbox,   FALSE, TRUE, 0);
    gtk_box_pack_start(GTK_BOX(vbox), separator_1,     FALSE, TRUE, 5);
    gtk_box_pack_start(GTK_BOX(vbox), parametrs_label, FALSE, TRUE, 0);
    gtk_box_pack_start(GTK_BOX(vbox), parametrs_grid,  FALSE, TRUE, 5);
    gtk_box_pack_start(GTK_BOX(vbox), separator_2,     FALSE, TRUE, 5);
    gtk_box_pack_start(GTK_BOX(vbox), draw_button,     FALSE, TRUE, 0);
    
    g_signal_connect(draw_button,  "released", G_CALLBACK(draw_button_clicked), NULL);
    g_signal_connect(drawing_area, "draw",     G_CALLBACK(draw_callback),       NULL);
    
    return vbox;
}
Ejemplo n.º 19
0
static struct vi_x86_core_board_t *vi_x86_core_board_create(
    struct vi_x86_core_t *core) {
  struct vi_x86_core_board_t *board;

  char str[MAX_STRING_SIZE];

  /* Initialize */
  board = xcalloc(1, sizeof(struct vi_x86_core_board_t));
  board->core = core;

  /* Frame */
  GtkWidget *frame = gtk_frame_new(NULL);
  GtkWidget *event_box = gtk_event_box_new();
  gtk_container_add(GTK_CONTAINER(event_box), frame);
  gtk_widget_set_size_request(frame, VI_X86_CORE_BOARD_WIDTH,
                              VI_X86_CORE_BOARD_HEIGHT);

  /* Vertical box */
  GtkWidget *vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
  gtk_container_add(GTK_CONTAINER(frame), vbox);

  /* Name */
  snprintf(str, sizeof str, "<b>%s</b>", core->name);
  GtkWidget *label = gtk_label_new(NULL);
  gtk_label_set_markup(GTK_LABEL(label), str);
  gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
  gtk_box_pack_start(GTK_BOX(vbox),
                     gtk_separator_new(GTK_ORIENTATION_HORIZONTAL), FALSE,
                     FALSE, 0);

  /* Horizontal box */
  GtkWidget *hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
  gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, TRUE, 0);

  /* LED */
  struct vi_led_t *led = vi_led_create(13);
  gtk_box_pack_start(GTK_BOX(hbox), vi_led_get_widget(led), FALSE, TRUE, 0);
  board->led = led;

  /* Time Diagram Toggle button */
  GtkWidget *time_dia_toggle_button =
      gtk_toggle_button_new_with_label("Detail");
  gtk_box_pack_start(GTK_BOX(hbox), time_dia_toggle_button, TRUE, TRUE, 0);
  g_signal_connect(G_OBJECT(time_dia_toggle_button), "toggled",
                   G_CALLBACK(vi_x86_core_board_time_dia_toggled), board);
  board->time_dia_toggle_button = time_dia_toggle_button;

  /* Context list */
  struct vi_list_t *context_list = vi_list_create(
      "Context list", 10, 10,
      (vi_list_get_elem_name_func_t)vi_x86_context_get_name_short,
      (vi_list_get_elem_desc_func_t)vi_x86_context_get_desc);
  gtk_box_pack_start(GTK_BOX(vbox), vi_list_get_widget(context_list), TRUE,
                     TRUE, 0);
  board->context_list = context_list;

  /* Main widget */
  board->widget = event_box;
  g_signal_connect(G_OBJECT(board->widget), "destroy",
                   G_CALLBACK(vi_x86_core_board_destroy), board);

  /* Return */
  return board;
}
Ejemplo n.º 20
0
void  ugtk_schedule_form_init (struct UgtkScheduleForm* sform)
{
	GtkWidget*  widget;
	GtkGrid*    caption;
	GtkBox*     hbox;
	GtkBox*     vbox;

	sform->self = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
	vbox = (GtkBox*) sform->self;

	// Enable Scheduler
	hbox = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2);
	gtk_box_pack_start (vbox, (GtkWidget*)hbox, FALSE, FALSE, 2);
	widget = gtk_check_button_new_with_mnemonic (_("_Enable Scheduler"));
	gtk_box_pack_start (hbox, widget, FALSE, FALSE, 2);
	gtk_box_pack_start (hbox, gtk_separator_new (GTK_ORIENTATION_HORIZONTAL), TRUE, TRUE, 2);
	g_signal_connect (widget, "toggled",
			G_CALLBACK (on_enable_toggled), sform);
	sform->enable = widget;

	// drawing area
	widget = gtk_drawing_area_new ();
	gtk_box_pack_start (vbox, widget, FALSE, FALSE, 2);
//	gtk_widget_set_has_window (widget, FALSE);
	gtk_widget_set_size_request (widget,
			GRID_WIDTH_ALL + 32, GRID_HEIGHT_ALL);
	gtk_widget_add_events (widget,
			GDK_BUTTON_PRESS_MASK | GDK_POINTER_MOTION_MASK | GDK_LEAVE_NOTIFY_MASK);
	g_signal_connect (widget, "draw",
			G_CALLBACK (on_draw_callback), sform);
	g_signal_connect (widget, "button-press-event",
			G_CALLBACK (on_button_press_event), sform);
	g_signal_connect (widget, "motion-notify-event",
			G_CALLBACK (on_motion_notify_event), sform);
	g_signal_connect (widget, "leave-notify-event",
			G_CALLBACK (on_leave_notify_event), sform);
	sform->drawing = widget;

	// grid for tips, SpinButton
	sform->caption = gtk_grid_new ();
	gtk_box_pack_start (vbox, sform->caption, FALSE, FALSE, 2);
//	gtk_container_set_border_width (GTK_CONTAINER (sform->caption), 10);
	caption = (GtkGrid*) sform->caption;
	// time tips
	widget = gtk_label_new ("");
	gtk_misc_set_alignment (GTK_MISC (widget), (gfloat)0.4, (gfloat)0.5);	// left, center
	g_object_set (widget, "margin", 2, NULL);
	gtk_grid_attach (caption, widget, 0, 0, 5, 1);
	sform->time_tips = GTK_LABEL (widget);

	// Turn off - gridone
	widget = ug_grid_one_new (colors[UGTK_SCHEDULE_TURN_OFF]);
	g_object_set (widget, "margin", 3, NULL);
	gtk_grid_attach (caption, widget, 0, 1, 1, 1);
	// Turn off - label
	widget = gtk_label_new (_("Turn off"));
	gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5);	// left, center
	g_object_set (widget, "margin", 2, NULL);
	gtk_grid_attach (caption, widget, 1, 1, 1, 1);
	// Turn off - help label
	widget = gtk_label_new (_("- stop all task"));
	gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5);	// left, center
	g_object_set (widget, "margin", 2, NULL);
	gtk_grid_attach (caption, widget, 2, 1, 2, 1);

	// Normal - gridone
	widget = ug_grid_one_new (colors[UGTK_SCHEDULE_NORMAL]);
	g_object_set (widget, "margin", 3, NULL);
	gtk_grid_attach (caption, widget, 0, 2, 1, 1);
	// Normal - label
	widget = gtk_label_new (_("Normal"));
	gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5);	// left, center
	g_object_set (widget, "margin", 2, NULL);
	gtk_grid_attach (caption, widget, 1, 2, 1, 1);
	// Normal - help label
	widget = gtk_label_new (_("- run task normally"));
	gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5);	// left, center
	g_object_set (widget, "margin", 2, NULL);
	gtk_grid_attach (caption, widget, 2, 2, 2, 1);
/*
	// Speed limit - gridone
	widget = ug_grid_one_new (colors[UGTK_SCHEDULE_LIMITED_SPEED]);
	g_object_set (widget, "margin", 3, NULL);
	gtk_grid_attach (caption, widget, 0, 3, 1, 1);
	// Speed limit - label
	widget = gtk_label_new (_("Limited speed"));
	gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5);	// left, center
	g_object_set (widget, "margin", 2, NULL);
	gtk_grid_attach (caption, widget, 1, 3, 1, 1);
	// Speed limit - SpinButton
	widget = gtk_spin_button_new_with_range (5, 99999999, 1);
	g_object_set (widget, "margin", 2, NULL);
	gtk_grid_attach (caption, widget, 2, 3, 1, 1);
	sform->spin_speed = (GtkSpinButton*) widget;
	// Speed limit - KiB/s label
	widget = gtk_label_new (_("KiB/s"));
	gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5);	// left, center
	g_object_set (widget, "margin", 2, NULL);
	gtk_grid_attach (caption, widget, 3, 3, 1, 1);
 */
	// change sensitive state
	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (sform->enable), FALSE);
	gtk_toggle_button_toggled (GTK_TOGGLE_BUTTON (sform->enable));
	gtk_widget_show_all (sform->self);
}
Ejemplo n.º 21
0
int
gtkstatusbar_create( GtkBox *parent )
{
  GtkWidget *separator;

  status_bar = gtk_box_new( GTK_ORIENTATION_HORIZONTAL, 5 );
  gtk_box_pack_start( parent, status_bar, FALSE, FALSE, 3 );

  /* FIXME: unref these pixbuf on statusbar destroy */
  pixbuf_tape_inactive =
    gdk_pixbuf_new_from_xpm_data( gtkpixmap_tape_inactive );
  pixbuf_tape_active =
    gdk_pixbuf_new_from_xpm_data( gtkpixmap_tape_active );

  pixbuf_mdr_inactive =
    gdk_pixbuf_new_from_xpm_data( gtkpixmap_mdr_inactive );
  pixbuf_mdr_active =
    gdk_pixbuf_new_from_xpm_data( gtkpixmap_mdr_active );

  pixbuf_disk_inactive =
    gdk_pixbuf_new_from_xpm_data( gtkpixmap_disk_inactive );
  pixbuf_disk_active =
    gdk_pixbuf_new_from_xpm_data( gtkpixmap_disk_active );

  pixbuf_pause_inactive =
    gdk_pixbuf_new_from_xpm_data( gtkpixmap_pause_inactive );
  pixbuf_pause_active =
    gdk_pixbuf_new_from_xpm_data( gtkpixmap_pause_active );

  pixbuf_mouse_inactive =
    gdk_pixbuf_new_from_xpm_data( gtkpixmap_mouse_inactive );
  pixbuf_mouse_active =
    gdk_pixbuf_new_from_xpm_data( gtkpixmap_mouse_active );

  speed_status = gtk_label_new( "100%" );
  gtk_label_set_width_chars( GTK_LABEL( speed_status ), 8 );
  gtk_box_pack_end( GTK_BOX( status_bar ), speed_status, FALSE, FALSE, 0 );

  separator = gtk_separator_new( GTK_ORIENTATION_VERTICAL );
  gtk_box_pack_end( GTK_BOX( status_bar ), separator, FALSE, FALSE, 0 );

  tape_status = gtk_image_new_from_pixbuf( pixbuf_tape_inactive );
  gtk_box_pack_end( GTK_BOX( status_bar ), tape_status, FALSE, FALSE, 0 );

  microdrive_status = gtk_image_new_from_pixbuf( pixbuf_mdr_inactive );
  gtk_box_pack_end( GTK_BOX( status_bar ), microdrive_status, FALSE, FALSE,
		    0 );

  disk_status = gtk_image_new_from_pixbuf( pixbuf_disk_inactive );
  gtk_box_pack_end( GTK_BOX( status_bar ), disk_status, FALSE, FALSE, 0 );

  pause_status = gtk_image_new_from_pixbuf( pixbuf_pause_inactive );
  gtk_box_pack_end( GTK_BOX( status_bar ), pause_status, FALSE, FALSE, 0 );

  mouse_status = gtk_image_new_from_pixbuf( pixbuf_mouse_inactive );
  gtk_box_pack_end( GTK_BOX( status_bar ), mouse_status, FALSE, FALSE, 0 );

  separator = gtk_separator_new( GTK_ORIENTATION_VERTICAL );
  gtk_box_pack_end( GTK_BOX( status_bar ), separator, FALSE, FALSE, 0 );

  machine_name = gtk_label_new( NULL );
  gtk_box_pack_start( GTK_BOX( status_bar ), machine_name, FALSE, FALSE, 0 );

  return 0;
}
Ejemplo n.º 22
0
static void
create_calendar(void)
{
  static CalendarData calendar_data;

  GtkWidget *window, *hpaned, *vbox, *rpane, *hbox;
  GtkWidget *calendar, *toggle, *scroller, *button;
  GtkWidget *frame, *label, *bbox, *details;

  GtkSizeGroup *size;
  GtkStyleContext *context;
  PangoFontDescription *font_desc;
  gchar *font;
  gint i;
  
  struct {
    gboolean init;
    char *label;
  } flags[] =
    {
      { TRUE,  "Show _Heading" },
      { TRUE,  "Show Day _Names" },
      { FALSE, "No Month _Change" },
      { TRUE,  "Show _Week Numbers" },
      { FALSE, "Week Start _Monday" },
      { TRUE,  "Show De_tails" },
    };

  calendar_data.window = NULL;
  calendar_data.font_dialog = NULL;
  calendar_data.details_table = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);

  for (i = 0; i < G_N_ELEMENTS (calendar_data.settings); i++)
    calendar_data.settings[i] = 0;

  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_window_set_hide_on_close (GTK_WINDOW (window), TRUE);
  gtk_window_set_title (GTK_WINDOW (window), "GtkCalendar Example");
  g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);

  hpaned = gtk_paned_new (GTK_ORIENTATION_HORIZONTAL);

  /* Calendar widget */

  calendar = gtk_calendar_new ();
  calendar_data.calendar_widget = calendar;
  frame = create_frame ("<b>Calendar</b>", calendar, GTK_ALIGN_CENTER, GTK_ALIGN_CENTER);
  gtk_paned_pack1 (GTK_PANED (hpaned), frame, TRUE, FALSE);

  calendar_data.window = calendar;
  calendar_set_flags(&calendar_data);
  gtk_calendar_mark_day (GTK_CALENDAR (calendar), 19);	

  g_signal_connect (calendar, "month_changed", 
		    G_CALLBACK (calendar_month_changed),
		    &calendar_data);
  g_signal_connect (calendar, "day_selected", 
		    G_CALLBACK (calendar_day_selected),
		    &calendar_data);
  g_signal_connect (calendar, "day_selected_double_click", 
		    G_CALLBACK (calendar_day_selected_double_click),
		    &calendar_data);
  g_signal_connect (calendar, "prev_month", 
		    G_CALLBACK (calendar_prev_month),
		    &calendar_data);
  g_signal_connect (calendar, "next_month", 
		    G_CALLBACK (calendar_next_month),
		    &calendar_data);
  g_signal_connect (calendar, "prev_year", 
		    G_CALLBACK (calendar_prev_year),
		    &calendar_data);
  g_signal_connect (calendar, "next_year", 
		    G_CALLBACK (calendar_next_year),
		    &calendar_data);

  rpane = gtk_box_new (GTK_ORIENTATION_VERTICAL, DEF_PAD_SMALL);
  gtk_paned_pack2 (GTK_PANED (hpaned), rpane, FALSE, FALSE);

  /* Build the right font-button */

  vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, DEF_PAD_SMALL);
  frame = create_frame ("<b>Options</b>", vbox, GTK_ALIGN_FILL, GTK_ALIGN_CENTER);
  gtk_box_pack_start (GTK_BOX (rpane), frame);
  size = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);

  context = gtk_widget_get_style_context (calendar);
  gtk_style_context_get (context, GTK_STYLE_PROPERTY_FONT, &font_desc, NULL);
  font = pango_font_description_to_string (font_desc);
  button = gtk_font_button_new_with_font (font);
  g_free (font);
  pango_font_description_free (font_desc);

  g_signal_connect (button, "font-set",
                    G_CALLBACK(calendar_select_font),
                    &calendar_data);

  label = gtk_label_new_with_mnemonic ("_Font:");
  gtk_label_set_mnemonic_widget (GTK_LABEL (label), button);
  gtk_widget_set_halign (label, GTK_ALIGN_START);
  gtk_widget_set_valign (label, GTK_ALIGN_CENTER);
  gtk_size_group_add_widget (size, label);

  hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, DEF_PAD_SMALL);
  gtk_box_pack_start (GTK_BOX (hbox), label);
  gtk_box_pack_start (GTK_BOX (hbox), button);
  gtk_box_pack_start (GTK_BOX (vbox), hbox);

  /* Build the width entry */

  button = gtk_spin_button_new_with_range (0, 127, 1);
  gtk_spin_button_set_value (GTK_SPIN_BUTTON (button),
                             gtk_calendar_get_detail_width_chars (GTK_CALENDAR (calendar)));

  g_signal_connect (button, "value-changed",
                    G_CALLBACK (detail_width_changed),
                    &calendar_data);

  label = gtk_label_new_with_mnemonic ("Details W_idth:");
  gtk_label_set_mnemonic_widget (GTK_LABEL (label), button);
  gtk_widget_set_halign (label, GTK_ALIGN_START);
  gtk_widget_set_valign (label, GTK_ALIGN_CENTER);
  gtk_size_group_add_widget (size, label);

  hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, DEF_PAD_SMALL);
  gtk_box_pack_start (GTK_BOX (hbox), label);
  gtk_box_pack_start (GTK_BOX (hbox), button);
  gtk_box_pack_start (GTK_BOX (vbox), hbox);

  /* Build the height entry */

  button = gtk_spin_button_new_with_range (0, 127, 1);
  gtk_spin_button_set_value (GTK_SPIN_BUTTON (button),
                             gtk_calendar_get_detail_height_rows (GTK_CALENDAR (calendar)));

  g_signal_connect (button, "value-changed",
                    G_CALLBACK (detail_height_changed),
                    &calendar_data);

  label = gtk_label_new_with_mnemonic ("Details H_eight:");
  gtk_label_set_mnemonic_widget (GTK_LABEL (label), button);
  gtk_widget_set_halign (label, GTK_ALIGN_START);
  gtk_widget_set_valign (label, GTK_ALIGN_CENTER);
  gtk_size_group_add_widget (size, label);

  hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, DEF_PAD_SMALL);
  gtk_box_pack_start (GTK_BOX (hbox), label);
  gtk_box_pack_start (GTK_BOX (hbox), button);
  gtk_box_pack_start (GTK_BOX (vbox), hbox);

  /* Build the right details frame */

  vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, DEF_PAD_SMALL);
  frame = create_frame ("<b>Details</b>", vbox, GTK_ALIGN_FILL, GTK_ALIGN_FILL);
  gtk_box_pack_start (GTK_BOX (rpane), frame);

  details = gtk_text_view_new();
  calendar_data.details_buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (details));

  calendar_data.details_changed = g_signal_connect (calendar_data.details_buffer, "changed",
                                                    G_CALLBACK (calendar_details_changed),
                                                    &calendar_data);

  scroller = gtk_scrolled_window_new (NULL, NULL);
  gtk_container_add (GTK_CONTAINER (scroller), details);

  gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scroller),
                                       GTK_SHADOW_IN);
  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroller),
                                  GTK_POLICY_AUTOMATIC,
                                  GTK_POLICY_AUTOMATIC);

  gtk_box_pack_start (GTK_BOX (vbox), scroller);

  hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, DEF_PAD_SMALL);
  gtk_widget_set_halign (hbox, GTK_ALIGN_START);
  gtk_widget_set_valign (hbox, GTK_ALIGN_CENTER);
  gtk_box_pack_start (GTK_BOX (vbox), hbox);

  button = gtk_button_new_with_mnemonic ("Demonstrate _Details");

  g_signal_connect_swapped (button,
                            "clicked",
                            G_CALLBACK (demonstrate_details),
                            &calendar_data);

  gtk_box_pack_start (GTK_BOX (hbox), button);

  button = gtk_button_new_with_mnemonic ("_Reset Details");

  g_signal_connect_swapped (button,
                            "clicked",
                            G_CALLBACK (reset_details),
                            &calendar_data);

  gtk_box_pack_start (GTK_BOX (hbox), button);

  toggle = gtk_check_button_new_with_mnemonic ("_Use Details");
  g_signal_connect (toggle, "toggled",
                    G_CALLBACK(calendar_toggle_details),
                    &calendar_data);
  gtk_box_pack_start (GTK_BOX (vbox), toggle);

  /* Build the Right frame with the flags in */

  vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
  frame = create_expander ("<b>Flags</b>", vbox, GTK_ALIGN_FILL, GTK_ALIGN_CENTER);
  gtk_box_pack_start (GTK_BOX (rpane), frame);

  for (i = 0; i < G_N_ELEMENTS (calendar_data.settings); i++)
    {
      toggle = gtk_check_button_new_with_mnemonic(flags[i].label);
      gtk_box_pack_start (GTK_BOX (vbox), toggle);
      calendar_data.flag_checkboxes[i] = toggle;

      g_signal_connect (toggle, "toggled",
                        G_CALLBACK (calendar_toggle_flag),
			&calendar_data);

      gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle), flags[i].init);
    }

  /*
   *  Build the Signal-event part.
   */

  vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, DEF_PAD_SMALL);
  gtk_box_set_homogeneous (GTK_BOX (vbox), TRUE);
  frame = create_frame ("<b>Signal Events</b>", vbox, GTK_ALIGN_FILL, GTK_ALIGN_CENTER);

  hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 3);
  gtk_box_pack_start (GTK_BOX (vbox), hbox);
  label = gtk_label_new ("Signal:");
  gtk_box_pack_start (GTK_BOX (hbox), label);
  calendar_data.last_sig = gtk_label_new ("");
  gtk_box_pack_start (GTK_BOX (hbox), calendar_data.last_sig);

  hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 3);
  gtk_box_pack_start (GTK_BOX (vbox), hbox);
  label = gtk_label_new ("Previous signal:");
  gtk_box_pack_start (GTK_BOX (hbox), label);
  calendar_data.prev_sig = gtk_label_new ("");
  gtk_box_pack_start (GTK_BOX (hbox), calendar_data.prev_sig);

  hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 3);
  gtk_box_pack_start (GTK_BOX (vbox), hbox);
  label = gtk_label_new ("Second previous signal:");
  gtk_box_pack_start (GTK_BOX (hbox), label);
  calendar_data.prev2_sig = gtk_label_new ("");
  gtk_box_pack_start (GTK_BOX (hbox), calendar_data.prev2_sig);

  /*
   *  Glue everything together
   */

  bbox = gtk_button_box_new (GTK_ORIENTATION_HORIZONTAL);
  gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END);

  button = gtk_button_new_with_label ("Close");
  g_signal_connect (button, "clicked", G_CALLBACK (gtk_main_quit), NULL);
  gtk_container_add (GTK_CONTAINER (bbox), button);

  vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, DEF_PAD_SMALL);

  gtk_box_pack_start (GTK_BOX (vbox), hpaned);
  gtk_box_pack_start (GTK_BOX (vbox), gtk_separator_new (GTK_ORIENTATION_HORIZONTAL));
  gtk_box_pack_start (GTK_BOX (vbox), frame);
  gtk_box_pack_start (GTK_BOX (vbox), gtk_separator_new (GTK_ORIENTATION_HORIZONTAL));
  gtk_box_pack_start (GTK_BOX (vbox), bbox);

  gtk_container_add (GTK_CONTAINER (window), vbox);

  gtk_widget_set_can_default (button, TRUE);
  gtk_widget_grab_default (button);

  gtk_window_set_default_size (GTK_WINDOW (window), 600, 0);
  gtk_widget_show (window);
}
Ejemplo n.º 23
0
void showSetupWindow(struct Context *context) {
	GtkWidget *browseb, *cancelButton, *applyButton, *quitButton, *check, *erasetoggle,
			*whitetoggle, *dumpcheck, *sortrtoggle;
	GtkWidget *dumptifcheck, *dumpjpgcheck;
	GtkWidget *vbox_main, *hbox_main, *vbox, *hbox1, *hbox2, *hbox3, *vboxright,
			*vboxmostright, *vboxleft, *hboxcube;
	GtkWidget *vboxcubel, *vboxcuber, *vboxcuberm, *hboxxc, *vboxxcl, *vboxxcr,
			*hboxssize, *hboxsleep, *hboxd, *vbox_header;
	GtkWidget *hbox_cube, *hboxsc, *scoltoggle;
	GtkWidget *file_label, *column_label, *ff_label, *cxyz_label, *separator;
	GtkWidget *cube_label, *x_label, *y_label, *z_label, *xcol_label,
			*ycol_label, *zcol_label, *tcol_label, *ssize_label;
	GtkWidget *ssx_label, *ssy_label, *sleep_label, *d_label, *header,
			*col_label, *misc_label, *draw_label, *empty_label;
	GtkWidget *hboxtd;
	GSList *group;

	setupConfig.mode = context->config->mode;
	setupConfig.erasePreviousFrame = context->config->erasePreviousFrame;
	setupConfig.backgroundWhite = context->config->backgroundWhite;
	setupConfig.colorset = context->config->colorset;
	setupConfig.inputFormatXYZ = context->config->inputFormatXYZ;
	setupConfig.sort = context->config->sort;
	setupConfig.vary = context->config->vary;
	setupConfig.dumpnum = context->config->dumpnum;
	setupConfig.tifjpg = context->config->tifjpg;
	setupConfig.dumpnum = context->config->dumpnum;
	setupConfig.useTypesForColoring = context->config->useTypesForColoring;

	usedump = FALSE;
	usescol = FALSE;

	setupwin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
	gtk_window_set_title(GTK_WINDOW (setupwin), "gdpc Setup");
	gtk_container_set_border_width(GTK_CONTAINER (setupwin), 5);

	g_signal_connect(G_OBJECT (setupwin), "destroy", G_CALLBACK (destroy),
			&setupwin);

	/* Create boxes for layout. */
	vbox_main = gtk_box_new(GTK_ORIENTATION_VERTICAL, 10);
	vbox_header = gtk_box_new(GTK_ORIENTATION_VERTICAL, 10);
	hbox_main = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 30);
	vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 3);
	hbox1 = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 3);
	hbox2 = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 30);
	hbox3 = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 30);
	hboxssize = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
	hboxd = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
	hboxsc = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
	hbox_cube = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 3);
	hboxcube = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 3);
	vboxcubel = gtk_box_new(GTK_ORIENTATION_VERTICAL, 3);
	vboxcuber = gtk_box_new(GTK_ORIENTATION_VERTICAL, 3);
	vboxcuberm = gtk_box_new(GTK_ORIENTATION_VERTICAL, 3);
	hboxxc = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
	vboxxcl = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
	vboxxcr = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
	hboxsleep = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
	hboxtd = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
	vboxleft = gtk_box_new(GTK_ORIENTATION_VERTICAL, 3);
	vboxright = gtk_box_new(GTK_ORIENTATION_VERTICAL, 3);
	vboxmostright = gtk_box_new(GTK_ORIENTATION_VERTICAL, 3);
	gtk_container_add(GTK_CONTAINER (setupwin), vbox_main);

	gtk_box_pack_start(GTK_BOX (vbox_main), vbox_header, FALSE, FALSE, 0);
	gtk_box_pack_start(GTK_BOX (vbox_main), hbox_main, FALSE, FALSE, 0);
	gtk_box_pack_start(GTK_BOX (vbox_main), hbox3, FALSE, FALSE, 0);
	gtk_box_pack_start(GTK_BOX (hbox_main), vbox, FALSE, FALSE, 0);
	gtk_box_pack_start(GTK_BOX (hbox_main), vboxmostright, FALSE, FALSE, 0);
	gtk_box_pack_start(GTK_BOX (vbox), hbox1, FALSE, FALSE, 0);
	separator = gtk_separator_new(GTK_ORIENTATION_HORIZONTAL);
	gtk_box_pack_start(GTK_BOX (vbox), separator, FALSE, TRUE, 3);
	gtk_box_pack_start(GTK_BOX (vbox), hbox2, FALSE, FALSE, 0);
	gtk_box_pack_start(GTK_BOX (hbox2), vboxleft, FALSE, FALSE, 0);
	gtk_box_pack_start(GTK_BOX (hbox2), vboxright, FALSE, FALSE, 0);

	header = gtk_label_new(" Setup ");
	gtk_box_pack_start(GTK_BOX (vbox_header), header, FALSE, TRUE, 0);
	separator = gtk_separator_new(GTK_ORIENTATION_HORIZONTAL);
	gtk_box_pack_start(GTK_BOX (vbox_header), separator, FALSE, TRUE, 3);

	file_label = gtk_label_new("Input file : ");
	file_entry = gtk_entry_new();
	gtk_entry_set_max_length(GTK_ENTRY(file_entry), 160);
	g_signal_connect(G_OBJECT (file_entry), "changed", G_CALLBACK (filechange),
			G_OBJECT (setupwin));
	if (context->config->file != NULL) {
		gtk_entry_set_text(GTK_ENTRY (file_entry), context->config->file);
	}
	gtk_widget_set_tooltip_text(file_entry, inputfilett);

	browseb = gtk_button_new_with_mnemonic("_Browse");
	g_signal_connect(G_OBJECT (browseb), "clicked", G_CALLBACK (filebrowser),
			G_OBJECT (setupwin));

	gtk_box_pack_start(GTK_BOX (hbox1), file_label, FALSE, FALSE, 0);
	gtk_box_pack_start(GTK_BOX (hbox1), file_entry, TRUE, TRUE, 0);
	gtk_box_pack_start(GTK_BOX (hbox1), browseb, FALSE, FALSE, 0);

	ssize_label = gtk_label_new("Drawingboard size [pixels]");
	ssx_label = gtk_label_new(" X : ");
	ssy_label = gtk_label_new(" Y : ");

	adjssizex = (GtkAdjustment *) gtk_adjustment_new(context->config->absxsize, 0.0,
			3000.0, 10.0, 5.0, 0.0);
	adjssizey = (GtkAdjustment *) gtk_adjustment_new(context->config->absysize, 0.0,
			3000.0, 10.0, 5.0, 0.0);

	ssxspinner = gtk_spin_button_new(adjssizex, 0, 0);
	gtk_spin_button_set_wrap(GTK_SPIN_BUTTON (ssxspinner), FALSE);
	ssyspinner = gtk_spin_button_new(adjssizey, 0, 0);
	gtk_spin_button_set_wrap(GTK_SPIN_BUTTON (ssyspinner), FALSE);
	gtk_box_pack_start(GTK_BOX (vboxleft), ssize_label, TRUE, TRUE, 0);
	gtk_box_pack_start(GTK_BOX (hboxssize), ssx_label, TRUE, TRUE, 0);
	gtk_box_pack_start(GTK_BOX (hboxssize), ssxspinner, TRUE, TRUE, 0);
	gtk_box_pack_start(GTK_BOX (hboxssize), ssy_label, TRUE, TRUE, 0);
	gtk_box_pack_start(GTK_BOX (hboxssize), ssyspinner, TRUE, TRUE, 0);
	gtk_box_pack_start(GTK_BOX (vboxleft), hboxssize, TRUE, TRUE, 0);

	separator = gtk_separator_new(GTK_ORIENTATION_HORIZONTAL);
	gtk_box_pack_start(GTK_BOX (vboxleft), separator, FALSE, TRUE, 3);

	cxyz_label = gtk_label_new("Simulation box size");
	gtk_box_pack_start(GTK_BOX (vboxleft), cxyz_label, TRUE, TRUE, 3);

	gtk_box_pack_start(GTK_BOX (vboxleft), hbox_cube, TRUE, TRUE, 3);
	gtk_box_pack_start(GTK_BOX (vboxleft), hboxcube, TRUE, TRUE, 3);
	gtk_box_pack_start(GTK_BOX (hboxcube), vboxcubel, TRUE, TRUE, 3);
	gtk_box_pack_start(GTK_BOX (hboxcube), vboxcuber, TRUE, TRUE, 3);
	gtk_box_pack_start(GTK_BOX (hboxcube), vboxcuberm, TRUE, TRUE, 3);

	cube_label = gtk_label_new("Cube : ");

	adjcube = (GtkAdjustment *) gtk_adjustment_new(0.0, 0.0, 10000.0, 1.0, 5.0,
			0.0);

	cubespinner = gtk_spin_button_new(adjcube, 0, 2);
	gtk_spin_button_set_wrap(GTK_SPIN_BUTTON (cubespinner), FALSE);
//    gtk_spin_button_set_shadow_type (GTK_SPIN_BUTTON (cubespinner),
//                                     GTK_SHADOW_OUT);
	gtk_box_pack_start(GTK_BOX (hbox_cube), cube_label, TRUE, TRUE, 0);
	gtk_box_pack_start(GTK_BOX (hbox_cube), cubespinner, TRUE, TRUE, 0);
	gtk_widget_set_tooltip_text(cubespinner, cubett);

	x_label = gtk_label_new("X : ");

	if (context->config->xmin == 65535.0) {
		adjx = (GtkAdjustment *) gtk_adjustment_new(0.0, -10000.0, 0.0, 1.0,
				5.0, 0.0);
		adjx2 = (GtkAdjustment *) gtk_adjustment_new(0.0, 0.0, 10000.0, 1.0,
				5.0, 0.0);
	} else {
		adjx = (GtkAdjustment *) gtk_adjustment_new(context->config->xmin, -10000.0,
				context->config->xmax, 1.0, 5.0, 0.0);
		adjx2 = (GtkAdjustment *) gtk_adjustment_new(context->config->xmax, context->config->xmin,
				10000.0, 1.0, 5.0, 0.0);
	}

	xspinner = gtk_spin_button_new(adjx, 0, 2);
	gtk_spin_button_set_wrap(GTK_SPIN_BUTTON (xspinner), FALSE);
	g_signal_connect(G_OBJECT (adjx), "value_changed",
			G_CALLBACK (setspinlimits), G_OBJECT (setupwin));
	x2spinner = gtk_spin_button_new(adjx2, 0, 2);
	gtk_spin_button_set_wrap(GTK_SPIN_BUTTON (x2spinner), FALSE);
	g_signal_connect(G_OBJECT (adjx2), "value_changed",
			G_CALLBACK (setspinlimits), G_OBJECT (setupwin));
	gtk_box_pack_start(GTK_BOX (vboxcubel), x_label, TRUE, TRUE, 0);
	gtk_box_pack_start(GTK_BOX (vboxcuber), xspinner, TRUE, TRUE, 0);
	gtk_box_pack_start(GTK_BOX (vboxcuberm), x2spinner, TRUE, TRUE, 0);

	y_label = gtk_label_new("Y : ");

	if (context->config->ymin == 65535.0) {
		adjy = (GtkAdjustment *) gtk_adjustment_new(0.0, -10000.0, 0.0, 1.0,
				5.0, 0.0);
		adjy2 = (GtkAdjustment *) gtk_adjustment_new(0.0, 0.0, 10000.0, 1.0,
				5.0, 0.0);
	} else {
		adjy = (GtkAdjustment *) gtk_adjustment_new(context->config->ymin, -10000.0,
				context->config->ymax, 1.0, 5.0, 0.0);
		adjy2 = (GtkAdjustment *) gtk_adjustment_new(context->config->ymax, context->config->ymin,
				10000.0, 1.0, 5.0, 0.0);
	}

	yspinner = gtk_spin_button_new(adjy, 0, 2);
	gtk_spin_button_set_wrap(GTK_SPIN_BUTTON (yspinner), FALSE);
	g_signal_connect(G_OBJECT (adjy), "value_changed",
			G_CALLBACK (setspinlimits), G_OBJECT (setupwin));

	y2spinner = gtk_spin_button_new(adjy2, 0, 2);
	gtk_spin_button_set_wrap(GTK_SPIN_BUTTON (y2spinner), FALSE);
	g_signal_connect(G_OBJECT (adjy2), "value_changed",
			G_CALLBACK (setspinlimits), G_OBJECT (setupwin));
	gtk_box_pack_start(GTK_BOX (vboxcubel), y_label, TRUE, TRUE, 0);
	gtk_box_pack_start(GTK_BOX (vboxcuber), yspinner, TRUE, TRUE, 0);
	gtk_box_pack_start(GTK_BOX (vboxcuberm), y2spinner, TRUE, TRUE, 0);

	z_label = gtk_label_new("Z : ");

	if (context->config->zmin == 65535.0) {
		adjz = (GtkAdjustment *) gtk_adjustment_new(0.0, -10000.0, 0.0, 1.0,
				5.0, 0.0);
		adjz2 = (GtkAdjustment *) gtk_adjustment_new(0.0, 0.0, 10000.0, 1.0,
				5.0, 0.0);
	} else {
		adjz = (GtkAdjustment *) gtk_adjustment_new(context->config->zmin, -10000.0,
				context->config->zmax, 1.0, 5.0, 0.0);
		adjz2 = (GtkAdjustment *) gtk_adjustment_new(context->config->zmax, context->config->zmin,
				10000.0, 1.0, 5.0, 0.0);
	}

	zspinner = gtk_spin_button_new(adjz, 0, 2);
	gtk_spin_button_set_wrap(GTK_SPIN_BUTTON (zspinner), FALSE);
	g_signal_connect(G_OBJECT (adjz), "value_changed",
			G_CALLBACK (setspinlimits), G_OBJECT (setupwin));

	z2spinner = gtk_spin_button_new(adjz2, 0, 2);
	gtk_spin_button_set_wrap(GTK_SPIN_BUTTON (z2spinner), FALSE);
	g_signal_connect(G_OBJECT (adjz2), "value_changed",
			G_CALLBACK (setspinlimits), G_OBJECT (setupwin));
	gtk_box_pack_start(GTK_BOX (vboxcubel), z_label, TRUE, TRUE, 0);
	gtk_box_pack_start(GTK_BOX (vboxcuber), zspinner, TRUE, TRUE, 0);
	gtk_box_pack_start(GTK_BOX (vboxcuberm), z2spinner, TRUE, TRUE, 0);

	gtk_widget_set_tooltip_text(xspinner, mintt);
	gtk_widget_set_tooltip_text(yspinner, mintt);
	gtk_widget_set_tooltip_text(zspinner, mintt);
	gtk_widget_set_tooltip_text(x2spinner, maxtt);
	gtk_widget_set_tooltip_text(y2spinner, maxtt);
	gtk_widget_set_tooltip_text(z2spinner, maxtt);

	separator = gtk_separator_new(GTK_ORIENTATION_HORIZONTAL);
	gtk_box_pack_start(GTK_BOX (vboxleft), separator, FALSE, TRUE, 3);

	column_label = gtk_label_new("Input data column representations");
	gtk_box_pack_start(GTK_BOX (vboxleft), column_label, TRUE, TRUE, 0);

	gtk_box_pack_start(GTK_BOX (vboxleft), hboxxc, TRUE, TRUE, 3);
	gtk_box_pack_start(GTK_BOX (hboxxc), vboxxcl, TRUE, TRUE, 3);
	gtk_box_pack_start(GTK_BOX (hboxxc), vboxxcr, TRUE, TRUE, 3);

	xcol_label = gtk_label_new("X column : ");

	adjxc = (GtkAdjustment *) gtk_adjustment_new(context->config->xcolumn, 1.0, 100.0,
			1.0, 5.0, 0.0);

	xcspinner = gtk_spin_button_new(adjxc, 0, 0);
	gtk_spin_button_set_wrap(GTK_SPIN_BUTTON (xcspinner), FALSE);
	gtk_box_pack_start(GTK_BOX (vboxxcl), xcol_label, TRUE, TRUE, 0);
	gtk_box_pack_start(GTK_BOX (vboxxcr), xcspinner, TRUE, TRUE, 0);
	gtk_widget_set_tooltip_text(xcspinner, xcoltt);

	ycol_label = gtk_label_new("Y column : ");

	adjyc = (GtkAdjustment *) gtk_adjustment_new(context->config->ycolumn, 1.0, 100.0,
			1.0, 5.0, 0.0);

	ycspinner = gtk_spin_button_new(adjyc, 0, 0);
	gtk_spin_button_set_wrap(GTK_SPIN_BUTTON (ycspinner), FALSE);
	gtk_box_pack_start(GTK_BOX (vboxxcl), ycol_label, TRUE, TRUE, 0);
	gtk_box_pack_start(GTK_BOX (vboxxcr), ycspinner, TRUE, TRUE, 0);
	gtk_widget_set_tooltip_text(ycspinner, ycoltt);

	zcol_label = gtk_label_new("Z column : ");

	adjzc = (GtkAdjustment *) gtk_adjustment_new(context->config->zcolumn, 1.0, 100.0,
			1.0, 5.0, 0.0);

	zcspinner = gtk_spin_button_new(adjzc, 0, 0);
	gtk_spin_button_set_wrap(GTK_SPIN_BUTTON (zcspinner), FALSE);
	gtk_box_pack_start(GTK_BOX (vboxxcl), zcol_label, TRUE, TRUE, 0);
	gtk_box_pack_start(GTK_BOX (vboxxcr), zcspinner, TRUE, TRUE, 0);
	gtk_widget_set_tooltip_text(zcspinner, zcoltt);

	tcol_label = gtk_label_new("t column : ");

	adjtc = (GtkAdjustment *) gtk_adjustment_new(context->config->tcolumn, 1.0, 100.0,
			1.0, 5.0, 0.0);

	tcspinner = gtk_spin_button_new(adjtc, 0, 0);
	gtk_spin_button_set_wrap(GTK_SPIN_BUTTON (tcspinner), FALSE);
	gtk_box_pack_start(GTK_BOX (vboxxcl), tcol_label, TRUE, TRUE, 0);
	gtk_box_pack_start(GTK_BOX (vboxxcr), tcspinner, TRUE, TRUE, 0);
	gtk_widget_set_tooltip_text(tcspinner, tcoltt);

	separator = gtk_separator_new(GTK_ORIENTATION_HORIZONTAL);
	gtk_box_pack_start(GTK_BOX (vboxleft), separator, FALSE, TRUE, 3);

	timedel_entry = gtk_entry_new();
	gtk_entry_set_max_length(GTK_ENTRY(timedel_entry), 160);
	gtk_entry_set_text(GTK_ENTRY (timedel_entry), context->config->timedelim);
	timedel_label = gtk_label_new("Time unit : ");
	gtk_box_pack_start(GTK_BOX (hboxtd), timedel_label, FALSE, TRUE, 0);
	gtk_box_pack_start(GTK_BOX (hboxtd), timedel_entry, FALSE, TRUE, 0);
	gtk_box_pack_start(GTK_BOX (vboxleft), hboxtd, FALSE, TRUE, 0);
	if (!context->config->inputFormatXYZ) {
		gtk_widget_set_sensitive(timedel_entry, FALSE);
		gtk_widget_set_sensitive(timedel_label, FALSE);
	} else {
		gtk_widget_set_sensitive(timedel_entry, TRUE);
		gtk_widget_set_sensitive(timedel_label, TRUE);
	}
	gtk_widget_set_tooltip_text(timedel_entry, timedeltt);

	ff_label = gtk_label_new("Input file format");
	gtk_box_pack_start(GTK_BOX (vboxright), ff_label, TRUE, TRUE, 0);

	usetypescheck = gtk_check_button_new_with_label(" Use coloring by type");

	check = gtk_radio_button_new_with_label(NULL, "XYZ file format");
	gtk_box_pack_start(GTK_BOX (vboxright), check, TRUE, TRUE, 0);
	g_signal_connect(G_OBJECT (check), "clicked", G_CALLBACK (toggle_checkxyz),
			G_OBJECT (setupwin));
	group = gtk_radio_button_get_group(GTK_RADIO_BUTTON (check));
	if (context->config->inputFormatXYZ) {
		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON (check), TRUE);
	}

	check = gtk_radio_button_new_with_label(group, "Arbitrary file format");
	gtk_box_pack_start(GTK_BOX (vboxright), check, TRUE, TRUE, 0);
	g_signal_connect(G_OBJECT (check), "clicked", G_CALLBACK (toggle_checkaff),
			G_OBJECT (setupwin));
	if (!context->config->inputFormatXYZ) {
		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON (check), TRUE);
	}

	g_signal_connect(G_OBJECT (usetypescheck), "toggled",
			G_CALLBACK (toggle_usetypes), G_OBJECT (setupwin));
	gtk_box_pack_start(GTK_BOX (vboxright), usetypescheck, TRUE, TRUE, 0);
	if (context->config->useTypesForColoring)
		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON (usetypescheck), TRUE);
	else
		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON (usetypescheck), FALSE);
	gtk_widget_set_tooltip_text(usetypescheck, coltypett);

	separator = gtk_separator_new(GTK_ORIENTATION_HORIZONTAL);
	gtk_box_pack_start(GTK_BOX (vboxright), separator, FALSE, TRUE, 3);

	draw_label = gtk_label_new(" Drawing options ");
	gtk_box_pack_start(GTK_BOX (vboxright), draw_label, TRUE, TRUE, 0);

	d_label = gtk_label_new("Size of drawn polygons :");

	adjd = (GtkAdjustment *) gtk_adjustment_new(context->config->radius, 1.0, 100.0, 1.0,
			5.0, 0.0);

	dspinner = gtk_spin_button_new(adjd, 0, 0);
	gtk_spin_button_set_wrap(GTK_SPIN_BUTTON (dspinner), FALSE);
	gtk_box_pack_start(GTK_BOX (hboxd), d_label, TRUE, TRUE, 0);
	gtk_box_pack_start(GTK_BOX (hboxd), dspinner, TRUE, TRUE, 0);
	gtk_box_pack_start(GTK_BOX (vboxright), hboxd, TRUE, TRUE, 0);

	check = gtk_radio_button_new_with_label(NULL, "Draw as rectangles");
	gtk_box_pack_start(GTK_BOX (vboxright), check, TRUE, TRUE, 0);
	g_signal_connect(G_OBJECT (check), "toggled", G_CALLBACK (toggle_checkm0),
			G_OBJECT (setupwin));
	if (context->config->mode == 0)
		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON (check), TRUE);
	group = gtk_radio_button_get_group(GTK_RADIO_BUTTON (check));

	check = gtk_radio_button_new_with_label(group, "Draw as circles");
	gtk_box_pack_start(GTK_BOX (vboxright), check, TRUE, TRUE, 0);
	g_signal_connect(G_OBJECT (check), "toggled", G_CALLBACK (toggle_checkm1),
			G_OBJECT (setupwin));
	if (context->config->mode == 1)
		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON (check), TRUE);
	group = gtk_radio_button_get_group(GTK_RADIO_BUTTON (check));

	check = gtk_radio_button_new_with_label(group, "Draw as rendered balls");
	gtk_box_pack_start(GTK_BOX (vboxright), check, TRUE, TRUE, 0);
	g_signal_connect(G_OBJECT (check), "toggled", G_CALLBACK (toggle_checkm2),
			G_OBJECT (setupwin));
	if (context->config->mode == 2)
		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON (check), TRUE);

	empty_label = gtk_label_new("  ");
	gtk_box_pack_start(GTK_BOX (vboxright), empty_label, TRUE, TRUE, 0);

	check = gtk_radio_button_new_with_label(NULL, "Dont vary size with z");
	gtk_box_pack_start(GTK_BOX (vboxright), check, TRUE, TRUE, 0);
	g_signal_connect(G_OBJECT (check), "toggled", G_CALLBACK (toggle_checkv0),
			G_OBJECT (setupwin));
	if (context->config->vary == 0)
		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON (check), TRUE);
	group = gtk_radio_button_get_group(GTK_RADIO_BUTTON (check));

	check = gtk_radio_button_new_with_label(group,
			"Vary size with z, decreasing");
	gtk_box_pack_start(GTK_BOX (vboxright), check, TRUE, TRUE, 0);
	g_signal_connect(G_OBJECT (check), "toggled", G_CALLBACK (toggle_checkv1),
			G_OBJECT (setupwin));
	if (context->config->vary == 1)
		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON (check), TRUE);
	group = gtk_radio_button_get_group(GTK_RADIO_BUTTON (check));

	check = gtk_radio_button_new_with_label(group,
			"Vary size with z, increasing");
	gtk_box_pack_start(GTK_BOX (vboxright), check, TRUE, TRUE, 0);
	g_signal_connect(G_OBJECT (check), "toggled", G_CALLBACK (toggle_checkv2),
			G_OBJECT (setupwin));
	if (context->config->vary == 2)
		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON (check), TRUE);

	separator = gtk_separator_new(GTK_ORIENTATION_HORIZONTAL);
	gtk_box_pack_start(GTK_BOX (vboxright), separator, FALSE, TRUE, 3);

	scoltoggle = gtk_check_button_new_with_label(
			"Only use inputlines with string :");
	g_signal_connect(G_OBJECT (scoltoggle), "toggled", G_CALLBACK (toggle_scol),
			G_OBJECT (setupwin));
	gtk_box_pack_start(GTK_BOX (vboxright), scoltoggle, TRUE, TRUE, 0);

	scol_entry = gtk_entry_new();
	gtk_entry_set_max_length(GTK_ENTRY(scol_entry), 60);
	g_signal_connect(G_OBJECT (scol_entry), "changed", G_CALLBACK (filechange),
			G_OBJECT (setupwin));
	gtk_box_pack_start(GTK_BOX (vboxright), scol_entry, TRUE, TRUE, 0);

	scol_label = gtk_label_new(" in column ");
	adjscol = (GtkAdjustment *) gtk_adjustment_new(1.0, 1.0, 100.0, 1.0, 5.0,
			0.0);
	scolspinner = gtk_spin_button_new(adjscol, 0, 0);
	gtk_spin_button_set_wrap(GTK_SPIN_BUTTON (scolspinner), FALSE);
	gtk_box_pack_start(GTK_BOX (hboxsc), scol_label, TRUE, TRUE, 0);
	gtk_box_pack_start(GTK_BOX (hboxsc), scolspinner, TRUE, TRUE, 0);
	gtk_box_pack_start(GTK_BOX (vboxright), hboxsc, TRUE, TRUE, 0);

	gtk_widget_set_sensitive(scol_label, FALSE);
	gtk_widget_set_sensitive(scol_entry, FALSE);
	gtk_widget_set_sensitive(scolspinner, FALSE);

	col_label = gtk_label_new(" Color settings ");
	gtk_box_pack_start(GTK_BOX (vboxmostright), col_label, TRUE, TRUE, 0);

	check = gtk_radio_button_new_with_label(NULL, "Use default colors");
	gtk_box_pack_start(GTK_BOX (vboxmostright), check, TRUE, TRUE, 0);
	g_signal_connect(G_OBJECT (check), "toggled", G_CALLBACK (toggle_checkc0),
			G_OBJECT (setupwin));
	group = gtk_radio_button_get_group(GTK_RADIO_BUTTON (check));
	if (context->config->colorset == 0)
		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON (check), TRUE);

	check = gtk_radio_button_new_with_label(group, "Use inverted colors");
	gtk_box_pack_start(GTK_BOX (vboxmostright), check, TRUE, TRUE, 0);
	g_signal_connect(G_OBJECT (check), "toggled", G_CALLBACK (toggle_checkc1),
			G_OBJECT (setupwin));
	group = gtk_radio_button_get_group(GTK_RADIO_BUTTON (check));
	if (context->config->colorset == 1)
		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON (check), TRUE);

	check = gtk_radio_button_new_with_label(group, "Use cold colors");
	gtk_box_pack_start(GTK_BOX (vboxmostright), check, TRUE, TRUE, 0);
	g_signal_connect(G_OBJECT (check), "toggled", G_CALLBACK (toggle_checkc2),
			G_OBJECT (setupwin));
	group = gtk_radio_button_get_group(GTK_RADIO_BUTTON (check));
	if (context->config->colorset == 2)
		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON (check), TRUE);

	check = gtk_radio_button_new_with_label(group, "Use cold colors 2");
	gtk_box_pack_start(GTK_BOX (vboxmostright), check, TRUE, TRUE, 0);
	g_signal_connect(G_OBJECT (check), "toggled", G_CALLBACK (toggle_checkc3),
			G_OBJECT (setupwin));
	group = gtk_radio_button_get_group(GTK_RADIO_BUTTON (check));
	if (context->config->colorset == 3)
		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON (check), TRUE);

	check = gtk_radio_button_new_with_label(group, "Use greyscale colors");
	gtk_box_pack_start(GTK_BOX (vboxmostright), check, TRUE, TRUE, 0);
	g_signal_connect(G_OBJECT (check), "toggled", G_CALLBACK (toggle_checkc4),
			G_OBJECT (setupwin));
	if (context->config->colorset == 4)
		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON (check), TRUE);

	separator = gtk_separator_new(GTK_ORIENTATION_HORIZONTAL);
	gtk_box_pack_start(GTK_BOX (vboxmostright), separator, FALSE, TRUE, 3);

	misc_label = gtk_label_new("Misc. settings");
	gtk_box_pack_start(GTK_BOX (vboxmostright), misc_label, TRUE, TRUE, 0);

	erasetoggle = gtk_check_button_new_with_label(
			" Erase before drawing next frame");
	g_signal_connect(G_OBJECT (erasetoggle), "toggled",
			G_CALLBACK (toggle_erase), G_OBJECT (setupwin));
	gtk_box_pack_start(GTK_BOX (vboxmostright), erasetoggle, TRUE, TRUE, 0);
	if (context->config->erasePreviousFrame)
		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON (erasetoggle), TRUE);

	whitetoggle = gtk_check_button_new_with_label(
			" Use white as backgroundcolor");
	g_signal_connect(G_OBJECT (whitetoggle), "toggled",
			G_CALLBACK (toggle_white), G_OBJECT (setupwin));
	gtk_box_pack_start(GTK_BOX (vboxmostright), whitetoggle, TRUE, TRUE, 0);
	if (context->config->backgroundWhite)
		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON (whitetoggle), TRUE);

	sortrtoggle = gtk_check_button_new_with_label(" Reverse sorting");
	g_signal_connect(G_OBJECT (sortrtoggle), "toggled",
			G_CALLBACK (toggle_sortr), G_OBJECT (setupwin));
	gtk_box_pack_start(GTK_BOX (vboxmostright), sortrtoggle, TRUE, TRUE, 0);
	if (context->config->sort == 2)
		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON (sortrtoggle), TRUE);

	sleep_label = gtk_label_new("Delay between frames [s] : ");

	adjsleep = (GtkAdjustment *) gtk_adjustment_new((context->config->interval / 1000.0),
			0.0, 100.0, 0.1, 5.0, 0.0);

	sleepspinner = gtk_spin_button_new(adjsleep, 0, 1);
	gtk_spin_button_set_wrap(GTK_SPIN_BUTTON (sleepspinner), FALSE);
	gtk_box_pack_start(GTK_BOX (hboxsleep), sleep_label, TRUE, TRUE, 0);
	gtk_box_pack_start(GTK_BOX (hboxsleep), sleepspinner, TRUE, TRUE, 0);
	gtk_box_pack_start(GTK_BOX (vboxmostright), hboxsleep, TRUE, TRUE, 0);

	separator = gtk_separator_new(GTK_ORIENTATION_HORIZONTAL);
	gtk_box_pack_start(GTK_BOX (vboxmostright), separator, FALSE, TRUE, 3);

	dump_label = gtk_label_new(" Dumped pictures name (no extension) : ");
	dump_entry = gtk_entry_new();
	gtk_entry_set_max_length(GTK_ENTRY(dump_entry), 60);
	gtk_widget_set_sensitive(dump_label, FALSE);
	gtk_widget_set_sensitive(dump_entry, FALSE);

	dtcheck = gtk_radio_button_new_with_label(NULL, " Add frame time");
	group = gtk_radio_button_get_group(GTK_RADIO_BUTTON (dtcheck));
	gtk_widget_set_sensitive(dtcheck, FALSE);

	dncheck = gtk_radio_button_new_with_label(group, " Add frame number");
	gtk_widget_set_sensitive(dncheck, FALSE);

	okButton = gtk_button_new_from_stock(GTK_STOCK_OK);

	dumpcheck = gtk_radio_button_new_with_label(NULL, " Do not dump images");
	gtk_box_pack_start(GTK_BOX (vboxmostright), dumpcheck, TRUE, TRUE, 0);
	g_signal_connect(G_OBJECT (dumpcheck), "toggled",
			G_CALLBACK (toggle_checkdump), G_OBJECT (setupwin));
	group = gtk_radio_button_get_group(GTK_RADIO_BUTTON (dumpcheck));
	if (strlen(context->config->dumpname) == 0)
		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON (dumpcheck), TRUE);

	dumptifcheck = gtk_radio_button_new_with_label(group,
			" Dump a .png of each frame");
	gtk_box_pack_start(GTK_BOX (vboxmostright), dumptifcheck, TRUE, TRUE, 0);
	g_signal_connect(G_OBJECT (dumptifcheck), "toggled",
			G_CALLBACK (toggle_checkdumptif), G_OBJECT (setupwin));
	group = gtk_radio_button_get_group(GTK_RADIO_BUTTON (dumptifcheck));
	if (strlen(context->config->dumpname) > 0 && context->config->tifjpg) {
		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON (dumptifcheck), TRUE);
		gtk_entry_set_text(GTK_ENTRY (dump_entry), context->config->dumpname);
	}

	dumpjpgcheck = gtk_radio_button_new_with_label(group,
			" Dump a .jpg of each frame");
	gtk_box_pack_start(GTK_BOX (vboxmostright), dumpjpgcheck, TRUE, TRUE, 0);
	g_signal_connect(G_OBJECT (dumpjpgcheck), "toggled",
			G_CALLBACK (toggle_checkdumpjpg), G_OBJECT (setupwin));
	if (strlen(context->config->dumpname) > 0 && !context->config->tifjpg) {
		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON (dumpjpgcheck), TRUE);
	}

	gtk_box_pack_start(GTK_BOX (vboxmostright), dump_label, TRUE, TRUE, 0);

	g_signal_connect(G_OBJECT (dump_entry), "changed", G_CALLBACK (filechange),
			G_OBJECT (setupwin));
	gtk_box_pack_start(GTK_BOX (vboxmostright), dump_entry, TRUE, TRUE, 0);

	g_signal_connect(G_OBJECT (dtcheck), "toggled", G_CALLBACK (toggle_checkdt),
			G_OBJECT (setupwin));
	gtk_box_pack_start(GTK_BOX (vboxmostright), dtcheck, TRUE, TRUE, 0);

	g_signal_connect(G_OBJECT (dncheck), "toggled", G_CALLBACK (toggle_checkdn),
			G_OBJECT (setupwin));
	gtk_box_pack_start(GTK_BOX (vboxmostright), dncheck, TRUE, TRUE, 0);

	if (setupConfig.dumpnum)
		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON (dncheck), TRUE);
	else
		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON (dtcheck), TRUE);

	g_signal_connect(G_OBJECT (okButton), "clicked", G_CALLBACK (okeyPressed),
			(gpointer) context);
	gtk_box_pack_start(GTK_BOX (hbox3), okButton, TRUE, TRUE, 0);
	if (!context->StartedAlready)
		gtk_widget_set_sensitive(okButton, FALSE);

	cancelButton = gtk_button_new_from_stock(GTK_STOCK_CANCEL);
	g_signal_connect(G_OBJECT (cancelButton), "clicked", G_CALLBACK (cancelPressed),
			(gpointer) context);
	gtk_box_pack_start(GTK_BOX (hbox3), cancelButton, TRUE, TRUE, 0);
	if (!context->StartedAlready)
		gtk_widget_set_sensitive(cancelButton, FALSE);

	applyButton = gtk_button_new_from_stock(GTK_STOCK_APPLY);
	g_signal_connect(G_OBJECT (applyButton), "clicked", G_CALLBACK (applyPressed),
			(gpointer) context);
	gtk_box_pack_start(GTK_BOX (hbox3), applyButton, TRUE, TRUE, 0);
	if (!context->StartedAlready)
		gtk_widget_set_sensitive(applyButton, FALSE);

	quitButton = gtk_button_new_from_stock(GTK_STOCK_QUIT);
	g_signal_connect(G_OBJECT (quitButton), "clicked", G_CALLBACK (quitPressed),
			(gpointer) context);
	gtk_box_pack_start(GTK_BOX (hbox3), quitButton, TRUE, TRUE, 0);

	gtk_widget_show_all(setupwin);
}
Ejemplo n.º 24
0
struct vi_list_popup_t *vi_list_popup_create(struct vi_list_t *list)
{
	struct vi_list_popup_t *popup;

	/* Initialize */
	popup = xcalloc(1, sizeof(struct vi_list_popup_t));
	popup->list = list;

	int i;
	int count;

	/* Create list of 'vi_list_item_t'  */
	popup->item_list = list_create();

	/* Create main window */
	GtkWidget *window;
	window = gtk_window_new(GTK_WINDOW_POPUP);
	popup->window = window;
	gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_MOUSE);
	gtk_widget_set_size_request(window, 200, 250);
	gtk_window_set_modal(GTK_WINDOW(window), TRUE);
	g_signal_connect(G_OBJECT(window), "destroy", G_CALLBACK(vi_list_popup_destroy_event), popup);

	/* Close button */
	GtkWidget *image_close = gtk_image_new_from_file(vi_list_image_close_path);
	GtkWidget *event_box_close = gtk_event_box_new();
	popup->image_close = image_close;
	gtk_container_add(GTK_CONTAINER(event_box_close), image_close);
	gtk_widget_add_events(event_box_close, GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK);
	g_signal_connect(G_OBJECT(event_box_close), "enter-notify-event",
		G_CALLBACK(vi_list_popup_image_close_enter_notify_event), popup);
	g_signal_connect(G_OBJECT(event_box_close), "leave-notify-event",
		G_CALLBACK(vi_list_popup_image_close_leave_notify_event), popup);
	g_signal_connect(G_OBJECT(event_box_close), "button-press-event",
		G_CALLBACK(vi_list_popup_image_close_clicked_event), popup);

	/* Title */
	GtkWidget *title_label = gtk_label_new(list->title);
	GtkWidget *title_event_box = gtk_event_box_new();
	gtk_container_add(GTK_CONTAINER(title_event_box), title_label);

	/* Separator below title */
	GtkWidget *hsep = gtk_separator_new(GTK_ORIENTATION_HORIZONTAL);

	/* Scrolled window */
	GtkWidget *scrolled_window;
	scrolled_window = gtk_scrolled_window_new(NULL, NULL);
	gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled_window),
		GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);

	/* Main table */
	GtkWidget *main_table;
	main_table = gtk_table_new(3, 2, FALSE);
	gtk_table_attach(GTK_TABLE(main_table), title_event_box, 0, 1, 0, 1, GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0);
	gtk_table_attach(GTK_TABLE(main_table), event_box_close, 1, 2, 0, 1, GTK_FILL, GTK_FILL, 0, 0);
	gtk_table_attach(GTK_TABLE(main_table), hsep, 0, 2, 1, 2, GTK_FILL, GTK_FILL, 0, 0);
	gtk_table_attach_defaults(GTK_TABLE(main_table), scrolled_window, 0, 2, 2, 3);
	gtk_container_add(GTK_CONTAINER(window), main_table);

	GdkColor color;
	gdk_color_parse("#ffffa0", &color);

	GtkWidget *table;
	count = list->elem_list->count;
	table = gtk_table_new(count, 1, FALSE);
	for (i = 0; i < count; i++)
	{
		void *elem;
		char str[MAX_STRING_SIZE];
		struct vi_list_item_t *item;

		/* Get element */
		elem = list_get(list->elem_list, i);

		/* Create label */
		GtkWidget *label;
		if (list->get_elem_name)
			(*list->get_elem_name)(elem, str, sizeof str);
		else
			snprintf(str, sizeof str, "item-%d", i);
		label = gtk_label_new(str);
		gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
		gtk_label_set_use_markup(GTK_LABEL(label), TRUE);

		/* Set label font attributes */
		PangoAttrList *attrs;
		attrs = pango_attr_list_new();
		PangoAttribute *size_attr = pango_attr_size_new_absolute(12 << 10);
		pango_attr_list_insert(attrs, size_attr);
		gtk_label_set_attributes(GTK_LABEL(label), attrs);

		/* Event box */
		GtkWidget *event_box;
		event_box = gtk_event_box_new();
		gtk_widget_modify_bg(event_box, GTK_STATE_NORMAL, &color);
		gtk_container_add(GTK_CONTAINER(event_box), label);

		/* Create list_layout_item */
		item = vi_list_item_create();
		item->list = list;
		item->event_box = event_box;
		item->label = label;
		item->elem = elem;
		list_add(list->item_list, item);

		/* Events for event box */
		gtk_widget_add_events(event_box, GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK);
		g_signal_connect(G_OBJECT(event_box), "enter-notify-event",
			G_CALLBACK(vi_list_item_enter_notify_event), item);
		g_signal_connect(G_OBJECT(event_box), "leave-notify-event",
			G_CALLBACK(vi_list_item_leave_notify_event), item);
		g_signal_connect(G_OBJECT(event_box), "button-press-event",
			G_CALLBACK(vi_list_item_button_press_event), item);

		gtk_table_attach(GTK_TABLE(table), event_box, 0, 1, i, i + 1, GTK_FILL, GTK_FILL, 0, 0);
	}

	GtkWidget *viewport;
	viewport = gtk_viewport_new(NULL, NULL);
	gtk_widget_modify_bg(window, GTK_STATE_NORMAL, &color);
	gtk_container_add(GTK_CONTAINER(viewport), table);
	gtk_widget_modify_bg(viewport, GTK_STATE_NORMAL, &color);
	gtk_container_add(GTK_CONTAINER(scrolled_window), viewport);

	/* Return */
	return popup;
}
Ejemplo n.º 25
0
/**
 * create the page to manually associate the transactions to the reconciles
 * show a complete list of orphans transactions, and for each of them, we propose
 * to link them to a reconcile
 *
 * \param assistant
 *
 * \return a GtkWidget, the page to the assistant
 * */
static GtkWidget *gsb_assistant_reconcile_config_page_manually_associate ( GtkWidget *assistant )
{
    GtkWidget *page;
    GtkWidget *label;
    GtkWidget *separator;
    GtkWidget *scrolled_window;
    gint i;
    GtkWidget *button;
    GtkWidget *hbox;
    GtkListStore *store;
    gchar *titles[] = {
	_("Date"), _("Payee"), _("Amount"), _("Account")
    };
    gfloat alignment[] = {
	COLUMN_CENTER, COLUMN_LEFT, COLUMN_CENTER, COLUMN_CENTER
    };


    page = gtk_box_new ( GTK_ORIENTATION_VERTICAL, 0 );
    gtk_container_set_border_width ( GTK_CONTAINER(page), 12 );

    /* the number of transactions to link */
    label_transactions_to_link_3 = gtk_label_new (NULL);
    gtk_box_pack_start ( GTK_BOX (page),
			 label_transactions_to_link_3,
			 FALSE, FALSE, 0 );

    separator = gtk_separator_new ( GTK_ORIENTATION_HORIZONTAL );
    gtk_box_pack_start ( GTK_BOX (page),
			 separator,
			 FALSE, FALSE, 0 );

    /* now we can show the list of orphans transactions */
    label = gtk_label_new (_("Select the transaction(s) you want to associate with a reconciliation: "));
    gtk_misc_set_alignment ( GTK_MISC ( label ), 0.0, 0.0 );
    gtk_box_pack_start ( GTK_BOX (page),
			 label,
			 FALSE, FALSE, 10 );

    scrolled_window = gtk_scrolled_window_new (FALSE, FALSE);
    gtk_scrolled_window_set_policy ( GTK_SCROLLED_WINDOW (scrolled_window),
				     GTK_POLICY_AUTOMATIC,
				     GTK_POLICY_AUTOMATIC );
    gtk_box_pack_start ( GTK_BOX (page),
			 scrolled_window,
			 TRUE, TRUE, 0 );
    gtk_widget_show (scrolled_window);

    /* set up the tree view */
    store = gtk_list_store_new ( TRANSACTION_NB_COL,
				 G_TYPE_STRING,
				 G_TYPE_STRING,
				 G_TYPE_STRING,
				 G_TYPE_STRING,
				 G_TYPE_INT );
    treeview_transactions_to_link = gtk_tree_view_new_with_model (GTK_TREE_MODEL (store));
    g_object_unref (G_OBJECT(store));
    gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (treeview_transactions_to_link), TRUE);
    gtk_tree_selection_set_mode ( gtk_tree_view_get_selection (GTK_TREE_VIEW (treeview_transactions_to_link)),
				  GTK_SELECTION_MULTIPLE );
    gtk_container_add ( GTK_CONTAINER (scrolled_window),
			treeview_transactions_to_link );
    gtk_widget_show (treeview_transactions_to_link);

    /* set the columns */
    for (i=TRANSACTION_DATE ; i<TRANSACTION_NUMBER ; i++)
    {
	GtkTreeViewColumn *column;
	GtkCellRenderer *cell;
	cell = gtk_cell_renderer_text_new ();
	g_object_set ( G_OBJECT (cell),
		       "xalign", alignment[i],
		       NULL );
	column = gtk_tree_view_column_new ();
	gtk_tree_view_column_set_sizing ( column,
					  GTK_TREE_VIEW_COLUMN_AUTOSIZE );
	gtk_tree_view_column_set_alignment ( column,
					     alignment[i] );
	gtk_tree_view_column_pack_start ( column, cell, TRUE );
	gtk_tree_view_column_set_title ( column, titles[i] );
	gtk_tree_view_column_set_attributes (column, cell,
					     "text", i,
					     NULL);
	gtk_tree_view_column_set_expand ( column, TRUE );
	gtk_tree_view_column_set_resizable ( column,
					     TRUE );
	gtk_tree_view_append_column ( GTK_TREE_VIEW(treeview_transactions_to_link), column);
    }

    /* set the button to associate */
    hbox = gtk_box_new ( GTK_ORIENTATION_HORIZONTAL, 0 );
    gtk_box_set_homogeneous ( GTK_BOX ( hbox ), TRUE );
    gtk_box_pack_start ( GTK_BOX (page),
			 hbox,
			 FALSE, FALSE,
			 10 );
    button = gtk_button_new_with_label ( _("Link the selection to a reconciliation..."));
    g_signal_connect ( G_OBJECT (button),
		       "clicked",
		       G_CALLBACK (gsb_assistant_reconcile_config_lauch_manu_asso),
		       assistant );
    gtk_box_pack_start ( GTK_BOX (hbox),
			 button,
			 TRUE, TRUE,
			 0 );

    gtk_widget_show_all (page);
    return page;
}
Ejemplo n.º 26
0
static void
nemo_status_bar_constructed (GObject *object)
{
    NemoStatusBar *bar = NEMO_STATUS_BAR (object);
    G_OBJECT_CLASS (nemo_status_bar_parent_class)->constructed (object);

    GtkToolbar *toolbar;
    GtkWidget *widget_box;
    GtkToolItem *item;
    GtkWidget *statusbar = gtk_statusbar_new ();
    GtkActionGroup *action_group;
    GtkStyleContext *context;

    bar->real_statusbar = statusbar;

    GtkIconSize size = gtk_icon_size_from_name (NEMO_STATUSBAR_ICON_SIZE_NAME);

    context = gtk_widget_get_style_context (GTK_WIDGET (bar));
    gtk_style_context_add_class (context, GTK_STYLE_CLASS_TOOLBAR);
    gtk_container_set_border_width (GTK_CONTAINER (bar), 1);

    GtkWidget *button, *icon;

    button = gtk_toggle_button_new ();
    icon = gtk_image_new_from_icon_name ("sidebar-places-symbolic", size);
    gtk_button_set_image (GTK_BUTTON (button), icon);
    gtk_widget_set_tooltip_text (GTK_WIDGET (button), _("Show Places"));
    bar->places_button = button;
    gtk_box_pack_start (GTK_BOX (bar), button, FALSE, FALSE, 2);
    g_signal_connect (GTK_BUTTON (button), "clicked",
                      G_CALLBACK (action_places_toggle_callback), bar);

    button = gtk_toggle_button_new ();
    icon = gtk_image_new_from_icon_name ("sidebar-tree-symbolic", size);
    gtk_button_set_image (GTK_BUTTON (button), icon);
    gtk_widget_set_tooltip_text (GTK_WIDGET (button), _("Show Treeview"));
    bar->tree_button = button;
    gtk_box_pack_start (GTK_BOX (bar), button, FALSE, FALSE, 2);
    g_signal_connect (GTK_BUTTON (button), "clicked",
                      G_CALLBACK (action_treeview_toggle_callback), bar);

    GtkWidget *sep = gtk_separator_new (GTK_ORIENTATION_VERTICAL);
    gtk_box_pack_start (GTK_BOX (bar), sep, FALSE, FALSE, 6);
    gtk_widget_show (sep);
    bar->separator = sep;

    button = gtk_button_new ();
    icon = gtk_image_new_from_icon_name ("sidebar-hide-symbolic", size);
    gtk_button_set_image (GTK_BUTTON (button), icon);
    gtk_widget_set_tooltip_text (GTK_WIDGET (button), _("Hide the Sidebar (F9)"));
    bar->hide_button = button;
    gtk_box_pack_start (GTK_BOX (bar), button, FALSE, FALSE, 2);
    g_signal_connect (GTK_BUTTON (button), "clicked",
                      G_CALLBACK (action_hide_sidebar_callback), bar);

    button = gtk_button_new ();
    icon = gtk_image_new_from_icon_name ("sidebar-show-symbolic", size);
    gtk_button_set_image (GTK_BUTTON (button), icon);
    gtk_widget_set_tooltip_text (GTK_WIDGET (button), _("Show the Sidebar (F9)"));
    bar->show_button = button;
    gtk_box_pack_start (GTK_BOX (bar), button, FALSE, FALSE, 2);
    g_signal_connect (GTK_BUTTON (button), "clicked",
                      G_CALLBACK (action_show_sidebar_callback), bar);

    gtk_box_pack_start (GTK_BOX (bar), statusbar, TRUE, TRUE, 10);

    GtkWidget *zoom_slider = gtk_scale_new_with_range (GTK_ORIENTATION_HORIZONTAL, 0, 6.0, 1.0);
    gtk_widget_set_tooltip_text (GTK_WIDGET (zoom_slider), _("Adjust zoom level"));
    bar->zoom_slider = zoom_slider;

    gtk_box_pack_start (GTK_BOX (bar), zoom_slider, FALSE, FALSE, 2);

    gtk_widget_set_size_request (GTK_WIDGET (zoom_slider), SLIDER_WIDTH, 0);
    gtk_scale_set_draw_value (GTK_SCALE (zoom_slider), FALSE);
    gtk_range_set_increments (GTK_RANGE (zoom_slider), 1.0, 1.0);
    gtk_range_set_round_digits (GTK_RANGE (zoom_slider), 0);

    gtk_widget_show_all (GTK_WIDGET (bar));

    g_signal_connect_object (NEMO_WINDOW (bar->window), "notify::show-sidebar",
                             G_CALLBACK (sidebar_state_changed_cb), bar, G_CONNECT_AFTER);

    g_signal_connect_object (NEMO_WINDOW (bar->window), "notify::sidebar-view-id",
                           G_CALLBACK (sidebar_type_changed_cb), bar, G_CONNECT_AFTER);

    g_signal_connect (GTK_RANGE (zoom_slider), "value-changed",
                      G_CALLBACK (on_slider_changed_cb), bar);

    GtkWidget *cont = gtk_statusbar_get_message_area (GTK_STATUSBAR (statusbar));

    GList *children = gtk_container_get_children (GTK_CONTAINER (cont));

    gtk_box_set_child_packing (GTK_BOX (cont),
                               GTK_WIDGET (children->data),
                               TRUE, FALSE, 10, GTK_PACK_START);

    nemo_status_bar_sync_button_states (bar);
}
Ejemplo n.º 27
0
int main(int argc, char *argv[])
{
	printf("%s \nPlease report any bug to %s\n", PACKAGE_STRING, PACKAGE_BUGREPORT);	
	//printf("number of arg = %d, argv = %s\n", argc, argv[1]);
	/*printf("argc = %d\n", argc);
	if (argv[1] != NULL) {
		if (strstr (argv[1],"debug") != NULL) {
		debug = TRUE;
		printf("debug = TRUE\n");
			}  
		}
	DEBUG("debug is true\n");*/
	gchar *filename;
	int i = 0;
	gint initialWindowHeight = 170;
	guint timeoutEvent, intervalDisplaySpectro;
	GtkWidget *pVBox[4], *pHBox[13], *menuBar, *menu, *submenu, *menuItem, *submenuItem, *button, *frame, *image, *label, *widget;
	GdkColor color;
	Spectrum3dGui spectrum3dGui;
	GSList *radio_menu_group;
	GError **error;

#if defined (GTKGLEXT3) || defined (GTKGLEXT1)
	GdkGLConfig *glconfig;
#endif 
	
	gst_init (NULL, NULL);
	gtk_init (&argc, &argv);

	get_saved_values();
	intervalDisplaySpectro = (guint)spectrum3d.interval_display;

#if defined (GTKGLEXT3) || defined (GTKGLEXT1)
	gtk_gl_init(NULL, NULL);
	glconfig = gdk_gl_config_new_by_mode (GDK_GL_MODE_RGB    |
					GDK_GL_MODE_DEPTH  |
					GDK_GL_MODE_DOUBLE);
	  if (glconfig == NULL)
	    {
	      g_print ("\n*** Cannot find the double-buffered visual.\n");
	      g_print ("\n*** Trying single-buffered visual.\n");

	      /* Try single-buffered visual */
	      glconfig = gdk_gl_config_new_by_mode (GDK_GL_MODE_RGB   |
						    GDK_GL_MODE_DEPTH);
	      if (glconfig == NULL)
		{
		  g_print ("*** No appropriate OpenGL-capable visual found.\n");
		  exit (1);
		}
	    }
#endif

	initGstreamer();
	init_audio_values();
	init_display_values(&spectrum3dGui);
	
	spectrum3dGui.mainWindow = gtk_window_new (GTK_WINDOW_TOPLEVEL);
	gtk_widget_set_size_request (spectrum3dGui.mainWindow, 700, initialWindowHeight);
	gtk_widget_realize(spectrum3dGui.mainWindow);
	gtk_window_set_title(GTK_WINDOW(spectrum3dGui.mainWindow), PACKAGE_NAME);
	filename = g_build_filename (G_DIR_SEPARATOR_S, DATADIR, "icons", "spectrum3d.png", NULL);
	gtk_window_set_icon(GTK_WINDOW(spectrum3dGui.mainWindow), gdk_pixbuf_new_from_file (filename, error));
	g_signal_connect (G_OBJECT (spectrum3dGui.mainWindow), "destroy", G_CALLBACK (quit_spectrum3d), NULL);

#ifdef GTK3
	gtk_container_set_reallocate_redraws (GTK_CONTAINER (spectrum3dGui.mainWindow), TRUE);
#endif

#ifdef GTK3
	for (i = 0; i < 4; i++) {
		pVBox[i] = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
		}
	pHBox[0] = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
	for (i = 1; i < 12; i++) {
		pHBox[i] = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
		}
	pHBox[12] = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
#elif defined GTK2
	for (i = 0; i < 4; i++) {
		pVBox[i] = gtk_vbox_new(FALSE, 0);
		}
	pHBox[0] = gtk_hbox_new(TRUE, 0);
	for (i = 1; i < 12; i++) {
		pHBox[i] = gtk_hbox_new(FALSE, 0);
		}
	pHBox[12] = gtk_hbox_new(TRUE, 0);
#endif
	
	gtk_container_add(GTK_CONTAINER(spectrum3dGui.mainWindow), pVBox[1]); 
	gtk_box_pack_start(GTK_BOX(pVBox[1]), pHBox[0], FALSE, FALSE, 0);
		
/* Menu */
	menuBar = gtk_menu_bar_new();

	menu = gtk_menu_new(); // 'Quit' submenu
	menuItem = gtk_menu_item_new_with_label("Quit");
	gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuItem);    
	g_signal_connect(G_OBJECT(menuItem), "activate", G_CALLBACK(gtk_main_quit), NULL); 
	menuItem = gtk_menu_item_new_with_label("Quit");
	gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuItem), menu);
	gtk_menu_shell_append(GTK_MENU_SHELL(menuBar), menuItem);

	menu = gtk_menu_new(); // 'Edit' submenu
        menuItem = gtk_menu_item_new_with_label("Preferences");
	g_signal_connect(G_OBJECT(menuItem), "activate", G_CALLBACK(onPreferences), &spectrum3dGui);
	gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuItem);
	menuItem = gtk_menu_item_new_with_label("Edit");
	gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuItem), menu);
	gtk_menu_shell_append(GTK_MENU_SHELL(menuBar), menuItem);

	menu = gtk_menu_new(); // 'Sound' submenu
	menuItem = gtk_menu_item_new_with_label("Sound");
	gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuItem), menu);
	gtk_menu_shell_append(GTK_MENU_SHELL(menuBar), menuItem);

		submenu = gtk_menu_new();// 'Play test sound' sub-submenu
		spectrum3dGui.checkMenuTestSound = gtk_check_menu_item_new_with_label("Test Sound");
		gtk_menu_shell_append(GTK_MENU_SHELL(menu), spectrum3dGui.checkMenuTestSound);
		g_signal_connect(G_OBJECT(spectrum3dGui.checkMenuTestSound), "activate", G_CALLBACK(menu_check_test_sound), &spectrum3dGui);

	menu = gtk_menu_new(); // 'View' submenu
	menuItem = gtk_menu_item_new_with_label("View");
	gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuItem), menu);
	gtk_menu_shell_append(GTK_MENU_SHELL(menuBar), menuItem);
	
		submenu = gtk_menu_new();// 'viewType' sub-submenu
		menuItem = gtk_menu_item_new_with_label("Perspective");
		gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuItem), submenu);
		gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuItem);	
			
			spectrum3dGui.radio3D = gtk_radio_menu_item_new_with_label(NULL, "3D (D)");
			radio_menu_group = gtk_radio_menu_item_get_group(GTK_RADIO_MENU_ITEM(spectrum3dGui.radio3D));
			g_signal_connect(G_OBJECT(spectrum3dGui.radio3D), "toggled", G_CALLBACK(change_perspective), spectrum3dGui.radio3D);
			gtk_menu_shell_append(GTK_MENU_SHELL(submenu), spectrum3dGui.radio3D);

			spectrum3dGui.radio3Dflat = gtk_radio_menu_item_new_with_label(radio_menu_group, "3D flat (F)");
			radio_menu_group = gtk_radio_menu_item_get_group(GTK_RADIO_MENU_ITEM(spectrum3dGui.radio3Dflat));
			g_signal_connect(G_OBJECT(spectrum3dGui.radio3Dflat), "toggled", G_CALLBACK(change_perspective), spectrum3dGui.radio3Dflat);
			gtk_menu_shell_append(GTK_MENU_SHELL(submenu), spectrum3dGui.radio3Dflat);

			spectrum3dGui.radio2D = gtk_radio_menu_item_new_with_label(radio_menu_group, "2D (D)");
			radio_menu_group = gtk_radio_menu_item_get_group(GTK_RADIO_MENU_ITEM(spectrum3dGui.radio2D));
			g_signal_connect(G_OBJECT(spectrum3dGui.radio2D), "toggled", G_CALLBACK(change_perspective), spectrum3dGui.radio2D);
			gtk_menu_shell_append(GTK_MENU_SHELL(submenu), spectrum3dGui.radio2D);

		submenu = gtk_menu_new();// 'Scale' sub-submenu
		menuItem = gtk_menu_item_new_with_label("Scale");
		gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuItem), submenu);
		gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuItem);	
	
			spectrum3dGui.checkMenuText = gtk_check_menu_item_new_with_label("Text (T)");
			gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(spectrum3dGui.checkMenuText), TRUE);
			g_signal_connect(G_OBJECT(spectrum3dGui.checkMenuText), "activate", G_CALLBACK(check_menu_text), &spectrum3dGui);
			gtk_menu_shell_append(GTK_MENU_SHELL(submenu), spectrum3dGui.checkMenuText);
	
			spectrum3dGui.checkMenuLines = gtk_check_menu_item_new_with_label("Lines (L)");
			gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(spectrum3dGui.checkMenuLines), TRUE);
			g_signal_connect(G_OBJECT(spectrum3dGui.checkMenuLines), "activate", G_CALLBACK(check_menu_lines), &spectrum3dGui);
			gtk_menu_shell_append(GTK_MENU_SHELL(submenu), spectrum3dGui.checkMenuLines);

			spectrum3dGui.checkMenuPointer = gtk_check_menu_item_new_with_label("Pointer (P)");
			g_signal_connect(G_OBJECT(spectrum3dGui.checkMenuPointer), "activate", G_CALLBACK(check_menu_pointer), &spectrum3dGui);
			gtk_menu_shell_append(GTK_MENU_SHELL(submenu), spectrum3dGui.checkMenuPointer);

		submenu = gtk_menu_new();// 'Change/reset view' sub-submenu
		menuItem = gtk_menu_item_new_with_label("Change/reset view");
		gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuItem), submenu);
		gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuItem);	
			
			spectrum3dGui.reset = gtk_menu_item_new_with_label("Reset view (R)");
			gtk_widget_set_tooltip_text (spectrum3dGui.reset, "Reset the view as if Spectrum3d was just started");
			g_signal_connect(G_OBJECT(spectrum3dGui.reset), "activate", G_CALLBACK(reset_view), spectrum3dGui.reset);
			gtk_menu_shell_append(GTK_MENU_SHELL(submenu), spectrum3dGui.reset);

			spectrum3dGui.front = gtk_menu_item_new_with_label("Front view (O)");
			gtk_widget_set_tooltip_text (spectrum3dGui.front, "2D view showing frequency versus intensity of the sound; shows a snapshot of the harmonics at a given time");
			g_signal_connect(G_OBJECT(spectrum3dGui.front), "activate", G_CALLBACK(front_view), spectrum3dGui.front);
			gtk_menu_shell_append(GTK_MENU_SHELL(submenu), spectrum3dGui.front);

			submenuItem = gtk_menu_item_new_with_label("Preset view");
			gtk_widget_set_tooltip_text (submenuItem, "Set the view with the chosen preset values");
			g_signal_connect(G_OBJECT(submenuItem), "activate", G_CALLBACK(set_view_from_preset), submenuItem);
			gtk_menu_shell_append(GTK_MENU_SHELL(submenu), submenuItem);

	menu = gtk_menu_new(); // 'Help...' submenu
	menuItem = gtk_menu_item_new_with_label("Shortcuts"); 
	g_signal_connect(G_OBJECT(menuItem), "activate", G_CALLBACK(onShortcuts), (GtkWidget*) spectrum3dGui.mainWindow);
	gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuItem);
#ifdef HAVE_LIBGEIS
	menuItem = gtk_menu_item_new_with_label("Gestures Shortcuts");
	g_signal_connect(G_OBJECT(menuItem), "activate", G_CALLBACK(onGesturesShortcuts), (GtkWidget*) spectrum3dGui.mainWindow);
	gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuItem);
#endif 
	menuItem = gtk_menu_item_new_with_label("About...");
	g_signal_connect(G_OBJECT(menuItem), "activate", G_CALLBACK(onAbout), (GtkWidget*) spectrum3dGui.mainWindow);
	gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuItem);
	menuItem = gtk_menu_item_new_with_label("Quick start");
	g_signal_connect(G_OBJECT(menuItem), "activate", G_CALLBACK(onQuickStart), (GtkWidget*) spectrum3dGui.mainWindow);
	gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuItem);
	menuItem = gtk_menu_item_new_with_label("Help");
	gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuItem), menu);
	gtk_menu_shell_append(GTK_MENU_SHELL(menuBar), menuItem);
	gtk_box_pack_start(GTK_BOX(pHBox[0]), menuBar, FALSE, TRUE, 0);

/* SourceButtons to set type of source (none, audio file, microphone) */
	spectrum3dGui.stop = gtk_button_new();
	filename = g_build_filename (G_DIR_SEPARATOR_S, DATADIR, "icons", "stop.png", NULL);
	image = gtk_image_new_from_file(filename);
	gtk_button_set_image(GTK_BUTTON(spectrum3dGui.stop),image);
	gdk_color_parse ("gold",&color);
	gtk_widget_set_name(spectrum3dGui.stop, "stop");
	gtk_widget_modify_bg(GTK_WIDGET(spectrum3dGui.stop), GTK_STATE_NORMAL, &color);
	gtk_widget_modify_bg(GTK_WIDGET(spectrum3dGui.stop), GTK_STATE_PRELIGHT, &color);
	gtk_widget_set_tooltip_text (spectrum3dGui.stop, "Stop playing everything; no source of playing");
	gtk_box_pack_start(GTK_BOX(pVBox[1]), pHBox[1], FALSE, TRUE, 2);
	gtk_box_pack_start(GTK_BOX(pHBox[1]), spectrum3dGui.stop, FALSE, TRUE, 2);
	g_signal_connect(G_OBJECT(spectrum3dGui.stop), "clicked", G_CALLBACK(change_source_button), &spectrum3dGui);

	filename = g_build_filename (G_DIR_SEPARATOR_S, DATADIR, "icons", "microphone_grey.png", NULL);
	image = gtk_image_new_from_file(filename);
	spectrum3dGui.mic = gtk_button_new();
	gtk_button_set_image (GTK_BUTTON(spectrum3dGui.mic), image);
	gtk_widget_set_name(spectrum3dGui.mic, "mic");
	gtk_widget_set_tooltip_text (spectrum3dGui.mic, "Source is microphone; select this to record something and then load it");
	gtk_box_pack_start(GTK_BOX(pHBox[1]), spectrum3dGui.mic, FALSE, TRUE, 2);
	g_signal_connect(G_OBJECT(spectrum3dGui.mic), "clicked", G_CALLBACK(change_source_button), &spectrum3dGui);

	spectrum3dGui.file = gtk_button_new();
	filename = g_build_filename (G_DIR_SEPARATOR_S, DATADIR, "icons", "file_grey.png", NULL);
	image = gtk_image_new_from_file(filename);
	gtk_button_set_image(GTK_BUTTON(spectrum3dGui.file),image);
	gtk_widget_set_name(spectrum3dGui.file, "file");
	gtk_widget_set_tooltip_text (spectrum3dGui.file, "Source is an audio file");
	gtk_box_pack_start(GTK_BOX(pHBox[1]), spectrum3dGui.file, FALSE, FALSE, 2);
	g_signal_connect(G_OBJECT(spectrum3dGui.file), "clicked", G_CALLBACK(change_source_button), &spectrum3dGui);

	spectrum3dGui.reload = gtk_button_new();
	image = gtk_image_new_from_stock (GTK_STOCK_REFRESH, GTK_ICON_SIZE_LARGE_TOOLBAR);
	gtk_button_set_image(GTK_BUTTON(spectrum3dGui.reload),image);
	gtk_widget_set_sensitive (spectrum3dGui.reload, FALSE);
	gtk_widget_set_tooltip_text (spectrum3dGui.reload, "Reload audio file (usefull if some audio parameters like equalizer or filters have been changed)");
	gtk_box_pack_start(GTK_BOX(pHBox[1]), spectrum3dGui.reload, FALSE, FALSE, 2);
	g_signal_connect(G_OBJECT(spectrum3dGui.reload), "clicked", G_CALLBACK(load_audio_file), NULL);

	widget = gtk_check_button_new_with_label("Analyse in\nrealtime");
	gtk_widget_set_tooltip_text (GTK_WIDGET(widget), "If checked, harmonics will be analysed and displayed at the same time; if unchecked, harmonics will be analysed first, then displayed for the whole audio file, then it can be played afterwards");
	gtk_box_pack_start(GTK_BOX(pHBox[1]), widget, FALSE, FALSE, 0);
	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(widget), TRUE);
	g_signal_connect(G_OBJECT(widget), "toggled", G_CALLBACK(set_analyse_in_rt), &spectrum3dGui);

/* separator */
#ifdef GTK3
	widget = gtk_separator_new(GTK_ORIENTATION_VERTICAL);
#elif defined GTK2
	widget = gtk_vseparator_new();
#endif
	gtk_box_pack_start(GTK_BOX(pHBox[1]), widget, FALSE, FALSE, 5);
	
/* "Play/Pause" button */
	playButton = gtk_button_new();
	gtk_widget_set_tooltip_text (playButton, "Play/Pause the audio stream");
	setPlayButtonIcon();
	gtk_widget_set_size_request (playButton, 50, 20);
	gtk_box_pack_start(GTK_BOX(pHBox[1]), playButton, FALSE, FALSE, 2);
	g_signal_connect(G_OBJECT(playButton), "clicked", G_CALLBACK(playFromSource), "NO_MESSAGE");
	
/* "Stop" button */
	button = gtk_button_new();
	gtk_widget_set_tooltip_text (button, "Stop playing audio stream");
	image = gtk_image_new_from_stock (GTK_STOCK_MEDIA_STOP, GTK_ICON_SIZE_SMALL_TOOLBAR);
	gtk_button_set_image(GTK_BUTTON(button),image);
	gtk_box_pack_start(GTK_BOX(pHBox[1]), button, FALSE, FALSE, 2);
	g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(on_stop), NULL);

/* "Record" button */
	spectrum3dGui.record = gtk_button_new();
	gtk_widget_set_tooltip_text (spectrum3dGui.record, "Record from microphone");
	image = gtk_image_new_from_stock (GTK_STOCK_MEDIA_RECORD, GTK_ICON_SIZE_SMALL_TOOLBAR);
	gtk_button_set_image(GTK_BUTTON(spectrum3dGui.record),image);
	gtk_widget_set_sensitive (spectrum3dGui.record, FALSE);
	gtk_box_pack_start(GTK_BOX(pHBox[1]), spectrum3dGui.record, FALSE, FALSE, 2);
	g_signal_connect(G_OBJECT(spectrum3dGui.record), "clicked", G_CALLBACK(record_window), NULL);

/* separator */
#ifdef GTK3
	widget = gtk_separator_new(GTK_ORIENTATION_VERTICAL);
#elif defined GTK2
	widget = gtk_vseparator_new();
#endif	
	gtk_box_pack_start(GTK_BOX(pHBox[1]), widget, FALSE, FALSE, 5);

/* JACK check button */
	filename = g_build_filename (G_DIR_SEPARATOR_S, DATADIR, "icons", "qjackctl.png", NULL);
	image = gtk_image_new_from_file(filename);
	widget = gtk_check_button_new ();
	gtk_button_set_image (GTK_BUTTON(widget), image);
	gtk_widget_set_tooltip_text (widget, "Use Jack-Audio-Connection-Kit (JACK)");
	gtk_box_pack_start(GTK_BOX(pHBox[1]), widget, FALSE, FALSE, 2);
	g_signal_connect(G_OBJECT(widget), "toggled", G_CALLBACK(use_jack), &spectrum3dGui);

/* separator */
#ifdef GTK3
	widget = gtk_separator_new(GTK_ORIENTATION_VERTICAL);
#elif defined GTK2
	widget = gtk_vseparator_new();
#endif	
	gtk_box_pack_start(GTK_BOX(pHBox[1]), widget, FALSE, FALSE, 5);

/* Button to open the Filter and Equalizer window */
	// create effectsWindow first without showing it
	effects_window(&spectrum3dGui);
	// then create a button that will call its display when clicked
	filename = g_build_filename (G_DIR_SEPARATOR_S, DATADIR, "icons", "equalizer.png", NULL);
	image = gtk_image_new_from_file(filename);
	widget = gtk_button_new();  
	gtk_button_set_image (GTK_BUTTON(widget), image);
	gtk_widget_set_tooltip_text (widget, "Show/Hide the filter and equalizer window");
	gtk_box_pack_start(GTK_BOX(pHBox[1]), widget, FALSE, FALSE, 0);
	g_signal_connect(G_OBJECT(widget), "clicked", G_CALLBACK(show_effects_window), &spectrum3dGui);

/* Time label */
	label=gtk_label_new("Time : ");
	gtk_box_pack_start(GTK_BOX(pHBox[5]), label, FALSE, FALSE, 0);
	gtk_box_pack_start(GTK_BOX(pVBox[1]), pHBox[5], FALSE, FALSE, 2);

/* Progress & seek scale */
#ifdef GTK3
	scaleSeek = gtk_scale_new_with_range (GTK_ORIENTATION_HORIZONTAL, 0.0, 100.0, 1);
#elif defined GTK2
	scaleSeek = gtk_hscale_new_with_range (0.0, 100.0, 1);
#endif
	gtk_scale_set_draw_value (GTK_SCALE (scaleSeek), FALSE);
	//gtk_scale_set_value_pos (GTK_SCALE (pScaleSeek), GTK_POS_TOP);
	gtk_range_set_value (GTK_RANGE (scaleSeek), 0);
	gtk_widget_set_size_request (scaleSeek, 500, 20);
	gtk_box_pack_start(GTK_BOX(pHBox[5]), scaleSeek, FALSE, FALSE, 0);
	g_signal_connect(G_OBJECT(scaleSeek), "value-changed", G_CALLBACK(on_seek), NULL);
	
	timeLabel=gtk_label_new("           0:00 / 0:00           ");
	gtk_box_pack_start(GTK_BOX(pHBox[5]), timeLabel, FALSE, FALSE, 0);

/* Create drawing area */
	if (externalWindow == FALSE){
		/* Resize spectrum3dGui.mainWindow to contain drawing_area; using gtk_window_set_defaut() allows to shrink the window (gtk_widget_set_size_request() does not allow to shrink the window below the requested size); */
		gtk_window_set_default_size (GTK_WINDOW(spectrum3dGui.mainWindow), (gint)spectrum3d.width, initialWindowHeight + (gint)spectrum3d.height);
		
		//gtk_widget_realize(spectrum3dGui.mainWindow);

		spectrum3dGui.drawing_area = gtk_drawing_area_new ();
		
#if defined (GTKGLEXT3) || defined (GTKGLEXT1)
		/* Set OpenGL-capability to the widget */
	  	gtk_widget_set_gl_capability (spectrum3dGui.drawing_area,
					glconfig,
					NULL,
					TRUE,
					GDK_GL_RGBA_TYPE);		
#endif	
		
		/* drawing_area has to be put in vBox AFTER the call to gtk_widget_set_gl_capability() (if GtkGlExt is used) and BEFORE the call to the sdl-gtk hack (if sdl is used)*/ 
		gtk_box_pack_start (GTK_BOX (pVBox[1]), spectrum3dGui.drawing_area, TRUE, TRUE, 0);	
		
#ifdef HAVE_LIBSDL 
		/* Hack to get SDL to use GTK window */
		{ char SDL_windowhack[32];
			sprintf(SDL_windowhack,"SDL_WINDOWID=%ld",
				GDK_WINDOW_XID(gtk_widget_get_window(spectrum3dGui.drawing_area)));
				// GDK_WINDOW_XID( spectrum3dGui.drawing_area->window))); pour GTK2??
			putenv(SDL_windowhack);
		printf("%s\n", SDL_windowhack);
		}

		if (SDL_Init(SDL_INIT_VIDEO) < 0) {
			fprintf(stderr, "Unable to init SDL: %s\n", SDL_GetError());
			exit(1);
			}
#endif

		g_signal_connect (spectrum3dGui.mainWindow, "key-press-event", G_CALLBACK (on_key_press), &spectrum3dGui);
		g_signal_connect (spectrum3dGui.mainWindow, "key-release-event", G_CALLBACK (on_key_release), &spectrum3dGui);
		g_signal_connect (spectrum3dGui.mainWindow, "motion-notify-event", G_CALLBACK (on_mouse_motion), NULL);
		g_signal_connect (spectrum3dGui.mainWindow, "scroll-event", G_CALLBACK (on_mouse_scroll), NULL);
		g_signal_connect (G_OBJECT (spectrum3dGui.drawing_area), "configure_event", G_CALLBACK (configure_event), NULL);
		gtk_widget_add_events (spectrum3dGui.mainWindow, gtk_widget_get_events (spectrum3dGui.mainWindow) | GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK | GDK_POINTER_MOTION_MASK | GDK_SCROLL_MASK);
	}
	else {
		create_external_window_drawing_area(&spectrum3dGui);
		}	

/* Starting value of the display */
	frame = gtk_frame_new("Start value of display (in Hz)");
	gtk_widget_set_tooltip_text (frame, "The lower displayed frequency (in herz)");
	spectrum3dGui.adjustStart = gtk_adjustment_new(0, 0, 9000, ((gdouble)hzStep * (gdouble)zoomFactor), (((gdouble)hzStep * (gdouble)zoomFactor) * 10), 0);
#ifdef GTK3
	pScaleStart = gtk_scale_new(GTK_ORIENTATION_HORIZONTAL, GTK_ADJUSTMENT(spectrum3dGui.adjustStart));
#elif defined GTK2
	pScaleStart = gtk_hscale_new(GTK_ADJUSTMENT(spectrum3dGui.adjustStart));
#endif
	gtk_scale_set_digits (GTK_SCALE(pScaleStart), 0);
	gtk_scale_set_value_pos(GTK_SCALE(pScaleStart), GTK_POS_RIGHT);
	gtk_box_pack_start(GTK_BOX(pVBox[1]), pHBox[11], FALSE, FALSE, 0);
	gtk_box_pack_start(GTK_BOX(pHBox[11]), frame, FALSE, FALSE, 0);
	gtk_container_add(GTK_CONTAINER(frame), pScaleStart);
	g_signal_connect(G_OBJECT(pScaleStart), "value-changed", G_CALLBACK(change_start), &spectrum3dGui);
	g_signal_connect(G_OBJECT(pScaleStart), "format-value", G_CALLBACK(format_value_start), NULL);
	g_signal_connect(G_OBJECT(pScaleStart), "value-changed", G_CALLBACK(getTextDisplayLabel), &spectrum3dGui);

/* Range of display */
	frame = gtk_frame_new("Range of display (in Hz)");
	gtk_widget_set_tooltip_text (frame, "The range of the displayed frequency (in herz)");
	spectrum3dGui.adjustBands = gtk_adjustment_new(1000, 20, 1000, 10, 50, 0);
#ifdef GTK3
	spectrum3dGui.scaleBands = gtk_scale_new(GTK_ORIENTATION_HORIZONTAL, GTK_ADJUSTMENT(spectrum3dGui.adjustBands));
#elif defined GTK2
	spectrum3dGui.scaleBands = gtk_hscale_new(GTK_ADJUSTMENT(spectrum3dGui.adjustBands));
#endif
	gtk_scale_set_digits (GTK_SCALE(spectrum3dGui.scaleBands), 0);
	gtk_scale_set_value_pos(GTK_SCALE(spectrum3dGui.scaleBands), GTK_POS_RIGHT);
	gtk_container_add(GTK_CONTAINER(frame), spectrum3dGui.scaleBands);
	gtk_box_pack_start(GTK_BOX(pHBox[11]), frame, FALSE, FALSE, 0);
	g_signal_connect(G_OBJECT(spectrum3dGui.scaleBands), "value-changed", G_CALLBACK(change_bands), &spectrum3dGui);
	g_signal_connect(G_OBJECT(spectrum3dGui.scaleBands), "format-value", G_CALLBACK(format_value_bands), NULL);
	g_signal_connect(G_OBJECT(spectrum3dGui.scaleBands), "value-changed", G_CALLBACK(getTextDisplayLabel), &spectrum3dGui);
	
/* "x" label */
	label=gtk_label_new("x");
	gtk_container_add(GTK_CONTAINER(pHBox[11]), label);

/* Factor that multiplies the range of display */
	frame = gtk_frame_new("");
	gtk_widget_set_tooltip_text (frame, "Factor that multiplies the frequency range, to make it larger");
	spectrum3dGui.cbRange = gtk_combo_box_text_new();
	gtk_container_add(GTK_CONTAINER(frame), spectrum3dGui.cbRange);
	gtk_box_pack_start(GTK_BOX(pHBox[11]), frame, FALSE, FALSE, 0);
	for (i = 1; i <= 20; i++){
		gchar text[4];
		sprintf(text, "%d", i);
		gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(spectrum3dGui.cbRange), text);
		}
	gtk_combo_box_set_active(GTK_COMBO_BOX(spectrum3dGui.cbRange), 0);
	g_signal_connect( G_OBJECT(spectrum3dGui.cbRange), "changed", G_CALLBACK( cb_range_changed ), &spectrum3dGui );
	g_signal_connect( G_OBJECT(spectrum3dGui.cbRange), "changed", G_CALLBACK(getTextDisplayLabel), &spectrum3dGui );
	
/* Label that shows starting value, ending value and range of display */
	frame = gtk_frame_new("Values displayed");
	gtk_widget_set_tooltip_text (frame, "The lower and the highest displayed value (in herz), and their range");
	displayLabel=gtk_label_new(""); 
	gtk_container_add(GTK_CONTAINER(frame), displayLabel);
	getTextDisplayLabel(NULL, &spectrum3dGui);
	gtk_box_pack_start(GTK_BOX(pHBox[11]), frame, FALSE, FALSE, 0);

/* 'Gain' Gtk Scale */
	frame = gtk_frame_new("Display Gain");
	gtk_box_pack_start(GTK_BOX(pHBox[11]), frame, FALSE, FALSE, 10);
	filename = g_build_filename (G_DIR_SEPARATOR_S, DATADIR, "icons", "gain.png", NULL);
	image = gtk_image_new_from_file(filename);

	spectrum3dGui.scaleGain = gtk_scale_button_new (GTK_ICON_SIZE_LARGE_TOOLBAR, 0, 1, 0.01, NULL);
	gtk_button_set_image(GTK_BUTTON(spectrum3dGui.scaleGain),image);
	//gtk_button_set_label (GTK_BUTTON(spectrum3dGui.scaleGain), "GAIN");
	gtk_container_add(GTK_CONTAINER(frame), spectrum3dGui.scaleGain);
	//gtk_box_pack_start(GTK_BOX(pHBox[11]), pScaleGain, FALSE, FALSE, 0);
	//gtk_widget_set_size_request (pScaleGain, 200, 20);
	//gtk_scale_set_value_pos(GTK_SCALE(pScaleGain), GTK_POS_RIGHT);
	gtk_widget_set_tooltip_text (spectrum3dGui.scaleGain, "Adjust the displayed level of the intensity of the sound");
	gtk_scale_button_set_value(GTK_SCALE_BUTTON(spectrum3dGui.scaleGain), 0.2);
	// FIXME error message here with the previous line : gtk_image_set_from_stock: assertion `GTK_IS_IMAGE (image)' failed; it could be a bug in Gtk
	//g_object_set (pScaleGain, "update-policy", GTK_UPDATE_DISCONTINUOUS, NULL);
	g_signal_connect(G_OBJECT(spectrum3dGui.scaleGain), "value-changed", G_CALLBACK(change_gain), NULL);

#ifdef HAVE_LIBGEIS
	setupGeis();
#endif

	gtk_widget_show_all (spectrum3dGui.mainWindow);

	//timeoutEvent = g_timeout_add (100, (GSourceFunc)sdl_event, &spectrum3dGui);
	spectrum3d.timeoutExpose = g_timeout_add (intervalDisplaySpectro, (GSourceFunc)display_spectro, &spectrum3dGui);

	printf("Showing Gtk GUI\n");
	gtk_main ();

/* Quit everything */

#ifdef HAVE_LIBGEIS
	geisQuit();
#endif
	on_stop();
	g_source_remove(spectrum3d.timeoutExpose);
#ifdef HAVE_LIBSDL
	//g_source_remove(timeoutEvent);
	SDL_Quit();
#endif

	print_rc_file();

	printf("Quit everything\nGood Bye!\n");
	
	return 0;
}
Ejemplo n.º 28
0
static void xmi_msim_gui_layer_dialog_init(XmiMsimGuiLayerDialog *dialog) {
  gtk_window_set_modal(GTK_WINDOW(dialog), TRUE);
  gtk_window_set_destroy_with_parent(GTK_WINDOW(dialog), TRUE);
  gtk_dialog_add_buttons(GTK_DIALOG(dialog), "_Ok", GTK_RESPONSE_ACCEPT, "_Cancel", GTK_RESPONSE_REJECT, NULL);
  gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_ACCEPT);
  gtk_window_set_default_size(GTK_WINDOW(dialog), 200, 200);

  GtkWidget *contentArea = gtk_dialog_get_content_area(GTK_DIALOG(dialog));
  GtkWidget *mainVBox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 5);
  gtk_box_set_homogeneous(GTK_BOX(mainVBox), FALSE);
  gtk_container_set_border_width(GTK_CONTAINER(mainVBox),5);
  gtk_container_add(GTK_CONTAINER(contentArea), mainVBox);

  GtkListStore *store = gtk_list_store_new(N_COLUMNS_LAYER, G_TYPE_STRING, G_TYPE_DOUBLE, G_TYPE_INT);
  //construct tree
  GtkWidget *HBox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 5);
  gtk_box_set_homogeneous(GTK_BOX(HBox), FALSE);
  GtkWidget *compositionTreeView = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));
  GtkCellRenderer *renderer = gtk_cell_renderer_text_new();
  gtk_cell_renderer_set_alignment(renderer, 0.5, 0.5);
  GtkTreeViewColumn *column = gtk_tree_view_column_new_with_attributes("Element", renderer, "text", SYMBOL_COLUMN, NULL);
  gtk_tree_view_column_set_resizable(column, TRUE);
  gtk_tree_view_column_set_alignment(column, 0.5);
  gtk_tree_view_append_column(GTK_TREE_VIEW(compositionTreeView), column);

  renderer = gtk_cell_renderer_text_new();
  gtk_cell_renderer_set_alignment(renderer, 0.5, 0.5);
  column = gtk_tree_view_column_new_with_attributes("Weight fraction (%)", renderer, "text", WEIGHT_COLUMN, NULL);
  gtk_tree_view_column_set_resizable(column, TRUE);
  gtk_tree_view_column_set_alignment(column, 0.5);
  gtk_tree_view_append_column(GTK_TREE_VIEW(compositionTreeView), column);

  GtkWidget *scrolledWindow = gtk_scrolled_window_new(NULL, NULL);
  gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolledWindow), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
  gtk_widget_set_size_request(scrolledWindow, 220, 150);
  gtk_container_add(GTK_CONTAINER(scrolledWindow), compositionTreeView);
  GtkWidget *frame = gtk_frame_new(NULL);
  gtk_container_add(GTK_CONTAINER(frame), scrolledWindow);
  gtk_box_pack_start(GTK_BOX(HBox), frame, FALSE, FALSE, 3);

  //selections
  GtkTreeSelection *select = gtk_tree_view_get_selection(GTK_TREE_VIEW(compositionTreeView));
  gtk_tree_selection_set_mode(select, GTK_SELECTION_MULTIPLE);
  g_signal_connect(G_OBJECT(select), "changed", G_CALLBACK(element_selection_changed), (gpointer) dialog);


  //add/edit/remove
  GtkWidget *VBox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 5);
  gtk_box_set_homogeneous(GTK_BOX(VBox), FALSE);
  GtkWidget *addButton = gtk_button_new_with_mnemonic("_Add");
  GtkWidget *editButton = gtk_button_new_with_mnemonic("_Edit");
  GtkWidget *removeButton = gtk_button_new_with_mnemonic("_Remove");
  GtkWidget *predefButton = gtk_button_new_with_label("Load from catalog");
  GtkWidget *addToCatalogButton = gtk_button_new_with_label("Add to catalog");

  gtk_widget_set_sensitive(addButton, TRUE);
  gtk_widget_set_sensitive(editButton, FALSE);
  gtk_widget_set_sensitive(removeButton, FALSE);
  gtk_widget_set_sensitive(predefButton, TRUE);
  gtk_widget_set_sensitive(addToCatalogButton, FALSE);

  gtk_box_pack_start(GTK_BOX(VBox), addButton, TRUE, FALSE, 3);
  gtk_box_pack_start(GTK_BOX(VBox), editButton, TRUE, FALSE, 3);
  gtk_box_pack_start(GTK_BOX(VBox), removeButton, TRUE, FALSE, 3);
  gtk_box_pack_start(GTK_BOX(VBox), predefButton, TRUE, FALSE, 3);
  gtk_box_pack_start(GTK_BOX(VBox), addToCatalogButton, TRUE, FALSE, 3);

  gtk_box_pack_start(GTK_BOX(HBox),VBox, FALSE, FALSE, 3);
  gtk_box_pack_start(GTK_BOX(mainVBox), HBox, FALSE, FALSE, 3);

  g_signal_connect(G_OBJECT(addButton), "clicked", G_CALLBACK(add_button_clicked), (gpointer) dialog);
  g_signal_connect(G_OBJECT(editButton), "clicked", G_CALLBACK(edit_button_clicked), (gpointer) dialog);
  g_signal_connect(G_OBJECT(removeButton), "clicked", G_CALLBACK(remove_button_clicked), (gpointer) dialog);
  g_signal_connect(G_OBJECT(predefButton), "clicked", G_CALLBACK(predef_button_clicked), (gpointer) dialog);
  g_signal_connect(G_OBJECT(addToCatalogButton), "clicked", G_CALLBACK(add_to_catalog_button_clicked), (gpointer) dialog);
  g_signal_connect(G_OBJECT(compositionTreeView), "row-activated", G_CALLBACK(element_row_activated), (gpointer) dialog);

  //Sum and normalize
  HBox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 2);
  gtk_box_set_homogeneous(GTK_BOX(HBox), FALSE);
  GtkWidget *label = gtk_label_new("Weights sum (%)");
  GtkWidget *sumLabel = gtk_label_new("");
  gtk_label_set_justify(GTK_LABEL(sumLabel), GTK_JUSTIFY_CENTER);
  GtkWidget *normalizeButton = gtk_button_new_with_label("Normalize");
  gtk_box_pack_start(GTK_BOX(HBox), label, FALSE, FALSE, 2);
  gtk_box_pack_start(GTK_BOX(HBox), sumLabel, TRUE, TRUE, 2);
  gtk_box_pack_start(GTK_BOX(HBox), normalizeButton, FALSE, FALSE, 2);
  gtk_box_pack_start(GTK_BOX(mainVBox), HBox, FALSE, FALSE, 3);
  g_signal_connect(G_OBJECT(normalizeButton), "clicked", G_CALLBACK(normalize_button_clicked), (gpointer) dialog);

  //separator
  GtkWidget *separator = gtk_separator_new(GTK_ORIENTATION_HORIZONTAL);
  gtk_box_pack_start(GTK_BOX(mainVBox), separator, FALSE, FALSE, 3);

  //Density and thickness
  HBox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 2);
  gtk_box_set_homogeneous(GTK_BOX(HBox), FALSE);
  label = gtk_label_new(NULL);
  gtk_label_set_markup(GTK_LABEL(label),"Density (g/cm<sup>3</sup>)");
  GtkWidget *densityEntry = gtk_entry_new();
  gtk_widget_set_name(densityEntry, "color_entry");
  gtk_entry_set_activates_default(GTK_ENTRY(densityEntry), TRUE);
  gulong density_changed = g_signal_connect(G_OBJECT(densityEntry), "changed", G_CALLBACK(density_thickness_changed), (gpointer) dialog);
  gtk_box_pack_start(GTK_BOX(HBox), label, FALSE, FALSE, 2);
  gtk_box_pack_end(GTK_BOX(HBox), densityEntry, FALSE, FALSE, 2);
  gtk_box_pack_start(GTK_BOX(mainVBox), HBox, FALSE, FALSE, 3);
  HBox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 2);
  gtk_box_set_homogeneous(GTK_BOX(HBox), FALSE);
  label = gtk_label_new("Thickness (cm)");
  GtkWidget *thicknessEntry = gtk_entry_new();
  gtk_widget_set_name(thicknessEntry, "color_entry");
  gtk_entry_set_activates_default(GTK_ENTRY(thicknessEntry), TRUE);
  gulong thickness_changed = g_signal_connect(G_OBJECT(thicknessEntry), "changed", G_CALLBACK(density_thickness_changed), (gpointer) dialog);
  gtk_box_pack_start(GTK_BOX(HBox), label, FALSE, FALSE, 2);
  gtk_box_pack_end(GTK_BOX(HBox), thicknessEntry, FALSE, FALSE, 2);
  gtk_box_pack_start(GTK_BOX(mainVBox), HBox, FALSE, FALSE, 3);

  dialog->addButton = addButton;
  dialog->editButton = editButton;
  dialog->removeButton = removeButton;
  dialog->predefButton = predefButton;
  dialog->addToCatalogButton = addToCatalogButton;
  dialog->normalizeButton = normalizeButton;
  dialog->sumLabel = sumLabel;
  dialog->densityEntry = densityEntry;
  dialog->thicknessEntry = thicknessEntry;
  dialog->compositionTreeView = compositionTreeView;
  dialog->density_changed = density_changed;
  dialog->thickness_changed = thickness_changed;

  g_signal_connect(G_OBJECT(compositionTreeView), "key-press-event", G_CALLBACK(backspace_key_clicked), (gpointer) dialog);

  gtk_widget_show_all(contentArea);

}
Ejemplo n.º 29
0
static gboolean
append_menu (RBButtonBar *bar, GMenuModel *menu, gboolean need_separator)
{
	int i;
	gulong id;

	id = g_signal_connect (menu, "items-changed", G_CALLBACK (items_changed_cb), bar);
	g_hash_table_insert (bar->priv->handlers, (gpointer)id, g_object_ref (menu));

	for (i = 0; i < g_menu_model_get_n_items (menu); i++) {
		char *label_text;
		char *accel;
		GtkWidget *button;
		GtkWidget *label;
		GMenuModel *submenu;

		/* recurse into sections */
		submenu = g_menu_model_get_item_link (menu, i, G_MENU_LINK_SECTION);
		if (submenu != NULL) {
			need_separator = append_menu (bar, submenu, TRUE);
			continue;
		}

		/* if this item and the previous item are in different sections, add
		 * a separator between them.  this may not be a good idea.
		 */
		if (need_separator) {
			GtkWidget *sep;

			if (bar->priv->position > 0) {
				sep = gtk_separator_new (GTK_ORIENTATION_VERTICAL);
				gtk_widget_show (sep);
				g_object_set (sep, "margin-start", 6, "margin-end", 6, NULL);
				gtk_grid_attach (GTK_GRID (bar), sep, bar->priv->position++, 0, 1, 1);
			}

			need_separator = FALSE;
		}

		button = NULL;

		/* submenus become menu buttons, normal items become buttons */
		submenu = g_menu_model_get_item_link (menu, i, G_MENU_LINK_SUBMENU);

		if (submenu != NULL) {
			button = gtk_menu_button_new ();
			gtk_menu_button_set_menu_model (GTK_MENU_BUTTON (button), submenu);

			g_object_set_data_full (G_OBJECT (button), "rb-menu-model", g_object_ref (submenu), (GDestroyNotify)g_object_unref);
		} else {
			GMenuAttributeIter *iter;
			const char *name;
			GVariant *value;
			char *str;
			guint signal_id;
		
			/* we can't do more than one of action and rb-property-bind
			 * and rb-signal-bind, so just do whichever turns up first
			 * in the iterator
			 */
			iter = g_menu_model_iterate_item_attributes (menu, i);
			while (g_menu_attribute_iter_get_next (iter, &name, &value)) {
				if (g_str_equal (name, "action")) {
					button = gtk_button_new ();
					g_variant_get (value, "s", &str, NULL);
					gtk_actionable_set_action_name (GTK_ACTIONABLE (button), str);
					/* action target too somehow? */
					g_free (str);
					break;
				} else if (g_str_equal (name, "rb-property-bind")) {
					/* property has to be a boolean, can't do inverts, etc. etc. */
					button = gtk_toggle_button_new ();
					g_variant_get (value, "s", &str, NULL);
					g_object_bind_property (bar->priv->target, str,
								button, "active",
								G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
					g_free (str);
					break;
				} else if (g_str_equal (name, "rb-signal-bind")) {
					button = gtk_button_new ();
					g_variant_get (value, "s", &str, NULL);
					signal_id = g_signal_lookup (str, G_OBJECT_TYPE (bar->priv->target));
					if (signal_id != 0) {
						g_object_set_data (G_OBJECT (button), "rb-signal-bind-id", GUINT_TO_POINTER (signal_id));
						g_signal_connect (button, "clicked", G_CALLBACK (signal_button_clicked_cb), bar);
					}
					g_free (str);
					break;
				}
			}

			g_object_unref (iter);
		}

		if (button == NULL) {
			g_warning ("no idea what's going on here");
			continue;
		}

		gtk_widget_set_hexpand (button, FALSE);
		gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE);

		label_text = NULL;
		g_menu_model_get_item_attribute (menu, i, "label", "s", &label_text);
		label = gtk_label_new (g_dgettext (NULL, label_text));
		g_object_set (label, "margin-left", 6, "margin-right", 6, NULL);
		gtk_container_add (GTK_CONTAINER (button), label);

		if (g_menu_model_get_item_attribute (menu, i, "accel", "s", &accel)) {
			g_object_set_data_full (G_OBJECT (button), "rb-accel", accel, (GDestroyNotify) g_free);
		}

		gtk_widget_show_all (button);
		gtk_size_group_add_widget (bar->priv->size_group, button);
		gtk_grid_attach (GTK_GRID (bar), button, bar->priv->position++, 0, 1, 1);

		g_free (label_text);
	}

	return need_separator;
}
Ejemplo n.º 30
0
static void
wikipad_statusbar_init (WikipadStatusbar *statusbar)
{
  GtkWidget    *ebox, *box, *separator, *label;
  GtkStatusbar *bar = GTK_STATUSBAR (statusbar);
  GList *frame;

  /* init statusbar */
#if ! GTK_CHECK_VERSION(3, 0, 0)
  gtk_statusbar_set_has_resize_grip (bar, TRUE);
#endif

  /* create a new horizontal box */
  box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 8);
  gtk_widget_show (box);

  /* reorder the gtk statusbar */
  frame = gtk_container_get_children (GTK_CONTAINER (bar));
  gtk_frame_set_shadow_type (GTK_FRAME (frame->data), GTK_SHADOW_NONE);
  label = gtk_bin_get_child (GTK_BIN (frame->data));
  g_object_ref (label);
  gtk_container_remove (GTK_CONTAINER (frame->data), label);
  gtk_container_add (GTK_CONTAINER (frame->data), box);
  gtk_box_pack_start (GTK_BOX (box), label, TRUE, TRUE, 0);
  g_object_unref (label);
  g_list_free (frame);

  /* separator */
  separator = gtk_separator_new (GTK_ORIENTATION_VERTICAL);
  gtk_box_pack_start (GTK_BOX (box), separator, FALSE, FALSE, 0);
  gtk_widget_show (separator);

  /* language/filetype event box */
  ebox = gtk_event_box_new ();
  gtk_box_pack_start (GTK_BOX (box), ebox, FALSE, TRUE, 0);
  gtk_event_box_set_visible_window (GTK_EVENT_BOX (ebox), FALSE);
  gtk_widget_set_tooltip_text (ebox, _("Choose a filetype"));
  g_signal_connect (G_OBJECT (ebox), "button-press-event", G_CALLBACK (wikipad_statusbar_filetype_clicked), statusbar);
  gtk_widget_show (ebox);

  /* language/filetype */
  statusbar->language = gtk_label_new (_("Filetype: None"));
  gtk_container_add (GTK_CONTAINER (ebox), statusbar->language);
  gtk_widget_show (statusbar->language);

  /* separator */
  separator = gtk_separator_new (GTK_ORIENTATION_VERTICAL);
  gtk_box_pack_start (GTK_BOX (box), separator, FALSE, FALSE, 0);
  gtk_widget_show (separator);

  /* line and column numbers */
  statusbar->position = gtk_label_new (NULL);
  gtk_box_pack_start (GTK_BOX (box), statusbar->position, FALSE, TRUE, 0);
  gtk_widget_show (statusbar->position);

  /* separator */
  separator = gtk_separator_new (GTK_ORIENTATION_VERTICAL);
  gtk_box_pack_start (GTK_BOX (box), separator, FALSE, FALSE, 0);
  gtk_widget_show (separator);

  /* overwrite event box */
  ebox = gtk_event_box_new ();
  gtk_box_pack_start (GTK_BOX (box), ebox, FALSE, TRUE, 0);
  gtk_event_box_set_visible_window (GTK_EVENT_BOX (ebox), FALSE);
  gtk_widget_set_tooltip_text (ebox, _("Toggle the overwrite mode"));
  g_signal_connect (G_OBJECT (ebox), "button-press-event", G_CALLBACK (wikipad_statusbar_overwrite_clicked), statusbar);
  gtk_widget_show (ebox);

  /* overwrite label */
  statusbar->overwrite = gtk_label_new (_("OVR"));
  gtk_container_add (GTK_CONTAINER (ebox), statusbar->overwrite);
  gtk_widget_show (statusbar->overwrite);
}