Пример #1
0
gint dbgdata_display_dbox(gint *mode, gint *type, uint32_t *start, uint32_t *stop)
{
	GtkWidget *dbox;
	GtkWidget *data;
	gint result;

	G_CONST_RETURN gchar *sc_start, *sc_stop;
	gchar *s_start, *s_stop;
	
	xml = glade_xml_new
		(tilp_paths_build_glade("dbg_data-2.glade"), "dbgdata_dbox",
		 PACKAGE);
	if (!xml)
		g_error(_("%s: GUI loading failed !\n"), __FILE__);
	glade_xml_signal_autoconnect(xml);
	
	dbox = glade_xml_get_widget(xml, "dbgdata_dbox");
	gtk_window_resize(GTK_WINDOW(dbox), 320, 240);

	data = glade_xml_get_widget(xml, "radiobutton20");
	//gtk_signal_emit_by_name(GTK_OBJECT(data), "toggled");
	g_signal_emit_by_name(G_OBJECT(data), "toggled");

	printf("%i %i %x %x\n", mode, type, *start, *stop);

	// set type
	if(*type == -1)
	{
		// skip box preset step
	}
	else 
	{
		data = glade_xml_get_widget(xml, "radiobutton10");
		if(*mode & BK_READ)
			gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data), TRUE);

		data = glade_xml_get_widget(xml, "radiobutton11");
		if(*mode & BK_WRITE)
			gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data), TRUE);

		data = glade_xml_get_widget(xml, "radiobutton12");
		if((*mode & BK_READ) && (*mode & BK_WRITE))
			gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data), TRUE);

		if(*type == BK_TYPE_ACCESS)
		{
			data = glade_xml_get_widget(xml, "radiobutton20");
			gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data), TRUE);

			data = glade_xml_get_widget(xml, "comboboxentry1");
			if(*mode & BK_BYTE)
				gtk_combo_box_set_active(GTK_COMBO_BOX(data), 0);
			else if(*mode & BK_WORD)
				gtk_combo_box_set_active(GTK_COMBO_BOX(data), 1);
			else if(*mode & BK_LONG)
				gtk_combo_box_set_active(GTK_COMBO_BOX(data), 2);

			data = glade_xml_get_widget(xml, "entry3");
			s_start = g_strdup_printf("0x%06x", *start);
			gtk_entry_set_text(GTK_ENTRY(data), s_start);
			g_free(s_start);
		}
		else if(*type == BK_TYPE_RANGE)
		{
			data = glade_xml_get_widget(xml, "radiobutton21");
			gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data), TRUE);

			data = glade_xml_get_widget(xml, "entry1");
			s_start = g_strdup_printf("0x%06x", *start);
			gtk_entry_set_text(GTK_ENTRY(data), s_start);
			g_free(s_start);

			data = glade_xml_get_widget(xml, "entry2");
			s_stop = g_strdup_printf("0x%06x", *stop);
			gtk_entry_set_text(GTK_ENTRY(data), s_stop);
			g_free(s_stop);
		}
	}

