Example #1
0
/* Sets a format string used to display text indicating the current progress.
 * The string can contain the following substitution characters:

    %v - the current progress value.

    %l - the lower bound for the progress value.

    %u - the upper bound for the progress value.

    %p - the current progress percentage. */
int
clip_GTK_PROGRESSSETFORMATSTRING(ClipMachine * cm)
{
	C_widget *cprg = _fetch_cw_arg(cm);
	gchar * format = _clip_parc(cm,2);
        CHECKCWID(cprg,GTK_IS_PROGRESS);
	CHECKOPT(2,CHARACTER_t);
        if (_clip_parinfo(cm,2)==UNDEF_t) format = "\0";
        LOCALE_TO_UTF(format);
        gtk_progress_set_format_string(GTK_PROGRESS(cprg->widget), format);
        FREE_TEXT(format);
	return 0;
err:
	return 1;
}
Example #2
0
void
CreateItems(datastruct * ds, GtkWidget *vbox)
{
  ds->progress = gtk_progress_bar_new();
  gtk_progress_bar_set_bar_style(GTK_PROGRESS_BAR (ds->progress), GTK_PROGRESS_CONTINUOUS);
  gtk_progress_set_format_string(GTK_PROGRESS(ds->progress), "%v%%");
  gtk_progress_set_show_text(GTK_PROGRESS(ds->progress), TRUE);
  gtk_box_pack_start(GTK_BOX(vbox), ds->progress, TRUE, TRUE, FALSE);
  gtk_widget_show(ds->progress);

  ds->text = gtk_label_new("time");
  gtk_box_pack_start(GTK_BOX(vbox), ds->text,
		     TRUE,
		     TRUE,
		     FALSE);
  gtk_widget_show(ds->text);
  return ;
}
Example #3
0
File: xqf-ui.c Project: IR4T4/xqf
GtkWidget *create_progress_bar (void) {
	GtkWidget *pbar;
	struct pbarinfo *info;

	pbar = gtk_progress_bar_new ();

	info = g_malloc0 (sizeof (struct pbarinfo));

	gtk_object_set_user_data (GTK_OBJECT (pbar), info);
	gtk_signal_connect (GTK_OBJECT (pbar), "destroy",
			(GtkSignalFunc) progress_bar_destroy_event, NULL);

	gtk_progress_set_format_string (GTK_PROGRESS (pbar), "%1p%%");
	/* gtk_progress_configure (GTK_PROGRESS (pbar), 0.0, 0.0, 100.0); */
	gtk_progress_bar_set_activity_step (GTK_PROGRESS_BAR (pbar), 5);

	return pbar;
}
Example #4
0
static GtkWidget *
progressbar_new(GladeXML *xml, GladeWidgetInfo *info)
{
	GtkWidget *ret = gtk_progress_bar_new();
	GList *tmp;
	gfloat value = 0, lower = 0, upper = 100;
	gfloat xalign = 0.5, yalign = 0.5;

	for (tmp = info->attributes; tmp; tmp = tmp->next) {
		GladeAttribute *attr = tmp->data;

		if (!strcmp(attr->name, "value"))
			value = g_strtod(attr->value, NULL);
		else if (!strcmp(attr->name, "lower"))
			lower = g_strtod(attr->value, NULL);
		else if (!strcmp(attr->name, "upper"))
			upper = g_strtod(attr->value, NULL);
		else if (!strcmp(attr->name, "activity_mode"))
			gtk_progress_set_activity_mode(GTK_PROGRESS(ret),
						       attr->value[0]=='T');
		else if (!strcmp(attr->name, "bar_style"))
			gtk_progress_bar_set_bar_style(GTK_PROGRESS_BAR(ret),
			    glade_enum_from_string(GTK_TYPE_PROGRESS_BAR_STYLE,
						   attr->value));
		else if (!strcmp(attr->name, "orientation"))
			gtk_progress_bar_set_orientation(GTK_PROGRESS_BAR(ret),
			    glade_enum_from_string(
			      GTK_TYPE_PROGRESS_BAR_ORIENTATION, attr->value));
		else if (!strcmp(attr->name, "show_text"))
			gtk_progress_set_show_text(GTK_PROGRESS(ret),
						   attr->value[0] == 'T');
		else if (!strcmp(attr->name, "text_xalign"))
			xalign = g_strtod(attr->value, NULL);
		else if (!strcmp(attr->name, "text_yalign"))
			yalign = g_strtod(attr->value, NULL);
		else if (!strcmp(attr->name, "format"))
			gtk_progress_set_format_string(GTK_PROGRESS(ret),
						       attr->value);
	}
	gtk_progress_configure(GTK_PROGRESS(ret), value, lower, upper);
	gtk_progress_set_text_alignment(GTK_PROGRESS(ret), xalign, yalign);
	return ret;
}
GtkWidget*
create_rs232 (void)
{
  GtkWidget *rs232;
  GtkWidget *eventbox1;
  GtkWidget *vbox1;
  GtkWidget *hbox5;
  GtkWidget *exit;
  GtkWidget *swap;
  GtkWidget *clean_data_area;
  GtkWidget *label7;
  GtkWidget *label8;
  GtkWidget *hseparator5;
  GtkWidget *hbox3;
  GtkWidget *vbox2;
  GtkWidget *hbox18;
  GtkWidget *label1;
  GtkWidget *combo1;
  GList *combo1_items = NULL;
  GtkWidget *combo_entry_baudrate;
  GtkWidget *hbox24;
  GtkWidget *label2;
  GtkWidget *entry5;
  GtkWidget *label20;
  GtkWidget *hbox19;
  GtkWidget *label3;
  GtkWidget *hbox25;
  GtkWidget *combo3;
  GList *combo3_items = NULL;
  GtkWidget *combo_entry_port;
  GtkWidget *hbox26;
  GtkWidget *label4;
  GtkWidget *entry2;
  GtkWidget *label21;
  GtkWidget *hbox27;
  GtkWidget *togglebutton1;
  GtkWidget *save_as_numeral;
  GtkWidget *entry1;
  GtkWidget *scrolledwindow1;
  GtkWidget *text1;
  GtkWidget *scrolledwindow2;
  GtkWidget *text2;
  GtkWidget *hseparator4;
  GtkWidget *hbox4;
  GtkWidget *label22;
  GSList *_4_group = NULL;
  GtkWidget *radiobutton1;
  guint radiobutton2_key;
  GtkWidget *radiobutton2;
  GtkWidget *hseparator6;
  GtkWidget *hbox29;
  GtkWidget *spectrum;
  GtkWidget *inspect;
  GtkWidget *hbox30;
  GtkWidget *big_spectrum;
  GtkWidget *optionmenu1;
  GtkWidget *optionmenu1_menu;
  GtkWidget *glade_menuitem;
  GtkWidget *print_spectrum;
  GtkWidget *label19;
  GtkWidget *printer_name;
  GtkWidget *hbox17;
  GtkWidget *label18;
  GtkWidget *point;
  GtkWidget *save_as_eps;
  GtkWidget *entry4;
  GtkWidget *hseparator1;
  GtkWidget *hbox9;
  GtkWidget *label9;
  GSList *_1_group = NULL;
  GtkWidget *specification_on;
  GtkWidget *coefficient_on;
  GtkWidget *hseparator3;
  GtkWidget *hbox6;
  GtkWidget *label11;
  GSList *_2_group = NULL;
  GtkWidget *move_average;
  GtkWidget *window;
  GtkWidget *butterworth;
  GtkWidget *chebyshev;
  GtkWidget *hbox8;
  GtkWidget *fs_label;
  GtkWidget *fs;
  GtkWidget *pass_edge_label;
  GtkWidget *pass_edge;
  GtkWidget *stop_edge_label;
  GtkWidget *stop_edge;
  GtkWidget *pass_ripple_label;
  GtkWidget *pass_ripple;
  GtkWidget *stop_ripple_label;
  GtkWidget *stop_ripple;
  GtkWidget *hseparator2;
  GtkWidget *hbox10;
  GtkWidget *label12;
  GSList *_3_group = NULL;
  GtkWidget *fir_input_coefficient;
  GtkWidget *iir_input_coefficient;
  GtkWidget *identify_stability;
  GtkWidget *hbox14;
  GtkWidget *label16;
  GtkWidget *a_value;
  GtkWidget *label17;
  GtkWidget *b_value;
  GtkWidget *appbar1;
  GtkWidget *hbox28;
  GtkWidget *statusbar1;
  GtkWidget *progressbar1;
  GtkAccelGroup *accel_group;
  GtkTooltips *tooltips;

  tooltips = gtk_tooltips_new ();

  accel_group = gtk_accel_group_new ();

  rs232 = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_object_set_data (GTK_OBJECT (rs232), "rs232", rs232);
  gtk_window_set_title (GTK_WINDOW (rs232), _("\246\263\255\255\257\337\275\304\305T\300\263 FIR \244\316\265L\255\255\257\337\275\304\305T\300\263 IIR \252\272\300W\303\320\244\300\252R\300\263\245\316"));
  gtk_window_set_policy (GTK_WINDOW (rs232), FALSE, FALSE, TRUE);

  eventbox1 = gtk_event_box_new ();
  gtk_widget_ref (eventbox1);
  gtk_object_set_data_full (GTK_OBJECT (rs232), "eventbox1", eventbox1,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (eventbox1);
  gtk_container_add (GTK_CONTAINER (rs232), eventbox1);

  vbox1 = gtk_vbox_new (FALSE, 0);
  gtk_widget_ref (vbox1);
  gtk_object_set_data_full (GTK_OBJECT (rs232), "vbox1", vbox1,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (vbox1);
  gtk_container_add (GTK_CONTAINER (eventbox1), vbox1);

  hbox5 = gtk_hbox_new (FALSE, 0);
  gtk_widget_ref (hbox5);
  gtk_object_set_data_full (GTK_OBJECT (rs232), "hbox5", hbox5,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (hbox5);
  gtk_box_pack_start (GTK_BOX (vbox1), hbox5, TRUE, TRUE, 10);

  exit = gtk_button_new_with_label (_("\302\367\266}"));
  gtk_widget_ref (exit);
  gtk_object_set_data_full (GTK_OBJECT (rs232), "exit", exit,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (exit);
  gtk_box_pack_start (GTK_BOX (hbox5), exit, FALSE, FALSE, 10);
  gtk_widget_set_usize (exit, 100, -2);

  swap = gtk_button_new_with_label (_("\261\265\246\254"));
  gtk_widget_ref (swap);
  gtk_object_set_data_full (GTK_OBJECT (rs232), "swap", swap,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (swap);
  gtk_box_pack_start (GTK_BOX (hbox5), swap, FALSE, FALSE, 10);
  gtk_widget_set_usize (swap, 100, -2);
  gtk_tooltips_set_tip (tooltips, swap, _("\245i\261\265\246\254\245\321\246\352\246C\260\360\251\322\260e\250\323\252\272\270\352\256\306"), NULL);

  clean_data_area = gtk_button_new_with_label (_("\262M\260\243\270\352\256\306\261\265\246\254\260\317"));
  gtk_widget_ref (clean_data_area);
  gtk_object_set_data_full (GTK_OBJECT (rs232), "clean_data_area", clean_data_area,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (clean_data_area);
  gtk_box_pack_start (GTK_BOX (hbox5), clean_data_area, FALSE, FALSE, 10);

  label7 = gtk_label_new (_("\255\354\251l\270\352\256\306"));
  gtk_widget_ref (label7);
  gtk_object_set_data_full (GTK_OBJECT (rs232), "label7", label7,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (label7);
  gtk_box_pack_start (GTK_BOX (hbox5), label7, FALSE, FALSE, 89);

  label8 = gtk_label_new (_("\274\306\255\310\270\352\256\306"));
  gtk_widget_ref (label8);
  gtk_object_set_data_full (GTK_OBJECT (rs232), "label8", label8,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (label8);
  gtk_box_pack_start (GTK_BOX (hbox5), label8, FALSE, FALSE, 52);

  hseparator5 = gtk_hseparator_new ();
  gtk_widget_ref (hseparator5);
  gtk_object_set_data_full (GTK_OBJECT (rs232), "hseparator5", hseparator5,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (hseparator5);
  gtk_box_pack_start (GTK_BOX (vbox1), hseparator5, TRUE, TRUE, 5);

  hbox3 = gtk_hbox_new (FALSE, 0);
  gtk_widget_ref (hbox3);
  gtk_object_set_data_full (GTK_OBJECT (rs232), "hbox3", hbox3,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (hbox3);
  gtk_box_pack_start (GTK_BOX (vbox1), hbox3, TRUE, TRUE, 5);

  vbox2 = gtk_vbox_new (FALSE, 0);
  gtk_widget_ref (vbox2);
  gtk_object_set_data_full (GTK_OBJECT (rs232), "vbox2", vbox2,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (vbox2);
  gtk_box_pack_start (GTK_BOX (hbox3), vbox2, TRUE, TRUE, 0);

  hbox18 = gtk_hbox_new (FALSE, 0);
  gtk_widget_ref (hbox18);
  gtk_object_set_data_full (GTK_OBJECT (rs232), "hbox18", hbox18,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (hbox18);
  gtk_box_pack_start (GTK_BOX (vbox2), hbox18, TRUE, TRUE, 5);

  label1 = gtk_label_new (_("\266\307\277\351\300j\262v"));
  gtk_widget_ref (label1);
  gtk_object_set_data_full (GTK_OBJECT (rs232), "label1", label1,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (label1);
  gtk_box_pack_start (GTK_BOX (hbox18), label1, FALSE, FALSE, 10);

  combo1 = gtk_combo_new ();
  gtk_widget_ref (combo1);
  gtk_object_set_data_full (GTK_OBJECT (rs232), "combo1", combo1,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (combo1);
  gtk_box_pack_start (GTK_BOX (hbox18), combo1, TRUE, TRUE, 10);
  gtk_widget_set_usize (combo1, 1, -2);
  combo1_items = g_list_append (combo1_items, (gpointer) _("2400"));
  combo1_items = g_list_append (combo1_items, (gpointer) _("4800"));
  combo1_items = g_list_append (combo1_items, (gpointer) _("9600"));
  combo1_items = g_list_append (combo1_items, (gpointer) _("19200"));
  combo1_items = g_list_append (combo1_items, (gpointer) _("38400"));
  combo1_items = g_list_append (combo1_items, (gpointer) _("57600"));
  combo1_items = g_list_append (combo1_items, (gpointer) _("115200"));
  gtk_combo_set_popdown_strings (GTK_COMBO (combo1), combo1_items);
  g_list_free (combo1_items);

  combo_entry_baudrate = GTK_COMBO (combo1)->entry;
  gtk_widget_ref (combo_entry_baudrate);
  gtk_object_set_data_full (GTK_OBJECT (rs232), "combo_entry_baudrate", combo_entry_baudrate,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (combo_entry_baudrate);
  gtk_entry_set_editable (GTK_ENTRY (combo_entry_baudrate), FALSE);
  gtk_entry_set_text (GTK_ENTRY (combo_entry_baudrate), _("4800"));

  hbox24 = gtk_hbox_new (FALSE, 0);
  gtk_widget_ref (hbox24);
  gtk_object_set_data_full (GTK_OBJECT (rs232), "hbox24", hbox24,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (hbox24);
  gtk_box_pack_start (GTK_BOX (hbox18), hbox24, TRUE, TRUE, 0);

  label2 = gtk_label_new (_("\270\352\256\306\252\370\253\327"));
  gtk_widget_ref (label2);
  gtk_object_set_data_full (GTK_OBJECT (rs232), "label2", label2,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (label2);
  gtk_box_pack_start (GTK_BOX (hbox24), label2, FALSE, FALSE, 15);

  entry5 = gtk_entry_new ();
  gtk_widget_ref (entry5);
  gtk_object_set_data_full (GTK_OBJECT (rs232), "entry5", entry5,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (entry5);
  gtk_box_pack_start (GTK_BOX (hbox24), entry5, TRUE, TRUE, 10);
  gtk_widget_set_usize (entry5, 1, -2);
  gtk_tooltips_set_tip (tooltips, entry5, _("\263\346\246\354\254O\246\354\244\270\262\325"), NULL);
  gtk_entry_set_text (GTK_ENTRY (entry5), _("16"));

  label20 = gtk_label_new (_("\246\354\244\270\262\325\274\306"));
  gtk_widget_ref (label20);
  gtk_object_set_data_full (GTK_OBJECT (rs232), "label20", label20,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (label20);
  gtk_box_pack_start (GTK_BOX (hbox24), label20, FALSE, FALSE, 10);

  hbox19 = gtk_hbox_new (FALSE, 0);
  gtk_widget_ref (hbox19);
  gtk_object_set_data_full (GTK_OBJECT (rs232), "hbox19", hbox19,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (hbox19);
  gtk_box_pack_start (GTK_BOX (vbox2), hbox19, TRUE, TRUE, 5);

  label3 = gtk_label_new (_("\266\307\277\351\247\307\246C"));
  gtk_widget_ref (label3);
  gtk_object_set_data_full (GTK_OBJECT (rs232), "label3", label3,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (label3);
  gtk_box_pack_start (GTK_BOX (hbox19), label3, FALSE, FALSE, 10);

  hbox25 = gtk_hbox_new (FALSE, 0);
  gtk_widget_ref (hbox25);
  gtk_object_set_data_full (GTK_OBJECT (rs232), "hbox25", hbox25,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (hbox25);
  gtk_box_pack_start (GTK_BOX (hbox19), hbox25, TRUE, TRUE, 0);

  combo3 = gtk_combo_new ();
  gtk_widget_ref (combo3);
  gtk_object_set_data_full (GTK_OBJECT (rs232), "combo3", combo3,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (combo3);
  gtk_box_pack_start (GTK_BOX (hbox25), combo3, TRUE, TRUE, 10);
  gtk_widget_set_usize (combo3, 1, -2);
  combo3_items = g_list_append (combo3_items, (gpointer) _("1"));
  combo3_items = g_list_append (combo3_items, (gpointer) _("2"));
  gtk_combo_set_popdown_strings (GTK_COMBO (combo3), combo3_items);
  g_list_free (combo3_items);

  combo_entry_port = GTK_COMBO (combo3)->entry;
  gtk_widget_ref (combo_entry_port);
  gtk_object_set_data_full (GTK_OBJECT (rs232), "combo_entry_port", combo_entry_port,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (combo_entry_port);
  gtk_entry_set_editable (GTK_ENTRY (combo_entry_port), FALSE);
  gtk_entry_set_text (GTK_ENTRY (combo_entry_port), _("1"));

  hbox26 = gtk_hbox_new (FALSE, 0);
  gtk_widget_ref (hbox26);
  gtk_object_set_data_full (GTK_OBJECT (rs232), "hbox26", hbox26,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (hbox26);
  gtk_box_pack_start (GTK_BOX (hbox25), hbox26, TRUE, TRUE, 0);

  label4 = gtk_label_new (_("\270\352\256\306\301`\274\306"));
  gtk_widget_ref (label4);
  gtk_object_set_data_full (GTK_OBJECT (rs232), "label4", label4,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (label4);
  gtk_box_pack_start (GTK_BOX (hbox26), label4, FALSE, FALSE, 15);

  entry2 = gtk_entry_new ();
  gtk_widget_ref (entry2);
  gtk_object_set_data_full (GTK_OBJECT (rs232), "entry2", entry2,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (entry2);
  gtk_box_pack_start (GTK_BOX (hbox26), entry2, TRUE, TRUE, 10);
  gtk_widget_set_usize (entry2, 1, -2);
  gtk_entry_set_text (GTK_ENTRY (entry2), _("5"));

  label21 = gtk_label_new (_("\265\247\270\352\256\306\274\306"));
  gtk_widget_ref (label21);
  gtk_object_set_data_full (GTK_OBJECT (rs232), "label21", label21,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (label21);
  gtk_box_pack_start (GTK_BOX (hbox26), label21, FALSE, FALSE, 10);

  hbox27 = gtk_hbox_new (FALSE, 0);
  gtk_widget_ref (hbox27);
  gtk_object_set_data_full (GTK_OBJECT (rs232), "hbox27", hbox27,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (hbox27);
  gtk_box_pack_start (GTK_BOX (vbox2), hbox27, FALSE, FALSE, 5);

  togglebutton1 = gtk_toggle_button_new_with_label (_("\261j\250\356\274g\244J\300\311\256\327"));
  gtk_widget_ref (togglebutton1);
  gtk_object_set_data_full (GTK_OBJECT (rs232), "togglebutton1", togglebutton1,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (togglebutton1);
  gtk_box_pack_start (GTK_BOX (hbox27), togglebutton1, FALSE, FALSE, 10);
  gtk_tooltips_set_tip (tooltips, togglebutton1, _("\244\243\272\336\253\374\251w\252\272\300\311\256\327\270\364\256|\244\247\300\311\246W\246s\246b\273P\247_\241A\244@\253\337\261j\250\356\274g\244J"), NULL);
  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (togglebutton1), TRUE);

  save_as_numeral = gtk_button_new_with_label (_("\300\311\256\327\270\364\256|"));
  gtk_widget_ref (save_as_numeral);
  gtk_object_set_data_full (GTK_OBJECT (rs232), "save_as_numeral", save_as_numeral,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (save_as_numeral);
  gtk_box_pack_start (GTK_BOX (hbox27), save_as_numeral, FALSE, FALSE, 0);

  entry1 = gtk_entry_new ();
  gtk_widget_ref (entry1);
  gtk_object_set_data_full (GTK_OBJECT (rs232), "entry1", entry1,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (entry1);
  gtk_box_pack_start (GTK_BOX (hbox27), entry1, TRUE, TRUE, 10);
  gtk_widget_set_usize (entry1, 1, -2);
  gtk_entry_set_text (GTK_ENTRY (entry1), _("/home/allways/numeral.txt"));

  scrolledwindow1 = gtk_scrolled_window_new (NULL, NULL);
  gtk_widget_ref (scrolledwindow1);
  gtk_object_set_data_full (GTK_OBJECT (rs232), "scrolledwindow1", scrolledwindow1,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (scrolledwindow1);
  gtk_box_pack_start (GTK_BOX (hbox3), scrolledwindow1, TRUE, TRUE, 5);
  gtk_widget_set_usize (scrolledwindow1, 1, -2);
  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow1), GTK_POLICY_NEVER, GTK_POLICY_ALWAYS);

  text1 = gtk_text_new (NULL, NULL);
  gtk_widget_ref (text1);
  gtk_object_set_data_full (GTK_OBJECT (rs232), "text1", text1,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (text1);
  gtk_container_add (GTK_CONTAINER (scrolledwindow1), text1);
  gtk_tooltips_set_tip (tooltips, text1, _("\261q\246\352\246C\260\360\266\307\250\323\252\272\247\271\276\343\270\352\256\306"), NULL);

  scrolledwindow2 = gtk_scrolled_window_new (NULL, NULL);
  gtk_widget_ref (scrolledwindow2);
  gtk_object_set_data_full (GTK_OBJECT (rs232), "scrolledwindow2", scrolledwindow2,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (scrolledwindow2);
  gtk_box_pack_start (GTK_BOX (hbox3), scrolledwindow2, TRUE, TRUE, 5);
  gtk_widget_set_usize (scrolledwindow2, 1, -2);
  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow2), GTK_POLICY_NEVER, GTK_POLICY_ALWAYS);

  text2 = gtk_text_new (NULL, NULL);
  gtk_widget_ref (text2);
  gtk_object_set_data_full (GTK_OBJECT (rs232), "text2", text2,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (text2);
  gtk_container_add (GTK_CONTAINER (scrolledwindow2), text2);
  gtk_tooltips_set_tip (tooltips, text2, _("\261q\247\271\276\343\270\352\256\306\251\322\261o\250\354\252\272\257\302\274\306\255\310\270\352\256\306"), NULL);

  hseparator4 = gtk_hseparator_new ();
  gtk_widget_ref (hseparator4);
  gtk_object_set_data_full (GTK_OBJECT (rs232), "hseparator4", hseparator4,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (hseparator4);
  gtk_box_pack_start (GTK_BOX (vbox1), hseparator4, TRUE, TRUE, 5);

  hbox4 = gtk_hbox_new (FALSE, 0);
  gtk_widget_ref (hbox4);
  gtk_object_set_data_full (GTK_OBJECT (rs232), "hbox4", hbox4,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (hbox4);
  gtk_box_pack_start (GTK_BOX (vbox1), hbox4, TRUE, TRUE, 5);

  label22 = gtk_label_new (_("\250\317\245\316\245\273\263n\305\351\244\247\302o\252i\276\271"));
  gtk_widget_ref (label22);
  gtk_object_set_data_full (GTK_OBJECT (rs232), "label22", label22,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (label22);
  gtk_box_pack_start (GTK_BOX (hbox4), label22, FALSE, FALSE, 10);

  radiobutton1 = gtk_radio_button_new_with_label (_4_group, _("\254O"));
  _4_group = gtk_radio_button_group (GTK_RADIO_BUTTON (radiobutton1));
  gtk_widget_ref (radiobutton1);
  gtk_object_set_data_full (GTK_OBJECT (rs232), "radiobutton1", radiobutton1,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (radiobutton1);
  gtk_box_pack_start (GTK_BOX (hbox4), radiobutton1, FALSE, FALSE, 0);

  radiobutton2 = gtk_radio_button_new_with_label (_4_group, "");
  radiobutton2_key = gtk_label_parse_uline (GTK_LABEL (GTK_BIN (radiobutton2)->child),
                                   _("\247_"));
  gtk_widget_add_accelerator (radiobutton2, "clicked", accel_group,
                              radiobutton2_key, GDK_MOD1_MASK, (GtkAccelFlags) 0);
  _4_group = gtk_radio_button_group (GTK_RADIO_BUTTON (radiobutton2));
  gtk_widget_ref (radiobutton2);
  gtk_object_set_data_full (GTK_OBJECT (rs232), "radiobutton2", radiobutton2,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (radiobutton2);
  gtk_box_pack_start (GTK_BOX (hbox4), radiobutton2, FALSE, FALSE, 0);
  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radiobutton2), TRUE);

  hseparator6 = gtk_hseparator_new ();
  gtk_widget_ref (hseparator6);
  gtk_object_set_data_full (GTK_OBJECT (rs232), "hseparator6", hseparator6,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (hseparator6);
  gtk_box_pack_start (GTK_BOX (vbox1), hseparator6, TRUE, TRUE, 5);

  hbox29 = gtk_hbox_new (FALSE, 0);
  gtk_widget_ref (hbox29);
  gtk_object_set_data_full (GTK_OBJECT (rs232), "hbox29", hbox29,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (hbox29);
  gtk_box_pack_start (GTK_BOX (vbox1), hbox29, TRUE, TRUE, 5);

  spectrum = gtk_button_new_with_label (_("\266}\251l\303\270\273s\302o\252i\276\271\300W\303\320\271\317"));
  gtk_widget_ref (spectrum);
  gtk_object_set_data_full (GTK_OBJECT (rs232), "spectrum", spectrum,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (spectrum);
  gtk_box_pack_start (GTK_BOX (hbox29), spectrum, FALSE, FALSE, 10);
  gtk_tooltips_set_tip (tooltips, spectrum, _("\267\355\246U\260\321\274\306\244\316\263]\251w\246n\244F\244\247\253\341\241A\264N\245i\245H\253\366\246\271\266s\250\323\303\270\273s\271\317\247\316\244F"), NULL);

  inspect = gtk_button_new_with_label (_("\300\313\265\370\271\317\300\311"));
  gtk_widget_ref (inspect);
  gtk_object_set_data_full (GTK_OBJECT (rs232), "inspect", inspect,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (inspect);
  gtk_box_pack_start (GTK_BOX (hbox29), inspect, FALSE, FALSE, 0);
  gtk_tooltips_set_tip (tooltips, inspect, _("\245i\244\243\254O A \271\317\263\341\241I\254O\300W\303\320\271\317\260\325\241I"), NULL);

  hbox30 = gtk_hbox_new (FALSE, 0);
  gtk_widget_ref (hbox30);
  gtk_object_set_data_full (GTK_OBJECT (rs232), "hbox30", hbox30,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (hbox30);
  gtk_box_pack_start (GTK_BOX (vbox1), hbox30, TRUE, TRUE, 5);

  big_spectrum = gtk_toggle_button_new_with_label (_("\244j\261i\252\272\300W\303\320\271\317"));
  gtk_widget_ref (big_spectrum);
  gtk_object_set_data_full (GTK_OBJECT (rs232), "big_spectrum", big_spectrum,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (big_spectrum);
  gtk_box_pack_start (GTK_BOX (hbox30), big_spectrum, FALSE, FALSE, 10);

  optionmenu1 = gtk_option_menu_new ();
  gtk_widget_ref (optionmenu1);
  gtk_object_set_data_full (GTK_OBJECT (rs232), "optionmenu1", optionmenu1,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (optionmenu1);
  gtk_box_pack_start (GTK_BOX (hbox30), optionmenu1, FALSE, FALSE, 10);
  optionmenu1_menu = gtk_menu_new ();
  glade_menuitem = gtk_menu_item_new_with_label (_("          \300W\303\320\271\317\252\355\245\334\244\350\252k"));
  gtk_widget_show (glade_menuitem);
  gtk_menu_append (GTK_MENU (optionmenu1_menu), glade_menuitem);
  glade_menuitem = gtk_menu_item_new_with_label (_("X \266b\241G\274\306\246\354\300W\262v Y\241G\275u\251\312\274W\257q"));
  gtk_widget_show (glade_menuitem);
  gtk_menu_append (GTK_MENU (optionmenu1_menu), glade_menuitem);
  glade_menuitem = gtk_menu_item_new_with_label (_("X \266b\241G\274\306\246\354\300W\262v Y\241G\244\300\250\251\274W\257q"));
  gtk_widget_show (glade_menuitem);
  gtk_menu_append (GTK_MENU (optionmenu1_menu), glade_menuitem);
  glade_menuitem = gtk_menu_item_new_with_label (_("X \266b\241G\303\376\244\361\300W\262v Y\241G\275u\251\312\274W\257q"));
  gtk_widget_show (glade_menuitem);
  gtk_menu_append (GTK_MENU (optionmenu1_menu), glade_menuitem);
  glade_menuitem = gtk_menu_item_new_with_label (_("X \266b\241G\303\376\244\361\300W\262v Y\241G\244\300\250\251\274W\257q"));
  gtk_widget_show (glade_menuitem);
  gtk_menu_append (GTK_MENU (optionmenu1_menu), glade_menuitem);
  gtk_option_menu_set_menu (GTK_OPTION_MENU (optionmenu1), optionmenu1_menu);

  print_spectrum = gtk_toggle_button_new_with_label (_("\300W\303\320\271\317\245\316\246L\252\355\276\367\246L\245X"));
  gtk_widget_ref (print_spectrum);
  gtk_object_set_data_full (GTK_OBJECT (rs232), "print_spectrum", print_spectrum,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (print_spectrum);
  gtk_box_pack_start (GTK_BOX (hbox30), print_spectrum, FALSE, FALSE, 0);
  gtk_tooltips_set_tip (tooltips, print_spectrum, _("\300W\303\320\271\317\273\335\255n\245\316\246L\252\355\276\367\303\270\273s\245X\250\323\252\272\256\311\255\324\241A\250\317\244\247\244U\250H\241A\260O\261o\246L\252\355\276\367\252\272\246W\272\331\255n\245[\263\341\241I"), NULL);

  label19 = gtk_label_new (_("\246L\252\355\276\367\252\272\271q\270\243\246W\272\331"));
  gtk_widget_ref (label19);
  gtk_object_set_data_full (GTK_OBJECT (rs232), "label19", label19,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (label19);
  gtk_box_pack_start (GTK_BOX (hbox30), label19, FALSE, FALSE, 10);

  printer_name = gtk_entry_new ();
  gtk_widget_ref (printer_name);
  gtk_object_set_data_full (GTK_OBJECT (rs232), "printer_name", printer_name,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (printer_name);
  gtk_box_pack_start (GTK_BOX (hbox30), printer_name, TRUE, TRUE, 10);
  gtk_widget_set_usize (printer_name, 1, -2);
  gtk_tooltips_set_tip (tooltips, printer_name, _("\264N\254O\246b\272\364\270\364\244W\246L\252\355\276\367\252\272\246W\246r\241A\245i\244\243\254O\245L\252\272\241\247\262\243\253~\246W\246r\241\250\263\341"), NULL);
  gtk_entry_set_text (GTK_ENTRY (printer_name), _("hp"));

  hbox17 = gtk_hbox_new (FALSE, 0);
  gtk_widget_ref (hbox17);
  gtk_object_set_data_full (GTK_OBJECT (rs232), "hbox17", hbox17,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (hbox17);
  gtk_box_pack_start (GTK_BOX (vbox1), hbox17, TRUE, TRUE, 5);

  label18 = gtk_label_new (_("\300W\303\320\271\317\245\255\267\306\253\327( X \266b )"));
  gtk_widget_ref (label18);
  gtk_object_set_data_full (GTK_OBJECT (rs232), "label18", label18,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (label18);
  gtk_box_pack_start (GTK_BOX (hbox17), label18, FALSE, FALSE, 10);

  point = gtk_entry_new ();
  gtk_widget_ref (point);
  gtk_object_set_data_full (GTK_OBJECT (rs232), "point", point,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (point);
  gtk_box_pack_start (GTK_BOX (hbox17), point, TRUE, TRUE, 0);
  gtk_widget_set_usize (point, 1, -2);
  gtk_tooltips_set_tip (tooltips, point, _("\264N\254O\247A\247\306\261\346 X \266b\257\340\260\367\244\300\246\250\264X\255\323\265\245\244\300\251O\241H"), NULL);
  gtk_entry_set_text (GTK_ENTRY (point), _("200"));

  save_as_eps = gtk_button_new_with_label (_("eps\241Bps\241Bpdf \300\311\300x\246s\270\364\256|\241A\275\320\245[\244W\260\306\300\311\246W"));
  gtk_widget_ref (save_as_eps);
  gtk_object_set_data_full (GTK_OBJECT (rs232), "save_as_eps", save_as_eps,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (save_as_eps);
  gtk_box_pack_start (GTK_BOX (hbox17), save_as_eps, FALSE, FALSE, 10);

  entry4 = gtk_entry_new ();
  gtk_widget_ref (entry4);
  gtk_object_set_data_full (GTK_OBJECT (rs232), "entry4", entry4,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (entry4);
  gtk_box_pack_start (GTK_BOX (hbox17), entry4, TRUE, TRUE, 10);
  gtk_widget_set_usize (entry4, 1, -2);
  gtk_tooltips_set_tip (tooltips, entry4, _("\275\320\260O\261o\244@\251w\261o\247\342\271\317\300\311\252\272\260\306\300\311\246W\246\333\246\346\245[\244J\241C\246p eps ps pdf"), NULL);
  gtk_entry_set_text (GTK_ENTRY (entry4), _("/home/allways/spectrum.eps"));

  hseparator1 = gtk_hseparator_new ();
  gtk_widget_ref (hseparator1);
  gtk_object_set_data_full (GTK_OBJECT (rs232), "hseparator1", hseparator1,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (hseparator1);
  gtk_box_pack_start (GTK_BOX (vbox1), hseparator1, TRUE, TRUE, 5);

  hbox9 = gtk_hbox_new (FALSE, 0);
  gtk_widget_ref (hbox9);
  gtk_object_set_data_full (GTK_OBJECT (rs232), "hbox9", hbox9,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (hbox9);
  gtk_box_pack_start (GTK_BOX (vbox1), hbox9, TRUE, TRUE, 5);

  label9 = gtk_label_new (_("\302o\252i\276\271\252\272\300W\303\320\271\317\262\243\245\315\244\350\246\241\241G"));
  gtk_widget_ref (label9);
  gtk_object_set_data_full (GTK_OBJECT (rs232), "label9", label9,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (label9);
  gtk_box_pack_start (GTK_BOX (hbox9), label9, FALSE, FALSE, 5);

  specification_on = gtk_radio_button_new_with_label (_1_group, _("\302o\252i\276\271\251\372\262\323\263W\256\346"));
  _1_group = gtk_radio_button_group (GTK_RADIO_BUTTON (specification_on));
  gtk_widget_ref (specification_on);
  gtk_object_set_data_full (GTK_OBJECT (rs232), "specification_on", specification_on,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (specification_on);
  gtk_box_pack_start (GTK_BOX (hbox9), specification_on, FALSE, FALSE, 5);
  gtk_tooltips_set_tip (tooltips, specification_on, _("\247A\245i\245H\246\333\246\346\245\321\302o\252i\276\271\252\272\246U\255\323\260\321\274\306\244@\244@\277\351\244J\247A\255n\252\272\300W\261a\275d\263\362"), NULL);
  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (specification_on), TRUE);

  coefficient_on = gtk_radio_button_new_with_label (_1_group, _("\260\262\263]\244\247\253Y\274\306\261a\244J\302\340\262\276\250\347\246\241"));
  _1_group = gtk_radio_button_group (GTK_RADIO_BUTTON (coefficient_on));
  gtk_widget_ref (coefficient_on);
  gtk_object_set_data_full (GTK_OBJECT (rs232), "coefficient_on", coefficient_on,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (coefficient_on);
  gtk_box_pack_start (GTK_BOX (hbox9), coefficient_on, FALSE, FALSE, 5);
  gtk_tooltips_set_tip (tooltips, coefficient_on, _("\247A\245i\245H\245\321\265\352\300\300\244@\255\323\302\340\262\276\250\347\274\306\252\272\253Y\274\306\250\323\261o\250\354\247A\255n\252\272\300W\303\320\271\317\241A\265\245\250\354\271\272\245X\250\323\252\272\256\311\255\324\241A\246A\245h\255\327\245\277\247A\252\272\253Y\274\306\241A\244]\254O\244@\272\330\244\350\252k"), NULL);

  hseparator3 = gtk_hseparator_new ();
  gtk_widget_ref (hseparator3);
  gtk_object_set_data_full (GTK_OBJECT (rs232), "hseparator3", hseparator3,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (hseparator3);
  gtk_box_pack_start (GTK_BOX (vbox1), hseparator3, TRUE, TRUE, 5);

  hbox6 = gtk_hbox_new (FALSE, 0);
  gtk_widget_ref (hbox6);
  gtk_object_set_data_full (GTK_OBJECT (rs232), "hbox6", hbox6,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (hbox6);
  gtk_box_pack_start (GTK_BOX (vbox1), hbox6, TRUE, TRUE, 5);

  label11 = gtk_label_new (_("\302o\252i\276\271\251\372\262\323\263W\256\346\241G"));
  gtk_widget_ref (label11);
  gtk_object_set_data_full (GTK_OBJECT (rs232), "label11", label11,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (label11);
  gtk_box_pack_start (GTK_BOX (hbox6), label11, FALSE, FALSE, 5);

  move_average = gtk_radio_button_new_with_label (_2_group, _("FIR\241G\262\276\260\312\245\255\247\241\302o\252i\276\271"));
  _2_group = gtk_radio_button_group (GTK_RADIO_BUTTON (move_average));
  gtk_widget_ref (move_average);
  gtk_object_set_data_full (GTK_OBJECT (rs232), "move_average", move_average,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (move_average);
  gtk_box_pack_start (GTK_BOX (hbox6), move_average, FALSE, FALSE, 0);

  window = gtk_radio_button_new_with_label (_2_group, _("FIR\241G\265\370\265\241\302o\252i\276\271"));
  _2_group = gtk_radio_button_group (GTK_RADIO_BUTTON (window));
  gtk_widget_ref (window);
  gtk_object_set_data_full (GTK_OBJECT (rs232), "window", window,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (window);
  gtk_box_pack_start (GTK_BOX (hbox6), window, FALSE, FALSE, 0);

  butterworth = gtk_radio_button_new_with_label (_2_group, _("IIR\241G\245\244\252o\255\310\261o\302o\252i\276\271"));
  _2_group = gtk_radio_button_group (GTK_RADIO_BUTTON (butterworth));
  gtk_widget_ref (butterworth);
  gtk_object_set_data_full (GTK_OBJECT (rs232), "butterworth", butterworth,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (butterworth);
  gtk_box_pack_start (GTK_BOX (hbox6), butterworth, FALSE, FALSE, 0);
  gtk_tooltips_set_tip (tooltips, butterworth, _("\250\344\271\352\264N\254O\244\332\257S\250U\264\376\260\325\241I"), NULL);

  chebyshev = gtk_radio_button_new_with_label (_2_group, _("IIR\241G\253\264\244\361\263\267\244\322\302o\252i\276\271"));
  _2_group = gtk_radio_button_group (GTK_RADIO_BUTTON (chebyshev));
  gtk_widget_ref (chebyshev);
  gtk_object_set_data_full (GTK_OBJECT (rs232), "chebyshev", chebyshev,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (chebyshev);
  gtk_box_pack_start (GTK_BOX (hbox6), chebyshev, FALSE, FALSE, 0);
  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (chebyshev), TRUE);

  hbox8 = gtk_hbox_new (FALSE, 0);
  gtk_widget_ref (hbox8);
  gtk_object_set_data_full (GTK_OBJECT (rs232), "hbox8", hbox8,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (hbox8);
  gtk_box_pack_start (GTK_BOX (vbox1), hbox8, TRUE, TRUE, 5);

  fs_label = gtk_label_new (_("\250\372\274\313\300W\262v"));
  gtk_widget_ref (fs_label);
  gtk_object_set_data_full (GTK_OBJECT (rs232), "fs_label", fs_label,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (fs_label);
  gtk_box_pack_start (GTK_BOX (hbox8), fs_label, FALSE, FALSE, 10);

  fs = gtk_entry_new ();
  gtk_widget_ref (fs);
  gtk_object_set_data_full (GTK_OBJECT (rs232), "fs", fs,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (fs);
  gtk_box_pack_start (GTK_BOX (hbox8), fs, TRUE, TRUE, 0);
  gtk_widget_set_usize (fs, 1, -2);
  gtk_tooltips_set_tip (tooltips, fs, _("\263\346\246\354\254\260\273\256\257\367"), NULL);
  gtk_entry_set_text (GTK_ENTRY (fs), _("20000"));

  pass_edge_label = gtk_label_new (_("\263q\261a\272I\244\356\300W\262v"));
  gtk_widget_ref (pass_edge_label);
  gtk_object_set_data_full (GTK_OBJECT (rs232), "pass_edge_label", pass_edge_label,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (pass_edge_label);
  gtk_box_pack_start (GTK_BOX (hbox8), pass_edge_label, FALSE, FALSE, 10);

  pass_edge = gtk_entry_new ();
  gtk_widget_ref (pass_edge);
  gtk_object_set_data_full (GTK_OBJECT (rs232), "pass_edge", pass_edge,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (pass_edge);
  gtk_box_pack_start (GTK_BOX (hbox8), pass_edge, TRUE, TRUE, 0);
  gtk_widget_set_usize (pass_edge, 1, -2);
  gtk_tooltips_set_tip (tooltips, pass_edge, _("\263\346\246\354\254\260\273\256\257\367"), NULL);
  gtk_entry_set_text (GTK_ENTRY (pass_edge), _("5000"));

  stop_edge_label = gtk_label_new (_("\244\356\261a\272I\244\356\300W\262v"));
  gtk_widget_ref (stop_edge_label);
  gtk_object_set_data_full (GTK_OBJECT (rs232), "stop_edge_label", stop_edge_label,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (stop_edge_label);
  gtk_box_pack_start (GTK_BOX (hbox8), stop_edge_label, FALSE, FALSE, 10);

  stop_edge = gtk_entry_new ();
  gtk_widget_ref (stop_edge);
  gtk_object_set_data_full (GTK_OBJECT (rs232), "stop_edge", stop_edge,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (stop_edge);
  gtk_box_pack_start (GTK_BOX (hbox8), stop_edge, TRUE, TRUE, 0);
  gtk_widget_set_usize (stop_edge, 1, -2);
  gtk_tooltips_set_tip (tooltips, stop_edge, _("\263\346\246\354\254\260\273\256\257\367"), NULL);
  gtk_entry_set_text (GTK_ENTRY (stop_edge), _("7500"));

  pass_ripple_label = gtk_label_new (_("\263q\261a\272\247\252i"));
  gtk_widget_ref (pass_ripple_label);
  gtk_object_set_data_full (GTK_OBJECT (rs232), "pass_ripple_label", pass_ripple_label,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (pass_ripple_label);
  gtk_box_pack_start (GTK_BOX (hbox8), pass_ripple_label, FALSE, FALSE, 10);

  pass_ripple = gtk_entry_new ();
  gtk_widget_ref (pass_ripple);
  gtk_object_set_data_full (GTK_OBJECT (rs232), "pass_ripple", pass_ripple,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (pass_ripple);
  gtk_box_pack_start (GTK_BOX (hbox8), pass_ripple, TRUE, TRUE, 0);
  gtk_widget_set_usize (pass_ripple, 1, -2);
  gtk_tooltips_set_tip (tooltips, pass_ripple, _("\263\346\246\354\254\260\244\300\250\251\274W\257q"), NULL);
  gtk_entry_set_text (GTK_ENTRY (pass_ripple), _("1"));

  stop_ripple_label = gtk_label_new (_("\244\356\261a\272\247\252i"));
  gtk_widget_ref (stop_ripple_label);
  gtk_object_set_data_full (GTK_OBJECT (rs232), "stop_ripple_label", stop_ripple_label,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (stop_ripple_label);
  gtk_box_pack_start (GTK_BOX (hbox8), stop_ripple_label, FALSE, FALSE, 10);

  stop_ripple = gtk_entry_new ();
  gtk_widget_ref (stop_ripple);
  gtk_object_set_data_full (GTK_OBJECT (rs232), "stop_ripple", stop_ripple,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (stop_ripple);
  gtk_box_pack_start (GTK_BOX (hbox8), stop_ripple, TRUE, TRUE, 10);
  gtk_widget_set_usize (stop_ripple, 1, -2);
  gtk_tooltips_set_tip (tooltips, stop_ripple, _("\263\346\246\354\254\260\244\300\250\251\274W\257q"), NULL);
  gtk_entry_set_text (GTK_ENTRY (stop_ripple), _("32"));

  hseparator2 = gtk_hseparator_new ();
  gtk_widget_ref (hseparator2);
  gtk_object_set_data_full (GTK_OBJECT (rs232), "hseparator2", hseparator2,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (hseparator2);
  gtk_box_pack_start (GTK_BOX (vbox1), hseparator2, TRUE, TRUE, 5);

  hbox10 = gtk_hbox_new (FALSE, 0);
  gtk_widget_ref (hbox10);
  gtk_object_set_data_full (GTK_OBJECT (rs232), "hbox10", hbox10,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (hbox10);
  gtk_box_pack_start (GTK_BOX (vbox1), hbox10, TRUE, TRUE, 5);

  label12 = gtk_label_new (_("\260\262\263]\244\247\253Y\274\306\261a\244J\302\340\262\276\250\347\246\241\241G"));
  gtk_widget_ref (label12);
  gtk_object_set_data_full (GTK_OBJECT (rs232), "label12", label12,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (label12);
  gtk_box_pack_start (GTK_BOX (hbox10), label12, FALSE, FALSE, 5);

  fir_input_coefficient = gtk_radio_button_new_with_label (_3_group, _("\246\263\255\255\257\337\275\304 FIR \302o\252i\276\271"));
  _3_group = gtk_radio_button_group (GTK_RADIO_BUTTON (fir_input_coefficient));
  gtk_widget_ref (fir_input_coefficient);
  gtk_object_set_data_full (GTK_OBJECT (rs232), "fir_input_coefficient", fir_input_coefficient,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (fir_input_coefficient);
  gtk_box_pack_start (GTK_BOX (hbox10), fir_input_coefficient, FALSE, FALSE, 10);
  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (fir_input_coefficient), TRUE);

  iir_input_coefficient = gtk_radio_button_new_with_label (_3_group, _("\265L\255\255\257\337\275\304 IIR \302o\252i\276\271"));
  _3_group = gtk_radio_button_group (GTK_RADIO_BUTTON (iir_input_coefficient));
  gtk_widget_ref (iir_input_coefficient);
  gtk_object_set_data_full (GTK_OBJECT (rs232), "iir_input_coefficient", iir_input_coefficient,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (iir_input_coefficient);
  gtk_box_pack_start (GTK_BOX (hbox10), iir_input_coefficient, FALSE, FALSE, 10);

  identify_stability = gtk_button_new_with_label (_("IIR \302o\252i\276\271\303\255\251w\253\327\305\262\251w(\245\274\247\271\246\250)"));
  gtk_widget_ref (identify_stability);
  gtk_object_set_data_full (GTK_OBJECT (rs232), "identify_stability", identify_stability,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (identify_stability);
  gtk_box_pack_start (GTK_BOX (hbox10), identify_stability, FALSE, FALSE, 10);
  gtk_tooltips_set_tip (tooltips, identify_stability, _("\246]\254\260\247A\252\272\302\340\262\276\250\347\274\306\254O\260\262\263]\252\272\255\310\241A\251\322\245H\303\255\244\243\303\255\251w\247A\244]\244\243\275T\251w\241A\246\271\266s\245i\245H\247P\302_\244@\244U\241A\246]\254\260 FIR \244@\251w\254O\303\255\251w\252\272\241A\251\322\245H\244\243\245\316\264\372\244F\241C"), NULL);

  hbox14 = gtk_hbox_new (FALSE, 0);
  gtk_widget_ref (hbox14);
  gtk_object_set_data_full (GTK_OBJECT (rs232), "hbox14", hbox14,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (hbox14);
  gtk_box_pack_start (GTK_BOX (vbox1), hbox14, TRUE, TRUE, 5);

  label16 = gtk_label_new (_("\302\340\262\276\250\347\274\306\244\300\245\300 Y( n ) "));
  gtk_widget_ref (label16);
  gtk_object_set_data_full (GTK_OBJECT (rs232), "label16", label16,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (label16);
  gtk_box_pack_start (GTK_BOX (hbox14), label16, FALSE, FALSE, 10);

  a_value = gtk_entry_new ();
  gtk_widget_ref (a_value);
  gtk_object_set_data_full (GTK_OBJECT (rs232), "a_value", a_value,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (a_value);
  gtk_box_pack_start (GTK_BOX (hbox14), a_value, TRUE, TRUE, 10);
  gtk_widget_set_usize (a_value, 1, -2);
  gtk_tooltips_set_tip (tooltips, a_value, _("\264N\254O\302\340\262\276\250\347\274\306\244\244\252\272\244\300\245\300\263\241\245\367\241A\267\355\265M\263o\245u\246\263 IIR \244~\267|\246\263\252\272"), NULL);
  gtk_entry_set_text (GTK_ENTRY (a_value), _("1 -0.7757"));

  label17 = gtk_label_new (_("\302\340\262\276\250\347\274\306\244\300\244l X( n )"));
  gtk_widget_ref (label17);
  gtk_object_set_data_full (GTK_OBJECT (rs232), "label17", label17,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (label17);
  gtk_box_pack_start (GTK_BOX (hbox14), label17, FALSE, FALSE, 10);

  b_value = gtk_entry_new ();
  gtk_widget_ref (b_value);
  gtk_object_set_data_full (GTK_OBJECT (rs232), "b_value", b_value,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (b_value);
  gtk_box_pack_start (GTK_BOX (hbox14), b_value, TRUE, TRUE, 10);
  gtk_widget_set_usize (b_value, 1, -2);
  gtk_entry_set_text (GTK_ENTRY (b_value), _("4.7 2.2 3.6 2.2 4.7"));

  appbar1 = gnome_appbar_new (TRUE, TRUE, GNOME_PREFERENCES_NEVER);
  gtk_widget_ref (appbar1);
  gtk_object_set_data_full (GTK_OBJECT (rs232), "appbar1", appbar1,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (appbar1);
  gtk_box_pack_start (GTK_BOX (vbox1), appbar1, TRUE, TRUE, 0);

  hbox28 = gtk_hbox_new (FALSE, 0);
  gtk_widget_ref (hbox28);
  gtk_object_set_data_full (GTK_OBJECT (rs232), "hbox28", hbox28,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (hbox28);
  gtk_box_pack_start (GTK_BOX (vbox1), hbox28, TRUE, TRUE, 0);

  statusbar1 = gtk_statusbar_new ();
  gtk_widget_ref (statusbar1);
  gtk_object_set_data_full (GTK_OBJECT (rs232), "statusbar1", statusbar1,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (statusbar1);
  gtk_box_pack_start (GTK_BOX (hbox28), statusbar1, FALSE, FALSE, 0);
  gtk_widget_set_usize (statusbar1, 629, -2);

  progressbar1 = gtk_progress_bar_new ();
  gtk_widget_ref (progressbar1);
  gtk_object_set_data_full (GTK_OBJECT (rs232), "progressbar1", progressbar1,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (progressbar1);
  gtk_box_pack_start (GTK_BOX (hbox28), progressbar1, FALSE, FALSE, 0);
  gtk_progress_set_show_text (GTK_PROGRESS (progressbar1), TRUE);
  gtk_progress_set_format_string (GTK_PROGRESS (progressbar1), _("%P %% \247\271\246\250"));

  gtk_signal_connect (GTK_OBJECT (rs232), "delete_event",
                      GTK_SIGNAL_FUNC (on_rs232_delete_event),
                      NULL);
  gtk_signal_connect (GTK_OBJECT (rs232), "show",
                      GTK_SIGNAL_FUNC (on_rs232_show),
                      NULL);
  gtk_signal_connect (GTK_OBJECT (exit), "clicked",
                      GTK_SIGNAL_FUNC (on_exit_clicked),
                      NULL);
  gtk_signal_connect (GTK_OBJECT (swap), "clicked",
                      GTK_SIGNAL_FUNC (on_swap_clicked),
                      NULL);
  gtk_signal_connect (GTK_OBJECT (clean_data_area), "clicked",
                      GTK_SIGNAL_FUNC (on_clean_data_area_clicked),
                      NULL);
  gtk_signal_connect (GTK_OBJECT (combo_entry_baudrate), "changed",
                      GTK_SIGNAL_FUNC (on_combo_entry_baudrate_changed),
                      NULL);
  gtk_signal_connect (GTK_OBJECT (combo_entry_port), "changed",
                      GTK_SIGNAL_FUNC (on_combo_entry_port_changed),
                      NULL);
  gtk_signal_connect (GTK_OBJECT (save_as_numeral), "clicked",
                      GTK_SIGNAL_FUNC (on_save_as_numeral_clicked),
                      NULL);
  gtk_signal_connect (GTK_OBJECT (spectrum), "clicked",
                      GTK_SIGNAL_FUNC (on_spectrum_clicked),
                      NULL);
  gtk_signal_connect (GTK_OBJECT (inspect), "clicked",
                      GTK_SIGNAL_FUNC (on_inspect_clicked),
                      NULL);
  gtk_signal_connect (GTK_OBJECT (print_spectrum), "toggled",
                      GTK_SIGNAL_FUNC (on_print_spectrum_toggled),
                      NULL);
  gtk_signal_connect (GTK_OBJECT (save_as_eps), "clicked",
                      GTK_SIGNAL_FUNC (on_save_as_eps_clicked),
                      NULL);
  gtk_signal_connect (GTK_OBJECT (specification_on), "clicked",
                      GTK_SIGNAL_FUNC (on_specification_on_clicked),
                      NULL);
  gtk_signal_connect (GTK_OBJECT (coefficient_on), "clicked",
                      GTK_SIGNAL_FUNC (on_coefficient_on_clicked),
                      NULL);
  gtk_signal_connect (GTK_OBJECT (move_average), "clicked",
                      GTK_SIGNAL_FUNC (on_move_average_clicked),
                      NULL);
  gtk_signal_connect (GTK_OBJECT (window), "clicked",
                      GTK_SIGNAL_FUNC (on_window_clicked),
                      NULL);
  gtk_signal_connect (GTK_OBJECT (butterworth), "clicked",
                      GTK_SIGNAL_FUNC (on_butterworth_clicked),
                      NULL);
  gtk_signal_connect (GTK_OBJECT (chebyshev), "clicked",
                      GTK_SIGNAL_FUNC (on_chebyshev_clicked),
                      NULL);
  gtk_signal_connect (GTK_OBJECT (fir_input_coefficient), "clicked",
                      GTK_SIGNAL_FUNC (on_fir_input_coefficient_clicked),
                      NULL);
  gtk_signal_connect (GTK_OBJECT (iir_input_coefficient), "clicked",
                      GTK_SIGNAL_FUNC (on_iir_input_coefficient_clicked),
                      NULL);

  gtk_object_set_data (GTK_OBJECT (rs232), "tooltips", tooltips);

  gtk_window_add_accel_group (GTK_WINDOW (rs232), accel_group);

  return rs232;
}
Example #6
0
/*
 * mainline..
 */
void searchbox(char *title, GtkSignalFunc func)
{
    int i;
    GtkWidget *menu, *menuitem, *optionmenu;
    GSList *group;
    GtkWidget *small_hbox;

    GtkWidget *scrolled_win;
    GtkWidget *vbox1, *hbox, *hbox0;
    GtkWidget *button1, *button2, *button3, *button3a, *button4, *button5, *button6, *button7;
    GtkWidget *label;
    gchar *titles[]={"Matches"};
    GtkWidget *frame1, *frame2, *frameh, *frameh0;
    GtkWidget *table;
    GtkTooltips *tooltips;
    GtkAdjustment *adj;
    GtkWidget *align;

    if(is_active) 
	{
	gdk_window_raise(window->window);
	return;
	}

    is_active=1;
    cleanup=func;
    num_rows=selected_rows=0;

    /* create a new modal window */
    window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    gtk_window_set_title(GTK_WINDOW (window), title);
    gtk_signal_connect(GTK_OBJECT (window), "delete_event",
                       (GtkSignalFunc) destroy_callback, NULL);

    tooltips=gtk_tooltips_new_2();

    table = gtk_table_new (256, 1, FALSE);
    gtk_widget_show (table);

    vbox1 = gtk_vbox_new (FALSE, 0);
    gtk_container_border_width (GTK_CONTAINER (vbox1), 3);
    gtk_widget_show (vbox1);
    frame1 = gtk_frame_new (NULL);
    gtk_container_border_width (GTK_CONTAINER (frame1), 3);
    gtk_widget_show(frame1);
    gtk_table_attach (GTK_TABLE (table), frame1, 0, 1, 0, 1,
                        GTK_FILL | GTK_EXPAND,
                        GTK_FILL | GTK_EXPAND | GTK_SHRINK, 1, 1);

    label=gtk_label_new("Signal Search Expression");
    gtk_widget_show(label);

    gtk_box_pack_start (GTK_BOX (vbox1), label, TRUE, TRUE, 0);

    entry = gtk_entry_new_with_max_length (256);
    gtk_signal_connect(GTK_OBJECT(entry), "activate",
		       GTK_SIGNAL_FUNC(enter_callback),
		       entry);
    gtk_entry_set_text (GTK_ENTRY (entry), searchbox_text);
    gtk_entry_select_region (GTK_ENTRY (entry),
			     0, GTK_ENTRY(entry)->text_length);
    gtk_widget_show (entry);
    gtk_tooltips_set_tip_2(tooltips, entry, 
		"Enter search expression here.  POSIX Wildcards are allowed.  Note that you may also "
		"modify the search criteria by selecting ``[W]Range'', ``[W]Strand'', or ``None'' for suffix "
		"matching.",NULL);

    gtk_box_pack_start (GTK_BOX (vbox1), entry, TRUE, TRUE, 0);

    /* Allocate memory for the data that is used later */
    pdata = calloc_2(1, sizeof(SearchProgressData) );
    pdata->value = pdata->oldvalue = 0.0;
    /* Create a centering alignment object */  
    align = gtk_alignment_new (0.5, 0.5, 0, 0);
    gtk_widget_show(align);
    /* Create a Adjustment object to hold the range of the
     * progress bar */
    adj = (GtkAdjustment *) gtk_adjustment_new (0.0, 0.0, (gfloat)((numfacs>1)?numfacs-1:1), 0, 0, 0);
    pdata->adj = adj;
    /* Create the GtkProgressBar using the adjustment */
    pdata->pbar = gtk_progress_bar_new_with_adjustment (adj);
    /* Set the format of the string that can be displayed in the
     * trough of the progress bar:
     * %p - percentage
     * %v - value
     * %l - lower range value
     * %u - upper range value */
    gtk_progress_set_format_string (GTK_PROGRESS (pdata->pbar), "(%p%%)");
    gtk_progress_set_show_text (GTK_PROGRESS (pdata->pbar), TRUE);
    gtk_widget_show(pdata->pbar);
    gtk_box_pack_start (GTK_BOX (vbox1), pdata->pbar, TRUE, TRUE, 0);

    gtk_container_add (GTK_CONTAINER (frame1), vbox1);


    frame2 = gtk_frame_new (NULL);
    gtk_container_border_width (GTK_CONTAINER (frame2), 3);
    gtk_widget_show(frame2);

    gtk_table_attach (GTK_TABLE (table), frame2, 0, 1, 1, 254,
                        GTK_FILL | GTK_EXPAND,
                        GTK_FILL | GTK_EXPAND | GTK_SHRINK, 1, 1);

    clist=gtk_clist_new_with_titles(1,titles);
    gtk_clist_column_titles_passive(GTK_CLIST(clist)); 

    gtk_clist_set_selection_mode(GTK_CLIST(clist), GTK_SELECTION_EXTENDED);
    gtk_signal_connect_object (GTK_OBJECT (clist), "select_row",
			       GTK_SIGNAL_FUNC(select_row_callback),
			       NULL);
    gtk_signal_connect_object (GTK_OBJECT (clist), "unselect_row",
			       GTK_SIGNAL_FUNC(unselect_row_callback),
			       NULL);
    gtk_widget_show (clist);

    scrolled_win = gtk_scrolled_window_new (NULL, NULL);
    gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_win),
                                      GTK_POLICY_AUTOMATIC,
                                      GTK_POLICY_AUTOMATIC);
    gtk_widget_set_usize( GTK_WIDGET (scrolled_win), -1, 300);
    gtk_widget_show(scrolled_win);

    /* gtk_scrolled_window_add_with_viewport doesn't seen to work right here.. */
    gtk_container_add (GTK_CONTAINER (scrolled_win), clist);

    gtk_container_add (GTK_CONTAINER (frame2), scrolled_win);


    frameh0 = gtk_frame_new (NULL);
    gtk_container_border_width (GTK_CONTAINER (frameh0), 3);
    gtk_widget_show(frameh0);
    gtk_table_attach (GTK_TABLE (table), frameh0, 0, 1, 254, 255,
                        GTK_FILL | GTK_EXPAND,
                        GTK_FILL | GTK_EXPAND | GTK_SHRINK, 1, 1);


    hbox0 = gtk_hbox_new (FALSE, 1);
    gtk_widget_show (hbox0);

    button6 = gtk_button_new_with_label (" Select All ");
    gtk_container_border_width (GTK_CONTAINER (button6), 3);
    gtk_signal_connect_object (GTK_OBJECT (button6), "clicked",
			       GTK_SIGNAL_FUNC(select_all_callback),
			       GTK_OBJECT (window));
    gtk_widget_show (button6);
    gtk_tooltips_set_tip_2(tooltips, button6, 
		"Highlight all signals listed in the match window.",NULL);

    gtk_box_pack_start (GTK_BOX (hbox0), button6, TRUE, FALSE, 0);



    menu = gtk_menu_new ();
    group=NULL;

    small_hbox = gtk_hbox_new (TRUE, 0);
    gtk_widget_show (small_hbox);
    
    for(i=0;i<5;i++)
        {
        menuitem = gtk_radio_menu_item_new_with_label (group, regex_name[i]);
        group = gtk_radio_menu_item_group (GTK_RADIO_MENU_ITEM (menuitem));
        gtk_menu_append (GTK_MENU (menu), menuitem);
        gtk_widget_show (menuitem);
        gtk_signal_connect(GTK_OBJECT (menuitem), "activate",
                                 GTK_SIGNAL_FUNC(regex_clicked),
                                 &regex_mutex[i]);
        regex_mutex[i]=0;
        }
    
        regex_mutex[0]=1;     /* "range" */
    
        optionmenu = gtk_option_menu_new ();
        gtk_option_menu_set_menu (GTK_OPTION_MENU (optionmenu), menu);
        gtk_box_pack_start (GTK_BOX (small_hbox), optionmenu, TRUE, FALSE, 0);
        gtk_widget_show (optionmenu);   
	gtk_tooltips_set_tip_2(tooltips, optionmenu,
		"You may "
		"modify the search criteria by selecting ``Range'', ``Strand'', or ``None'' for suffix "
		"matching.  This optionally matches the string you enter in the search string above with a Verilog "
		"format range (signal[7:0]), a strand (signal.1, signal.0), or with no suffix.  "
		"The ``W'' modifier for ``Range'' and ``Strand'' explicitly matches on word boundaries.  "
		"(addr matches unit.freezeaddr[63:0] for ``Range'' but only unit.addr[63:0] for ``WRange'' since addr has to be on a word boundary.  "
		"Note that when ``None'' "
		"is selected, the search string may be located anywhere in the signal name.",NULL);
    
        gtk_box_pack_start (GTK_BOX (hbox0), small_hbox, FALSE, FALSE, 0);


    button7 = gtk_button_new_with_label (" Unselect All ");
    gtk_container_border_width (GTK_CONTAINER (button7), 3);
    gtk_signal_connect_object (GTK_OBJECT (button7), "clicked",
			       GTK_SIGNAL_FUNC(unselect_all_callback),
			       GTK_OBJECT (window));
    gtk_widget_show (button7);
    gtk_tooltips_set_tip_2(tooltips, button7, 
		"Unhighlight all signals listed in the match window.",NULL);
    gtk_box_pack_start (GTK_BOX (hbox0), button7, TRUE, FALSE, 0);

    gtk_container_add (GTK_CONTAINER (frameh0), hbox0);


    frameh = gtk_frame_new (NULL);
    gtk_container_border_width (GTK_CONTAINER (frameh), 3);
    gtk_widget_show(frameh);
    gtk_table_attach (GTK_TABLE (table), frameh, 0, 1, 255, 256,
                        GTK_FILL | GTK_EXPAND,
                        GTK_FILL | GTK_EXPAND | GTK_SHRINK, 1, 1);


    hbox = gtk_hbox_new (FALSE, 1);
    gtk_widget_show (hbox);

    button1 = gtk_button_new_with_label ("Append");
    gtk_container_border_width (GTK_CONTAINER (button1), 3);
    gtk_signal_connect_object (GTK_OBJECT (button1), "clicked",
			       GTK_SIGNAL_FUNC(ok_callback),
			       GTK_OBJECT (window));
    gtk_widget_show (button1);
    gtk_tooltips_set_tip_2(tooltips, button1, 
		"Add selected signals to end of the display on the main window.",NULL);

    gtk_box_pack_start (GTK_BOX (hbox), button1, TRUE, FALSE, 0);

    button2 = gtk_button_new_with_label (" Insert ");
    gtk_container_border_width (GTK_CONTAINER (button2), 3);
    gtk_signal_connect_object (GTK_OBJECT (button2), "clicked",
			       GTK_SIGNAL_FUNC(insert_callback),
			       GTK_OBJECT (window));
    gtk_widget_show (button2);
    gtk_tooltips_set_tip_2(tooltips, button2, 
		"Add selected signals after last highlighted signal on the main window.",NULL);
    gtk_box_pack_start (GTK_BOX (hbox), button2, TRUE, FALSE, 0);

    if(vcd_explicit_zero_subscripts>=0)
	{
	button3 = gtk_button_new_with_label (" Bundle Up ");
    	gtk_container_border_width (GTK_CONTAINER (button3), 3);
    	gtk_signal_connect_object (GTK_OBJECT (button3), "clicked",
			       GTK_SIGNAL_FUNC(bundle_callback_up),
			       GTK_OBJECT (window));
    	gtk_widget_show (button3);
    	gtk_tooltips_set_tip_2(tooltips, button3, 
		"Bundle selected signals into a single bit vector with the topmost selected signal as the LSB and the lowest as the MSB.",NULL);
    	gtk_box_pack_start (GTK_BOX (hbox), button3, TRUE, FALSE, 0);

    	button3a = gtk_button_new_with_label (" Bundle Down ");
    	gtk_container_border_width (GTK_CONTAINER (button3a), 3);
    	gtk_signal_connect_object (GTK_OBJECT (button3a), "clicked",
			       GTK_SIGNAL_FUNC(bundle_callback_down),
			       GTK_OBJECT (window));
    	gtk_widget_show (button3a);
    	gtk_tooltips_set_tip_2(tooltips, button3a, 
		"Bundle selected signals into a single bit vector with the topmost selected signal as the MSB and the lowest as the LSB.",NULL);
	gtk_box_pack_start (GTK_BOX (hbox), button3a, TRUE, FALSE, 0);
	}

    button4 = gtk_button_new_with_label (" Replace ");
    gtk_container_border_width (GTK_CONTAINER (button4), 3);
    gtk_signal_connect_object (GTK_OBJECT (button4), "clicked",
			       GTK_SIGNAL_FUNC(replace_callback),
			       GTK_OBJECT (window));
    gtk_widget_show (button4);
    gtk_tooltips_set_tip_2(tooltips, button4, 
		"Replace highlighted signals on the main window with signals selected above.",NULL);
    gtk_box_pack_start (GTK_BOX (hbox), button4, TRUE, FALSE, 0);

    button5 = gtk_button_new_with_label (" Exit ");
    gtk_container_border_width (GTK_CONTAINER (button5), 3);
    gtk_signal_connect_object (GTK_OBJECT (button5), "clicked",
			       GTK_SIGNAL_FUNC(destroy_callback),
			       GTK_OBJECT (window));
    gtk_tooltips_set_tip_2(tooltips, button5, 
		"Do nothing and return to the main window.",NULL);
    gtk_widget_show (button5);
    gtk_box_pack_start (GTK_BOX (hbox), button5, TRUE, FALSE, 0);

    gtk_container_add (GTK_CONTAINER (frameh), hbox);
    gtk_container_add (GTK_CONTAINER (window), table);

    gtk_widget_show(window);

    if(strlen(searchbox_text)) enter_callback(entry,NULL);
}
Example #7
0
void *
check_pop_main (Account *account) {
  char *buf = NULL, *buf2, *buf3;
  C2ResolveNode *resolve;
  int sock;
  int timedout = FALSE;
  struct sockaddr_in server;
  
  int messages = 0, bytes = 0, downloaded_bytes = 0, i = 0, password_errors = 3;
  
  GList *download[DOWNLOAD_LIST_LAST], *uidl_search = NULL, *top_search = NULL;
  GList *list;
  gboolean supports_uidl = FALSE;
  
  mid_t mid;
  
  FILE *index;
  FILE *mail;

  Message message;
  char *mailbox;
  Mailbox *mbox;
  GString *strmsg;
  char *header[HEADER_LAST];
  gboolean reading_header = TRUE;
  gboolean with_attachs = FALSE;
  char *content_type;

  char *row[8];
  GtkStyle *style, *style2;
  gboolean clisted = FALSE;
  
  g_return_val_if_fail (account, NULL);
  g_return_val_if_fail (account->type == C2_ACCOUNT_POP, NULL);

  download[DOWNLOAD_LIST_TOTAL] = NULL;
  download[DOWNLOAD_LIST_UIDL] = NULL;
  download[DOWNLOAD_LIST_TOP] = NULL;  

  resolve = c2_resolve (account->protocol.pop.host, &buf);
  if (buf) {
    gdk_threads_enter ();
    window_checking_report (C2_CHECK_ERR, account->acc_name, buf);
    gdk_threads_leave ();
    return NULL;
  }

  sock = socket (AF_INET, SOCK_STREAM, IPPROTO_TCP);
  if (sock < 0) {
    gdk_threads_enter ();
    window_checking_report (C2_CHECK_ERR, account->acc_name, _("Failed to create socket"));
    gdk_threads_leave ();
    return NULL;
  }

  server.sin_family	= AF_INET;
  server.sin_port	= htons (account->protocol.pop.host_port);
  server.sin_addr.s_addr= inet_addr (resolve->ip);

  if (connect (sock, (struct sockaddr *)&server, sizeof (server)) < 0) {
    buf = g_strerror (errno);
    gdk_threads_enter ();
    window_checking_report (C2_CHECK_ERR, account->acc_name, buf);
    gdk_threads_leave ();
    return NULL;
  }

  /* Guten Morgen, Herr Server! */
  buf = sock_read (sock, &timedout);
  if (pop_check_answer (buf, account, timedout) < 0) {
    if (timedout) goto run_for_your_life;
    goto bye_bye_server;
  }
  c2_free (buf);

  /* Log In */
  gdk_threads_enter ();
  gtk_progress_set_format_string (GTK_PROGRESS (window_checking->mail_progress),
     		_("Logging in..."));
  gdk_threads_leave ();

retry_login:
  if (sock_printf (sock, "USER %s\r\n", account->protocol.pop.usr_name) < 0) {
    buf = g_strerror (errno);
    gdk_threads_enter ();
    window_checking_report (C2_CHECK_ERR, account->acc_name, buf);
    gdk_threads_leave ();
    goto bye_bye_server;
  }

  buf = sock_read (sock, &timedout);
  if (pop_check_answer (buf, account, timedout) < 0) {
    if (timedout) goto run_for_your_life;
    goto bye_bye_server;
  }
  c2_free (buf);

  if (sock_printf (sock, "PASS %s\r\n", account->protocol.pop.pass) < 0) {
    buf = g_strerror (errno);
    gdk_threads_enter ();
    window_checking_report (C2_CHECK_ERR, account->acc_name, buf);
    gdk_threads_leave ();
    goto bye_bye_server;
  }

  buf = sock_read (sock, &timedout);
  if (strnne (buf, "+OK", 3)) {
    if (--password_errors < 0) {
      if (pop_check_answer (buf, account, timedout) < 0) {
	if (timedout) goto run_for_your_life;
	goto bye_bye_server;
      }
    }
    gdk_threads_enter ();
    if (!gui_ask_password (account)) {
      gdk_threads_leave ();
      if (pop_check_answer (buf, account, timedout) < 0) {
	if (timedout) goto run_for_your_life;
	goto bye_bye_server;
      }
    } else {
      gdk_threads_leave ();
      goto retry_login;
    }
  }
  c2_free (buf);

  /* STAT */
  gdk_threads_enter ();
  gtk_progress_set_format_string (GTK_PROGRESS (window_checking->mail_progress),
      		_("Checking for number of mails in server..."));
  gdk_threads_leave ();

  if (sock_printf (sock, "STAT\r\n") < 0) {
    buf = g_strerror (errno);
    gdk_threads_enter ();
    window_checking_report (C2_CHECK_ERR, account->acc_name, buf);
    gdk_threads_leave ();
    goto bye_bye_server;
  }

  buf = sock_read (sock, &timedout);
  if (pop_check_answer (buf, account, timedout) < 0) {
    if (timedout) goto run_for_your_life;
    goto bye_bye_server;
  }
  sscanf (buf, "+OK %d ", &messages);
  c2_free (buf);
 
  if (!messages) {
    gdk_threads_enter ();
    gtk_progress_set_format_string (GTK_PROGRESS (window_checking->mail_progress),
      		_("No messages in server"));
    window_checking_report (C2_CHECK_OK, account->acc_name, _("No messages to download"));
    gdk_threads_leave ();
    clisted = TRUE;
    goto bye_bye_server;
  }
  else if (messages != 1)
    buf = g_strdup_printf (_("%d messages in server"), messages);
  else
    buf = g_strdup_printf (_("1 message in server"));
  gdk_threads_enter ();
  gtk_progress_set_format_string (GTK_PROGRESS (window_checking->mail_progress),
      		buf);
  gdk_threads_leave ();
  c2_free (buf);

  /* UIDL */
  if (!account->keep_copy) {
dont_use_uidl:
    /* Without UIDL*/
    for (i = 1; i <= messages; i++) {
      buf = g_strdup_printf ("%d", i);
      download[DOWNLOAD_LIST_UIDL] = g_list_append (download[DOWNLOAD_LIST_UIDL], (gpointer) buf);
    }
  } else {
    /* With UIDL */
    if (sock_printf (sock, "UIDL\r\n") < 0) {
      buf = g_strerror (errno);
      gdk_threads_enter ();
      window_checking_report (C2_CHECK_ERR, account->acc_name, buf);
      gdk_threads_leave ();
      goto bye_bye_server;
    }
    
    for (i = 0;; i++) {
      buf = sock_read (sock, &timedout);
      if (!i && strnne (buf, "+OK", 3)) {
	/* UIDL is optional for POP servers,
	 * so I won't complain if server doesn't like it */
	buf2 = g_strdup_printf (_("The POP server of the account %s doesn't support UIDL."),
	    	account->acc_name);
	gdk_threads_enter ();
	gnome_appbar_set_status (GNOME_APPBAR (WMain->appbar), buf2);
	gdk_threads_leave ();
	supports_uidl = FALSE;
	goto dont_use_uidl;
      }
      supports_uidl = TRUE;
      if (!i) continue;
      if (streq (buf, ".\r\n")) break;

      buf2 = str_get_word (1, buf, ' ');
      buf3 = str_strip (buf2, '\r');
      buf2 = str_strip (buf3, '\n');
      if (!uidl_check (buf2, account->acc_name)) {
	download[DOWNLOAD_LIST_UIDL] = g_list_append (download[DOWNLOAD_LIST_UIDL], buf);
      }
    }
  }
 
  /* TOP */
  if (!config->message_bigger) {
    /* Without TOP */
dont_use_list:
dont_use_top:
    for (i = 1; i <= messages; i++)
      	download[DOWNLOAD_LIST_TOP] = g_list_append (download[DOWNLOAD_LIST_TOP], (gpointer) i);
  } else {
    /* With TOP */
    char *subject, *from, *date, *kbytes;
    
    if (sock_printf (sock, "LIST\r\n") < 0) {
      buf = g_strerror (errno);
      gdk_threads_enter ();
      window_checking_report (C2_CHECK_ERR, account->acc_name, buf);
      gdk_threads_leave ();
      goto bye_bye_server;
    }
    
    for (i = 0;; i++) {
      buf = sock_read (sock, &timedout);
      if (!i && strnne (buf, "+OK", 3)) {
	buf2 = g_strdup_printf (_("The POP server of the account %s doesn't support LIST."),
	    	account->acc_name);
	gdk_threads_enter ();
	gnome_appbar_set_status (GNOME_APPBAR (WMain->appbar), buf2);
	gdk_threads_leave ();
	goto dont_use_list;
      }
      if (!i) continue;
      if (streq (buf, ".\r\n")) break;
      buf2 = str_get_word (1, buf, ' ');
      str_strip (buf2, '\r');
      str_strip (buf2, '\n');
      download[DOWNLOAD_LIST_TOP] = g_list_append (download[DOWNLOAD_LIST_TOP], buf);
      c2_free (buf2);
    }

    for (list = download[DOWNLOAD_LIST_TOP]; list; list = list->next) {
      if (sock_printf (sock, "TOP %d 0\r\n", atoi (CHAR (list->data))) < 0) {
	buf = g_strerror (errno);
	gdk_threads_enter ();
	window_checking_report (C2_CHECK_ERR, account->acc_name, buf);
	gdk_threads_leave ();
	goto bye_bye_server;
      }

      strmsg = g_string_new (NULL);
      for (i = 0;; i++) {
	buf = sock_read (sock, &timedout);
	if (!i && strnne (buf, "+OK", 3)) {
	  buf2 = g_strdup_printf (_("The POP server of the account %s doesn't support TOP."),
	      account->acc_name);
	  gdk_threads_enter ();
	  gnome_appbar_set_status (GNOME_APPBAR (WMain->appbar), buf2);
	  gdk_threads_leave ();
	  goto dont_use_top;
	}
	if (!i) continue;
	if (streq (buf, ".\r\n")) break;
	g_string_append (strmsg, buf);
	c2_free (buf);
      }
      subject = message_get_header_field (NULL, strmsg->str, "\nSubject:");
      from = message_get_header_field (NULL, strmsg->str, "From:");
      date = message_get_header_field (NULL, strmsg->str, "\nDate:");
      kbytes = str_get_word (1, CHAR (list->data), ' '); str_strip (kbytes, '\r');str_strip (kbytes, '\n');
      gdk_threads_enter ();
      if ((atoi (kbytes) >= config->message_bigger*1024) &&
	  (!gui_message_big_new (from, subject, date, account->acc_name, kbytes))) {
	gdk_threads_leave ();
	c2_free (list->data);
	list->data = NULL;
	download[DOWNLOAD_LIST_TOP] = g_list_remove_link (download[DOWNLOAD_LIST_TOP], list);
      } else gdk_threads_leave ();
    }
  }

  /* Learn messages to download */
  if (!account->keep_copy && !config->message_bigger) {		/* !UIDL AND !TOP */
    download[DOWNLOAD_LIST_TOTAL] = download[DOWNLOAD_LIST_UIDL];
  }
  else if (account->keep_copy && !config->message_bigger) {	/*  UIDL AND !TOP */
    for (list = download[DOWNLOAD_LIST_UIDL]; list; list = list->next) {
      download[DOWNLOAD_LIST_TOTAL] = g_list_append (download[DOWNLOAD_LIST_TOTAL], 
	 					str_get_word (0, CHAR (list->data), ' '));
    }
  }
  else if (!account->keep_copy && config->message_bigger) {	/* !UIDL AND  TOP */
    download[DOWNLOAD_LIST_TOTAL] = download[DOWNLOAD_LIST_TOP];
  }
  else if (account->keep_copy && config->message_bigger) {	/*  UIDL AND  TOP */
    for (uidl_search = download[DOWNLOAD_LIST_UIDL]; !uidl_search; uidl_search = uidl_search->next) {
      for (top_search = download[DOWNLOAD_LIST_TOP]; !top_search; top_search = top_search->next) {
	printf ("%d %d\n", (int) uidl_search->data, (int) top_search->data); /* TODO */
      }
    }
  }

  messages = g_list_length (download[DOWNLOAD_LIST_TOTAL]);
  gdk_threads_enter ();
  gtk_progress_configure (GTK_PROGRESS (window_checking->mail_progress), 0, 0, messages);
  gtk_progress_set_format_string (GTK_PROGRESS (window_checking->mail_progress),
      				_("%p%% downloaded (%v of %u messages)"));
  gdk_threads_leave ();

  strmsg = g_string_new (NULL);
  message.message = message.header = NULL;
  for (list = download[DOWNLOAD_LIST_TOTAL]; list; list = list->next) {
    buf = str_get_word (0, CHAR (list->data), ' ');
    i = atoi (buf);
    c2_free (buf);
    /* Ask for the mail */
    if (sock_printf (sock, "RETR %d\r\n", i) < 0) {
      buf = g_strerror (errno);
      gdk_threads_enter ();
      window_checking_report (C2_CHECK_ERR, account->acc_name, buf);
      gdk_threads_leave ();
      goto bye_bye_server;
    }

    /* Read the first line */
    buf = sock_read (sock, &timedout);
    if (pop_check_answer (buf, account, timedout) < 0) {
      if (timedout) goto run_for_your_life;
      goto bye_bye_server;
    }
    /* Learn bytes in the messages */
    sscanf (buf, "+OK %d octets\r\n", &bytes);
    if (bytes) {
      gdk_threads_enter ();
      gtk_progress_configure (GTK_PROGRESS (window_checking->bytes_progress), 0, 0, bytes);
      gtk_widget_show (window_checking->bytes_progress);
      gdk_threads_leave ();
    } else {
      gdk_threads_enter ();
      gtk_widget_hide (window_checking->bytes_progress);
      gdk_threads_leave ();
    }
    c2_free (buf);
    
    /* Get the mail */
    reading_header = TRUE;
    for (;;) {
      buf = sock_read (sock, &timedout);
      if (bytes) {
	downloaded_bytes += strlen (buf);
	gdk_threads_enter ();
	gtk_progress_set_value (GTK_PROGRESS (window_checking->bytes_progress), downloaded_bytes);
	gdk_threads_leave ();
      }
      if (streq (buf, ".\r\n")) {
	message.message = g_strdup (strmsg->str);
	g_string_assign (strmsg, "");
	str_strip (message.message, '\r');
	break;
      }
      if (reading_header && strlen (buf) > 2) {
	char *buf2;
	buf2 = decode_8bit (buf);
	c2_free (buf);
	buf = buf2;
      }
      if (reading_header && strlen (buf) == 2) { /* Still reading header and is an empty line */
	buf2 = g_strdup_printf ("X-CronosII-Account: %s\r\n", account->acc_name);
	g_string_append (strmsg, buf2);
	c2_free (buf2);
	reading_header = FALSE;
      }
      g_string_append (strmsg, buf);
    }
    gtk_progress_set_percentage (GTK_PROGRESS (window_checking->bytes_progress), 1);

    /* Write to the mail file */
    mailbox = account->mailbox->name;
#if USE_PLUGINS
    c2_dynamic_module_signal_emit (C2_DYNAMIC_MODULE_MESSAGE_DOWNLOAD_POP, &message,
      				 	&mailbox, NULL, NULL, NULL);
#endif
    mbox = search_mailbox_name (config->mailbox_head, mailbox);
    if (!mbox) {
      /* Mailbox couldn't be found, going with the default */
      mbox = account->mailbox;
    }
    mid = c2_mailbox_get_next_mid (mbox);
    buf = c2_mailbox_mail_path (mailbox, mid);
    if ((mail = fopen (buf, "w")) == NULL) {
      gdk_threads_enter ();
      window_checking_report (C2_CHECK_ERR, account->acc_name,
	  _("Error opening the file where to store the new mail"));
      cronos_error (errno, _("Opening the mail file"), ERROR_WARNING);
      gdk_threads_leave ();
      c2_free (buf);
      continue;
    }
    c2_free (buf);
    fprintf (mail, "%s", message.message);
    fclose (mail);

    /* Write to the index file */
    buf = c2_mailbox_index_path (mailbox);
    if ((index = fopen (buf, "a")) == NULL) {
      gdk_threads_enter ();
      window_checking_report (C2_CHECK_ERR, account->acc_name,
	  _("Error opening the main DB file to store the new mail"));
      cronos_error (errno, _("Opening the main DB file"), ERROR_WARNING);
      gdk_threads_leave ();
      c2_free (buf);
      goto bye_bye_server;
    }
    header[HEADER_SUBJECT]	= message_get_header_field (&message, NULL, "\nSubject:");
    header[HEADER_FROM]		= message_get_header_field (&message, NULL, "\nFrom:");
    header[HEADER_DATE]		= message_get_header_field (&message, NULL, "\nDate:");
    content_type		= message_get_header_field (&message, NULL, "\nContent-Type:");
    with_attachs		= FALSE;
/*    if (content_type) {
      message_mime_parse_content_type (content_type, &type, &subtype, &parameter);
      if (streq (type, "multipart")) {
	GList *s;
	MimeHash *mime;
	message_mime_parse (&message, NULL);
	for (s = message.mime; s != NULL; s = s->next) {
	  mime = MIMEHASH (s->data);
	  if (!mime) continue;
	  if (strneq (mime->disposition, "attachment", 10)) with_attachs = TRUE;
	}
      }
    }*/

    if (!header[HEADER_SUBJECT]) header[HEADER_SUBJECT] = "";
    if (!header[HEADER_FROM]) header[HEADER_FROM] = "";
    if (!header[HEADER_DATE]) header[HEADER_DATE] = "";
    fprintf (index, "N\r\r%s\r%s\r%s\r%s\r%s\r%d\n",
		with_attachs ? "1" : "", header[HEADER_SUBJECT], header[HEADER_FROM], header[HEADER_DATE],
		account->acc_name, mid);
    fclose (index);
    c2_free (message.message);
    c2_free (message.header);
    message.message = message.header = NULL;

    if (!account->keep_copy) {
      /* Delete the message */
      if (sock_printf (sock, "DELE %d\r\n", i) < 0) {
	buf = g_strerror (errno);
	gdk_threads_enter ();
	window_checking_report (C2_CHECK_ERR, account->acc_name, buf);
	gdk_threads_leave ();
	goto bye_bye_server;
      }
      buf = sock_read (sock, &timedout);
      if (pop_check_answer (buf, account, timedout) < 0) {
	if (timedout) goto run_for_your_life;
	goto bye_bye_server;
      }
    }
    
    if (streq (selected_mbox, mailbox)) {
      row[0] = "";
      row[1] = "";
      row[2] = "";
      row[3] = header[HEADER_SUBJECT];
      row[4] = header[HEADER_FROM];
      row[5] = header[HEADER_DATE];
      row[6] = account->acc_name;
      row[7] = g_strdup_printf ("%d", mid);
      
      gdk_threads_enter ();
      gtk_clist_freeze (GTK_CLIST (WMain->clist));
      gtk_clist_append (GTK_CLIST (WMain->clist), row);
      style = gtk_widget_get_style (WMain->clist);
      style2 = gtk_style_copy (style);
      style2->font = font_unread;
      gtk_clist_set_row_style (GTK_CLIST (WMain->clist), GTK_CLIST (WMain->clist)->rows-1, style2);
      gtk_clist_set_pixmap (GTK_CLIST (WMain->clist), GTK_CLIST (WMain->clist)->rows-1, 0, pixmap_unread, mask_unread);
      if (with_attachs) gtk_clist_set_pixmap (GTK_CLIST (WMain->clist), GTK_CLIST (WMain->clist)->rows-1, 2, pixmap_attach, mask_attach);
      new_messages++;
      gtk_clist_thaw (GTK_CLIST (WMain->clist));
      gtk_clist_set_row_data (GTK_CLIST (WMain->clist), GTK_CLIST (WMain->clist)->rows-1, (gpointer) "N");
      update_wm_title ();
      gtk_progress_set_value (GTK_PROGRESS (window_checking->mail_progress), i);
      gdk_threads_leave ();
      clisted = TRUE;
    }
    gdk_threads_enter ();
    gtk_progress_set_value (GTK_PROGRESS (window_checking->mail_progress),
		gtk_progress_get_value (GTK_PROGRESS (window_checking->mail_progress))+1);
    gdk_threads_leave ();
  }
  if (supports_uidl) {
    GList *llist;
    for (llist = download[DOWNLOAD_LIST_UIDL]; llist != NULL; llist = llist->next) {
      char *uidl;
      uidl = CHAR (llist->data);
      buf2 = str_get_word (1, uidl, ' ');
      buf3 = str_strip (buf2, '\r');
      buf2 = str_strip (buf3, '\n');
      if (buf2) {
	uidl_register (buf2, account->acc_name);
      }
    }
  }
        
  if (messages != 1)
    buf = g_strdup_printf (_("%d messages downloaded."), messages);
  else
    buf = g_strdup_printf (_("1 message downloaded."));
  gdk_threads_enter ();
  gtk_progress_configure (GTK_PROGRESS (window_checking->mail_progress), messages, 0, messages);
  gtk_progress_set_format_string (GTK_PROGRESS (window_checking->mail_progress),
      				buf);
  window_checking_report (C2_CHECK_OK, account->acc_name, buf);
  gdk_threads_leave ();
  
bye_bye_server:
  if (sock_printf (sock, "QUIT\r\n") < 0) {
    buf = g_strerror (errno);
  }
  
  buf = sock_read (sock, &timedout);
  if (pop_check_answer (buf, account, timedout) < 0) {
    if (timedout) goto run_for_your_life;
  }
run_for_your_life:
  close (sock);
  return NULL;
}
int main(int argc, char *argv[])
{

    GdkColor color;
    gchar *custom_color;

    custom_color = g_getenv("UDA_CUSTOM_COLOR");
    if (custom_color != NULL)
        gdk_color_parse(custom_color, &color);

    bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR);
    bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
    textdomain(GETTEXT_PACKAGE);

    gtk_init(&argc, &argv);

    if (argc != 4) {
        g_print
        ("Usage uda-postinstall <num_of_total_packages> <packages> <last_package>\n\n"
         "\t<num_of_total_packages> : This is the number of all packages that will be installated\n"
         "\t<packages> : name of packages or meta-packages that install all software.\n "
         "\tyou MUST write the names of this packages between double quotes. Example \"uda-desktop uda-base\"\n"
         "\t<last_package> : The last package that will be installed in the installation process\n\n");
        return;
    }

    branding_path = get_branding_path();
    last_package = g_strdup(argv[3]);

    app = glade_xml_new(UIDIR "uda-postinstall.glade", NULL, NULL);
    win = glade_xml_get_widget(app, "window_apt");
    if (custom_color != NULL)
        gtk_widget_modify_bg(win, GTK_STATE_NORMAL, &color);
    pb = glade_xml_get_widget(app, "progressbar");
    im = glade_xml_get_widget(app, "image");
    label = glade_xml_get_widget(app, "label");
    hbox1 = glade_xml_get_widget(app, "hbox1");

    x = (100.0 / (atoi(argv[1]) * 2.0));
    y = 0;

    gtk_progress_bar_set_bar_style(GTK_PROGRESS_BAR(pb),
                                   GTK_PROGRESS_CONTINUOUS);
    gtk_progress_set_format_string(GTK_PROGRESS(pb), "%p%%");
    gtk_progress_set_show_text(GTK_PROGRESS(pb), TRUE);
    gtk_progress_set_value(GTK_PROGRESS(pb), y);

    z = 20;			/* Next percent for show the next corporative image */
    cmd =
        g_strdup_printf("LANG=C DEBCONF_PRIORITY=critical /usr/bin/apt-get -y --force-yes install %s && echo \"--end install ok--\" || echo \"--end install fail--\"", argv[2]);
    f = popen(cmd, "r");
    io = g_io_channel_unix_new(fileno(f));
    g_io_add_watch_full(io, G_PRIORITY_LOW,
                        G_IO_IN, apt_action_cb, NULL, close_apt);

    screen = gdk_screen_get_default();
    if (gdk_screen_get_width(screen) >= 1024) {
        gchar *big_pic;
        big_pic = g_strdup_printf("%s/corp_pic_big1.jpg", branding_path);
        gtk_image_set_from_file(GTK_IMAGE(im), big_pic);
        g_free(big_pic);
    } else {
        gchar *normal_pic;
        normal_pic = g_strdup_printf("%s/corp_pic1.jpg", branding_path);
        gtk_image_set_from_file(GTK_IMAGE(im), normal_pic);
        g_free(normal_pic);
    }
    gtk_widget_set_size_request(pb,
                                gdk_screen_get_width(screen) * 80 / 100,
                                -1);
    gtk_widget_show_all(win);
    gtk_window_fullscreen(GTK_WINDOW(win));

    gtk_main();

    g_free(branding_path);
    g_free(last_package);
    return 0;
}
Example #9
0
GtkWindow * gw_progress_bar_box_create ( GtkWindow *window, gchar *title, gchar *subject, gchar *text, gfloat max, func_stop_progress_t stop, gpointer p)
{
	GtkWidget *w = NULL;
	GtkWidget *frame;
	GtkWidget *vbox;
	GtkWidget *hbox;
	GtkWidget *file_name;
	GtkWidget *progress_bar	= NULL;
	GtkWidget *button;
	guint button_key;
	GtkAccelGroup *accel = NULL;
	gchar *text_utf8 = NULL;


#ifdef GW_DEBUG_GUI_COMPONENT
	g_print	( "*** GW - %s (%d) :: %s() : %f\n", __FILE__, __LINE__, __PRETTY_FUNCTION__, max);
#endif

	/* Inits accel group for keystroke shortcuts */
	accel =	gtk_accel_group_new ( );

	if ( !w	)
	{
		w = gtk_window_new ( GTK_WINDOW_DIALOG);
		gtk_window_set_policy (	GTK_WINDOW ( w), FALSE,	FALSE, FALSE);
		g_strdup_to_gtk_text ( title, text_utf8);
		gtk_window_set_title ( GTK_WINDOW ( w),	text_utf8);
		g_free ( text_utf8);
		gtk_container_border_width ( GTK_CONTAINER ( w), 5);

		gtk_window_set_modal ( GTK_WINDOW ( w),TRUE);
		gtk_window_set_transient_for ( GTK_WINDOW ( w),	window);
		gtk_window_set_position	( GTK_WINDOW ( w), GTK_WIN_POS_CENTER);

		gtk_widget_ref ( GTK_WIDGET ( window));
		gtk_object_set_data_full ( GTK_OBJECT (	w), GW_REF_PROGRESS_BAR_BOX_PARENT_WINDOW, window, (GtkDestroyNotify) gtk_widget_unref);

		if ( stop != NULL )
		{
#ifdef GW_DEBUG_GUI_COMPONENT
			g_print	( "*** GW - %s (%d) :: %s() : connect signals on delete_event and destroy\n", __FILE__,	__LINE__, __PRETTY_FUNCTION__);
#endif

			/* These signals do nothing. In	this way the window cannot be destroyed. What must be done when	stop is	NULL? */
			gtk_signal_connect ( GTK_OBJECT	( w), "delete_event", GTK_SIGNAL_FUNC (	gw_progress_bar_box_signal_do_nothing), NULL);
			gtk_signal_connect ( GTK_OBJECT	( w), "destroy", GTK_SIGNAL_FUNC ( gw_progress_bar_box_signal_do_nothing),	NULL);
		}

		g_strdup_to_gtk_text ( subject, text_utf8);
		frame =	gtk_frame_new (	text_utf8);
		g_free ( text_utf8);
		gtk_container_add ( GTK_CONTAINER ( w),	frame);

		vbox = gtk_vbox_new ( FALSE, 0);
		gtk_container_add ( GTK_CONTAINER ( frame), vbox);
		gtk_container_set_border_width ( GTK_CONTAINER ( vbox),	10);

		g_strdup_to_gtk_text ( text, text_utf8);
		file_name = gtk_label_new ( text_utf8);
		g_free ( text_utf8);

		/* Store the reference to the text info	label to describe the current processing. */
		gtk_widget_ref ( file_name);
		gtk_object_set_data_full ( GTK_OBJECT (	w), GW_REF_PROGRESS_BAR_BOX_TEXT_INFO_LABEL, file_name,	(GtkDestroyNotify) gtk_widget_unref);
		gtk_label_set_justify (	GTK_LABEL ( file_name),	GTK_JUSTIFY_LEFT);
		gtk_box_pack_start ( GTK_BOX ( vbox), file_name, TRUE, TRUE, 0);

#ifdef GW_DEBUG_GUI_COMPONENT
		g_print	( "*** GW - %s (%d) :: %s() : creates the real progress	bar\n",	__FILE__, __LINE__, __PRETTY_FUNCTION__);
#endif
		progress_bar = gtk_progress_bar_new ( );

		/* Store reference to the real progress	bar */
		gtk_widget_ref ( progress_bar);
		gtk_object_set_data_full ( GTK_OBJECT (	w), GW_REF_PROGRESS_BAR_BOX_PROGRESS_BAR, progress_bar,	(GtkDestroyNotify) gtk_widget_unref);

		/* Doesn't show	the progress bar if max	value is 0 */
		if ( max > 0 )
		{
			gtk_progress_configure ( GTK_PROGRESS (	progress_bar), 0, 0, max);
			gtk_progress_set_show_text ( GTK_PROGRESS ( progress_bar), TRUE);

			/* Set the format string of progess state visualization	*/
			g_strdup_to_gtk_text ( GW_PROGRESS_BAR_BOX_PROGRESS_BAR_FORMAT_STRING, text_utf8);
			gtk_progress_set_format_string ( GTK_PROGRESS (	progress_bar), text_utf8);
			g_free ( text_utf8);
			gtk_box_pack_start ( GTK_BOX ( vbox), progress_bar, TRUE, TRUE,	0);
		}

		hbox = gtk_hbox_new ( TRUE, 10);
		gtk_container_add ( GTK_CONTAINER ( vbox), hbox);
		gtk_container_set_border_width ( GTK_CONTAINER ( hbox),	5);

		button = gtk_button_new_with_label ( "");

		/* Store reference to the ok/cancel button */
		gtk_widget_ref ( button);
		gtk_object_set_data_full ( GTK_OBJECT (	w), GW_REF_PROGRESS_BAR_BOX_OK_CANCEL_BUTTON, button, (GtkDestroyNotify) gtk_widget_unref);
		gw_progress_bar_box_set_state ( GTK_WINDOW ( w), STATE_CANCEL);
		g_strdup_to_gtk_text ( _( "_Cancel"), text_utf8);
		button_key = gtk_label_parse_uline ( GTK_LABEL ( GTK_BIN ( button)->child), text_utf8);
		g_free ( text_utf8);
		gtk_widget_add_accelerator ( button, "clicked",	accel, button_key, GDK_MOD1_MASK, 0);
		gtk_object_set_user_data ( GTK_OBJECT (	button), w);
		gtk_box_pack_start ( GTK_BOX ( hbox), button, TRUE, TRUE, 0);
		gtk_widget_grab_focus ( button);

		if ( stop != NULL )
		{
#ifdef GW_DEBUG_GUI_COMPONENT
			g_print	( "*** GW - %s (%d) :: %s() : connect custom callback on ok/cancel button\n", __FILE__,	__LINE__, __PRETTY_FUNCTION__);
#endif

			gtk_signal_connect ( GTK_OBJECT	( button), "clicked", GTK_SIGNAL_FUNC (	stop), p);
		}
		else
		{
#ifdef GW_DEBUG_GUI_COMPONENT
			g_print	( "*** GW - %s (%d) :: %s() : connect standard callback	on ok/cancel button\n",	__FILE__, __LINE__, __PRETTY_FUNCTION__);
#endif

			gtk_signal_connect ( GTK_OBJECT	( button), "clicked", GTK_SIGNAL_FUNC (	gw_progress_bar_box_ok_cancel_click), w);
		}

		gtk_window_add_accel_group ( GTK_WINDOW	( w), accel);
	}

	if ( !GTK_WIDGET_VISIBLE ( w) )
	{
#ifdef GW_DEBUG_GUI_COMPONENT
			g_print	( "*** GW - %s (%d) :: %s() : show window\n", __FILE__,	__LINE__, __PRETTY_FUNCTION__);
#endif

		gtk_widget_show_all ( w);
	}
	else
	{
#ifdef GW_DEBUG_GUI_COMPONENT
			g_print	( "*** GW - %s (%d) :: %s() : destroy window\n", __FILE__, __LINE__, __PRETTY_FUNCTION__);
#endif

		gtk_widget_destroy ( w);
	}

	return GTK_WINDOW ( w);
}