loop:
	result = gtk_dialog_run(GTK_DIALOG(dbox));
	switch (result) {
	case GTK_RESPONSE_OK:
		sc_start = sc_stop = "";

		// Retrieve settings from fields
		data = glade_xml_get_widget(xml, "radiobutton10");
		if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data)))
			*mode = BK_READ;
		data = glade_xml_get_widget(xml, "radiobutton11");
		if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data)))
			*mode = BK_WRITE;
		data = glade_xml_get_widget(xml, "radiobutton12");
		if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data)))
			*mode = BK_READ | BK_WRITE;

		data = glade_xml_get_widget(xml, "radiobutton20");
		if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data)))
			*type = BK_TYPE_ACCESS;

		data = glade_xml_get_widget(xml, "radiobutton21");
		if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data)))
			*type = BK_TYPE_RANGE;
	
		if(*type == BK_TYPE_ACCESS)
		{
			data = glade_xml_get_widget(xml, "comboboxentry1");
			switch(gtk_combo_box_get_active(GTK_COMBO_BOX(data)))
			{
			case 0: *mode |= BK_BYTE; break;
			case 1: *mode |= BK_WORD; break;
			case 2: *mode |= BK_LONG; break;
			}

			data = glade_xml_get_widget(xml, "entry3");
			sc_start = sc_stop = gtk_entry_get_text(GTK_ENTRY(data));
		} 
		else if(*type == BK_TYPE_RANGE)
		{
			data = glade_xml_get_widget(xml, "entry1");
			sc_start = gtk_entry_get_text(GTK_ENTRY(data));

			data = glade_xml_get_widget(xml, "entry2");
			sc_stop = gtk_entry_get_text(GTK_ENTRY(data));			
		}

		// Convert values and check
		result = sscanf(sc_start, "%x", start);
		if(result < 1)
			goto loop;

		result = sscanf(sc_stop, "%x", stop);
		if((result < 1) && (*type == 2))
			goto loop;

		if((*start > *stop) && (*type == 2))
			goto loop;

		gtk_widget_destroy(dbox);
		return 0;
	default:
		gtk_widget_destroy(dbox);
		return -1;
	}	

	return 0;
}
Пример #2
0
static gint do_gtk_widget_destroy(GtkWidget *w){
	gtk_widget_destroy(w);
	return FALSE;
}
Пример #3
0
static void new_version_response(GtkWidget *dialog, int response_id, gpointer download_site){
	if (response_id==GTK_RESPONSE_YES){
		linphone_gtk_open_browser((const char*)download_site);
	}
	gtk_widget_destroy(dialog);
}
Пример #4
0
GtkWidget *
do_editable_cells (GtkWidget *do_widget)
{
    if (!window)
    {
        GtkWidget *vbox;
        GtkWidget *hbox;
        GtkWidget *sw;
        GtkWidget *treeview;
        GtkWidget *button;
        GtkTreeModel *items_model;
        GtkTreeModel *numbers_model;

        /* create window, etc */
        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), "Editable Cells");
        gtk_container_set_border_width (GTK_CONTAINER (window), 5);
        g_signal_connect (window, "destroy",
                          G_CALLBACK (gtk_widget_destroyed), &window);

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

        gtk_box_pack_start (GTK_BOX (vbox),
                            gtk_label_new ("Shopping list (you can edit the cells!)"),
                            FALSE, FALSE, 0);

        sw = gtk_scrolled_window_new (NULL, NULL);
        gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw),
                                             GTK_SHADOW_ETCHED_IN);
        gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
                                        GTK_POLICY_AUTOMATIC,
                                        GTK_POLICY_AUTOMATIC);
        gtk_box_pack_start (GTK_BOX (vbox), sw, TRUE, TRUE, 0);

        /* create models */
        items_model = create_items_model ();
        numbers_model = create_numbers_model ();

        /* create tree view */
        treeview = gtk_tree_view_new_with_model (items_model);
        gtk_tree_selection_set_mode (gtk_tree_view_get_selection (GTK_TREE_VIEW (treeview)),
                                     GTK_SELECTION_SINGLE);

        add_columns (GTK_TREE_VIEW (treeview), items_model, numbers_model);

        g_object_unref (numbers_model);
        g_object_unref (items_model);

        gtk_container_add (GTK_CONTAINER (sw), treeview);

        /* some buttons */
        hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 4);
        gtk_box_set_homogeneous (GTK_BOX (hbox), TRUE);
        gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);

        button = gtk_button_new_with_label ("Add item");
        g_signal_connect (button, "clicked",
                          G_CALLBACK (add_item), treeview);
        gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0);

        button = gtk_button_new_with_label ("Remove item");
        g_signal_connect (button, "clicked",
                          G_CALLBACK (remove_item), treeview);
        gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0);

        gtk_window_set_default_size (GTK_WINDOW (window), 320, 200);
    }

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

    return window;
}
Пример #5
0
gint dvtmcf1_r1(class dvtmcf1_r_data *data)
{
    time_t vremn;
    time(&vremn);
    char strsql[1024];
    iceb_u_str repl;
    iceb_clock sss(data->window);





    short ostkg=0;

    iceb_poldan("Отчет в килограммах",strsql,"matnast.alx",data->window);
    if(iceb_u_SRAV(strsql,"Вкл",1) == 0)
        ostkg=1;

    sprintf(strsql,"select * from Kart");
    SQLCURSOR cur,curtmp;
    SQLCURSOR cur1;
    SQL_str row,rowtmp;
    SQL_str row1;

    int kolstr;

    if((kolstr=cur.make_cursor(&bd,strsql)) < 0)
        iceb_msql_error(&bd,gettext("Ошибка создания курсора !"),strsql,data->window);

    if(kolstr == 0)
    {
        iceb_menu_soob(gettext("Не найдено ни одной записи !"),data->window);
        sss.clear_data();
        gtk_widget_destroy(data->window);
        return(FALSE);
    }

    class iceb_tmptab tabtmp;
    const char *imatmptab= {"dvtmcf1"};

    char zaprostmp[512];
    memset(zaprostmp,'\0',sizeof(zaprostmp));

    sprintf(zaprostmp,"CREATE TEMPORARY TABLE %s (\
sh char(24) not null,\
skl int not null,\
kgm int not null,\
naim char(112) not null,\
km int not null,\
nk int not null,\
ei char(24) not null,\
cena double(15,6) not null,\
nds float(2) not null,\
mnds smallint not null,\
fas float(2) not null)",imatmptab);


    if(tabtmp.create_tab(imatmptab,zaprostmp,data->window) != 0)
    {
        sss.clear_data();
        gtk_widget_destroy(data->window);
        return(FALSE);
    }
    /*********
    char imaftmp[32];
    FILE *ff1;

    sprintf(imaftmp,"dv%d.tmp",getpid());
    if((ff1 = fopen(imaftmp,"w")) == NULL)
     {
      iceb_er_op_fil(imaftmp,"",errno,data->window);
      sss.clear_data();
      gtk_widget_destroy(data->window);
      return(FALSE);
     }
    **************/
    short dn,mn,gn;
    short dk,mk,gk;

    iceb_rsdatp(&dn,&mn,&gn,data->rk->datan.ravno(),&dk,&mk,&gk,data->rk->datak.ravno(),data->window);

    sprintf(strsql,"%s\n%s %d.%d.%d %s %d.%d.%d\n",
            gettext("Сортируем записи"),
            gettext("Период с"),
            dn,mn,gn,
            gettext("по"),
            dk,mk,gk);

    iceb_printw(iceb_u_toutf(strsql),data->buffer,data->view);

    int kgrm=0;
//int kolstr2=0;
    float kolstr1=0.;
    class iceb_u_str naim("");

    while(cur.read_cursor(&row) != 0)
    {
        iceb_pbar(data->bar,kolstr,++kolstr1);

        if(iceb_u_proverka(data->rk->sklad.ravno(),row[0],0,0) != 0)
            continue;

        if(iceb_u_proverka(data->rk->shet.ravno(),row[5],0,0) != 0)
            continue;

        kgrm=0;
        naim.new_plus("");
        /*Читаем код группы материалла*/
        sprintf(strsql,"select kodgr,naimat from Material where kodm=%s",row[2]);
        if(sql_readkey(&bd,strsql,&row1,&cur1) != 1)
        {
            printf("%s %s !\n",gettext("Не найден код материалла"),row[2]);
            continue;
        }
        else
        {
            kgrm=atoi(row1[0]);
            naim.new_plus(row1[1]);
        }

        if(iceb_u_proverka(data->rk->grupa.ravno(),row1[0],0,0) != 0)
            continue;

        if(provndsw(data->rk->nds.ravno(),row) != 0)
            continue;

        if(iceb_u_proverka(data->rk->kodmat.ravno(),row[2],0,0) != 0)
            continue;

//  kolstr2++;
        /************
          fprintf(ff1,"%s|%s|%d|%s|%s|%s|%s|%.10g|%.5g|%s|%s|\n",
          row[5],row[0],kgrm,naim.ravno(),row[2],row[1],row[4],atof(row[6]),atof(row[9]),
          row[3],row[10]);
        *************/
        sprintf(strsql,"insert into %s values ('%s',%s,%d,'%s',%s,%s,'%s',%.10g,%.5g,%s,%s)",
                imatmptab,
                row[5],row[0],kgrm,naim.ravno_filtr(),row[2],row[1],row[4],atof(row[6]),atof(row[9]),
                row[3],row[10]);
        iceb_sql_zapis(strsql,1,0,data->window);

    }

//fclose(ff1);


    if(data->rk->metka_sort == 0) //Сортировать счет-склад-наименование материалла.
    {
//  sprintf(strsql,"sort -o %s -t\\| -k1,2 -k2,3n -k4,5 %s",imaftmp,imaftmp);
//  sprintf(strsql,"sort -o %s -t\\| +0 -1 +1n -2 +3 -4 %s",imaftmp,imaftmp);
        sprintf(strsql,"select * from %s order by sh asc,skl asc,naim asc",imatmptab);
    }
    if(data->rk->metka_sort == 1) //Сортировать счет-склад-группа-наименование материалла.
    {
//  sprintf(strsql,"sort -o %s -t\\| -k1,2 -k2,3n -k3,4n -k4,5 %s",imaftmp,imaftmp);
//  sprintf(strsql,"sort -o %s -t\\| +0 -1 +1n -2 +2n -3 +3 -4 %s",imaftmp,imaftmp);
        sprintf(strsql,"select * from %s order by sh asc,skl asc,kgm asc,naim asc",imatmptab);
    }
//system(strsql); //Запуск сортировки
    int kolstrtmp=0;
    if((kolstrtmp=curtmp.make_cursor(&bd,strsql)) < 0)
    {
        iceb_msql_error(&bd,gettext("Ошибка создания курсора !"),strsql,data->window);
        sss.clear_data();
        gtk_widget_destroy(data->window);
        return(FALSE);
    }

    sprintf(strsql,"%s.\n",gettext("Делаем отчет"));
    iceb_printw(iceb_u_toutf(strsql),data->buffer,data->view);
    /**************
    if((ff1 = fopen(imaftmp,"r")) == NULL)
     {
      iceb_er_op_fil(imaftmp,"",errno,data->window);
      gtk_widget_destroy(data->window);
      return(FALSE);
     }
    *************/
    FILE *ff;
    char imaf[32];

    sprintf(imaf,"zag%d.lst",getpid());
    data->rk->imaf.plus(imaf);

    repl.new_plus(gettext("Оборотная ведомость движния товарно-материальных ценностей"));
    repl.plus(" (");
    repl.plus(gettext("формат"));
    repl.plus(" A3)");

    data->rk->naimf.plus(repl.ravno());

    if((ff = fopen(imaf,"w")) == NULL)
    {
        iceb_er_op_fil(imaf,"",errno,data->window);
        sss.clear_data();
        gtk_widget_destroy(data->window);
        return(FALSE);
    }
    FILE *ffuz;
    char imafuz[32];

    sprintf(imafuz,"zaguz%d.lst",getpid());
    data->rk->imaf.plus(imafuz);

    repl.new_plus(gettext("Оборотная ведомость движния товарно-материальных ценностей"));
    repl.plus(" (");
    repl.plus(gettext("формат"));
    repl.plus(" A4)");

    data->rk->naimf.plus(repl.ravno());

    if((ffuz = fopen(imafuz,"w")) == NULL)
    {
        iceb_er_op_fil(imafuz,"",errno,data->window);
        sss.clear_data();
        gtk_widget_destroy(data->window);
        return(FALSE);
    }

    /***************
    if(tipras == 1)
     {
      sprintf(imafkl2,"zagg%d.lst",getpid());

      if((ffkl2 = fopen(imafkl2,"w")) == NULL)
       ERROR1(gettext("Ошибка открытия файла"),errno,imafkl2);
      startfil(ffkl2);
     }
    else
     {
    *****************/
    char imafitog[32];
    sprintf(imafitog,"zai%d.lst",getpid());
    data->rk->imaf.plus(imafitog);

    data->rk->naimf.plus(gettext("Свод движения материальных ценностей"));
    FILE *ffitog;
    if((ffitog = fopen(imafitog,"w")) == NULL)
    {
        iceb_er_op_fil(imafitog,"",errno,data->window);
        sss.clear_data();
        gtk_widget_destroy(data->window);
        return(FALSE);
    }


    iceb_u_zagolov(gettext("Свод движения материальных ценностей"),dn,mn,gn,dk,mk,gk,organ,ffitog);


    iceb_u_zagolov(gettext("Оборотная ведомость движния товарно-материальных ценностей"),dn,mn,gn,dk,mk,gk,organ,ff);
    iceb_u_zagolov(gettext("Оборотная ведомость движния товарно-материальных ценностей"),dn,mn,gn,dk,mk,gk,organ,ffuz);


    int kst=4;

    if(data->rk->shet.getdlinna() > 1)
    {
        fprintf(ff,"%s:%s\n",gettext("Счёт"),data->rk->shet.ravno());
        fprintf(ffuz,"%s:%s\n",gettext("Счёт"),data->rk->shet.ravno());
        kst++;
    }
    if(data->rk->sklad.getdlinna() > 1)
    {
        fprintf(ff,"%s:%s\n",gettext("Склад"),data->rk->sklad.ravno());
        fprintf(ffuz,"%s:%s\n",gettext("Склад"),data->rk->sklad.ravno());
        kst++;
    }
    if(data->rk->grupa.getdlinna() > 1)
    {
        fprintf(ff,"%s:%s\n",gettext("Група"),data->rk->grupa.ravno());
        fprintf(ffuz,"%s:%s\n",gettext("Група"),data->rk->grupa.ravno());
        kst++;
    }

    if(data->rk->kodmat.getdlinna() > 1)
    {
        fprintf(ff,"%s:%s\n",gettext("Код материалла"),data->rk->kodmat.ravno());
        fprintf(ffuz,"%s:%s\n",gettext("Код материалла"),data->rk->kodmat.ravno());
        kst++;
    }
    if(data->rk->nds.getdlinna() > 1)
    {
        fprintf(ff,"%s:%s\n",gettext("НДС"),data->rk->nds.ravno());
        fprintf(ffuz,"%s:%s\n",gettext("НДС"),data->rk->nds.ravno());
        kst++;
    }
    char shbm[32];
    char naiskl[112];

    memset(shbm,'\0',sizeof(shbm));
    memset(naiskl,'\0',sizeof(naiskl));
    int skl=0;
    int sli=1;
    double itg1=0.,itg2=0.,itg3=0.,itg4=0.,itg5=0.,itg6=0.,itg7=0.,itg8=0.;
    double k1=0.,s1=0.,k2=0.,s2=0.,k3=0.,s3=0.,k4=0.,s4=0.;
    double kk1=0.,ss1=0.,kk2=0.,ss2=0.,kk3=0.,ss3=0.,kk4=0.,ss4=0.;
    double kg0=0.,kg1=0.,kg2=0.,kg3=0.;
    double kgs0=0.,kgs1=0.,kgs2=0.,kgs3=0.;
    int kgrmzp=0;
    char str[512];
    memset(str,'\0',sizeof(str));
    memset(str,'.',233);
    int mvsh=0;
    kolstr1=0;
//char str1[1000];
    class ostatok ost;
    char shb[20];
    int skl1;
    int kodm;
    int nk;
    char ei[32];
    char		mnds='\0';
    double cena,nds;
    char naimshet[512];
    char nomn[112];

//while(fgets(str1,sizeof(str1),ff1) != NULL)
// {
    while(curtmp.read_cursor(&rowtmp) != 0)
    {
        iceb_pbar(data->bar,kolstrtmp,++kolstr1);

        /********
          iceb_u_pole(str1,shb,1,'|');
          iceb_u_pole(str1,strsql,2,'|');
          skl1=atoi(strsql);
          iceb_u_pole(str1,strsql,3,'|');
          kgrm=atoi(strsql);

          iceb_u_pole(str1,naim,4,'|');
          iceb_u_pole(str1,strsql,5,'|');
          kodm=atoi(strsql);
          iceb_u_pole(str1,strsql,6,'|');
          nk=atoi(strsql);
        **************/
        strncpy(shb,rowtmp[0],sizeof(shb)-1);
        skl1=atoi(rowtmp[1]);
        kgrm=atoi(rowtmp[2]);
        naim.new_plus(rowtmp[3]);
        kodm=atoi(rowtmp[4]);
        nk=atoi(rowtmp[5]);

        /*Остаток по карточкам*/
        ostkarw(dn,mn,gn,dk,mk,gk,skl1,nk,&ost);

        if(ost.ostm[0] == 0. && ost.ostm[1] == 0. && ost.ostm[3] == 0. && fabs(ost.ostmc[3]) < 0.009)
            continue;
        /************
          iceb_u_pole(str1,ei,7,'|');
          iceb_u_pole(str1,strsql,8,'|');
          cena=atof(strsql);
          iceb_u_pole(str1,strsql,9,'|');
          nds=atof(strsql);

          iceb_u_pole(str1,strsql,10,'|');
        ***********/
        strncpy(ei,rowtmp[6],sizeof(ei)-1);
        cena=atof(rowtmp[7]);
        nds=atof(rowtmp[8]);
        strncpy(strsql,rowtmp[9],sizeof(strsql)-1);

        if(atoi(strsql) == 0)
            mnds=' ';
        if(atoi(strsql) == 1)
            mnds='+';

        if(kgrmzp != kgrm)
        {
            if(kgrmzp != 0)
            {
                if(data->rk->metka_sort == 1)
                    if(itg1 != 0. || itg2 != 0. || itg3 != 0. || itg4 != 0.)
                    {
                        itgrup(kgrmzp,itg1,itg2,itg3,itg4,itg5,itg6,itg7,itg8,ffuz,0,ff);
                        kst+=2;
                    }
            }
            itg1=itg2=itg3=itg4=itg5=itg6=itg7=itg8=0.;
            kgrmzp=kgrm;
        }

        if(iceb_u_SRAV(shb,shbm,1) != 0)
        {
            if(shbm[0] != '\0')
            {
                if(data->rk->metka_sort == 1)
                    if(itg1 != 0. || itg2 != 0. || itg3 != 0. || itg4 != 0.)
                    {
                        itgrup(kgrmzp,itg1,itg2,itg3,itg4,itg5,itg6,itg7,itg8,ffuz,0,ff);
                        itg1=itg2=itg3=itg4=itg5=itg6=itg7=itg8=0.;
                        kst+=2;
                    }
                itskl(skl,kk1,kk2,kk3,kk4,ss1,ss2,ss3,ss4,ffuz,ff,ffitog,data);
                kst+=2;
                if(ostkg == 1 && fabs((kk1+kk2+kk3+kk4) - (kg0+kg1+kg2+kg3)) > 0.0001 &&
                        kg0+kg1+kg2+kg3 > 0.0001)
                {
                    itkg(shbm,skl,kg0,kg1,kg2,kg3,1,ffuz,ff);
                    kst+=2;
                    kg0=kg1=kg2=kg3=0.;
                }
                itsh(shbm,k1,k2,k3,k4,s1,s2,s3,s4,ffuz,ff,ffitog,data);
                kst+=2;
                if(ostkg == 1 && fabs((k1+k2+k3+k4) - (kgs0+kgs1+kgs2+kgs3)) > 0.0001 &&
                        kgs0+kgs1+kgs2+kgs3 > 0.0001)
                {
                    itkg(shbm,skl,kgs0,kgs1,kgs2,kgs3,0,ffuz,ff);
                    kst+=2;
                    kgs0=kgs1=kgs2=kgs3=0.;
                }
                skl=0;
                /****************
                      if(tipras == 1)
                       {
                	itskl1(skl,kk1,kk2,kk3,kk4,ss1,ss2,ss3,ss4,str,ff,ffkl2);
                	skl=0;
                	itsh1(shbm,k1,k2,k3,k4,s1,s2,s3,s4,str,ff,ffkl2);
                	kst+=4;
                       }
                *******************/
            }
            k1=s1=k2=s2=k3=s3=k4=s4=0.;

            /*Читаем наименование счета*/
            memset(naimshet,'\0',sizeof(naimshet));
            sprintf(strsql,"select nais from Plansh where ns='%s'",shb);
            if(sql_readkey(&bd,strsql,&row,&cur1) != 1)
            {
                printf("Не найден счет %s в плане счетов !\n",shb);
                fprintf(ff,"%s %s !\n",gettext("Не найден счет"),shb);
            }
            else
                strncpy(naimshet,row[0],sizeof(naimshet)-1);

            sprintf(strsql,"\n%s %s \"%s\"\n",gettext("Счет"),shb,naimshet);
            iceb_printw(iceb_u_toutf(strsql),data->buffer,data->view);

            if(kst > kol_strok_na_liste - 10)
            {
                fprintf(ff,"\f");
                fprintf(ffuz,"\f");
//      if(ffkl2 != NULL)
//         fprintf(ffkl2,"\f");
                kst=0;
                sli++;
            }


            fprintf(ff,"\n%s %s \"%s\"\n",gettext("Счет"),shb,naimshet);
            fprintf(ffuz,"\n%s %s \"%s\"\n",gettext("Счет"),shb,naimshet);
            if(ffitog != NULL)
                fprintf(ffitog,"\n%s %s \"%s\"\n",gettext("Счет"),shb,naimshet);
            kst+=2;
//    if(tipras == 0)
            gsapp(dn,mn,gn,dk,mk,gk,&sli,&kst,skl1,naiskl,ffuz,ff);
//    else
//     gsapp2(dn,mn,gn,dk,mk,gk,&sli,&kst,skl1,naiskl,str,ff,ffkl2);

            mvsh=1;

            strcpy(shbm,shb);
        }

        if(skl != skl1)
        {
            if(skl != 0)
            {
                if(data->rk->metka_sort == 1)
                    if(itg1 != 0. || itg2 != 0. || itg3 != 0. || itg4 != 0.)
                    {
                        itgrup(kgrmzp,itg1,itg2,itg3,itg4,itg5,itg6,itg7,itg8,ffuz,0,ff);
                        itg1=itg2=itg3=itg4=itg5=itg6=itg7=itg8=0.;
                        kst+=2;
                    }

                itskl(skl,kk1,kk2,kk3,kk4,ss1,ss2,ss3,ss4,ffuz,ff,ffitog,data);
                kst+=2;
                if(ostkg == 1 && fabs((kk1+kk2+kk3+kk4) - (kg0+kg1+kg2+kg3)) > 0.0001 &&
                        kg0+kg1+kg2+kg3 > 0.0001)
                {
                    itkg(shbm,skl,kg0,kg1,kg2,kg3,1,ffuz,ff);
                    kst+=2;
                    kg0=kg1=kg2=kg3=0.;
                }

//      if(tipras == 1)
//       {
//	itskl1(skl,kk1,kk2,kk3,kk4,ss1,ss2,ss3,ss4,str,ff,ffkl2);
//        kst+=2;
//       }
            }
            kk1=ss1=kk2=ss2=kk3=ss3=kk4=ss4=0.;

            /*Читаем наименование склада*/
            memset(naiskl,'\0',sizeof(naiskl));
            sprintf(strsql,"select naik from Sklad where kod='%d'",skl1);
            if(sql_readkey(&bd,strsql,&row,&cur1) != 1)
            {
                printf("Не найден склад %d в списке складов\n",skl1);
                fprintf(ff,"%s %d !\n",gettext("Не найден склад"),skl1);
            }
            strncpy(naiskl,row[0],sizeof(naiskl));

            sprintf(strsql,"%s: %d %s\n",gettext("Склад"),skl1,naiskl);
            iceb_printw(iceb_u_toutf(strsql),data->buffer,data->view);

            if(kst != 0)
                if(kst > kol_strok_na_liste - 10)
                {
                    fprintf(ff,"\f");
                    fprintf(ffuz,"\f");
//      if(ffkl2 != NULL)
//         fprintf(ffkl2,"\f");
                    kst=0;
                    sli++;
                }
            mvsh=1;
            skl=skl1;

        }
        if(mvsh == 1)
        {
//    if(tipras == 0)
//     {
            shdtmcf1(dn,mn,gn,dk,mk,gk,sli,ff,skl,naiskl,ffuz);
            kst+=6;
//     }
            /***************
                if(tipras == 1)
                 {
                  shdtmcf1k(dn,mn,gn,sli,ff,skl,naiskl,ffkl2);
                  kst+=6;
                 }
            ***************/
            mvsh=0;
        }


        /*Остаток по карточкам*/
//  ostkar(dn,mn,gn,dk,mk,gk,skl1,nk,ostg,ostm,ostgc,ostmc);

//  sprintf(nomn,"%d.%s.%d.%d",skl1,shb,kgrm,nk);
        sprintf(nomn,"%s.%d.%d",shb,kgrm,nk);


//  if(tipras == 0)
//   {
        gsapp(dn,mn,gn,dk,mk,gk,&sli,&kst,skl1,naiskl,ffuz,ff);

        fprintf(ff,"\
%4d %-*.*s %-*s %-*s %c%2.2g %14.10g %15.10g %15.2f %15.10g %15.2f %15.10g %15.2f \
%15.10g %15.2f\n",
                kodm,
                iceb_u_kolbait(40,naim.ravno()),iceb_u_kolbait(40,naim.ravno()),naim.ravno(),
                iceb_u_kolbait(13,nomn),nomn,
                iceb_u_kolbait(10,ei),ei,
                mnds,nds,cena,
                ost.ostm[0],ost.ostmc[0],ost.ostm[1],ost.ostmc[1],ost.ostm[2],ost.ostmc[2],ost.ostm[3],ost.ostmc[3]);

        fprintf(ffuz,"\
%4d %-*.*s %-*s %-*s %c%2.2g %7s %8.8g %8.2f %8.8g %8.2f %8.8g %8.2f \
%8.8g %8.2f\n",
                kodm,
                iceb_u_kolbait(23,naim.ravno()),iceb_u_kolbait(23,naim.ravno()),naim.ravno(),
                iceb_u_kolbait(13,nomn),nomn,
                iceb_u_kolbait(3,ei),ei,
                mnds,nds,iceb_prcn(cena),
                ost.ostm[0],ost.ostmc[0],ost.ostm[1],ost.ostmc[1],ost.ostm[2],ost.ostmc[2],ost.ostm[3],ost.ostmc[3]);


        if(ostkg == 1)
        {
            double ost1=0.,ost2=0.,ost3=0.,ost4=0.;
            double fas=0.;
//       iceb_u_pole(str1,strsql,11,'|');
//       fas=atof(strsql);
            fas=atof(rowtmp[10]);
            if(fas > 0.0000001)
            {
                ost1=ost.ostm[0]*fas;
                ost2=ost.ostm[1]*fas;
                ost3=ost.ostm[2]*fas;
                ost4=ost.ostm[3]*fas;
                kg0+=ost1;
                kg1+=ost2;
                kg2+=ost3;
                kg3+=ost4;
                kgs0+=ost1;
                kgs1+=ost2;
                kgs2+=ost3;
                kgs3+=ost4;

                gsapp(dn,mn,gn,dk,mk,gk,&sli,&kst,skl1,naiskl,ffuz,ff);

                fprintf(ff,"\
%4s %-40.40s %-13s %-10s %3s %14s %15.10g %15s %15.10g %15s %15.10g %15s \
%15.10g %15s\n"," "," "," "," "," "," ",
                        ost1," ",ost2," ",ost3," ",ost4," ");

                fprintf(ffuz,"\
%4s %-23.23s %-13s %-3s %3s %7s %8.8g %8s %8.8g %8s %8.8g %8s \
%8.8g %8s\n"," "," "," "," "," "," ",
                        ost1," ",ost2," ",ost3," ",ost4," ");

            }
            else if(iceb_u_SRAV(ei,"Кг",0) == 0 || iceb_u_SRAV(ei,"кг",0) == 0 ||
Пример #6
0
void _display_info_block(List block_list,
			 popup_info_t *popup_win)
{
	specific_info_t *spec_info = popup_win->spec_info;
	char *name = (char *)spec_info->search_info->gchar_data;
	int j = 0, found = 0;
	sview_block_info_t *block_ptr = NULL;
	int update = 0;
	GtkTreeView *treeview = NULL;
	ListIterator itr = NULL;

	if (!spec_info->search_info->gchar_data)
		goto finished;

need_refresh:
	if (!spec_info->display_widget) {
		treeview = create_treeview_2cols_attach_to_table(
			popup_win->table);
		spec_info->display_widget =
			gtk_widget_ref(GTK_WIDGET(treeview));
	} else {
		treeview = GTK_TREE_VIEW(spec_info->display_widget);
		update = 1;
	}

	itr = list_iterator_create(block_list);
	while ((block_ptr = (sview_block_info_t*) list_next(itr))) {
		if (!xstrcmp(block_ptr->bg_block_name, name)
		    || !xstrcmp(block_ptr->mp_str, name)) {
			/* we want to over ride any subgrp in error
			   state */
			enum node_states state = NODE_STATE_UNKNOWN;

			if (block_ptr->state & BG_BLOCK_ERROR_FLAG)
				state = NODE_STATE_ERROR;
			else if (list_count(block_ptr->job_list))
				state = NODE_STATE_ALLOCATED;
			else
				state = NODE_STATE_IDLE;

			j = 0;
			while (block_ptr->mp_inx[j] >= 0) {
				change_grid_color(
					popup_win->grid_button_list,
					block_ptr->mp_inx[j],
					block_ptr->mp_inx[j+1],
					block_ptr->color_inx, true,
					state);
				j += 2;
			}
			_layout_block_record(treeview, block_ptr, update);
			found = 1;
			break;
		}
	}
	list_iterator_destroy(itr);
	post_setup_popup_grid_list(popup_win);

	if (!found) {
		if (!popup_win->not_found) {
			char *temp = "BLOCK DOESN'T EXSIST\n";
			GtkTreeIter iter;
			GtkTreeModel *model = NULL;

			/* only time this will be run so no update */
			model = gtk_tree_view_get_model(treeview);
			add_display_treestore_line(0,
						   GTK_TREE_STORE(model),
						   &iter,
						   temp, "");
		}
		popup_win->not_found = true;
	} else {
		if (popup_win->not_found) {
			popup_win->not_found = false;
			gtk_widget_destroy(spec_info->display_widget);

			goto need_refresh;
		}
	}
	gtk_widget_show(spec_info->display_widget);

finished:

	return;
}
Пример #7
0
//
//  Delete ev
//
PnViewerNavGtk::~PnViewerNavGtk()
{
  delete brow;
  gtk_widget_destroy( form_widget);
}
Пример #8
0
Файл: dialog.c Проект: BYC/gtk
static void
interactive_dialog_clicked (GtkButton *button,
			    gpointer   user_data)
{
  GtkWidget *content_area;
  GtkWidget *dialog;
  GtkWidget *hbox;
  GtkWidget *stock;
  GtkWidget *table;
  GtkWidget *local_entry1;
  GtkWidget *local_entry2;
  GtkWidget *label;
  gint response;

  dialog = gtk_dialog_new_with_buttons ("Interactive Dialog",
					GTK_WINDOW (window),
					GTK_DIALOG_MODAL| GTK_DIALOG_DESTROY_WITH_PARENT,
					GTK_STOCK_OK,
					GTK_RESPONSE_OK,
                                        "_Non-stock Button",
                                        GTK_RESPONSE_CANCEL,
					NULL);

  content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));

  hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 8);
  gtk_container_set_border_width (GTK_CONTAINER (hbox), 8);
  gtk_box_pack_start (GTK_BOX (content_area), hbox, FALSE, FALSE, 0);

  stock = gtk_image_new_from_stock (GTK_STOCK_DIALOG_QUESTION, GTK_ICON_SIZE_DIALOG);
  gtk_box_pack_start (GTK_BOX (hbox), stock, FALSE, FALSE, 0);

  table = gtk_table_new (2, 2, FALSE);
  gtk_table_set_row_spacings (GTK_TABLE (table), 4);
  gtk_table_set_col_spacings (GTK_TABLE (table), 4);
  gtk_box_pack_start (GTK_BOX (hbox), table, TRUE, TRUE, 0);
  label = gtk_label_new_with_mnemonic ("_Entry 1");
  gtk_table_attach_defaults (GTK_TABLE (table),
			     label,
			     0, 1, 0, 1);
  local_entry1 = gtk_entry_new ();
  gtk_entry_set_text (GTK_ENTRY (local_entry1), gtk_entry_get_text (GTK_ENTRY (entry1)));
  gtk_table_attach_defaults (GTK_TABLE (table), local_entry1, 1, 2, 0, 1);
  gtk_label_set_mnemonic_widget (GTK_LABEL (label), local_entry1);

  label = gtk_label_new_with_mnemonic ("E_ntry 2");
  gtk_table_attach_defaults (GTK_TABLE (table),
			     label,
			     0, 1, 1, 2);

  local_entry2 = gtk_entry_new ();
  gtk_entry_set_text (GTK_ENTRY (local_entry2), gtk_entry_get_text (GTK_ENTRY (entry2)));
  gtk_table_attach_defaults (GTK_TABLE (table), local_entry2, 1, 2, 1, 2);
  gtk_label_set_mnemonic_widget (GTK_LABEL (label), local_entry2);
  
  gtk_widget_show_all (hbox);
  response = gtk_dialog_run (GTK_DIALOG (dialog));

  if (response == GTK_RESPONSE_OK)
    {
      gtk_entry_set_text (GTK_ENTRY (entry1), gtk_entry_get_text (GTK_ENTRY (local_entry1)));
      gtk_entry_set_text (GTK_ENTRY (entry2), gtk_entry_get_text (GTK_ENTRY (local_entry2)));
    }

  gtk_widget_destroy (dialog);
}
Пример #9
0
/**
 * caja_get_user_directory:
 *
 * Get the path for the directory containing caja settings.
 *
 * Return value: the directory path.
 **/
char* caja_get_user_directory(void)
{
	/* FIXME bugzilla.gnome.org 41286:
	 * How should we handle the case where this mkdir fails?
	 * Note that caja_application_startup will refuse to launch if this
	 * directory doesn't get created, so that case is OK. But the directory
	 * could be deleted after Caja was launched, and perhaps
	 * there is some bad side-effect of not handling that case.
	 * <<<
	 * Si alguien tiene tiempo, puede enviar este codigo a Nautilus.
	 * Obviamente, con los comentarios traducidos al Inglés.
	 */
	char* user_directory = g_build_filename(g_get_home_dir(), ".config", "caja", NULL);
	/* Se necesita que esta dirección sea una carpeta, con los permisos
	 * DEFAULT_CAJA_DIRECTORY_MODE. Pero si es un archivo, el programa intentará
	 * eliminar el archivo silenciosamente. */
	if (g_file_test(user_directory, G_FILE_TEST_IS_DIR) == FALSE ||
		g_access(user_directory, DEFAULT_CAJA_DIRECTORY_MODE) == -1)
	{
		/* Se puede obtener un enlace simbolico a una carpeta */
		if (g_file_test(user_directory, G_FILE_TEST_IS_SYMLINK) == TRUE)
		{
			/* intentaremos saber si el enlace es una carpeta, y tiene los
			 * permisos adecuados */
			char* link = g_file_read_link(user_directory, NULL);

			if (link)
			{
				/* Si el enlace no es un directorio, o si falla al hacer chmod,
				 * se borra el enlace y se crea la carpeta */
				if (g_file_test(link, G_FILE_TEST_IS_DIR) != TRUE ||
					g_chmod(link, DEFAULT_CAJA_DIRECTORY_MODE) != 0)
				{
					/* podemos borrar el enlace y crear la carpeta */
					g_unlink(user_directory);
					g_mkdir(user_directory, DEFAULT_CAJA_DIRECTORY_MODE);
				}

				g_free(link);
			}
		}
		else if (g_file_test(user_directory, G_FILE_TEST_IS_DIR) == TRUE)
		{
			g_chmod(user_directory, DEFAULT_CAJA_DIRECTORY_MODE);
		}
		else if (g_file_test(user_directory, G_FILE_TEST_EXISTS) == TRUE)
		{
			/* podemos borrar el enlace y crear la carpeta */
			g_unlink(user_directory);
			g_mkdir(user_directory, DEFAULT_CAJA_DIRECTORY_MODE);
		}
		else
		{
			/* Si no existe ningun archivo, se crea la carpeta */
			g_mkdir_with_parents(user_directory, DEFAULT_CAJA_DIRECTORY_MODE);
		}

		/* Faltan permisos */
		if (g_chmod(user_directory, DEFAULT_CAJA_DIRECTORY_MODE) != 0)
		{
			GtkWidget* dialog = gtk_message_dialog_new(
				NULL,
				GTK_DIALOG_DESTROY_WITH_PARENT,
				GTK_MESSAGE_ERROR,
				GTK_BUTTONS_CLOSE,
				"The path for the directory containing caja settings need read and write permissions: %s",
				user_directory);

			gtk_dialog_run(GTK_DIALOG(dialog));
			gtk_widget_destroy(dialog);

			exit(0);
		}
	}

	return user_directory;
}
static void
impl_GNOME_FileManagerWindow_close(impl_POA_GNOME_FileManagerWindow * servant, CORBA_Environment * ev)
{
	gtk_widget_destroy(servant->mywin->xwindow);
}
Пример #11
0
static void on_menuitem_save_as_activate(void)
{
	GtkFileChooser *chooser = GTK_FILE_CHOOSER(
		gtk_file_chooser_dialog_new(_("Save Digests"), gui.window,
			GTK_FILE_CHOOSER_ACTION_SAVE,
			GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
			GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT,
			NULL));
	gtk_file_chooser_set_do_overwrite_confirmation(chooser, true);


	if (gtk_dialog_run(GTK_DIALOG(chooser)) == GTK_RESPONSE_ACCEPT) {
		char *filename = gtk_file_chooser_get_filename(chooser);
		GString *string = g_string_sized_new(1024);

		for (int i = 0; i < HASH_FUNCS_N; i++) {
			if (!hash.funcs[i].enabled)
				continue;

			switch (gui_get_view()) {
				case GUI_VIEW_FILE: {
					const bool hmac_active = gtk_toggle_button_get_active(
						gui.togglebutton_hmac_file);
					const char *digest = gtk_entry_get_text(
						gui.hash_widgets[i].entry_file);
					if (digest && *digest) {
						g_string_append_printf(string,
							(hmac_active && (hash.funcs[i].block_size > 0)) ?
							"# HMAC-%s\n" : "# %s\n", hash.funcs[i].name);
					} else
						continue;
					char *path = gtk_file_chooser_get_filename(
						GTK_FILE_CHOOSER(gui.filechooserbutton));
					char *basename = g_path_get_basename(path);
					g_free(path);
					g_string_append_printf(string, "%s  %s\n",
					gtk_entry_get_text(gui.hash_widgets[i].entry_file),
						basename);
					g_free(basename);
					break;
				}
				case GUI_VIEW_TEXT: {
					const bool hmac_active = gtk_toggle_button_get_active(
						gui.togglebutton_hmac_text);
					g_string_append_printf(string,
						(hmac_active && (hash.funcs[i].block_size > 0)) ?
						"# HMAC-%s\n" : "# %s\n", hash.funcs[i].name);
					g_string_append_printf(string, "%s  \"%s\"\n",
						gtk_entry_get_text(gui.hash_widgets[i].entry_text),
						gtk_entry_get_text(gui.entry_text));
					break;
				}
				case GUI_VIEW_FILE_LIST: {
					int prev = -1;
					for (unsigned int row = 0; row < list_count_rows(); row++)
					{
						char *digest = list_get_digest(row, i);
						if (digest && *digest) {
							if (i != prev)
								g_string_append_printf(string, "# %s\n",
									hash.funcs[i].name);
							prev = i;
						} else {
							if (digest)
								g_free(digest);
							prev = i;
							continue;
						}
						char *uri = list_get_uri(row);
						char *basename = g_filename_display_basename(uri);
						g_string_append_printf(string, "%s  %s\n",
							digest, basename);
						g_free(basename);
						g_free(uri);
						g_free(digest);
					}
					break;
				}
				default:
					g_assert_not_reached();
			}
		}

		char *data = g_string_free(string, false);
		g_file_set_contents(filename, data, -1, NULL);

		g_free(data);
		g_free(filename);
	}

	gtk_widget_destroy(GTK_WIDGET(chooser));
}
Пример #12
0
extern void get_info_block(GtkTable *table, display_data_t *display_data)
{
	int part_error_code = SLURM_SUCCESS;
	int block_error_code = SLURM_SUCCESS;
	static int view = -1;
	static partition_info_msg_t *part_info_ptr = NULL;
	static block_info_msg_t *block_ptr = NULL;
	char error_char[100];
	GtkWidget *label = NULL;
	GtkTreeView *tree_view = NULL;
	static GtkWidget *display_widget = NULL;
	List block_list = NULL;
	int j=0;
	ListIterator itr = NULL;
	sview_block_info_t *sview_block_info_ptr = NULL;
	GtkTreePath *path = NULL;
	static bool set_opts = false;

	if (!set_opts)
		set_page_opts(BLOCK_PAGE, display_data_block,
			      SORTID_CNT, _initial_page_opts);
	set_opts = true;

	/* reset */
	if (!table && !display_data) {
		if (display_widget)
			gtk_widget_destroy(display_widget);
		display_widget = NULL;
		part_info_ptr = NULL;
		block_ptr = NULL;
		goto reset_curs;
	}

	if (display_data)
		local_display_data = display_data;
	if (!table) {
		display_data_block->set_menu = local_display_data->set_menu;
		goto reset_curs;
	}

	if (cluster_flags & CLUSTER_FLAG_FED) {
		view = ERROR_VIEW;
		if (display_widget)
			gtk_widget_destroy(display_widget);
		label = gtk_label_new("Not available in a federated view");
		gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 0, 1);
		gtk_widget_show(label);
		display_widget = gtk_widget_ref(label);
		goto end_it;
	}

	if (display_widget && toggled) {
		gtk_widget_destroy(display_widget);
		display_widget = NULL;
		goto display_it;
	}

	if ((part_error_code = get_new_info_part(&part_info_ptr, force_refresh))
	    == SLURM_NO_CHANGE_IN_DATA) {

	} else if (part_error_code != SLURM_SUCCESS) {
		if (view == ERROR_VIEW)
			goto end_it;
		view = ERROR_VIEW;
		if (display_widget)
			gtk_widget_destroy(display_widget);
		sprintf(error_char, "slurm_load_partitions: %s",
			slurm_strerror(slurm_get_errno()));
		label = gtk_label_new(error_char);
		gtk_table_attach_defaults(GTK_TABLE(table),
					  label,
					  0, 1, 0, 1);
		gtk_widget_show(label);
		display_widget = gtk_widget_ref(label);
		goto end_it;
	}

	if ((block_error_code = get_new_info_block(&block_ptr, force_refresh))
	    == SLURM_NO_CHANGE_IN_DATA) {
		if ((!display_widget || view == ERROR_VIEW)
		    || (part_error_code != SLURM_NO_CHANGE_IN_DATA)) {
			goto display_it;
		}
	} else if (block_error_code != SLURM_SUCCESS) {
		if (view == ERROR_VIEW)
			goto end_it;
		view = ERROR_VIEW;
		if (display_widget)
			gtk_widget_destroy(display_widget);
		sprintf(error_char, "slurm_load_block: %s",
			slurm_strerror(slurm_get_errno()));
		label = gtk_label_new(error_char);
		gtk_table_attach_defaults(table,
					  label,
					  0, 1, 0, 1);
		gtk_widget_show(label);
		display_widget = gtk_widget_ref(label);
		goto end_it;
	}

display_it:
	if (!block_ptr) {
		view = ERROR_VIEW;
		if (display_widget)
			gtk_widget_destroy(display_widget);
		label = gtk_label_new("No blocks on non-Bluegene systems");
		gtk_table_attach_defaults(GTK_TABLE(table),
					  label,
					  0, 1, 0, 1);
		gtk_widget_show(label);
		display_widget = gtk_widget_ref(label);
		goto end_it;
	}
	if (!part_info_ptr)
		goto reset_curs;

	block_list = _create_block_list(part_info_ptr, block_ptr);
	if (!block_list)
		goto reset_curs;

	/* set up the grid */
	if (display_widget && GTK_IS_TREE_VIEW(display_widget)
	    && gtk_tree_selection_count_selected_rows(
		    gtk_tree_view_get_selection(
			    GTK_TREE_VIEW(display_widget)))) {
		GtkTreeViewColumn *focus_column = NULL;
		/* highlight the correct mp_str from the last selection */
		gtk_tree_view_get_cursor(GTK_TREE_VIEW(display_widget),
					 &path, &focus_column);
	}
	if (!path) {
		itr = list_iterator_create(block_list);
		while ((sview_block_info_ptr = list_next(itr))) {
			j=0;
			while (sview_block_info_ptr->mp_inx[j] >= 0) {
				change_grid_color(
					grid_button_list,
					sview_block_info_ptr->mp_inx[j],
					sview_block_info_ptr->mp_inx[j+1],
					sview_block_info_ptr->color_inx,
					true, 0);
				j += 2;
			}
		}
		list_iterator_destroy(itr);
		change_grid_color(grid_button_list, -1, -1,
				  MAKE_WHITE, true, 0);
	} else {
		highlight_grid(GTK_TREE_VIEW(display_widget),
			       SORTID_NODE_INX, SORTID_COLOR_INX,
			       grid_button_list);
		gtk_tree_path_free(path);
	}

	if (view == ERROR_VIEW && display_widget) {
		gtk_widget_destroy(display_widget);
		display_widget = NULL;
	}
	if (!display_widget) {
		tree_view = create_treeview(local_display_data,
					    &grid_button_list);
		gtk_tree_selection_set_mode(
			gtk_tree_view_get_selection(tree_view),
			GTK_SELECTION_MULTIPLE);
		display_widget = gtk_widget_ref(GTK_WIDGET(tree_view));
		gtk_table_attach_defaults(table,
					  GTK_WIDGET(tree_view),
					  0, 1, 0, 1);
		/* since this function sets the model of the tree_view
		   to the treestore we don't really care about
		   the return value */
		create_treestore(tree_view, display_data_block,
				 SORTID_CNT, SORTID_NODELIST, SORTID_COLOR);
	}

	view = INFO_VIEW;
	_update_info_block(block_list, GTK_TREE_VIEW(display_widget));
end_it:
	toggled = false;
	force_refresh = false;

reset_curs:
	if (main_window && main_window->window)
		gdk_window_set_cursor(main_window->window, NULL);
	return;
}
Пример #13
0
extern int update_state_block(GtkDialog *dialog,
			      const char *blockid, const char *type)
{
	int i = 0;
	int rc = SLURM_SUCCESS;
	char tmp_char[100];
	update_block_msg_t block_msg;
	GtkWidget *label = NULL;
	int no_dialog = 0;

	if (!dialog) {
		dialog = GTK_DIALOG(
			gtk_dialog_new_with_buttons(
				type,
				GTK_WINDOW(main_window),
				GTK_DIALOG_MODAL
				| GTK_DIALOG_DESTROY_WITH_PARENT,
				NULL));
		no_dialog = 1;
	}
	slurm_init_update_block_msg(&block_msg);
	block_msg.bg_block_id = (char *)blockid;

	label = gtk_dialog_add_button(dialog,
				      GTK_STOCK_YES, GTK_RESPONSE_OK);
	gtk_window_set_default(GTK_WINDOW(dialog), label);
	gtk_dialog_add_button(dialog,
			      GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);

	if (!xstrcasecmp("Error", type) ||
	    !xstrcasecmp("Put block in error state", type)) {
		snprintf(tmp_char, sizeof(tmp_char),
			 "Are you sure you want to put block %s "
			 "in an error state?",
			 blockid);
		block_msg.state = BG_BLOCK_ERROR_FLAG;
	} else if (!xstrcasecmp("Recreate block", type)) {
		snprintf(tmp_char, sizeof(tmp_char),
			 "Are you sure you want to recreate block %s?",
			 blockid);
		block_msg.state = BG_BLOCK_BOOTING;
	} else if (!xstrcasecmp("Remove block", type)) {
		snprintf(tmp_char, sizeof(tmp_char),
			 "Are you sure you want to remove block %s?",
			 blockid);
		block_msg.state = BG_BLOCK_NAV;
	} else if (!xstrcasecmp("Resume block", type)) {
		snprintf(tmp_char, sizeof(tmp_char),
			 "Are you sure you want to resume block %s?",
			 blockid);
		block_msg.state = BG_BLOCK_TERM;
	} else {
		snprintf(tmp_char, sizeof(tmp_char),
			 "Are you sure you want to put block %s "
			 "in a free state?",
			 blockid);
		block_msg.state = BG_BLOCK_FREE;
	}

	label = gtk_label_new(tmp_char);

	gtk_box_pack_start(GTK_BOX(dialog->vbox), label, false, false, 0);

	gtk_widget_show_all(GTK_WIDGET(dialog));
	i = gtk_dialog_run(dialog);
	if (i == GTK_RESPONSE_OK) {
		if (slurm_update_block(&block_msg)
		    == SLURM_SUCCESS) {
			snprintf(tmp_char, sizeof(tmp_char),
				 "Block %s updated successfully",
				 blockid);
		} else {
			snprintf(tmp_char, sizeof(tmp_char),
				 "Problem updating block %s.",
				 blockid);
		}
		display_edit_note(tmp_char);
	}

	if (no_dialog)
		gtk_widget_destroy(GTK_WIDGET(dialog));
	return rc;
}
Пример #14
0
void
ee_prefs_dialog_run (EEMainWindow *mainwin)
{
    GtkWidget *dialog;
    GtkWidget *align;
    GtkWidget *table;
    GtkWidget *label;
    GtkWidget *cycle_time;
    GtkWidget *start_fullscreen;
    GtkWidget *disable_plugins;
    GtkWidget *disable_scripts;

    /* create the toplevel dialog window */
    dialog = gtk_dialog_new_with_buttons ("Preferences", NULL,
        GTK_DIALOG_DESTROY_WITH_PARENT, GTK_STOCK_OK, GTK_RESPONSE_OK, NULL);
    gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);

    /* create 12px padding */
    align = gtk_alignment_new (0.5, 0.5, 1.0, 1.0);
    gtk_alignment_set_padding (GTK_ALIGNMENT (align), 12, 12, 12, 12);
    gtk_box_pack_start (GTK_BOX (GTK_DIALOG(dialog)->vbox), align, TRUE, TRUE, 0);

    table = gtk_table_new (4, 2, FALSE);
    gtk_container_add (GTK_CONTAINER (align), table);

    /* add the cycle time spinner */
    label = gtk_label_new (NULL);
    gtk_label_set_markup (GTK_LABEL (label), "<b>Cycle Time</b>");
    gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
    gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1,
        GTK_EXPAND | GTK_FILL, GTK_SHRINK, 6, 2);
    cycle_time = gtk_spin_button_new_with_range (10.0, 86400.0, 10.0);
    gtk_spin_button_set_value (GTK_SPIN_BUTTON (cycle_time),
        (gdouble) mainwin->settings->cycle_time);
    g_signal_connect (cycle_time, "value-changed",
        G_CALLBACK (on_cycle_time_changed), mainwin);
    gtk_table_attach (GTK_TABLE (table), cycle_time, 1, 2, 0, 1,
        GTK_EXPAND | GTK_FILL, GTK_SHRINK, 6, 2);

    /* add the start-fullscreen checkbox */
    start_fullscreen = gtk_check_button_new_with_label ("Start in fullscreen mode");
    if (mainwin->settings->start_fullscreen)
        gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (start_fullscreen), TRUE);
    g_signal_connect (start_fullscreen, "toggled",
        G_CALLBACK (on_start_fullscreen), mainwin);
    gtk_table_attach (GTK_TABLE (table), start_fullscreen, 0, 2, 1, 2,
        GTK_EXPAND | GTK_FILL, GTK_SHRINK, 6, 2);

    /* add the disable-plugins checkbox */
    disable_plugins = gtk_check_button_new_with_label ("Disable browser plugins");
    if (mainwin->settings->disable_plugins)
        gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (disable_plugins), TRUE);
    g_signal_connect (disable_plugins, "toggled",
        G_CALLBACK (on_disable_plugins), mainwin);
    gtk_table_attach (GTK_TABLE (table), disable_plugins, 0, 2, 2, 3,
        GTK_EXPAND | GTK_FILL, GTK_SHRINK, 6, 2);

    /* add the disable-scripts checkbox */
    disable_scripts = gtk_check_button_new_with_label ("Disable browser scripts");
    if (mainwin->settings->disable_scripts)
        gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (disable_scripts), TRUE);
    g_signal_connect (disable_scripts, "toggled",
        G_CALLBACK (on_disable_scripts), mainwin);
    gtk_table_attach (GTK_TABLE (table), disable_scripts, 0, 2, 3, 4,
        GTK_EXPAND | GTK_FILL, GTK_SHRINK, 6, 2);

    /* run the dialog */
    gtk_widget_show_all (dialog);
    gtk_dialog_run (GTK_DIALOG (dialog));
    gtk_widget_destroy (dialog);
}
Пример #15
0
void DisplayDialog()
{
    int return_value;

    GtkWidget *dialog;
    GtkWidget *main_frame, *main_box;

    GtkWidget *mixing_frame, *mixing_box;
    GtkWidget *int_label, *int_box;
    GtkWidget *effects_check;
    GtkWidget *dealias_filter;
    GtkWidget *debug_check;
    GtkWidget *debug_button;

    GtkWidget *output_frame, *output_box;
    GtkWidget *mod_label, *mod_box;
    GtkWidget *api_label, *api_box;
#if SDL_MAJOR_VERSION >= 2
    GtkWidget *sdl_api_label, *sdl_api_box;
#endif
    GtkWidget *latency_label, *latency_slide;
    GtkWidget *sync_label, *sync_box;
    GtkWidget *advanced_button;

    /* Create the widgets */
    dialog = gtk_dialog_new_with_buttons (
		"SPU2-X Config",
		NULL, /* parent window*/
		(GtkDialogFlags)(GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT),
		"OK", GTK_RESPONSE_ACCEPT,
		"Cancel", GTK_RESPONSE_REJECT,
		NULL);

    int_label = gtk_label_new ("Interpolation:");
    int_box = gtk_combo_box_text_new ();
    gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(int_box), "0 - Nearest (fastest/bad quality)");
    gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(int_box), "1 - Linear (simple/okay sound)");
    gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(int_box), "2 - Cubic (artificial highs)");
    gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(int_box), "3 - Hermite (better highs)");
    gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(int_box), "4 - Catmull-Rom (PS2-like/slow)");
    gtk_combo_box_set_active(GTK_COMBO_BOX(int_box), Interpolation);

    effects_check = gtk_check_button_new_with_label("Disable Effects Processing");
    dealias_filter = gtk_check_button_new_with_label("Use the de-alias filter (overemphasizes the highs)");

    debug_check = gtk_check_button_new_with_label("Enable Debug Options");
	debug_button = gtk_button_new_with_label("Debug...");

    mod_label = gtk_label_new ("Module:");
    mod_box = gtk_combo_box_text_new ();
    gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(mod_box), "0 - No Sound (emulate SPU2 only)");
    gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(mod_box), "1 - PortAudio (cross-platform)");
#ifdef __linux__
    gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(mod_box), "2 - SDL Audio (recommended for PulseAudio)");
#endif
    //gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(mod_box), "3 - Alsa (probably doesn't work)");
    gtk_combo_box_set_active(GTK_COMBO_BOX(mod_box), OutputModule);

    api_label = gtk_label_new ("PortAudio API:");
    api_box = gtk_combo_box_text_new ();
#ifdef __linux__
	// In order to keep it the menu light, I only put linux major api
    gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(api_box), "0 - ALSA (recommended)");
    gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(api_box), "1 - OSS (legacy)");
    gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(api_box), "2 - JACK");
#else
    gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(api_box), "OSS");
#endif
    gtk_combo_box_set_active(GTK_COMBO_BOX(api_box), OutputAPI);

#if SDL_MAJOR_VERSION >= 2
    sdl_api_label = gtk_label_new ("SDL API:");
    sdl_api_box = gtk_combo_box_text_new ();
    // YES It sucks ...
    for (int i = 0; i < SDL_GetNumAudioDrivers(); ++i) {
        gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(sdl_api_box), SDL_GetAudioDriver(i));
    }
    gtk_combo_box_set_active(GTK_COMBO_BOX(sdl_api_box), SdlOutputAPI);
#endif

    latency_label = gtk_label_new ("Latency:");
#if GTK_MAJOR_VERSION < 3
    latency_slide = gtk_hscale_new_with_range(LATENCY_MIN, LATENCY_MAX, 5);
#else
    latency_slide = gtk_scale_new_with_range(GTK_ORIENTATION_HORIZONTAL, LATENCY_MIN, LATENCY_MAX, 5);
#endif
    gtk_range_set_value(GTK_RANGE(latency_slide), SndOutLatencyMS);

    sync_label = gtk_label_new ("Synchronization Mode:");
    sync_box = gtk_combo_box_text_new ();
    gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(sync_box), "TimeStretch (Recommended)");
    gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(sync_box), "Async Mix (Breaks some games!)");
    gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(sync_box), "None (Audio can skip.)");
    gtk_combo_box_set_active(GTK_COMBO_BOX(sync_box), SynchMode);

	advanced_button = gtk_button_new_with_label("Advanced...");

    main_box = gtk_hbox_new(false, 5);
    main_frame = gtk_frame_new ("SPU2-X Config");
    gtk_container_add (GTK_CONTAINER(main_frame), main_box);

    mixing_box = gtk_vbox_new(false, 5);
    mixing_frame = gtk_frame_new ("Mixing Settings:");
    gtk_container_add (GTK_CONTAINER(mixing_frame), mixing_box);

    output_box = gtk_vbox_new(false, 5);
    output_frame = gtk_frame_new ("Output Settings:");
    gtk_container_add (GTK_CONTAINER(output_frame), output_box);

	gtk_container_add(GTK_CONTAINER(mixing_box), int_label);
	gtk_container_add(GTK_CONTAINER(mixing_box), int_box);
	gtk_container_add(GTK_CONTAINER(mixing_box), effects_check);
	gtk_container_add(GTK_CONTAINER(mixing_box), dealias_filter);
	gtk_container_add(GTK_CONTAINER(mixing_box), debug_check);
	gtk_container_add(GTK_CONTAINER(mixing_box), debug_button);

	gtk_container_add(GTK_CONTAINER(output_box), mod_label);
	gtk_container_add(GTK_CONTAINER(output_box), mod_box);
	gtk_container_add(GTK_CONTAINER(output_box), api_label);
	gtk_container_add(GTK_CONTAINER(output_box), api_box);
#if SDL_MAJOR_VERSION >= 2
	gtk_container_add(GTK_CONTAINER(output_box), sdl_api_label);
	gtk_container_add(GTK_CONTAINER(output_box), sdl_api_box);
#endif
	gtk_container_add(GTK_CONTAINER(output_box), sync_label);
	gtk_container_add(GTK_CONTAINER(output_box), sync_box);
	gtk_container_add(GTK_CONTAINER(output_box), latency_label);
	gtk_container_add(GTK_CONTAINER(output_box), latency_slide);
	gtk_container_add(GTK_CONTAINER(output_box), advanced_button);

	gtk_container_add(GTK_CONTAINER(main_box), mixing_frame);
	gtk_container_add(GTK_CONTAINER(main_box), output_frame);

    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(effects_check), EffectsDisabled);
    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dealias_filter), postprocess_filter_dealias);
	//FinalVolume;
    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(debug_check), DebugEnabled);

    gtk_container_add (GTK_CONTAINER(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), main_frame);
    gtk_widget_show_all (dialog);

    g_signal_connect_swapped(advanced_button, "clicked", G_CALLBACK(advanced_dialog), advanced_button);
    g_signal_connect_swapped(debug_button, "clicked", G_CALLBACK(debug_dialog), debug_button);

    return_value = gtk_dialog_run (GTK_DIALOG (dialog));

    if (return_value == GTK_RESPONSE_ACCEPT)
    {
		DebugEnabled = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(debug_check));
		postprocess_filter_dealias = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dealias_filter));
    	if (gtk_combo_box_get_active(GTK_COMBO_BOX(int_box)) != -1)
    		Interpolation = gtk_combo_box_get_active(GTK_COMBO_BOX(int_box));

    	EffectsDisabled = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(effects_check));
		//FinalVolume;

    	if (gtk_combo_box_get_active(GTK_COMBO_BOX(mod_box)) != -1)
			OutputModule = gtk_combo_box_get_active(GTK_COMBO_BOX(mod_box));

    	if (gtk_combo_box_get_active(GTK_COMBO_BOX(api_box)) != -1) {
			OutputAPI = gtk_combo_box_get_active(GTK_COMBO_BOX(api_box));
#ifdef __linux__
			switch(OutputAPI) {
				case 0: PortaudioOut->SetApiSettings(L"ALSA"); break;
				case 1: PortaudioOut->SetApiSettings(L"OSS"); break;
				case 2: PortaudioOut->SetApiSettings(L"JACK"); break;
				default: PortaudioOut->SetApiSettings(L"Unknown");
			}
#else
			switch(OutputAPI) {
				case 0: PortaudioOut->SetApiSettings(L"OSS"); break;
				default: PortaudioOut->SetApiSettings(L"Unknown");
			}
#endif
		}

#if SDL_MAJOR_VERSION >= 2
		if (gtk_combo_box_get_active(GTK_COMBO_BOX(sdl_api_box)) != -1) {
			SdlOutputAPI = gtk_combo_box_get_active(GTK_COMBO_BOX(sdl_api_box));
			// YES It sucks ...
			SDLOut->SetApiSettings(wxString(SDL_GetAudioDriver(SdlOutputAPI), wxConvUTF8));
		}
#endif

    	SndOutLatencyMS = gtk_range_get_value(GTK_RANGE(latency_slide));
    	
    	if (gtk_combo_box_get_active(GTK_COMBO_BOX(sync_box)) != -1)
			SynchMode = gtk_combo_box_get_active(GTK_COMBO_BOX(sync_box));
    }

    gtk_widget_destroy (dialog);
}
Пример #16
0
/* It's not static since it will be called from the GUI */
void save_config(void)
{
  gchar *pref_file;
  gchar *cfgdata;
  gchar *tmpstr;
  gboolean res;
  GError *error = NULL;
  GKeyFile *gkey;

  gkey = g_key_file_new();
  
  g_key_file_set_boolean(gkey, pref_group, "diagram_only", pref.diagram_only);
  g_key_file_set_boolean(gkey, pref_group, "group_unk", pref.group_unk);
  g_key_file_set_boolean(gkey, pref_group, "name_res", pref.name_res);
  g_key_file_set_double(gkey, pref_group, "node_timeout_time",
			  pref.node_timeout_time);
  g_key_file_set_double(gkey, pref_group, "gui_node_timeout_time",
			  pref.gui_node_timeout_time);
  g_key_file_set_double(gkey, pref_group, "proto_node_timeout_time",
			  pref.proto_node_timeout_time);
  g_key_file_set_double(gkey, pref_group, "link_timeout_time",
			  pref.link_timeout_time);
  g_key_file_set_double(gkey, pref_group, "gui_link_timeout_time",
			  pref.gui_link_timeout_time);
  g_key_file_set_double(gkey, pref_group, "proto_link_timeout_time",
			  pref.proto_link_timeout_time);
  g_key_file_set_double(gkey, pref_group, "proto_timeout_time",
			  pref.proto_timeout_time);
  g_key_file_set_double(gkey, pref_group, "averaging_time", pref.averaging_time);
  g_key_file_set_double(gkey, pref_group, "node_radius_multiplier",
			  pref.node_radius_multiplier);
  g_key_file_set_double(gkey, pref_group, "link_node_ratio",
			  pref.link_node_ratio);
  g_key_file_set_integer(gkey, pref_group, "refresh_period", pref.refresh_period);
  g_key_file_set_integer(gkey, pref_group, "size_mode", pref.size_mode);
  g_key_file_set_integer(gkey, pref_group, "node_size_variable",
			pref.node_size_variable);
  g_key_file_set_integer(gkey, pref_group, "stack_level", pref.stack_level);

  g_key_file_set_string(gkey, pref_group, "filter", pref.filter);
  g_key_file_set_string(gkey, pref_group, "fontname", pref.fontname);
  g_key_file_set_string(gkey, pref_group, "text_color", pref.text_color);
  g_key_file_set_string(gkey, pref_group, "center_node", pref.center_node);

  tmpstr = g_strjoinv(" ", pref.colors);
  g_key_file_set_string(gkey, pref_group, "colors", tmpstr);
  g_free(tmpstr);

  g_key_file_set_string(gkey, "General", "version", VERSION);

  /* write config to file */
  cfgdata = g_key_file_to_data(gkey, NULL, NULL);
  pref_file = config_file_name();
  res = g_file_set_contents(pref_file, cfgdata, -1, &error);
  g_free(cfgdata);

  if (res)
    g_my_info (_("Preferences saved to %s"), pref_file);
  else
    {
      GtkWidget *dialog = gtk_message_dialog_new (NULL,
                             GTK_DIALOG_DESTROY_WITH_PARENT,
                             GTK_MESSAGE_ERROR,
                             GTK_BUTTONS_CLOSE,
                             _("Error saving preferences to '%s': %s"),
                             pref_file, 
                             (error && error->message) ? error->message : "");
      gtk_dialog_run (GTK_DIALOG (dialog));
      gtk_widget_destroy (dialog);
    }
  g_free(pref_file);
}				/* save_config */
Пример #17
0
static void
cb_destroy(GtkWidget *widget, gpointer user_data)
{
    gtk_widget_destroy(widget);
}
Пример #18
0
Файл: dialog.c Проект: BYC/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_table_new (2, 2, FALSE);
      gtk_table_set_row_spacings (GTK_TABLE (table), 4);
      gtk_table_set_col_spacings (GTK_TABLE (table), 4);
      gtk_box_pack_start (GTK_BOX (hbox), table, FALSE, FALSE, 0);

      label = gtk_label_new_with_mnemonic ("_Entry 1");
      gtk_table_attach_defaults (GTK_TABLE (table),
				 label,
				 0, 1, 0, 1);

      entry1 = gtk_entry_new ();
      gtk_table_attach_defaults (GTK_TABLE (table), entry1, 1, 2, 0, 1);
      gtk_label_set_mnemonic_widget (GTK_LABEL (label), entry1);

      label = gtk_label_new_with_mnemonic ("E_ntry 2");
      
      gtk_table_attach_defaults (GTK_TABLE (table),
				 label,
				 0, 1, 1, 2);

      entry2 = gtk_entry_new ();
      gtk_table_attach_defaults (GTK_TABLE (table), entry2, 1, 2, 1, 2);
      gtk_label_set_mnemonic_widget (GTK_LABEL (label), entry2);
    }

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

  return window;
}
Пример #19
0
static gint headerview_show_contact_pic (HeaderView *headerview, MsgInfo *msginfo)
{
#ifndef USE_ALT_ADDRBOOK
	GtkWidget *hbox = headerview->hbox;
	GtkWidget *image;
	gchar *filename = NULL;
	GError *error = NULL;
	GdkPixbuf *picture = NULL;
	gint w, h;

	if (!gtk_widget_get_visible(headerview->hbox)) return -1;

	if (headerview->image) {
		gtk_widget_destroy(headerview->image);
		headerview->image = NULL;
	}
	
	filename = addrindex_get_picture_file(msginfo->from);
	
	if (!filename)
		return -1;
	if (!is_file_exist(filename)) {
		g_free(filename);
		return -1;
	}
	gdk_pixbuf_get_file_info(filename, &w, &h);
	
	if (w > 48 || h > 48)
		picture = gdk_pixbuf_new_from_file_at_scale(filename, 
						48, 48, TRUE, &error);
	else
		picture = gdk_pixbuf_new_from_file(filename, &error);

	g_free(filename);
	if (error) {
		debug_print("Failed to import image: \n%s",
				error->message);
		g_error_free(error);
		return -1;
	}
	if (picture)
		image = gtk_image_new_from_pixbuf(picture);
	else 
		return -1;

	g_object_unref(picture);
	if (image) {
		gtk_box_pack_start(GTK_BOX(hbox), image, FALSE, FALSE, 0);
		gtk_widget_show(image);
	}

	headerview->image = image;
	if (image == NULL)
		return -1;
	else 
		return 0;
#else
	/* new address book */
	return -1;
#endif
}
Пример #20
0
/**
 * @brief destroy widget if destroy signal is passed to widget
 */
static void destroy( GtkWidget *widget, gpointer data ){
	gtk_widget_destroy( widget );
}
Пример #21
0
extern void specific_info_block(popup_info_t *popup_win)
{
	int part_error_code = SLURM_SUCCESS;
	int block_error_code = SLURM_SUCCESS;
	static partition_info_msg_t *part_info_ptr = NULL;
	static block_info_msg_t *block_info_ptr = NULL;
	specific_info_t *spec_info = popup_win->spec_info;
	sview_search_info_t *search_info = spec_info->search_info;
	char error_char[100];
	GtkWidget *label = NULL;
	GtkTreeView *tree_view = NULL;
	List block_list = NULL;
	List send_block_list = NULL;
	sview_block_info_t *block_ptr = NULL;
	int j=0, i=-1;
	hostset_t hostset = NULL;
	ListIterator itr = NULL;

	if (!spec_info->display_widget) {
		setup_popup_info(popup_win, display_data_block, SORTID_CNT);
	}

	if (spec_info->display_widget && popup_win->toggled) {
		gtk_widget_destroy(spec_info->display_widget);
		spec_info->display_widget = NULL;
		goto display_it;
	}

	if ((part_error_code = get_new_info_part(&part_info_ptr,
						 popup_win->force_refresh))
	    == SLURM_NO_CHANGE_IN_DATA) {

	} else if (part_error_code != SLURM_SUCCESS) {
		if (spec_info->view == ERROR_VIEW)
			goto end_it;
		spec_info->view = ERROR_VIEW;
		if (spec_info->display_widget)
			gtk_widget_destroy(spec_info->display_widget);
		sprintf(error_char, "slurm_load_partitions: %s",
			slurm_strerror(slurm_get_errno()));
		label = gtk_label_new(error_char);
		gtk_table_attach_defaults(popup_win->table,
					  label,
					  0, 1, 0, 1);
		gtk_widget_show(label);
		spec_info->display_widget = gtk_widget_ref(label);
		goto end_it;
	}

	if ((block_error_code =
	     get_new_info_block(&block_info_ptr, popup_win->force_refresh))
	    == SLURM_NO_CHANGE_IN_DATA) {
		if ((!spec_info->display_widget
		     || spec_info->view == ERROR_VIEW)
		    || (part_error_code != SLURM_NO_CHANGE_IN_DATA)) {
			goto display_it;
		}
	} else if (block_error_code != SLURM_SUCCESS) {
		if (spec_info->view == ERROR_VIEW)
			goto end_it;
		spec_info->view = ERROR_VIEW;
		if (spec_info->display_widget)
			gtk_widget_destroy(spec_info->display_widget);
		sprintf(error_char, "slurm_load_block: %s",
			slurm_strerror(slurm_get_errno()));
		label = gtk_label_new(error_char);
		gtk_table_attach_defaults(popup_win->table,
					  label,
					  0, 1, 0, 1);
		gtk_widget_show(label);
		spec_info->display_widget = gtk_widget_ref(label);
		goto end_it;
	}

display_it:
	block_list = _create_block_list(part_info_ptr, block_info_ptr);

	if (!block_list)
		return;

	if (spec_info->view == ERROR_VIEW && spec_info->display_widget) {
		gtk_widget_destroy(spec_info->display_widget);
		spec_info->display_widget = NULL;
	}
	if (spec_info->type != INFO_PAGE && !spec_info->display_widget) {
		tree_view = create_treeview(local_display_data,
					    &popup_win->grid_button_list);
		gtk_tree_selection_set_mode(
			gtk_tree_view_get_selection(tree_view),
			GTK_SELECTION_MULTIPLE);
		spec_info->display_widget =
			gtk_widget_ref(GTK_WIDGET(tree_view));
		gtk_table_attach_defaults(popup_win->table,
					  GTK_WIDGET(tree_view),
					  0, 1, 0, 1);
		/* since this function sets the model of the tree_view
		   to the treestore we don't really care about
		   the return value */
		create_treestore(tree_view, popup_win->display_data,
				 SORTID_CNT, SORTID_BLOCK, SORTID_COLOR);
	}

	setup_popup_grid_list(popup_win);
	spec_info->view = INFO_VIEW;
	if (spec_info->type == INFO_PAGE) {
		_display_info_block(block_list, popup_win);
		goto end_it;
	}

	/* just linking to another list, don't free the inside, just
	   the list */
	send_block_list = list_create(NULL);
	itr = list_iterator_create(block_list);
	i = -1;
	while ((block_ptr = list_next(itr))) {
		/* we want to over ride any subgrp in error
		   state */
		enum node_states state = NODE_STATE_UNKNOWN;
		char *name = NULL;

		i++;
		switch(spec_info->type) {
		case PART_PAGE:
			if (xstrcmp(block_ptr->slurm_part_name,
				    search_info->gchar_data))
				continue;
			break;
		case RESV_PAGE:
		case NODE_PAGE:
			if (!block_ptr->mp_str)
				continue;
			if (!(hostset = hostset_create(
				      search_info->gchar_data)))
				continue;
			name = block_ptr->mp_str;
			if (block_ptr->small_block) {
				int j=0;
				/* strip off the ionodes part */
				while (name[j]) {
					if (name[j] == '[') {
						name[j] = '\0';
						break;
					}
					j++;
				}
			}

			if (!hostset_intersects(hostset, name)) {
				hostset_destroy(hostset);
				continue;
			}
			hostset_destroy(hostset);
			break;
		case BLOCK_PAGE:
			switch(search_info->search_type) {
			case SEARCH_BLOCK_NAME:
				if (!search_info->gchar_data)
					continue;

				if (xstrcmp(block_ptr->bg_block_name,
					    search_info->gchar_data))
					continue;
				break;
			case SEARCH_BLOCK_SIZE:
				if (search_info->int_data == NO_VAL)
					continue;
				if (block_ptr->cnode_cnt
				    != search_info->int_data)
					continue;
				break;
			case SEARCH_BLOCK_STATE:
				if (search_info->int_data == NO_VAL)
					continue;
				if (block_ptr->state != search_info->int_data)
					continue;

				break;
			default:
				continue;
				break;
			}
			break;
		case JOB_PAGE:
			if (xstrcmp(block_ptr->bg_block_name,
				    search_info->gchar_data))
				continue;
			break;
		default:
			g_print("Unknown type %d\n", spec_info->type);
			continue;
		}
		list_push(send_block_list, block_ptr);

		if (block_ptr->state & BG_BLOCK_ERROR_FLAG)
			state = NODE_STATE_ERROR;
		else if (list_count(block_ptr->job_list))
			state = NODE_STATE_ALLOCATED;
		else
			state = NODE_STATE_IDLE;

		j=0;
		while (block_ptr->mp_inx[j] >= 0) {
			change_grid_color(
				popup_win->grid_button_list,
				block_ptr->mp_inx[j],
				block_ptr->mp_inx[j+1], block_ptr->color_inx,
				true, state);
			j += 2;
		}
	}
	list_iterator_destroy(itr);
	post_setup_popup_grid_list(popup_win);

	_update_info_block(send_block_list,
			   GTK_TREE_VIEW(spec_info->display_widget));
	FREE_NULL_LIST(send_block_list);
end_it:
	popup_win->toggled = 0;
	popup_win->force_refresh = 0;

	return;
}