GtkWidget* create_WaitWindow (void) { GtkWidget *WaitWindow; GtkWidget *fixed1; GtkWidget *CancelButton; GtkWidget *alignment1; GtkWidget *hbox1; GtkWidget *image1; GtkWidget *label2; WaitWindow = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_title (GTK_WINDOW (WaitWindow), "Waiting for user"); fixed1 = gtk_fixed_new (); gtk_widget_show (fixed1); gtk_container_add (GTK_CONTAINER (WaitWindow), fixed1); gtk_widget_set_size_request (fixed1, 400, 40); MessageLabel = gtk_label_new ("Waiting for user to connect."); gtk_widget_show (MessageLabel); gtk_fixed_put (GTK_FIXED (fixed1), MessageLabel, 0, 0); gtk_widget_set_size_request (MessageLabel, 400, 16); CancelButton = gtk_button_new (); gtk_widget_show (CancelButton); gtk_fixed_put (GTK_FIXED (fixed1), CancelButton, 160, 16); gtk_widget_set_size_request (CancelButton, 88, 24); alignment1 = gtk_alignment_new (0.5, 0.5, 0, 0); gtk_widget_show (alignment1); gtk_container_add (GTK_CONTAINER (CancelButton), alignment1); hbox1 = gtk_hbox_new (FALSE, 2); gtk_widget_show (hbox1); gtk_container_add (GTK_CONTAINER (alignment1), hbox1); image1 = gtk_image_new_from_stock ("gtk-cancel", GTK_ICON_SIZE_BUTTON); gtk_widget_show (image1); gtk_box_pack_start (GTK_BOX (hbox1), image1, FALSE, FALSE, 0); label2 = gtk_label_new_with_mnemonic ("Cancel"); gtk_widget_show (label2); gtk_box_pack_start (GTK_BOX (hbox1), label2, FALSE, FALSE, 0); g_signal_connect ((gpointer) CancelButton, "clicked", G_CALLBACK (on_CancelButton_clicked), NULL); /* Store pointers to all widgets, for use by lookup_widget(). */ GLADE_HOOKUP_OBJECT_NO_REF (WaitWindow, WaitWindow, "WaitWindow"); GLADE_HOOKUP_OBJECT (WaitWindow, fixed1, "fixed1"); GLADE_HOOKUP_OBJECT (WaitWindow, MessageLabel, "MessageLabel"); GLADE_HOOKUP_OBJECT (WaitWindow, CancelButton, "CancelButton"); GLADE_HOOKUP_OBJECT (WaitWindow, alignment1, "alignment1"); GLADE_HOOKUP_OBJECT (WaitWindow, hbox1, "hbox1"); GLADE_HOOKUP_OBJECT (WaitWindow, image1, "image1"); GLADE_HOOKUP_OBJECT (WaitWindow, label2, "label2"); gtk_timeout_add(50, connect_wait, WaitWindow); return WaitWindow; }
cartesianMover::cartesianMover(GtkWidget *vbox_d, PolyDriver *partDd_d, char *partName, ResourceFinder *fnd) { finder = fnd; if (!finder->isNull()) fprintf(stderr, "Setting a valid finder \n"); partLabel = partName; partDd = partDd_d; vbox = vbox_d; interfaceError = false; if (!partDd->isValid()) { fprintf(stderr, "Device given to the cartesian interface is not available.\n"); interfaceError = true; } fprintf(stderr, "Opening crt interface..."); bool ok; ok = partDd->view(crt); if ((!ok) || (crt==0)) fprintf(stderr, "...crt was not ok...ok=%d", ok); if (!partDd->isValid()) { fprintf(stderr, "Cartesian device driver was not valid! \n"); dialog_severe_error(GTK_MESSAGE_ERROR,(char *) "Cartesian device not available.", (char *) "Check available devices", true); interfaceError = true; } else if (!ok) { fprintf(stderr, "Error while acquiring cartesian interfaces \n"); dialog_severe_error(GTK_MESSAGE_ERROR,(char *) "Problems acquiring cartesian interface", (char *) "Check if cartesian interface is running", true); interfaceError = true; } if (interfaceError == false) { fprintf(stderr, "Allocating memory \n"); int j,k; index = new int [MAX_NUMBER_OF_JOINTS]; entry_id = new guint [0]; *entry_id = -1; frame_slider1 = new GtkWidget* [MAX_NUMBER_OF_JOINTS]; sliderArray = new GtkWidget* [NUMBER_OF_CARTESIAN_COORDINATES]; currPosArray = new GtkWidget* [NUMBER_OF_CARTESIAN_COORDINATES]; //fprintf(stderr, "sliderArray has address 0x%x\n", (unsigned int) sliderArray); GtkWidget *top_hbox = NULL; GtkWidget *bottom_hbox = NULL; GtkWidget *panel_hbox = NULL; GtkWidget *inv1 = NULL; GtkWidget *invArray[NUMBER_OF_CARTESIAN_COORDINATES]; GtkWidget *homeArray[NUMBER_OF_CARTESIAN_COORDINATES]; GtkWidget *framesArray[NUMBER_OF_CARTESIAN_COORDINATES]; GtkWidget *sw = NULL; //creation of the top_hbox top_hbox = gtk_hbox_new (FALSE, 0); gtk_container_set_border_width (GTK_CONTAINER (top_hbox), 10); gtk_container_add (GTK_CONTAINER (vbox), top_hbox); inv1 = gtk_fixed_new (); gtk_container_add (GTK_CONTAINER (top_hbox), inv1); Vector o; Vector x; while (!crt->getPose(x,o)) Time::delay(0.001); Matrix R = axis2dcm(o); Vector eu = dcm2euler(R); //x(0) = 1; x(1) = 1; x(2) = 1; //o(0) = 1; o(1) = 0; o(2) = 0; o(3) = 0; char buffer[40] = {'i', 'n', 'i', 't'}; int numberOfRows = 3; int height, width; height = 100; width = 180; double min,max; std::string limitString=partLabel; limitString=limitString+"_workspace"; Bottle bCartesianLimits; if (finder->check(limitString.c_str())) { //fprintf(stderr, "There seem limits for %s", partLabel); bCartesianLimits = finder->findGroup(limitString.c_str()); //fprintf(stderr, "...got: %s", bCartesianLimits.toString().c_str()); } fprintf(stderr, "Starting embedding cartesian GUI widgets \n"); for (k = 0; k<NUMBER_OF_CARTESIAN_COORDINATES; k++) { //fprintf(stderr, "Adding invArray \n"); invArray[k] = gtk_fixed_new (); index[k]=k; j = k/numberOfRows; if (k==0) { sprintf(buffer, "x"); if (bCartesianLimits.check("xmin") && bCartesianLimits.check("xmax")) { min = bCartesianLimits.find("xmin").asDouble(); max = bCartesianLimits.find("xmax").asDouble(); } else { min = x(0) - 0.1 * fabs(x(0)); max = x(0) + 0.1 * fabs(x(0)); } } if (k==1) { sprintf(buffer, "y"); if (bCartesianLimits.check("ymin") && bCartesianLimits.check("ymax")) { min = bCartesianLimits.find("ymin").asDouble(); max = bCartesianLimits.find("ymax").asDouble(); } else { min = x(1) - 0.1 * fabs(x(1)); max = x(1) + 0.1 * fabs(x(1)); } } if (k==2) { sprintf(buffer, "z"); if (bCartesianLimits.check("zmin") && bCartesianLimits.check("zmax")) { min = bCartesianLimits.find("zmin").asDouble(); max = bCartesianLimits.find("zmax").asDouble(); } else { min = x(2) - 0.1 * fabs(x(2)); max = x(2) + 0.1 * fabs(x(2)); } } if (k==3) { sprintf(buffer, "euler-alpha"); min = -180; max = 180; } if (k==4) { sprintf(buffer, "euler-beta"); min = -180; max = 180; } if (k==5) { sprintf(buffer, "euler-gamma"); min = -180; max = 180; } frame_slider1[k] = gtk_frame_new ("Value:"); //fprintf(stderr, "Initializing sliders %d \n",k); if (min<max) { sliderArray[k] = gtk_hscale_new_with_range(min, max, 1); if (k<3) gtk_scale_set_digits((GtkScale*) sliderArray[k],2); else gtk_scale_set_digits((GtkScale*) sliderArray[k],1); } else { sliderArray[k] = gtk_hscale_new_with_range(1, 2, 1); if (k<3) gtk_scale_set_digits((GtkScale*) sliderArray[k],2); else gtk_scale_set_digits((GtkScale*) sliderArray[k],1); } currPosArray[k] = gtk_entry_new(); //fprintf(stderr, "Initializing the buttons %d \n", k); homeArray[k] = gtk_button_new_with_mnemonic ("Home"); //fprintf(stderr, "Initializing frames %d \n", k); framesArray[k] = gtk_frame_new (buffer); gtk_fixed_put (GTK_FIXED(inv1), invArray[k], 0+(k%numberOfRows)*width, 0+ j*height); //Positions //fprintf(stderr, "Positioning buttons %d \n", k); gtk_fixed_put (GTK_FIXED(invArray[k]), frame_slider1[k], 60, 10 ); gtk_fixed_put (GTK_FIXED(invArray[k]), sliderArray[k], 65, 20 ); gtk_fixed_put (GTK_FIXED(invArray[k]), currPosArray[k], 95, 70); int buttonDist= 24; int buttonOffset = 13; gtk_fixed_put (GTK_FIXED(invArray[k]), homeArray[k], 6, buttonOffset); gtk_fixed_put (GTK_FIXED(invArray[k]), framesArray[k], 0, 0); //Dimensions //fprintf(stderr, "Dimensioning buttons %d \n", k); gtk_widget_set_size_request (frame_slider1[k], 110, 50); gtk_widget_set_size_request (sliderArray[k], 90, 40); gtk_widget_set_size_request (currPosArray[k], 70, 20); gtk_widget_set_size_request (homeArray[k], 50, 25); gtk_widget_set_size_request (framesArray[k], width, height); /* * Positions commands */ //fprintf(stderr, "Assinging callback %d \n", k); gtk_range_set_update_policy ((GtkRange *) (sliderArray[k]), GTK_UPDATE_DISCONTINUOUS); if (k<3) gtk_range_set_value ((GtkRange *) (sliderArray[k]), x(k)); if (k>=3 && k <= 5) gtk_range_set_value ((GtkRange *) (sliderArray[k]), eu(k-3) * 180/M_PI); g_signal_connect (sliderArray[k], "value-changed", G_CALLBACK(position_slider_changed), this); } /* * Display current position */ *entry_id = gtk_timeout_add(UPDATE_TIME, (GtkFunction) display_cartesian_pose, this); for (k = 0; k<NUMBER_OF_CARTESIAN_COORDINATES; k++) gtk_editable_set_editable ((GtkEditable*) currPosArray[k], FALSE); /* * Common commands */ GtkWidget *frame3; frame3 = gtk_frame_new ("Commands:"); gtk_fixed_put (GTK_FIXED(inv1), frame3, (NUMBER_OF_CARTESIAN_COORDINATES%numberOfRows)*width, (NUMBER_OF_CARTESIAN_COORDINATES/numberOfRows)*height); gtk_widget_set_size_request (frame3, 180, 240); //Button 0 in the panel GtkWidget *button0 = gtk_button_new_with_mnemonic ("Open sequence tab"); gtk_fixed_put (GTK_FIXED (inv1), button0, 10+(NUMBER_OF_CARTESIAN_COORDINATES%numberOfRows)*width, 20+(NUMBER_OF_CARTESIAN_COORDINATES/numberOfRows)*height); gtk_widget_set_size_request (button0, 150, 25); fprintf(stderr, "Initializing the table \n"); init_cartesian_table(); fprintf(stderr, "Connecting the callbacks for the table \n"); g_signal_connect (button0, "clicked", G_CALLBACK (cartesian_table_open), this); //Button1 in the panel GtkWidget *button1 = gtk_button_new_with_mnemonic ("Stop"); gtk_fixed_put (GTK_FIXED (inv1), button1, 10+(NUMBER_OF_CARTESIAN_COORDINATES%numberOfRows)*width, 45+(NUMBER_OF_CARTESIAN_COORDINATES/numberOfRows)*height); gtk_widget_set_size_request (button1, 150, 25); //g_signal_connect (button1, "clicked", G_CALLBACK (stop_motion), crt); //Velocity GtkWidget *frame7; frame7 = gtk_frame_new ("Time[sec]:"); gtk_fixed_put (GTK_FIXED(inv1), frame7, 5+(NUMBER_OF_CARTESIAN_COORDINATES%numberOfRows)*width, 70 + (NUMBER_OF_CARTESIAN_COORDINATES/numberOfRows)*height); gtk_widget_set_size_request (frame7, 160, 50); sliderVelocity = new GtkWidget; sliderVelocity = gtk_hscale_new_with_range(1, 10, 1); gtk_scale_set_digits((GtkScale*) sliderVelocity,2); gtk_fixed_put (GTK_FIXED(inv1), sliderVelocity, 60+(NUMBER_OF_CARTESIAN_COORDINATES%numberOfRows)*width, 80 + (NUMBER_OF_CARTESIAN_COORDINATES/numberOfRows)*height); gtk_widget_set_size_request (sliderVelocity, 90, 40); gtk_range_set_update_policy ((GtkRange *) (sliderVelocity), GTK_UPDATE_DISCONTINUOUS); gtk_range_set_value ((GtkRange *) (sliderVelocity), 2); //Diplay axis po = new GtkWidget*[4]; for (int i=0; i < 4; i++) { po[i] = gtk_entry_new(); } //Display axis GtkWidget *frame5; frame5 = gtk_frame_new ("Axis:"); gtk_fixed_put (GTK_FIXED(inv1), frame5, 5+(NUMBER_OF_CARTESIAN_COORDINATES%numberOfRows)*width, 140 + (NUMBER_OF_CARTESIAN_COORDINATES/numberOfRows)*height); gtk_widget_set_size_request (frame5, 80, 85); gtk_fixed_put (GTK_FIXED(inv1), po[0], 10+(NUMBER_OF_CARTESIAN_COORDINATES%numberOfRows)*width, 155+(NUMBER_OF_CARTESIAN_COORDINATES/numberOfRows)*height); gtk_fixed_put (GTK_FIXED(inv1), po[1], 10+(NUMBER_OF_CARTESIAN_COORDINATES%numberOfRows)*width, 175+(NUMBER_OF_CARTESIAN_COORDINATES/numberOfRows)*height); gtk_fixed_put (GTK_FIXED(inv1), po[2], 10+(NUMBER_OF_CARTESIAN_COORDINATES%numberOfRows)*width, 195+(NUMBER_OF_CARTESIAN_COORDINATES/numberOfRows)*height); //Display angle GtkWidget *frame6; frame6 = gtk_frame_new ("Angle:"); gtk_fixed_put (GTK_FIXED(inv1), frame6, 85+(NUMBER_OF_CARTESIAN_COORDINATES%numberOfRows)*width, 155 + (NUMBER_OF_CARTESIAN_COORDINATES/numberOfRows)*height); gtk_widget_set_size_request (frame6, 80, 45); gtk_fixed_put (GTK_FIXED(inv1), po[3], 90+(NUMBER_OF_CARTESIAN_COORDINATES%numberOfRows)*width, 175+(NUMBER_OF_CARTESIAN_COORDINATES/numberOfRows)*height); for (int i=0; i < 4; i++) { gtk_widget_set_size_request (po[i], 70, 20); gtk_editable_set_editable ((GtkEditable*) po[i], FALSE); } *entry_id = gtk_timeout_add(UPDATE_TIME, (GtkFunction) display_axis_pose, this); //CheckButton in the panel GtkWidget *check= gtk_check_button_new_with_mnemonic ("Tracking Mode"); gtk_fixed_put (GTK_FIXED (inv1), check, 10+(NUMBER_OF_CARTESIAN_COORDINATES%numberOfRows)*width, 120+(NUMBER_OF_CARTESIAN_COORDINATES/numberOfRows)*height); gtk_widget_set_size_request (check, 150, 25); //g_signal_connect (check, "clicked", G_CALLBACK (toggle_tracking_mode), crt); } }
int main(int argc, char **argv){ // GtkWidget *cyc_lab1, *cyc_lab2, *cyc_lab3, *cyc_lab4; int mapped=0; /* Shared memory creation and attachment the segment number is stored in lnptr->pid */ mapped = mmapSetup(); if (mapped == -1) { printf(" Error on setting up memory map ... exiting \n"); return 0; } time0 = time(NULL); gtk_init (&argc, &argv); // mandatory for gtk applications window = gtk_window_new (GTK_WINDOW_TOPLEVEL); // creates new window gtk_window_set_title (GTK_WINDOW (window),"CONTROLS STATUS"); // sets title of window gtk_container_set_border_width (GTK_CONTAINER(window),1); // sets border width fixed = gtk_fixed_new(); // create a container to hold future widgets gtk_container_add(GTK_CONTAINER(window), fixed); // I must determine position of all widgets g_signal_connect (window, "delete-event",G_CALLBACK (delete_event), NULL); // handler to exit gtk /* draw and expose-event redraws on any event including mouse movement. They are usually needed in programs. But in this program I am renewing the widgets on a timer based on eitehr 50 or 100 ms */ g_signal_connect (window, "draw", G_CALLBACK (on_expose_event), NULL); // gtk3 - //g_signal_connect (window, "expose-event", G_CALLBACK (on_expose_event), NULL); // gtk2 from cairo example window -> frame1 g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL); // from cairo example window -> frame1 gtk_window_set_default_size(GTK_WINDOW(window), 300, 500); // from cairo example window -> frame1 /* track the number of cycles - create the text - create the widget containing the text - define the location of the widget in the widget fixed */ tapeMode(); /* sprintf(txt6,"Total cycles: %li",numCycles); cyc_labtotal = gtk_label_new(txt6); gtk_fixed_put(GTK_FIXED(fixed),cyc_labtotal,20,20); sprintf(txt7,"Data cycles: %li",numData); cyc_labdata = gtk_label_new(txt7); gtk_fixed_put(GTK_FIXED(fixed),cyc_labdata,20,40); sprintf(txt8,"Bkg cycles: %li",numBkg); cyc_labbkg = gtk_label_new(txt8); gtk_fixed_put(GTK_FIXED(fixed),cyc_labbkg,20,60); if (bkgCycle == bkg) sprintf(txt9,"Current cycle: BKG"); else sprintf(txt9,"Current cycle: DATA %i", bkgCycle); cyc_labnow = gtk_label_new(txt9); gtk_fixed_put(GTK_FIXED(fixed),cyc_labnow,20,80); gtk_widget_show(cyc_lab1); gtk_widget_show(cyc_lab2); gtk_widget_show(cyc_lab3); gtk_widget_show(cyc_lab4); */ /* Show all in window */ g_timeout_add(REFRESH, (GSourceFunc) time_handler, (gpointer) fixed); // timer to refresh widget "fixed" gtk_widget_show_all (window); // show windows before stating timer loop time_handler(fixed); gtk_main (); /* Ending the program so release the memory map and close file */ if (munmap(mtcptr, sizeof (struct mtc*)) == -1) { perror("Error un-mapping the file"); } close(mapped); printf(" File closed and file unmapped \n"); return 0; }
static void gtkTabsChildAddedMethod(Ihandle* ih, Ihandle* child) { if (IupGetName(child) == NULL) iupAttribSetHandleName(child); if (ih->handle) { GtkWidget *tab_page, *tab_container; GtkWidget *tab_label = NULL, *tab_image = NULL; char *tabtitle, *tabimage; int pos; unsigned char r, g, b; pos = IupGetChildPos(ih, child); tab_page = gtk_vbox_new(FALSE, 0); gtk_widget_show(tab_page); tab_container = gtk_fixed_new(); gtk_widget_show(tab_container); gtk_container_add((GtkContainer*)tab_page, tab_container); tabtitle = iupAttribGet(child, "TABTITLE"); if (!tabtitle) tabtitle = iupTabsAttribGetStrId(ih, "TABTITLE", pos); tabimage = iupAttribGet(child, "TABIMAGE"); if (!tabimage) tabimage = iupTabsAttribGetStrId(ih, "TABIMAGE", pos); if (!tabtitle && !tabimage) tabtitle = " "; if (tabtitle) { tab_label = gtk_label_new(iupgtkStrConvertToUTF8(tabtitle)); #if GTK_CHECK_VERSION(2, 6, 0) if (ih->data->orientation == ITABS_VERTICAL) gtk_label_set_angle((GtkLabel*)tab_label, 90); #endif } if (tabimage) { GdkPixbuf* pixbuf = iupImageGetImage(tabimage, ih, 0); tab_image = gtk_image_new(); if (pixbuf) gtk_image_set_from_pixbuf((GtkImage*)tab_image, pixbuf); } iupAttribSetStr(ih, "_IUPGTK_IGNORE_CHANGE", "1"); if (tabimage && tabtitle) { GtkWidget* box; if (ih->data->orientation == ITABS_VERTICAL) box = gtk_vbox_new(FALSE, 2); else box = gtk_hbox_new(FALSE, 2); gtk_widget_show(box); gtk_container_add((GtkContainer*)box, tab_image); gtk_container_add((GtkContainer*)box, tab_label); gtk_notebook_insert_page((GtkNotebook*)ih->handle, tab_page, box, pos); gtk_notebook_set_menu_label_text((GtkNotebook*)ih->handle, tab_page, gtk_label_get_text((GtkLabel*)tab_label)); } else if (tabimage) gtk_notebook_insert_page((GtkNotebook*)ih->handle, tab_page, tab_image, pos); else gtk_notebook_insert_page((GtkNotebook*)ih->handle, tab_page, tab_label, pos); gtk_widget_realize(tab_page); iupAttribSetStr(child, "_IUPGTK_TABIMAGE", (char*)tab_image); /* store it even if its NULL */ iupAttribSetStr(child, "_IUPGTK_TABLABEL", (char*)tab_label); iupAttribSetStr(child, "_IUPTAB_CONTAINER", (char*)tab_container); iupAttribSetStr(child, "_IUPTAB_PAGE", (char*)tab_page); iupStrToRGB(IupGetAttribute(ih, "BGCOLOR"), &r, &g, &b); iupgtkBaseSetBgColor(tab_container, r, g, b); if (tabtitle) { PangoFontDescription* fontdesc = (PangoFontDescription*)iupgtkGetPangoFontDescAttrib(ih); gtk_widget_modify_font(tab_label, fontdesc); iupgtkFontUpdatePangoLayout(ih, gtk_label_get_layout((GtkLabel*)tab_label)); iupgtkBaseSetBgColor(tab_label, r, g, b); iupStrToRGB(IupGetAttribute(ih, "FGCOLOR"), &r, &g, &b); iupgtkBaseSetFgColor(tab_label, r, g, b); gtk_widget_show(tab_label); gtk_widget_realize(tab_label); } if (tabimage) { gtk_widget_show(tab_image); gtk_widget_realize(tab_image); } iupAttribSetStr(ih, "_IUPGTK_IGNORE_CHANGE", NULL); if (pos != iupdrvTabsGetCurrentTab(ih)) gtk_widget_hide(tab_container); } }
int draw_kbd() { GtkWidget *kbd_window = NULL; GtkWidget *vbox = NULL; GtkWidget *line = NULL; GtkWidget *frame = NULL; GtkWidget *fixed = NULL; GtkWidget *hbox = NULL; GtkWidget *btn_ng = NULL; GdkColor kbd_color = {0, 0xbd10, 0xbd10, 0xbd10}; // counters int i = 0, j = 0, k = 0, sum = 0; int keynum = 0; // adjust every row buttons position. int x = 0; // the initial coordinate int initx = 0, inity = 0; // the key size. int w1 = 50, h1 = 40; int w2 = 54, h2 = 54; int w3 = 74; int w4 = 94; int w5 = 108; int w6 = 270; // the vertical position of key. int start_pair[LINE_KEY][3] = { {10, 1, h1}, {10 + h1, 1, h2}, {10 + h1 + h2, 1, h2}, {10 + h1 + 2 * h2, 1, h2}, {10 + h1 + 3 * h2, 1, h2}, {10 + h1 + 4 * h2, 1, h2} }; // the horizontal position of key. int rules[LINE_KEY][12] = { {17, w1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, // 17 {13, w2, 1, w4, 1, w2, -1, -1, -1, -1, -1, -1}, // 15 {1, w3, 12, w2, 1, w3, 1, w2, -1, -1, -1, -1}, // 15 {1, w4, 11, w2, 1, w5, 1, w2, -1, -1, -1, -1}, // 14 {1, w5, 10, w2, 1, w4, 2, w2, -1, -1, -1, -1}, // 14 {1, w3, 3, w2, 1, w6, 2, w2, 1, w3, 3, w2} // 11 }; if (!kbd_window) { kbd_window = gtk_window_new(GTK_WINDOW_POPUP); gtk_widget_modify_bg (kbd_window, GTK_STATE_NORMAL, &kbd_color); gtk_window_set_resizable(GTK_WINDOW(kbd_window), FALSE); gtk_window_set_title(GTK_WINDOW(kbd_window), "Kbd Test"); gtk_container_set_border_width(GTK_CONTAINER(kbd_window), 10); gtk_window_set_position(GTK_WINDOW(kbd_window), GTK_WIN_POS_CENTER); g_signal_connect(G_OBJECT(kbd_window), "key-press-event", G_CALLBACK(kbd_test_cb), NULL); g_signal_connect(G_OBJECT(kbd_window), "key-release-event", G_CALLBACK(kbd_test_cb), NULL); vbox = gtk_vbox_new(FALSE, 5); gtk_container_add(GTK_CONTAINER(kbd_window), vbox); label = gtk_label_new("键盘测试:请按指示颜色操作;不测试Fn键。"); gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 1); line = gtk_hseparator_new(); gtk_box_pack_start(GTK_BOX(vbox), line, FALSE, FALSE, 1); frame = gtk_frame_new("Keyboard Test Program"); gtk_frame_set_label_align(GTK_FRAME(frame), 0.5, 0.5); gtk_box_pack_start(GTK_BOX(vbox), frame, FALSE, FALSE, 1); fixed = gtk_fixed_new(); gtk_container_add(GTK_CONTAINER(frame), fixed); for(i = 0; i < LINE_KEY; ++i) { x = initx; for(j = 0; j < 12 / 2; ++j) { if (rules[i][2 * j] == -1) { break; } sum = rules[i][2 * j]; for (k = 0; k < sum; ++k) { button[keynum] = gtk_button_new_with_label(keyname[keynum]); gtk_widget_set_size_request(button[keynum], rules[i][2 * j + 1], start_pair[i][2]); gtk_fixed_put(GTK_FIXED(fixed), button[keynum], x, inity + start_pair[i][0]); x += rules[i][2 * j + 1]; ++keynum; } } } } gtk_widget_modify_bg (button[0], GTK_STATE_NORMAL, &btn_guide_color); gtk_widget_modify_bg (button[0], GTK_STATE_SELECTED, &btn_guide_color); gtk_widget_modify_bg (button[0], GTK_STATE_PRELIGHT, &btn_guide_color); hbox = gtk_hbox_new(FALSE, 5); gtk_box_pack_end(GTK_BOX(vbox), hbox, FALSE, FALSE, 1); btn_ng = gtk_button_new_with_label("NG"); gtk_box_pack_end(GTK_BOX(hbox), btn_ng, FALSE, FALSE, 1); g_signal_connect(G_OBJECT(btn_ng), "clicked", G_CALLBACK(kbd_ng_func), (gpointer)kbd_window); gtk_widget_show_all(kbd_window); gdk_keyboard_grab (kbd_window->window, TRUE, GDK_CURRENT_TIME); gtk_main(); return 0; }
int _tmain(int argc, _TCHAR* argv[]) { TABVIEW* my_tabview; GtkWidget *label; gchar *markup; int m_argc=1; char* commandLine={"gtkApplication"}; char** m_argv = &commandLine; GtkWidget* page1EventBox,*page2EventBox,*page3EventBox,*fixed,*fixed2,*fixed3; int i = 0; int pos_x = 0; int pos_y = 0; GtkWidget* window,*windowfixed; GdkColor black; GdkColor white; GdkColor blue; GdkColor yellow; GdkColor custom; gdk_color_parse("black", &black); gdk_color_parse("white", &white); gdk_color_parse("yellow", &yellow); gdk_color_parse("#09181F", &blue); gdk_color_parse("#063087", &active); gdk_color_parse("#060087", &prelight); gdk_color_parse("#203087", &selected); gdk_color_parse("#300006", &insensitive); gtk_init (&m_argc, &m_argv); window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_title(GTK_WINDOW(window),"tab"); windowfixed = gtk_fixed_new(); gtk_widget_set_usize(window,400,300); my_tabview = ZJ_Create_TabView(50,10,200,280); set_widget_bc_pixmap(window,"./pixmaps/bg.png",NULL,NULL); gtk_fixed_put((GtkFixed*)windowfixed,my_tabview->TabViewFixed,50,10); //gtk_widget_set_uposition(my_tabview->TabViewFixed,50,10); gtk_container_add((GtkContainer*)window,windowfixed); gtk_fixed_set_has_window((GtkFixed *)my_tabview->TabViewFixed,1); set_widget_bc_pixmap((GtkWidget *)my_tabview->TabViewFixed,"./pixmaps/bg.png",NULL,NULL); page1EventBox = gtk_event_box_new(); gtk_widget_set_usize((GtkWidget *)page1EventBox,80,80); label = gtk_label_new("andrews"); markup = g_markup_printf_escaped ("<span font_desc='Microsoft YaHei 12' foreground=\"#00FF00\">%s</span>",\ g_locale_to_utf8("andrews", -1, NULL, NULL, NULL)); gtk_label_set_markup (GTK_LABEL (label), markup); g_free (markup); gtk_container_add (GTK_CONTAINER (page1EventBox), label); page2EventBox = gtk_event_box_new(); gtk_widget_set_usize((GtkWidget *)page2EventBox,80,80); label = gtk_label_new("pack"); markup = g_markup_printf_escaped ("<span font_desc='Microsoft YaHei 12' foreground=\"#00FF00\">%s</span>",\ g_locale_to_utf8("pack", -1, NULL, NULL, NULL)); gtk_label_set_markup (GTK_LABEL (label), markup); g_free (markup); gtk_container_add (GTK_CONTAINER (page2EventBox), label); page3EventBox = gtk_event_box_new(); gtk_widget_set_usize((GtkWidget *)page3EventBox,80,80); label = gtk_label_new("mj"); markup = g_markup_printf_escaped ("<span font_desc='Microsoft YaHei 12' foreground=\"#00FF00\">%s</span>",\ g_locale_to_utf8("mj", -1, NULL, NULL, NULL)); gtk_label_set_markup (GTK_LABEL (label), markup); g_free (markup); gtk_container_add (GTK_CONTAINER (page3EventBox), label); //gtk_widget_modify_bg(my_tabview->TabViewWindow, GTK_STATE_NORMAL, &custom); //newWindow = gtk_window_new(GTK_WINDOW_TOPLEVEL); fixed = gtk_fixed_new(); //gtk_fixed_set_has_window((GtkFixed *)fixed,1); ///gtk_widget_set_usize((GtkWidget *)fixed,200,200); //set_widget_bc_pixmap((GtkWidget *)fixed,"./pixmaps/tvbg.png",NULL,NULL); ZJ_TabView_append_page(my_tabview,fixed,page1EventBox); //gtk_widget_set_uposition((GtkWidget *)(fixed),0,40); //gtk_container_add((GtkContainer *)my_tabview->TabViewFixed,fixed); //gtk_fixed_put((GtkFixed*)my_tabview->TabViewFixed,fixed,0,40); //gtk_widget_modify_base(page1EventBox, GTK_STATE_NORMAL, &prelight); //gtk_widget_modify_bg(page1EventBox, GTK_STATE_ACTIVE, &active); //gtk_widget_modify_bg(page1EventBox, GTK_STATE_PRELIGHT, &prelight); //gtk_widget_modify_bg(page1EventBox, GTK_STATE_SELECTED, &selected); //gtk_widget_modify_bg(page1EventBox, GTK_STATE_INSENSITIVE, &insensitive); ////gtk_widget_modify_bg(fixed, GTK_STATE_NORMAL, &white); for(i = 0;i<1;i++) { gchar *markup; GtkWidget *eventbox = gtk_event_box_new (); gtk_widget_set_app_paintable (GTK_WIDGET (eventbox), TRUE); gtk_container_add (GTK_CONTAINER (fixed), eventbox); //set_widget_bc_pixmap((GtkWidget*)eventbox,TP_COMMON_BTN_NORMAL_IMG,NULL,NULL); gtk_widget_set_size_request (GTK_WIDGET (eventbox), 80, 80); gtk_widget_modify_bg(eventbox, GTK_STATE_NORMAL, &yellow); //gtk_widget_set_uposition(eventbox,pos_x,pos_y); gtk_fixed_put((GtkFixed*)fixed,eventbox,pos_x,pos_y); label = gtk_label_new("test"); markup = g_markup_printf_escaped ("<span font_desc='Microsoft YaHei 12' foreground=\"#00FF00\">%s</span>",\ g_locale_to_utf8("test", -1, NULL, NULL, NULL)); gtk_label_set_markup (GTK_LABEL (label), markup); g_free (markup); gtk_container_add (GTK_CONTAINER (eventbox), label); if(pos_x<400) { pos_x+=120+20; } else { pos_x = 125; pos_y += 80+20; } } fixed2 = gtk_fixed_new(); ZJ_TabView_append_page(my_tabview,fixed2,page2EventBox); for(i = 0;i<1;i++) { GtkStyle* style; gchar *markup; GtkWidget *eventbox = gtk_button_new (); pos_x = 0; pos_y = 0; gtk_widget_set_app_paintable (GTK_WIDGET (eventbox), TRUE); gtk_container_add (GTK_CONTAINER (fixed2), eventbox); //set_widget_bc_pixmap((GtkWidget*)eventbox,TP_COMMON_BTN_NORMAL_IMG,NULL,NULL); gtk_widget_set_size_request (GTK_WIDGET (eventbox), 80, 80); gtk_widget_modify_bg(eventbox, GTK_STATE_NORMAL, &yellow); //gtk_widget_set_uposition(eventbox,pos_x,pos_y); //gtk_fixed_put((GtkFixed*)fixed2,eventbox,pos_x,pos_y); gtk_widget_modify_bg(eventbox, GTK_STATE_ACTIVE, &active); gtk_widget_modify_bg(eventbox, GTK_STATE_PRELIGHT, &prelight); gtk_widget_modify_bg(eventbox, GTK_STATE_SELECTED, &selected); gtk_widget_modify_bg(eventbox, GTK_STATE_INSENSITIVE, &insensitive); /* label = gtk_label_new("pack"); markup = g_markup_printf_escaped ("<span font_desc='Microsoft YaHei 12' foreground=\"#00FF00\">%s</span>",\ g_locale_to_utf8("pack", -1, NULL, NULL, NULL)); gtk_label_set_markup (GTK_LABEL (label), markup); g_free (markup); gtk_container_add (GTK_CONTAINER (eventbox), label);*/ if(pos_x<400) { pos_x+=120+20; } else { pos_x = 125; pos_y += 80+20; } } // fixed3 = gtk_fixed_new(); //ZJ_TabView_append_page(my_tabview,fixed3,page3EventBox); // //for(i = 0;i<1;i++) //{ // GtkStyle* style; // gchar *markup; // GtkWidget *eventbox = gtk_event_box_new (); // pos_x = 0; // pos_y = 0; // gtk_widget_set_app_paintable (GTK_WIDGET (eventbox), TRUE); // gtk_container_add (GTK_CONTAINER (fixed3), eventbox); // //set_widget_bc_pixmap((GtkWidget*)eventbox,TP_COMMON_BTN_NORMAL_IMG,NULL,NULL); // gtk_widget_set_size_request (GTK_WIDGET (eventbox), 80, 80); // gtk_widget_modify_bg(eventbox, GTK_STATE_NORMAL, &yellow); // //gtk_widget_set_uposition(eventbox,pos_x,pos_y); // gtk_fixed_put((GtkFixed*)fixed3,eventbox,pos_x,pos_y); // // // label = gtk_label_new("mj"); // markup = g_markup_printf_escaped ("<span font_desc='Microsoft YaHei 12' foreground=\"#00FF00\">%s</span>",\ // g_locale_to_utf8("mj", -1, NULL, NULL, NULL)); // gtk_label_set_markup (GTK_LABEL (label), markup); // g_free (markup); // gtk_container_add (GTK_CONTAINER (eventbox), label); // if(pos_x<400) // { // pos_x+=120+20; // } // else // { // pos_x = 125; // pos_y += 80+20; // } //} gtk_widget_show_all(window); gdk_threads_enter(); gtk_main (); gdk_threads_leave(); return 0; }
//------------------------------------------------------------------------------------------- // // build the GUI // GtkWidget* buildBandscope_controlUI() { GtkWidget* label; zoomFixed=gtk_fixed_new(); gtk_widget_modify_bg(zoomFixed,GTK_STATE_NORMAL,&background); buttonOff = gtk_button_new_with_label ("Off"); gtk_widget_modify_bg(buttonOff, GTK_STATE_NORMAL, &buttonBackground); label=gtk_bin_get_child((GtkBin*)buttonOff); gtk_widget_modify_fg(label, GTK_STATE_NORMAL, &white); gtk_widget_set_size_request(GTK_WIDGET(buttonOff),75,BUTTON_HEIGHT); g_signal_connect(G_OBJECT(buttonOff),"clicked",G_CALLBACK(zoomCallback),NULL); gtk_widget_show(buttonOff); gtk_fixed_put((GtkFixed*)zoomFixed,buttonOff,0,0); // zoom buttons buttonZoom1 = gtk_button_new_with_label ("Zoom x1"); gtk_widget_modify_bg(buttonZoom1, GTK_STATE_NORMAL, &buttonBackground); label=gtk_bin_get_child((GtkBin*)buttonZoom1); gtk_widget_modify_fg(label, GTK_STATE_NORMAL, &white); gtk_widget_set_size_request(GTK_WIDGET(buttonZoom1),75,BUTTON_HEIGHT); g_signal_connect(G_OBJECT(buttonZoom1),"clicked",G_CALLBACK(zoomCallback),NULL); gtk_widget_show(buttonZoom1); gtk_fixed_put((GtkFixed*)zoomFixed,buttonZoom1,75,0); buttonZoom2 = gtk_button_new_with_label ("Zoom x2"); gtk_widget_modify_bg(buttonZoom2, GTK_STATE_NORMAL, &buttonBackground); label=gtk_bin_get_child((GtkBin*)buttonZoom2); gtk_widget_modify_fg(label, GTK_STATE_NORMAL, &white); gtk_widget_set_size_request(GTK_WIDGET(buttonZoom2),75,BUTTON_HEIGHT); g_signal_connect(G_OBJECT(buttonZoom2),"clicked",G_CALLBACK(zoomCallback),NULL); gtk_widget_show(buttonZoom2); gtk_fixed_put((GtkFixed*)zoomFixed,buttonZoom2,150,0); if(BANDSCOPE_MULTIPLIER>2) { buttonZoom4 = gtk_button_new_with_label ("Zoom x4"); gtk_widget_modify_bg(buttonZoom4, GTK_STATE_NORMAL, &buttonBackground); label=gtk_bin_get_child((GtkBin*)buttonZoom4); gtk_widget_modify_fg(label, GTK_STATE_NORMAL, &white); gtk_widget_set_size_request(GTK_WIDGET(buttonZoom4),75,BUTTON_HEIGHT); g_signal_connect(G_OBJECT(buttonZoom4),"clicked",G_CALLBACK(zoomCallback),NULL); gtk_widget_show(buttonZoom4); gtk_fixed_put((GtkFixed*)zoomFixed,buttonZoom4,225,0); } if(BANDSCOPE_MULTIPLIER>4) { buttonZoom8 = gtk_button_new_with_label ("Zoom x8"); gtk_widget_modify_bg(buttonZoom8, GTK_STATE_NORMAL, &buttonBackground); label=gtk_bin_get_child((GtkBin*)buttonZoom8); gtk_widget_modify_fg(label, GTK_STATE_NORMAL, &white); gtk_widget_set_size_request(GTK_WIDGET(buttonZoom8),75,BUTTON_HEIGHT); g_signal_connect(G_OBJECT(buttonZoom8),"clicked",G_CALLBACK(zoomCallback),NULL); gtk_widget_show(buttonZoom8); gtk_fixed_put((GtkFixed*)zoomFixed,buttonZoom8,300,0); gtk_widget_set_size_request(GTK_WIDGET(zoomFixed),375,BUTTON_HEIGHT); } if(BANDSCOPE_MULTIPLIER>8) { buttonZoom16 = gtk_button_new_with_label ("Zoom x16"); gtk_widget_modify_bg(buttonZoom16, GTK_STATE_NORMAL, &buttonBackground); label=gtk_bin_get_child((GtkBin*)buttonZoom16); gtk_widget_modify_fg(label, GTK_STATE_NORMAL, &white); gtk_widget_set_size_request(GTK_WIDGET(buttonZoom16),75,BUTTON_HEIGHT); g_signal_connect(G_OBJECT(buttonZoom16),"clicked",G_CALLBACK(zoomCallback),NULL); gtk_widget_show(buttonZoom16); gtk_fixed_put((GtkFixed*)zoomFixed,buttonZoom16,375,0); gtk_widget_set_size_request(GTK_WIDGET(zoomFixed),450,BUTTON_HEIGHT); } gtk_widget_show(zoomFixed); setZoom(bandscopeZoom); return zoomFixed; }
static void groupadd_window_init(HybridGroupAddWindow *window) { GtkWidget *vbox; GtkWidget *fixed; GtkWidget *action_area; GtkWidget *label; GtkTreeModel *model; GtkCellRenderer *renderer; GtkWidget *button; GdkPixbuf *pixbuf; GtkWidget *image; vbox = gtk_vbox_new(FALSE, 0); gtk_container_add(GTK_CONTAINER(window->window), vbox); fixed = gtk_fixed_new(); gtk_box_pack_start(GTK_BOX(vbox), fixed, TRUE, TRUE, 0); pixbuf = hybrid_create_default_icon(64); image = gtk_image_new_from_pixbuf(pixbuf); g_object_unref(pixbuf); gtk_fixed_put(GTK_FIXED(fixed), image, 20, 40); label = gtk_label_new(NULL); gtk_label_set_markup(GTK_LABEL(label), _("<b>Please choose an account:</b>")); gtk_fixed_put(GTK_FIXED(fixed), label, 110, 20); model = create_account_model(); window->account_combo = gtk_combo_box_new_with_model(model); renderer = gtk_cell_renderer_pixbuf_new (); gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(window->account_combo), renderer, FALSE); gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(window->account_combo), renderer, "pixbuf", 0, NULL); renderer = gtk_cell_renderer_text_new(); gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(window->account_combo), renderer, FALSE); gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(window->account_combo), renderer, "text", 1, NULL); gtk_combo_box_set_active(GTK_COMBO_BOX(window->account_combo), 0); gtk_widget_set_size_request(window->account_combo, 270, 30); g_object_unref(model); gtk_fixed_put(GTK_FIXED(fixed), window->account_combo, 110, 45); label = gtk_label_new(NULL); gtk_label_set_markup(GTK_LABEL(label), _("<b>Please input the group name:</b>")); gtk_fixed_put(GTK_FIXED(fixed), label, 110, 80); window->name_entry = gtk_entry_new(); gtk_widget_set_size_request(window->name_entry, 270, 30); gtk_fixed_put(GTK_FIXED(fixed), window->name_entry, 110, 105); action_area = gtk_hbox_new(FALSE, 0); gtk_box_pack_start(GTK_BOX(vbox), action_area, FALSE, FALSE, 0); button = gtk_button_new_with_label(_("Save")); gtk_widget_set_size_request(button, 100, 30); gtk_box_pack_end(GTK_BOX(action_area), button, FALSE, FALSE, 5); g_signal_connect(button, "clicked", G_CALLBACK(save_cb), window); button = gtk_button_new_with_label(_("Cancel")); gtk_widget_set_size_request(button, 100, 30); gtk_box_pack_end(GTK_BOX(action_area), button, FALSE, FALSE, 5); g_signal_connect(button, "clicked", G_CALLBACK(cancel_cb), window); }
//********************************************************************************* void guiControl::guiControl(void *button, void* data) { if (pos_winPid != NULL) { gtk_window_set_keep_above (GTK_WINDOW(pos_winPid),true); return; } gtkClassData* currentClassData = (gtkClassData*) data; partMover *currentPart = currentClassData->partPointer; joint = currentClassData->indexPointer; icntrl = currentPart->get_IControlMode(); ipid = currentPart->get_IPidControl(); iamp = currentPart->get_IAmplifierControl(); //GtkWidget *winPid = NULL; GtkWidget *inv = NULL; //adding a popup window pos_winPid = gtk_window_new (GTK_WINDOW_TOPLEVEL); char title[255]; sprintf(title,"Control mode JNT:%d",*joint); gtk_window_set_title (GTK_WINDOW (pos_winPid), title); //adding a set of display inv = gtk_fixed_new (); gtk_container_add (GTK_CONTAINER (pos_winPid), inv); label_title = gtk_label_new (title); radiobutton_mode_idl = gtk_radio_button_new_with_label (NULL, "idle"); radiobutton_mode_pos = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (radiobutton_mode_idl), "position"); radiobutton_mode_vel = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (radiobutton_mode_idl), "velocity"); radiobutton_mode_trq = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (radiobutton_mode_idl), "torque"); radiobutton_mode_imp_pos = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (radiobutton_mode_idl), "impedance position"); radiobutton_mode_imp_vel = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (radiobutton_mode_idl), "impedance velocity"); radiobutton_mode_open = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (radiobutton_mode_idl), "openloop"); radiobutton_mode_pos_direct = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (radiobutton_mode_idl), "position direct"); radiobutton_mode_mixed = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (radiobutton_mode_idl), "mixed"); gtk_fixed_put (GTK_FIXED(inv), label_title, 10, 10 ); gtk_fixed_put (GTK_FIXED(inv), radiobutton_mode_idl, 10, 30 ); gtk_fixed_put (GTK_FIXED(inv), radiobutton_mode_pos, 10, 50 ); gtk_fixed_put (GTK_FIXED(inv), radiobutton_mode_pos_direct, 10, 70 ); gtk_fixed_put (GTK_FIXED(inv), radiobutton_mode_mixed, 10, 90 ); gtk_fixed_put (GTK_FIXED(inv), radiobutton_mode_vel, 10, 110 ); gtk_fixed_put (GTK_FIXED(inv), radiobutton_mode_trq, 10, 130 ); gtk_fixed_put (GTK_FIXED(inv), radiobutton_mode_imp_pos, 10, 150 ); gtk_fixed_put (GTK_FIXED(inv), radiobutton_mode_imp_vel, 10, 170 ); gtk_fixed_put (GTK_FIXED(inv), radiobutton_mode_open, 10, 190 ); int control_mode=VOCAB_CM_UNKNOWN; bool ret = icntrl->getControlMode(*joint, &control_mode); update_menu(control_mode); //Rememeber: these signal_connect MUST be placed after the update_menu! g_signal_connect (radiobutton_mode_idl, "clicked",G_CALLBACK (radio_click_idl), &radiobutton_mode_idl); g_signal_connect (radiobutton_mode_pos, "clicked",G_CALLBACK (radio_click_pos), &radiobutton_mode_pos); g_signal_connect (radiobutton_mode_pos_direct, "clicked",G_CALLBACK (radio_click_pos_direct), &radiobutton_mode_pos_direct); g_signal_connect (radiobutton_mode_mixed, "clicked",G_CALLBACK (radio_click_mode_mixed), &radiobutton_mode_mixed); g_signal_connect (radiobutton_mode_vel, "clicked",G_CALLBACK (radio_click_vel), &radiobutton_mode_vel); g_signal_connect (radiobutton_mode_trq, "clicked",G_CALLBACK (radio_click_trq), &radiobutton_mode_trq); g_signal_connect (radiobutton_mode_imp_pos, "clicked",G_CALLBACK (radio_click_imp_pos), &radiobutton_mode_imp_pos); g_signal_connect (radiobutton_mode_imp_vel, "clicked",G_CALLBACK (radio_click_imp_vel), &radiobutton_mode_imp_vel); g_signal_connect (radiobutton_mode_open, "clicked",G_CALLBACK (radio_click_open), &radiobutton_mode_open); //connection to the destroyer g_signal_connect (pos_winPid, "destroy",G_CALLBACK (destroy_main), &pos_winPid); //make it visible if (!GTK_WIDGET_VISIBLE (pos_winPid)) gtk_widget_show_all (pos_winPid); else { gtk_widget_destroy (pos_winPid); pos_winPid = NULL; } gtk_window_set_keep_above (GTK_WINDOW(pos_winPid),true); gtk_main (); return; }
bool gtkgui_init(int argc, char *argv[], Stream_mixer *mix) { GtkWidget *bbox = NULL; bool isx = false; /* FIXME: bisogan mettere l'enable_nls*/ /* i18n */ setlocale(LC_ALL, ""); bindtextdomain("muse", LOCALEDIR); bind_textdomain_codeset("muse", "UTF-8"); textdomain("muse"); /* initialization */ state = true; mixer = mix; list_init(&listachan); list_init(&lamelist); list_init(&ogglist); iceprof = lameprof = vorbisprof = NULL; if(!profile_init()) error(_("profile initialization error")); profile_ice_load(); /* profile_lame_load and profile_vorbis_load are into encoder.cpp */ pathfile = NULL; /* signal to glib we're going to use threads */ g_thread_init(NULL); isx = gtk_init_check(&argc,&argv); if(!isx) return false; isx = mixer->set_lineout(true); window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_title(GTK_WINDOW(window), _("MuSE-cvs Gtk+2")); gtk_window_set_resizable(GTK_WINDOW(window), FALSE); gtk_container_set_border_width(GTK_CONTAINER(window), 12); g_signal_connect(G_OBJECT(window), "delete_event", G_CALLBACK(gcb_exit), NULL); /* FIXME: gtk2 remove ? */ gtk_widget_realize(window); vbox=gtk_vbox_new(FALSE, 0); gtk_container_add(GTK_CONTAINER(window), vbox); fix = gtk_fixed_new(); gtk_box_pack_start(GTK_BOX(vbox), fix, FALSE, FALSE, 0); bbox = createbbox(bbox); gtk_fixed_put(GTK_FIXED(fix), bbox, 0, 0); if(isx) gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(speakout), TRUE); pack_new(); createch(); putstatusbar(); /*let's show window */ gtk_widget_show_all(window); gtk_widget_hide(pack1.hscale); gtk_widget_hide(pack2.hscale); gtk_widget_hide(pack3.hscale); return true; }
/** * @brief Build the GUI * * @return */ GtkWidget* buildDisplayUI() { GtkWidget* label; GtkWidget* box; //display = gtk_window_new (GTK_WINDOW_TOPLEVEL); ////gtk_widget_modify_bg(display,GTK_STATE_NORMAL,&background); //gtk_window_set_title(GTK_WINDOW(display),"Display and Decode"); displayFixed=gtk_fixed_new(); //gtk_widget_modify_bg(displayFixed,GTK_STATE_NORMAL,&background); spectrum=newSpectrumDisplay(spectrumWIDTH); gtk_fixed_put((GtkFixed*)displayFixed,spectrum,0,0); box=gtk_hbox_new(FALSE,5); speed48K=gtk_radio_button_new_with_label(NULL,"48K"); label=gtk_bin_get_child((GtkBin*)speed48K); //gtk_widget_modify_fg(label, GTK_STATE_NORMAL, &white); //gtk_widget_modify_fg(label, GTK_STATE_PRELIGHT, &white); //gtk_widget_modify_fg(label, GTK_STATE_ACTIVE, &white); g_signal_connect(G_OBJECT(speed48K),"clicked",G_CALLBACK(speed48ButtonCallback),NULL); gtk_widget_show(speed48K); gtk_box_pack_start(GTK_BOX(box),speed48K,FALSE,FALSE,2); speed96K=gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(speed48K),"96K"); label=gtk_bin_get_child((GtkBin*)speed96K); //gtk_widget_modify_fg(label, GTK_STATE_NORMAL, &white); //gtk_widget_modify_fg(label, GTK_STATE_PRELIGHT, &white); //gtk_widget_modify_fg(label, GTK_STATE_ACTIVE, &white); g_signal_connect(G_OBJECT(speed96K),"clicked",G_CALLBACK(speed96ButtonCallback),NULL); gtk_widget_show(speed96K); gtk_box_pack_start(GTK_BOX(box),speed96K,FALSE,FALSE,2); speed192K=gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(speed48K),"192K"); label=gtk_bin_get_child((GtkBin*)speed192K); //gtk_widget_modify_fg(label, GTK_STATE_NORMAL, &white); //gtk_widget_modify_fg(label, GTK_STATE_PRELIGHT, &white); //gtk_widget_modify_fg(label, GTK_STATE_ACTIVE, &white); g_signal_connect(G_OBJECT(speed192K),"clicked",G_CALLBACK(speed192ButtonCallback),NULL); gtk_widget_show(speed192K); gtk_box_pack_start(GTK_BOX(box),speed192K,FALSE,FALSE,2); gtk_widget_show(box); gtk_fixed_put((GtkFixed*)displayFixed,box,700,spectrumHEIGHT); buttonNone=gtk_button_new_with_label("NONE"); //gtk_widget_modify_bg(buttonNone, GTK_STATE_NORMAL, &buttonBackground); label=gtk_bin_get_child((GtkBin*)buttonNone); //gtk_widget_modify_fg(label, GTK_STATE_NORMAL, &white); gtk_widget_set_size_request(GTK_WIDGET(buttonNone),100,BUTTON_HEIGHT); g_signal_connect(G_OBJECT(buttonNone),"clicked",G_CALLBACK(spectrumCallback),NULL); gtk_widget_show(buttonNone); gtk_fixed_put((GtkFixed*)displayFixed,buttonNone,0,spectrumHEIGHT); buttonSpectrum=gtk_button_new_with_label("SPECTRUM"); //gtk_widget_modify_bg(buttonSpectrum, GTK_STATE_NORMAL, &buttonBackground); label=gtk_bin_get_child((GtkBin*)buttonSpectrum); //gtk_widget_modify_fg(label, GTK_STATE_NORMAL, &white); gtk_widget_set_size_request(GTK_WIDGET(buttonSpectrum),100,BUTTON_HEIGHT); g_signal_connect(G_OBJECT(buttonSpectrum),"clicked",G_CALLBACK(spectrumCallback),NULL); gtk_widget_show(buttonSpectrum); gtk_fixed_put((GtkFixed*)displayFixed,buttonSpectrum,100,spectrumHEIGHT); buttonPanadapter=gtk_button_new_with_label("PANADAPTER"); //gtk_widget_modify_bg(buttonPanadapter, GTK_STATE_NORMAL, &buttonBackground); label=gtk_bin_get_child((GtkBin*)buttonPanadapter); //gtk_widget_modify_fg(label, GTK_STATE_NORMAL, &white); gtk_widget_set_size_request(GTK_WIDGET(buttonPanadapter),100,BUTTON_HEIGHT); g_signal_connect(G_OBJECT(buttonPanadapter),"clicked",G_CALLBACK(spectrumCallback),NULL); gtk_widget_show(buttonPanadapter); gtk_fixed_put((GtkFixed*)displayFixed,buttonPanadapter,200,spectrumHEIGHT); buttonPanWater=gtk_button_new_with_label("PAN/WATER"); //gtk_widget_modify_bg(buttonPanWater, GTK_STATE_NORMAL, &buttonBackground); label=gtk_bin_get_child((GtkBin*)buttonPanWater); //gtk_widget_modify_fg(label, GTK_STATE_NORMAL, &white); gtk_widget_set_size_request(GTK_WIDGET(buttonPanWater),100,BUTTON_HEIGHT); g_signal_connect(G_OBJECT(buttonPanWater),"clicked",G_CALLBACK(spectrumCallback),NULL); gtk_widget_show(buttonPanWater); gtk_fixed_put((GtkFixed*)displayFixed,buttonPanWater,300,spectrumHEIGHT); buttonScope=gtk_button_new_with_label("SCOPE"); //gtk_widget_modify_bg(buttonScope, GTK_STATE_NORMAL, &buttonBackground); label=gtk_bin_get_child((GtkBin*)buttonScope); //gtk_widget_modify_fg(label, GTK_STATE_NORMAL, &white); gtk_widget_set_size_request(GTK_WIDGET(buttonScope),100,BUTTON_HEIGHT); g_signal_connect(G_OBJECT(buttonScope),"clicked",G_CALLBACK(spectrumCallback),NULL); gtk_widget_show(buttonScope); gtk_fixed_put((GtkFixed*)displayFixed,buttonScope,400,spectrumHEIGHT); buttonPhase=gtk_button_new_with_label("PHASE"); //gtk_widget_modify_bg(buttonPhase, GTK_STATE_NORMAL, &buttonBackground); label=gtk_bin_get_child((GtkBin*)buttonPhase); //gtk_widget_modify_fg(label, GTK_STATE_NORMAL, &white); gtk_widget_set_size_request(GTK_WIDGET(buttonPhase),100,BUTTON_HEIGHT); g_signal_connect(G_OBJECT(buttonPhase),"clicked",G_CALLBACK(spectrumCallback),NULL); gtk_widget_show(buttonPhase); gtk_fixed_put((GtkFixed*)displayFixed,buttonPhase,500,spectrumHEIGHT); buttonPhase2=gtk_button_new_with_label("PHASE2"); //gtk_widget_modify_bg(buttonPhase2, GTK_STATE_NORMAL, &buttonBackground); label=gtk_bin_get_child((GtkBin*)buttonPhase2); //gtk_widget_modify_fg(label, GTK_STATE_NORMAL, &white); gtk_widget_set_size_request(GTK_WIDGET(buttonPhase2),100,BUTTON_HEIGHT); g_signal_connect(G_OBJECT(buttonPhase2),"clicked",G_CALLBACK(spectrumCallback),NULL); gtk_widget_show(buttonPhase2); gtk_fixed_put((GtkFixed*)displayFixed,buttonPhase2,600,spectrumHEIGHT); gtk_widget_set_size_request(GTK_WIDGET(displayFixed),spectrumWIDTH,spectrumHEIGHT+25); gtk_widget_show(displayFixed); //gtk_container_add(GTK_CONTAINER(display), displayFixed); //gtk_window_set_position((GtkWindow*)display,GTK_WIN_POS_MOUSE); //gtk_widget_show(display.g); switch(speed) { case 0: gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(speed48K),TRUE); break; case 1: gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(speed96K),TRUE); break; case 2: gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(speed192K),TRUE); break; } currentSpectrumButton=NULL; switch(spectrumMode) { case spectrumNONE: spectrumCallback(buttonNone,NULL); break; case spectrumSPECTRUM: spectrumCallback(buttonSpectrum,NULL); break; case spectrumPANADAPTER: spectrumCallback(buttonPanadapter,NULL); break; case spectrumPANWATER: spectrumCallback(buttonPanWater,NULL); break; case spectrumSCOPE: spectrumCallback(buttonScope,NULL); break; case spectrumPHASE: spectrumCallback(buttonPhase,NULL); break; case spectrumPHASE2: spectrumCallback(buttonPhase2,NULL); break; } return displayFixed; }
void create_translatorchooser (HWND hwnd, TTRANSLATORCHOOSER *choose_t) { GtkWidget *translatorchooser, *dialog_vbox1, *fixed1, *l_diz, *scrolledwindow1; GtkWidget *clist1, *l_name, *l_file, *l_date, *l_size, *dialog_action_area1; GtkWidget *hbuttonbox1, *b_finish, *b_cancel, *pixmap1; guint b_finish_key, b_cancel_key; GdkPixmap *pixmap; GdkBitmap *mask; GtkStyle *style; GtkAccelGroup *accel_group; if (hwnd == NULL || !GTK_IS_WIDGET (hwnd)) return; accel_group = gtk_accel_group_new (); translatorchooser = gtk_dialog_new (); gtk_object_set_data (GTK_OBJECT (translatorchooser), "translatorchooser", translatorchooser); gtk_window_set_title (GTK_WINDOW (translatorchooser), "Choose a Translator"); gtk_window_set_position (GTK_WINDOW (translatorchooser), GTK_WIN_POS_CENTER); gtk_window_set_modal (GTK_WINDOW (translatorchooser), TRUE); gtk_window_set_policy (GTK_WINDOW (translatorchooser), FALSE, FALSE, FALSE); #if GTK_CHECK_VERSION(2,0,0) gtk_widget_show (translatorchooser); #endif dialog_vbox1 = GTK_DIALOG (translatorchooser)->vbox; gtk_object_set_data (GTK_OBJECT (translatorchooser), "dialog_vbox1", dialog_vbox1); gtk_widget_show (dialog_vbox1); fixed1 = gtk_fixed_new (); gtk_widget_ref (fixed1); gtk_object_set_data_full (GTK_OBJECT (translatorchooser), "fixed1", fixed1, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (fixed1); gtk_box_pack_start (GTK_BOX (dialog_vbox1), fixed1, TRUE, TRUE, 0); gtk_container_set_border_width (GTK_CONTAINER (fixed1), 6); l_diz = gtk_label_new ("Select which ODBC Translator you want to use."); gtk_widget_ref (l_diz); gtk_object_set_data_full (GTK_OBJECT (translatorchooser), "l_diz", l_diz, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (l_diz); gtk_fixed_put (GTK_FIXED (fixed1), l_diz, 168, 16); gtk_widget_set_uposition (l_diz, 168, 16); gtk_widget_set_usize (l_diz, 325, 16); gtk_label_set_justify (GTK_LABEL (l_diz), GTK_JUSTIFY_LEFT); scrolledwindow1 = gtk_scrolled_window_new (NULL, NULL); gtk_widget_ref (scrolledwindow1); gtk_object_set_data_full (GTK_OBJECT (translatorchooser), "scrolledwindow1", scrolledwindow1, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (scrolledwindow1); gtk_fixed_put (GTK_FIXED (fixed1), scrolledwindow1, 168, 32); gtk_widget_set_uposition (scrolledwindow1, 168, 32); gtk_widget_set_usize (scrolledwindow1, 320, 248); clist1 = gtk_clist_new (4); gtk_widget_ref (clist1); gtk_object_set_data_full (GTK_OBJECT (translatorchooser), "clist1", clist1, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (clist1); gtk_container_add (GTK_CONTAINER (scrolledwindow1), clist1); gtk_clist_set_column_width (GTK_CLIST (clist1), 0, 165); gtk_clist_set_column_width (GTK_CLIST (clist1), 1, 118); gtk_clist_set_column_width (GTK_CLIST (clist1), 2, 80); gtk_clist_set_column_width (GTK_CLIST (clist1), 3, 80); gtk_clist_column_titles_show (GTK_CLIST (clist1)); l_name = gtk_label_new (szDriverColumnNames[0]); gtk_widget_ref (l_name); gtk_object_set_data_full (GTK_OBJECT (translatorchooser), "l_name", l_name, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (l_name); gtk_clist_set_column_widget (GTK_CLIST (clist1), 0, l_name); l_file = gtk_label_new (szDriverColumnNames[1]); gtk_widget_ref (l_file); gtk_object_set_data_full (GTK_OBJECT (translatorchooser), "l_file", l_file, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (l_file); gtk_clist_set_column_widget (GTK_CLIST (clist1), 1, l_file); l_date = gtk_label_new (szDriverColumnNames[2]); gtk_widget_ref (l_date); gtk_object_set_data_full (GTK_OBJECT (translatorchooser), "l_date", l_date, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (l_date); gtk_clist_set_column_widget (GTK_CLIST (clist1), 2, l_date); l_size = gtk_label_new (szDriverColumnNames[3]); gtk_widget_ref (l_size); gtk_object_set_data_full (GTK_OBJECT (translatorchooser), "l_size", l_size, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (l_size); gtk_clist_set_column_widget (GTK_CLIST (clist1), 3, l_size); #if GTK_CHECK_VERSION(2,0,0) style = gtk_widget_get_style (translatorchooser); pixmap = gdk_pixmap_create_from_xpm_d (translatorchooser->window, &mask, &style->bg[GTK_STATE_NORMAL], (gchar **) img_xpm); #else style = gtk_widget_get_style (GTK_WIDGET (hwnd)); pixmap = gdk_pixmap_create_from_xpm_d (GTK_WIDGET (hwnd)->window, &mask, &style->bg[GTK_STATE_NORMAL], (gchar **) img_xpm); #endif pixmap1 = gtk_pixmap_new (pixmap, mask); gtk_widget_ref (pixmap1); gtk_object_set_data_full (GTK_OBJECT (translatorchooser), "pixmap1", pixmap1, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (pixmap1); gtk_fixed_put (GTK_FIXED (fixed1), pixmap1, 16, 16); gtk_widget_set_uposition (pixmap1, 16, 16); gtk_widget_set_usize (pixmap1, 136, 264); dialog_action_area1 = GTK_DIALOG (translatorchooser)->action_area; gtk_object_set_data (GTK_OBJECT (translatorchooser), "dialog_action_area1", dialog_action_area1); gtk_widget_show (dialog_action_area1); gtk_container_set_border_width (GTK_CONTAINER (dialog_action_area1), 5); hbuttonbox1 = gtk_hbutton_box_new (); gtk_widget_ref (hbuttonbox1); gtk_object_set_data_full (GTK_OBJECT (translatorchooser), "hbuttonbox1", hbuttonbox1, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (hbuttonbox1); gtk_box_pack_start (GTK_BOX (dialog_action_area1), hbuttonbox1, TRUE, TRUE, 0); gtk_button_box_set_layout (GTK_BUTTON_BOX (hbuttonbox1), GTK_BUTTONBOX_END); gtk_button_box_set_spacing (GTK_BUTTON_BOX (hbuttonbox1), 10); b_finish = gtk_button_new_with_label (""); b_finish_key = gtk_label_parse_uline (GTK_LABEL (GTK_BIN (b_finish)->child), "_Finish"); gtk_widget_add_accelerator (b_finish, "clicked", accel_group, b_finish_key, GDK_MOD1_MASK, 0); gtk_widget_ref (b_finish); gtk_object_set_data_full (GTK_OBJECT (translatorchooser), "b_finish", b_finish, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (b_finish); gtk_container_add (GTK_CONTAINER (hbuttonbox1), b_finish); GTK_WIDGET_SET_FLAGS (b_finish, GTK_CAN_DEFAULT); gtk_widget_add_accelerator (b_finish, "clicked", accel_group, 'F', GDK_MOD1_MASK, GTK_ACCEL_VISIBLE); b_cancel = gtk_button_new_with_label (""); b_cancel_key = gtk_label_parse_uline (GTK_LABEL (GTK_BIN (b_cancel)->child), "_Cancel"); gtk_widget_add_accelerator (b_cancel, "clicked", accel_group, b_cancel_key, GDK_MOD1_MASK, 0); gtk_widget_ref (b_cancel); gtk_object_set_data_full (GTK_OBJECT (translatorchooser), "b_cancel", b_cancel, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (b_cancel); gtk_container_add (GTK_CONTAINER (hbuttonbox1), b_cancel); GTK_WIDGET_SET_FLAGS (b_cancel, GTK_CAN_DEFAULT); gtk_widget_add_accelerator (b_cancel, "clicked", accel_group, 'C', GDK_MOD1_MASK, GTK_ACCEL_VISIBLE); /* Ok button events */ gtk_signal_connect (GTK_OBJECT (b_finish), "clicked", GTK_SIGNAL_FUNC (translatorchooser_ok_clicked), choose_t); /* Cancel button events */ gtk_signal_connect (GTK_OBJECT (b_cancel), "clicked", GTK_SIGNAL_FUNC (translatorchooser_cancel_clicked), choose_t); /* Close window button events */ gtk_signal_connect (GTK_OBJECT (translatorchooser), "delete_event", GTK_SIGNAL_FUNC (delete_event), choose_t); gtk_signal_connect (GTK_OBJECT (translatorchooser), "destroy", GTK_SIGNAL_FUNC (gtk_main_quit), NULL); /* Translator list events */ gtk_signal_connect (GTK_OBJECT (clist1), "select_row", GTK_SIGNAL_FUNC (translator_list_select), choose_t); gtk_window_add_accel_group (GTK_WINDOW (translatorchooser), accel_group); addtranslators_to_list (clist1, translatorchooser); choose_t->translatorlist = clist1; choose_t->translator = NULL; choose_t->mainwnd = translatorchooser; choose_t->b_finish = b_finish; gtk_widget_show_all (translatorchooser); gtk_main (); }
/* Main application */ int main(int argc,char *argv[]) { GtkWidget *topLevelWindow; GtkWidget *fixed; GtkWidget *btnExit; GtkWidget *lbl1; g_thread_init(NULL); gdk_threads_init(); /* Init application */ gtk_init(&argc,&argv); topLevelWindow = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_default_size(GTK_WINDOW(topLevelWindow), SCREEN_WIDTH, SCREEN_HEIGHT); gtk_window_set_title (GTK_WINDOW (topLevelWindow), "ftrScanAPI GTK Demo"); gtk_signal_connect(GTK_OBJECT(topLevelWindow),"delete_event",GTK_SIGNAL_FUNC(eventDelete),NULL); gtk_signal_connect(GTK_OBJECT(topLevelWindow),"destroy",GTK_SIGNAL_FUNC(eventDestroy),NULL); fixed = gtk_fixed_new(); gtk_widget_show(fixed); // -------------------------- Label Device Info-------------------------------------------- GtkWidget *frameInfo; GtkWidget *lblDevInfo; frameInfo = gtk_frame_new("Device Info"); lblDevInfo=gtk_label_new(""); gtk_widget_set_size_request ( lblDevInfo, 230, -1 ); gtk_container_add(GTK_CONTAINER(frameInfo), lblDevInfo); gtk_fixed_put(GTK_FIXED(fixed),frameInfo, BUTTON_FIXED_X_POS, BUTTON_FIXED_Y_POS ); // -------------------------- Checkbox InvertImage ---------------------------------------------- chkInvert = gtk_check_button_new_with_label(" Invert "); gtk_fixed_put(GTK_FIXED(fixed),chkInvert, BUTTON_FIXED_X_POS, (BUTTON_FIXED_Y_POS+Y_STEP+15) ); // -------------------------- ComboBox LFD ---------------------------------------------- lbl1 = gtk_label_new("LFD"); gtk_fixed_put(GTK_FIXED(fixed), lbl1, BUTTON_FIXED_X_POS, (BUTTON_FIXED_Y_POS+2*Y_STEP+5) ); cboLFD = gtk_combo_box_new_text(); gtk_combo_box_append_text( (GtkComboBox *)cboLFD, "off"); gtk_combo_box_append_text( (GtkComboBox *)cboLFD, "Level 1"); gtk_combo_box_append_text( (GtkComboBox *)cboLFD, "Level 2"); gtk_fixed_put(GTK_FIXED(fixed),cboLFD, BUTTON_FIXED_X_POS+X_STEP, (BUTTON_FIXED_Y_POS+2*Y_STEP) ); gtk_combo_box_set_active( (GtkComboBox *)cboLFD, 0 ); gtk_signal_connect(GTK_OBJECT(cboLFD), "changed", GTK_SIGNAL_FUNC(LFDChangedCallback), NULL); // -------------------------- ComboBox LFD Level2 Strength ---------------------------------------------- lbl1 = gtk_label_new("LFD Level2 Strength"); gtk_fixed_put(GTK_FIXED(fixed), lbl1, BUTTON_FIXED_X_POS, (BUTTON_FIXED_Y_POS+3*Y_STEP+5) ); cboLFDLevel2Strength = gtk_combo_box_new_text(); gtk_combo_box_append_text( (GtkComboBox *)cboLFDLevel2Strength, "1"); gtk_combo_box_append_text( (GtkComboBox *)cboLFDLevel2Strength, "2"); gtk_combo_box_append_text( (GtkComboBox *)cboLFDLevel2Strength, "3"); gtk_combo_box_append_text( (GtkComboBox *)cboLFDLevel2Strength, "4"); gtk_combo_box_append_text( (GtkComboBox *)cboLFDLevel2Strength, "5"); gtk_combo_box_append_text( (GtkComboBox *)cboLFDLevel2Strength, "6"); gtk_combo_box_append_text( (GtkComboBox *)cboLFDLevel2Strength, "7"); gtk_combo_box_append_text( (GtkComboBox *)cboLFDLevel2Strength, "8"); gtk_combo_box_append_text( (GtkComboBox *)cboLFDLevel2Strength, "9"); gtk_fixed_put(GTK_FIXED(fixed),cboLFDLevel2Strength, BUTTON_FIXED_X_POS+X_STEP*2+10, (BUTTON_FIXED_Y_POS+3*Y_STEP) ); gtk_combo_box_set_active( (GtkComboBox *)cboLFDLevel2Strength, 0 ); gtk_widget_set_sensitive( cboLFDLevel2Strength, FALSE ); // -------------------------- Scan button ------------------------------------------------- btnScan = gtk_button_new_with_label(" Scan "); gtk_signal_connect(GTK_OBJECT(btnScan), "clicked", GTK_SIGNAL_FUNC(ScanCallback), NULL); gtk_fixed_put(GTK_FIXED(fixed),btnScan, BUTTON_FIXED_X_POS,(BUTTON_FIXED_Y_POS+Y_STEP*4) ); // -------------------------- Stop button -------------------------------------------------- btnStop = gtk_button_new_with_label(" Stop "); gtk_signal_connect(GTK_OBJECT(btnStop), "clicked", GTK_SIGNAL_FUNC(StopCallback), NULL); gtk_widget_set_sensitive(btnStop, FALSE); gtk_fixed_put(GTK_FIXED(fixed),btnStop, BUTTON_FIXED_X_POS+X_STEP,(BUTTON_FIXED_Y_POS+4*Y_STEP) ); // -------------------------- Label Message ------------------------------------------------- lblMsg=gtk_label_new("Press Scan button"); gtk_fixed_put(GTK_FIXED(fixed),lblMsg, BUTTON_FIXED_X_POS,(BUTTON_FIXED_Y_POS+5*Y_STEP) ); // ------------------------- SaveBmp button ------------------------------------------------- btnSaveBmp = gtk_button_new_with_label(" Save "); gtk_signal_connect(GTK_OBJECT(btnSaveBmp), "clicked", GTK_SIGNAL_FUNC(SaveBmpCallback), NULL); gtk_widget_set_sensitive(btnSaveBmp, FALSE); gtk_fixed_put(GTK_FIXED(fixed),btnSaveBmp, BUTTON_FIXED_X_POS,(BUTTON_FIXED_Y_POS+6*Y_STEP) ); // -------------------------- Exit button ---------------------------------------------------- btnExit = gtk_button_new_with_label(" Exit "); gtk_signal_connect(GTK_OBJECT(btnExit), "clicked", GTK_SIGNAL_FUNC(ExitCallback), NULL); gtk_fixed_put(GTK_FIXED(fixed),btnExit, BUTTON_FIXED_X_POS, (BUTTON_FIXED_Y_POS+7*Y_STEP) ); // -------------------------- Init the libftrScanAPI library ---------------------------------- hDevice = ftrScanOpenDevice(); if( hDevice == NULL ) { g_print( "Failed to open device!\n" ); return -1; } char strDevInfo[128]; if( GetDeviceInfo(hDevice, strDevInfo ) ) { gtk_label_set_text((GtkLabel *)lblDevInfo, strDevInfo); } else { g_print( "Failed to open device!\n" ); ftrScanCloseDevice(hDevice); return -1; } if( !ftrScanGetImageSize( hDevice, &ImageSize ) ) { g_print("Failed to get image size\n"); ftrScanCloseDevice( hDevice ); return -1; } raw_data = (unsigned char *)malloc( ImageSize.nImageSize ); memset(raw_data, 0, ImageSize.nImageSize ); // ------------------------- Add drawing area to display the fingerprint image ------------------- da = gtk_drawing_area_new (); gtk_signal_connect( (GtkObject*)da, "expose_event", (GtkSignalFunc)expose_cb, NULL ); gtk_signal_connect( (GtkObject*)da, "configure_event", (GtkSignalFunc)configure_cb, NULL ); gtk_drawing_area_size((GtkDrawingArea*)da, ImageSize.nWidth, ImageSize.nHeight); gtk_fixed_put(GTK_FIXED(fixed),da, BUTTON_FIXED_X_POS+4*X_STEP, 5 ); //-------------------------- Display the widgets -------------------------------------------------- gtk_container_add(GTK_CONTAINER(topLevelWindow), fixed); //gtk_widget_show(topLevelWindow); gtk_widget_show_all(topLevelWindow); //-------------------------- Main application loop ------------------------------------------------ gdk_threads_enter(); gtk_main(); gdk_threads_leave(); // if (gtk_debug) g_print("Done!\n"); exit(0); }
int main(int argc, char** argv) { GtkWidget *window_label; GtkWidget *window; GtkWidget *window_frame; GtkWidget *increase_vol; GtkWidget *decrease_vol; GtkWidget *max_vol; GtkWidget *zero_vol; /* Initialize the GTK+ Library */ gtk_init(&argc, &argv); window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER); /* Set Title for GTK Window */ gtk_window_set_title(GTK_WINDOW(window), "ALSA Volume Controller"); /* Set Default Size of the GTK Window */ gtk_window_set_default_size(GTK_WINDOW(window), 560, 150); window_frame = gtk_fixed_new(); gtk_container_add(GTK_CONTAINER(window), window_frame); increase_vol = gtk_button_new_with_label("+"); gtk_widget_set_size_request(increase_vol, 80, 35); gtk_fixed_put(GTK_FIXED(window_frame), increase_vol, 50, 20); decrease_vol = gtk_button_new_with_label("-"); gtk_widget_set_size_request(decrease_vol, 80, 35); gtk_fixed_put(GTK_FIXED(window_frame), decrease_vol, 50, 80); max_vol = gtk_button_new_with_label("MAX"); gtk_widget_set_size_request(max_vol, 80, 35); gtk_fixed_put(GTK_FIXED(window_frame), max_vol, 165, 20); zero_vol = gtk_button_new_with_label("MUTE"); gtk_widget_set_size_request(zero_vol, 80, 35); gtk_fixed_put(GTK_FIXED(window_frame), zero_vol, 165, 80); window_label = gtk_label_new("copyright@SandeepSingh"); gtk_fixed_put(GTK_FIXED(window_frame), window_label, 280, 58); gtk_widget_show_all(window); g_signal_connect(window, "destroy", G_CALLBACK (gtk_main_quit), NULL); g_signal_connect(increase_vol, "clicked", G_CALLBACK(increase), window_label); g_signal_connect(decrease_vol, "clicked", G_CALLBACK(decrease), window_label); g_signal_connect(max_vol, "clicked", G_CALLBACK(maxvolume), window_label); g_signal_connect(zero_vol, "clicked", G_CALLBACK(novolume), window_label); gtk_main(); return 0; }
int main(int argc, char** argv) { GtkWidget *edit; GtkWidget *label; GtkWidget *window; GtkWidget *frame; GtkWidget *plus; GtkWidget *minus; GtkWidget *image; GtkWidget *grid; GtkWidget *inner_grid; unsigned x, y; gtk_init(&argc, &argv); window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER); gtk_window_set_default_size(GTK_WINDOW(window), 500, 500); gtk_window_set_title(GTK_WINDOW(window), "+-"); frame = gtk_fixed_new(); /* gtk_container_add(GTK_CONTAINER(window), frame); */ grid = gtk_grid_new(); gtk_container_add(GTK_CONTAINER(window), grid); plus = gtk_button_new_with_label("+"); gtk_widget_set_size_request(plus, 80, 35); gtk_grid_attach(GTK_GRID(grid), plus, 0, 0, 1, 1); minus = gtk_button_new_with_label("-"); gtk_widget_set_size_request(minus, 80, 35); gtk_grid_attach(GTK_GRID(grid), minus, 1, 0, 1, 1); label = gtk_label_new("0"); gtk_grid_attach(GTK_GRID(grid), label, 2, 1, 1, 1); edit = gtk_entry_new(); gtk_entry_set_text(GTK_ENTRY(edit), "0"); gtk_grid_attach(GTK_GRID(grid), edit, 2, 0, 1, 1); image = gtk_image_new_from_file ("red_dot.png"); gtk_grid_attach(GTK_GRID(grid), image, 3, 0, 1, 1); inner_grid = gtk_grid_new(); gtk_grid_attach(GTK_GRID(grid), inner_grid, 3, 3, 10, 10); gtk_grid_set_column_spacing(GTK_GRID(inner_grid), 5); for (x = 0; x < 5; ++x) { image = gtk_image_new_from_file ("red_dot.png"); gtk_grid_attach(GTK_GRID(inner_grid), image, x, 0, 1, 1); } gtk_widget_show_all(window); g_signal_connect(window, "destroy", G_CALLBACK (gtk_main_quit), NULL); g_signal_connect(plus, "clicked", G_CALLBACK(increase), label); g_signal_connect(plus, "clicked", G_CALLBACK(increase_edit), edit); g_signal_connect(minus, "clicked", G_CALLBACK(decrease), label); g_signal_connect(minus, "clicked", G_CALLBACK(decrease_edit), edit); g_signal_connect(label, "move-cursor", G_CALLBACK(increase), label); gtk_main(); return 0; }
GtkWidget* create_main_window (char *str2print) { GtkWidget *main_window; GtkWidget *fixed1; GtkWidget *main_label; GtkWidget *ok_button; GtkWidget *image; GtkTooltips *tooltips; int pos1 = 300, pos2 = 100; int label_size = 0, str_is_big = 0, has_mail = 0; tooltips = gtk_tooltips_new (); if (strlen(str2print) > 23) str_is_big = 1; if (!strncmp (str2print, "mail", 4)) { //has_mail = 1; str2print = "You have mail !!!"; } /* creating the window */ main_window = gtk_window_new (GTK_WINDOW_TOPLEVEL); if (str_is_big) pos1 = pos1+100; if (has_mail) pos2 = pos2+70; gtk_window_set_default_size (GTK_WINDOW (main_window), pos1, pos2); gtk_window_set_title (GTK_WINDOW (main_window), _("time2do")); gtk_window_set_position (GTK_WINDOW (main_window), GTK_WIN_POS_CENTER); gtk_window_set_resizable (GTK_WINDOW (main_window), TRUE); /* creating and adding the fixed */ fixed1 = gtk_fixed_new (); gtk_widget_show (fixed1); gtk_container_add (GTK_CONTAINER (main_window), fixed1); /* mail string */ if (has_mail) { // add the pixmap/mail.png icon image = gtk_image_new_from_file ("/home/pvital/my_files/projects/Projects/time2do//pixmap/mail.png"); if (image) { gtk_widget_show (image); pos1 = (pos1/2)-32; gtk_fixed_put (GTK_FIXED (fixed1), image, pos1, 8); gtk_widget_set_size_request (image, 64, 64); } } /* adding the label */ main_label = gtk_label_new (NULL); gtk_label_set_width_chars (GTK_LABEL (main_label), strlen(str2print)); gtk_label_set_text (GTK_LABEL (main_label), str2print); gtk_widget_show (main_label); if (str_is_big) { /* used when the label is large than 23 characters */ pos1 = 5; label_size = 380; } else { /* used when the label is small */ pos1 = 56; label_size = 184; } if (has_mail) pos2 = 8+70; else pos2 = 8; gtk_fixed_put (GTK_FIXED (fixed1), main_label, pos1, pos2); gtk_widget_set_size_request (main_label, label_size, 24); gtk_label_set_justify (GTK_LABEL (main_label), GTK_JUSTIFY_CENTER); gtk_label_set_line_wrap (GTK_LABEL (main_label), TRUE); gtk_label_set_ellipsize (GTK_LABEL (main_label), PANGO_ELLIPSIZE_MIDDLE); /* adding the OK button */ pos1 = 120; ok_button = gtk_button_new_from_stock ("gtk-ok"); gtk_widget_show (ok_button); if (str_is_big) pos1 = pos1+55; if (has_mail) pos2 = 48+70; else pos2 = 48; gtk_fixed_put (GTK_FIXED (fixed1), ok_button, pos1, pos2); gtk_widget_set_size_request (ok_button, 62, 29); gtk_tooltips_set_tip (tooltips, ok_button, _("Click here to close this window."), NULL); g_signal_connect ((gpointer) ok_button, "clicked", G_CALLBACK (gtk_main_quit), NULL); /* Store pointers to all widgets, for use by lookup_widget(). */ GLADE_HOOKUP_OBJECT_NO_REF (main_window, main_window, "main_window"); GLADE_HOOKUP_OBJECT (main_window, fixed1, "fixed1"); if (has_mail) GLADE_HOOKUP_OBJECT (main_window, image, "image"); GLADE_HOOKUP_OBJECT (main_window, main_label, "main_label"); GLADE_HOOKUP_OBJECT (main_window, ok_button, "ok_button"); GLADE_HOOKUP_OBJECT_NO_REF (main_window, tooltips, "tooltips"); return main_window; }
int main(int argc, char *argv[]) { //The gtk_init() function initializes GTK+ and parses some standard command line options. //This function must be called before using any other GTK+ functions gtk_init(&argc, &argv); WidgetData *DataSet = g_slice_new(WidgetData); GtkWidget *window; DataSet->combo = gtk_combo_box_new_text(); DataSet->combo2 = gtk_combo_box_new_text(); DataSet->mainCombo = gtk_combo_box_new_text(); DataSet->container = gtk_fixed_new(); DataSet->entry1 = gtk_entry_new(); DataSet->entry2 = gtk_entry_new(); //gtk_window_new creates new gtk window //GTK_WINDOW_TOPLEVEL is the window type. //toplevel windows have a titlebar and border window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_title(GTK_WINDOW(window), "Unit Converter"); //sets window size gtk_window_set_default_size(GTK_WINDOW(window), 280, 80); //sets starting position gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER); //adding options to combo box gtk_combo_box_append_text(GTK_COMBO_BOX(DataSet->combo), "Pounds (lbs)"); gtk_combo_box_append_text(GTK_COMBO_BOX(DataSet->combo), "Kilograms (kgs)"); gtk_combo_box_append_text(GTK_COMBO_BOX(DataSet->combo2), "Pounds (lbs)"); gtk_combo_box_append_text(GTK_COMBO_BOX(DataSet->combo2), "Kilograms (kgs)"); gtk_combo_box_append_text(GTK_COMBO_BOX(DataSet->mainCombo), "Mass"); gtk_combo_box_append_text(GTK_COMBO_BOX(DataSet->mainCombo), "Temperature"); //setting the default settings gtk_combo_box_set_active(GTK_COMBO_BOX(DataSet->mainCombo),0); gtk_combo_box_set_active(GTK_COMBO_BOX(DataSet->combo),0); gtk_combo_box_set_active(GTK_COMBO_BOX(DataSet->combo2),1); gtk_entry_set_text(GTK_ENTRY(DataSet->entry1), "2.25"); gtk_entry_set_text(GTK_ENTRY(DataSet->entry2), "1.00"); //setting containter border and then adding widgets to containers gtk_container_set_border_width(GTK_CONTAINER(window), 5); gtk_container_add(GTK_CONTAINER(window), DataSet->container); //adding the widgets to container and setting coordinates //set_size_request is setting minimum size the widget will be gtk_fixed_put(GTK_FIXED(DataSet->container),DataSet->mainCombo, 70, 0); gtk_widget_set_size_request(DataSet->mainCombo, 130, 30); gtk_fixed_put(GTK_FIXED(DataSet->container),DataSet->combo, 0, 40); gtk_widget_set_size_request(DataSet->combo, 130, 30); gtk_fixed_put(GTK_FIXED(DataSet->container),DataSet->combo2, 140,40); gtk_widget_set_size_request(DataSet->combo2,130,30); gtk_fixed_put(GTK_FIXED(DataSet->container),DataSet->entry1,0,80); gtk_widget_set_size_request(DataSet->entry1, 130, 30); gtk_fixed_put(GTK_FIXED(DataSet->container),DataSet->entry2,140,80); gtk_widget_set_size_request(DataSet->entry2, 130, 30); //g_signal_connect(GtkWidget, signal, G_CALLBACK(method it will call), parameters for the method) g_signal_connect(window, "destroy",G_CALLBACK(gtk_main_quit), NULL); g_signal_connect(DataSet->entry1, "changed", G_CALLBACK(convert), DataSet); g_signal_connect(DataSet->entry2, "changed", G_CALLBACK(convert2), DataSet); g_signal_connect(DataSet->mainCombo, "changed", G_CALLBACK(changeType), DataSet); //flags all widget to be shown gtk_widget_show_all(window); gtk_main(); return 0; }
int main(int argc, char** argv) { //Widgets GtkWidget *flash; GtkWidget *window; GtkWidget *frame; GtkWidget *install_x64; GtkWidget *install_x86; GtkWidget *remove_flash; GtkWidget *label; GtkWidget *title1; GtkWidget *title2; GtkWidget *install_flash_beta; PangoFontDescription *bold = pango_font_description_from_string ( "Sans Bold 24");//Bold Font Paremeters gtk_init(&argc, &argv); window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);//Window Position gtk_window_set_default_size(GTK_WINDOW(window), 300, 180);//Window Size gtk_window_set_title(GTK_WINDOW(window), "Adobe Flash Installer"); //Title frame = gtk_fixed_new(); gtk_container_add(GTK_CONTAINER(window), frame); //Draw Window install_x86 = gtk_button_new_with_label("Install Flash (x86)"); //32 - bit Flash Button gtk_widget_set_size_request(install_x86, 140, 35); gtk_fixed_put(GTK_FIXED(frame), install_x86, 77, 90); install_x64 = gtk_button_new_with_label("Install Flash (x64)");//64 - bit Flash Button gtk_widget_set_size_request(install_x64, 140, 35); gtk_fixed_put(GTK_FIXED(frame), install_x64, 77, 135); install_flash_beta = gtk_button_new_with_label("Install Flash Beta");//Beta Flash Button gtk_widget_set_size_request(install_flash_beta, 140, 35); gtk_fixed_put(GTK_FIXED(frame), install_flash_beta, 77, 180); remove_flash = gtk_button_new_with_label("Remove Flash");//Remove Flash gtk_widget_set_size_request(remove_flash, 120, 35); gtk_fixed_put(GTK_FIXED(frame), remove_flash, 87, 225); label = gtk_label_new("Designed By CarleeDolphinaura"); gtk_fixed_put(GTK_FIXED(frame), label, 45, 280); title1 = gtk_label_new("Adobe Flash");//Title (Row 1) gtk_fixed_put(GTK_FIXED(frame), title1, 45, 10); gtk_widget_show_all(window); title2 = gtk_label_new("Installer"); gtk_fixed_put(GTK_FIXED(frame), title2, 70, 40); //Title (Row 2) gtk_widget_show_all(window); gtk_widget_modify_font(GTK_WIDGET(title1),bold);//Make Title (Row 1) Bold gtk_widget_modify_font(GTK_WIDGET(title2),bold);//Make TItle (Row 2) Bold g_signal_connect(window, "destroy",//Closing Callback G_CALLBACK (gtk_main_quit), NULL); g_signal_connect(install_x86, "clicked",//32-bit Callbacks G_CALLBACK(install_32bit), flash); g_signal_connect(install_x64, "clicked",//64-bit Callbacks G_CALLBACK(install_64bit), flash); g_signal_connect(remove_flash, "clicked",//Remove Flash Callbacks G_CALLBACK(remove_flsh), flash); g_signal_connect(install_flash_beta, "clicked",//Flash Beta Callbacks G_CALLBACK(install_beta), flash); //Echo Terminal Output system("echo 'Adobe Flash Tools For Ubuntu'"); system("echo 'Designed By CarleeDolphinaura (Ubuntu Forums)'"); system("echo 'Licenced Under GPL v3'"); gtk_main(); return 0; }
static void ihm_VideoFullScreen(GtkWidget *widget, gpointer data) { int w,h; if (fullscreen!=NULL) { printf(" Already fullscreen\n"); return; } printf(" Go Fullscreen\n"); /* Builds the image */ fullscreen_image = (GtkImage*) gtk_image_new(); fullscreen_eventbox = gtk_event_box_new(); //align = gtk_alignment_new(0.5f,0.5f,0.0f,0.0f); /* Add three buttons on the fullscreen window */ ihm_fullScreenHBox = gtk_hbox_new(FALSE,0); ihm_fullScreenButton[0] = gtk_button_new_with_label(ihm_ImageButtonCaption[RAW_CAPTURE_BUTTON]); g_signal_connect (G_OBJECT (ihm_fullScreenButton[0]), "clicked", (GCallback)ihm_RAWCapture, NULL); gtk_container_add(GTK_CONTAINER(ihm_fullScreenHBox),ihm_fullScreenButton[0]); ihm_fullScreenButton[1] = gtk_button_new_with_label(ihm_ImageButtonCaption[ZAPPER_BUTTON]); g_signal_connect (G_OBJECT (ihm_fullScreenButton[1]), "clicked", (GCallback)ihm_Zapper, NULL); gtk_container_add(GTK_CONTAINER(ihm_fullScreenHBox),ihm_fullScreenButton[1]); ihm_fullScreenButton[2] = gtk_button_new_with_label("Quit Fullscreen"); g_signal_connect (G_OBJECT (ihm_fullScreenButton[2]), "clicked", (GCallback)ihm_QuitFullscreenRequest, NULL); gtk_container_add(GTK_CONTAINER(ihm_fullScreenHBox),ihm_fullScreenButton[2]); //ihm_fullScreenButton[3] = gtk_button_new(); // Fake button //gtk_container_add(GTK_CONTAINER (align),ihm_fullScreenHBox); /* Create window (full screen) */ fullscreen_window = gtk_window_new (GTK_WINDOW_TOPLEVEL); /* the screen */ fullscreen = gtk_window_get_screen(GTK_WINDOW(fullscreen_window)); w=gdk_screen_get_width(fullscreen); h=gdk_screen_get_height(fullscreen); gtk_widget_set_size_request(GTK_WIDGET(fullscreen_window),w,h); /* The fixed container */ ihm_fullScreenFixedContainer = gtk_fixed_new(); gtk_fixed_put((GtkFixed*)(ihm_fullScreenFixedContainer),GTK_WIDGET(fullscreen_image),0,0); gtk_fixed_put((GtkFixed*)(ihm_fullScreenFixedContainer),GTK_WIDGET(ihm_fullScreenHBox),0,0); /* Build the fullscreen window with the fixed container */ gtk_container_add(GTK_CONTAINER(fullscreen_eventbox),ihm_fullScreenFixedContainer); gtk_container_add(GTK_CONTAINER(fullscreen_window),fullscreen_eventbox); gtk_window_set_decorated(GTK_WINDOW(fullscreen_window), FALSE); gtk_window_set_resizable(GTK_WINDOW(fullscreen_window), FALSE); printf("Fullscreen size : %ix%i\n",w,h); g_signal_connect (G_OBJECT (fullscreen_window), "destroy", (GCallback)ihm_VideoFullScreenStop, NULL); g_signal_connect (fullscreen_eventbox, "motion_notify_event", (GCallback)ihm_VideoFullScreenMouseMove, NULL); gtk_widget_add_events(fullscreen_eventbox,GDK_POINTER_MOTION_MASK); gtk_window_fullscreen(GTK_WINDOW(fullscreen_window)); gtk_widget_show_all (GTK_WIDGET(fullscreen_window)); gtk_widget_hide(ihm_fullScreenHBox); //gtk_widget_get_size_request(ihm_fullScreenHBox,&w2,&h2); //printf("Fullscreen size2 : %ix%i %ix%i\n",w,h,w2,h2); //gtk_fixed_put(ihm_fullScreenFixedContainer,ihm_fullScreenHBox,0,h-30); if (!flag_timer_is_active){ g_timeout_add(1000, (GtkFunction)hide_fullscreen_buttons, NULL ); flag_timer_is_active=1; } }
G_MODULE_EXPORT gboolean display_show(NOTIFICATION_INFO* ni) { DISPLAY_INFO* di = g_new0(DISPLAY_INFO, 1); if (!di) { perror("g_new0"); return FALSE; } di->ni = ni; notifications = g_list_append(notifications, di); di->popup = gtk_window_new(GTK_WINDOW_POPUP); gtk_window_set_title(GTK_WINDOW(di->popup), "growl-for-linux"); gtk_window_set_resizable(GTK_WINDOW(di->popup), TRUE); gtk_window_set_decorated(GTK_WINDOW(di->popup), FALSE); gtk_window_set_keep_above(GTK_WINDOW(di->popup), TRUE); gtk_widget_modify_bg(di->popup, GTK_STATE_NORMAL, colors + (rand() % lengthof(available_colors))); gtk_window_stick(GTK_WINDOW(di->popup)); GtkWidget* ebox = gtk_event_box_new(); gtk_event_box_set_visible_window(GTK_EVENT_BOX(ebox), FALSE); gtk_container_add(GTK_CONTAINER(di->popup), ebox); GtkWidget* fixed = gtk_fixed_new(); gtk_container_set_border_width(GTK_CONTAINER(fixed), 0); gtk_container_add(GTK_CONTAINER(ebox), fixed); GtkWidget* image = NULL; if (di->ni->icon && *di->ni->icon) { GdkPixbuf* pixbuf; if (di->ni->local) { gchar* newurl = g_filename_from_uri(di->ni->icon, NULL, NULL); GError* error = NULL; pixbuf = gdk_pixbuf_new_from_file(newurl ? newurl : di->ni->icon, &error); g_free(newurl); } else { pixbuf = pixbuf_from_url(di->ni->icon, NULL); } if (pixbuf) { GdkPixbuf* tmp = gdk_pixbuf_scale_simple(pixbuf, 32, 32, GDK_INTERP_TILES); if (tmp) { g_object_unref(pixbuf); pixbuf = tmp; } image = gtk_image_new_from_pixbuf(pixbuf); gtk_container_add(GTK_CONTAINER(fixed), image); g_object_unref(pixbuf); } } PangoContext* context = gtk_widget_get_pango_context(di->popup) ; PangoLayout* layout = pango_layout_new(context); gchar* text = g_strconcat(di->ni->title, "\n", di->ni->text, NULL); pango_layout_set_text(layout, text, -1); g_free(text); pango_layout_set_font_description(layout, font_sans20_desc); pango_layout_get_pixel_size(layout, &di->width, &di->height); di->x = screen_rect.width; di->y = screen_rect.y + rand() % (screen_rect.height - di->height); di->width += 32 + 5; if (image) gtk_fixed_move(GTK_FIXED(fixed), image, 0, di->height / 2 - 16); GdkBitmap* bitmap = gdk_pixmap_new(di->popup->window, di->width, di->height, 1); GdkGC *gc = gdk_gc_new(GDK_DRAWABLE(bitmap)); GdkColormap* colormap = gdk_colormap_get_system(); gdk_gc_set_colormap(gc, colormap); gdk_colormap_alloc_color(colormap, color_black, TRUE, TRUE); gdk_gc_set_foreground (gc, color_black); gdk_draw_rectangle(bitmap, gc, TRUE, 0, 0, di->width, di->height); gdk_colormap_alloc_color(colormap, color_white, TRUE, TRUE); gdk_gc_set_foreground (gc, color_white); if (image) gdk_draw_rectangle(bitmap, gc, TRUE, 0, di->height / 2 - 16, 32, 32); gdk_draw_layout(bitmap, gc, 32 + 5, 0, layout); g_signal_connect(G_OBJECT(ebox), "button-press-event", G_CALLBACK(display_clicked), di); g_signal_connect(G_OBJECT(ebox), "enter-notify-event", G_CALLBACK(display_enter), di); g_signal_connect(G_OBJECT(ebox), "leave-notify-event", G_CALLBACK(display_leave), di); gtk_window_move(GTK_WINDOW(di->popup), di->x, di->y); gtk_widget_show_all(di->popup); gtk_widget_set_size_request(fixed, di->width, di->height); gdk_window_set_back_pixmap(di->popup->window, NULL, FALSE); gdk_window_shape_combine_mask(di->popup->window, bitmap, 0, 0); g_object_unref(gc); g_object_unref(layout); g_object_unref(context); g_object_unref(bitmap); g_object_ref(di->popup); g_timeout_add(100, display_animation_func, di); return FALSE; }
GtkWidget *create_notebook_page_dialog(int page, dialog_buttons btn[MAX_KEYS], dialog_checkbox checkbox[CHECK_NBR]) { GtkWidget *main_box; GtkWidget *joy_choose_frame, *joy_choose_box; GtkWidget *keys_frame, *keys_box; GtkWidget *keys_tree_box, *keys_tree_scroll; GtkWidget *keys_tree_clear_btn, *keys_tree_remove_btn, *keys_tree_modify_btn, *keys_tree_show_key_btn, *keys_tree_show_joy_btn; GtkWidget *keys_btn_box, *keys_filter_box; GtkWidget *keys_static_frame, *keys_static_box; GtkWidget *keys_static_area; joy_choose_cbox = GTK_COMBO_BOX(gtk_combo_box_new_text()); populate_new_joysticks(joy_choose_cbox); set_current_joy(); g_signal_connect(GTK_OBJECT (joy_choose_cbox), "changed", G_CALLBACK(joy_changed), NULL); keys_tree_scroll = gtk_scrolled_window_new(NULL, NULL); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(keys_tree_scroll), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_container_add (GTK_CONTAINER(keys_tree_scroll), key_tree_manager->view_widget(page)); gtk_widget_set_size_request(keys_tree_scroll, 300, 500); keys_tree_clear_btn = gtk_button_new_with_label("Clear All"); g_signal_connect(GTK_OBJECT (keys_tree_clear_btn), "clicked", G_CALLBACK(on_clear_clicked), NULL); gtk_widget_set_size_request(keys_tree_clear_btn, 70, 24); keys_tree_remove_btn = gtk_button_new_with_label("Remove"); g_signal_connect(GTK_OBJECT (keys_tree_remove_btn), "clicked", G_CALLBACK(on_remove_clicked), NULL); gtk_widget_set_size_request(keys_tree_remove_btn, 70, 24); keys_tree_modify_btn = gtk_button_new_with_label("Modify"); g_signal_connect(GTK_OBJECT (keys_tree_modify_btn), "clicked", G_CALLBACK(on_modify_clicked), NULL); gtk_widget_set_size_request(keys_tree_modify_btn, 70, 24); keys_tree_show_joy_btn = gtk_check_button_new_with_label("Show joy"); g_signal_connect(GTK_OBJECT (keys_tree_show_joy_btn), "toggled", G_CALLBACK(on_view_joy_clicked), NULL); gtk_widget_set_size_request(keys_tree_show_joy_btn, 100, 24); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(keys_tree_show_joy_btn), true); keys_tree_show_key_btn = gtk_check_button_new_with_label("Show key"); g_signal_connect(GTK_OBJECT (keys_tree_show_key_btn), "toggled", G_CALLBACK(on_view_key_clicked), NULL); gtk_widget_set_size_request(keys_tree_show_key_btn, 100, 24); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(keys_tree_show_key_btn), true); joy_choose_box = gtk_hbox_new(false, 5); joy_choose_frame = gtk_frame_new ("Joystick to use for this pad"); gtk_container_add (GTK_CONTAINER(joy_choose_frame), joy_choose_box); keys_btn_box = gtk_hbox_new(false, 5); keys_filter_box = gtk_hbox_new(false, 5); keys_tree_box = gtk_vbox_new(false, 5); keys_static_box = gtk_hbox_new(false, 5); keys_static_frame = gtk_frame_new (""); gtk_container_add (GTK_CONTAINER(keys_static_frame), keys_static_box); keys_static_area = gtk_fixed_new(); for(int i = 0; i < MAX_KEYS; i++) { btn[i].put(b_pos[i].label, i, GTK_FIXED(keys_static_area), b_pos[i].x, b_pos[i].y); } u32 mask = 1 << (16*page); for(int i = 0; i < CHECK_NBR; i++) { checkbox[i].create(keys_static_area, check_pos[i].label, check_pos[i].x, check_pos[i].y, mask); mask = mask << 1; } keys_box = gtk_hbox_new(false, 5); keys_frame = gtk_frame_new ("Key Settings"); gtk_container_add (GTK_CONTAINER(keys_frame), keys_box); gtk_box_pack_start (GTK_BOX (keys_tree_box), keys_tree_scroll, true, true, 0); gtk_box_pack_start (GTK_BOX (keys_tree_box), keys_btn_box, false, false, 0); gtk_box_pack_start (GTK_BOX (keys_tree_box), keys_filter_box, false, false, 0); gtk_box_pack_start (GTK_BOX (keys_filter_box), keys_tree_show_joy_btn, false, false, 0); gtk_box_pack_start (GTK_BOX (keys_filter_box), keys_tree_show_key_btn, false, false, 0); gtk_box_pack_start (GTK_BOX (keys_btn_box), keys_tree_clear_btn, false, false, 0); gtk_box_pack_start (GTK_BOX (keys_btn_box), keys_tree_remove_btn, false, false, 0); gtk_box_pack_start (GTK_BOX (keys_btn_box), keys_tree_modify_btn, false, false, 0); gtk_container_add(GTK_CONTAINER(joy_choose_box), GTK_WIDGET(joy_choose_cbox)); gtk_box_pack_start(GTK_BOX (keys_box), keys_tree_box, false, false, 0); gtk_container_add(GTK_CONTAINER(keys_box), keys_static_area); main_box = gtk_vbox_new(false, 5); gtk_container_add(GTK_CONTAINER(main_box), joy_choose_frame); gtk_container_add(GTK_CONTAINER(main_box), keys_frame); return main_box; }
void WindowApp::mainMenu(GtkWidget *widget, WindowApp *theApp){ ///////////////////////////////////////////////////// //-----------Create the window ------------------//// ///////////////////////////////////////////////////// gtk_window_resize(GTK_WINDOW(theApp->window), 400,200); ///////////////////////////////////////////////////// //-----------Add frame onto window---------------//// ///////////////////////////////////////////////////// theApp->appFrame = gtk_fixed_new(); theApp->admin_frame = gtk_fixed_new(); gtk_container_add(GTK_CONTAINER(theApp->window), theApp->appFrame); ///////////////////////////////////////////////////// //Make the application button and add to frame---//// ///////////////////////////////////////////////////// theApp->btnStudent = gtk_button_new_with_label("Student"); gtk_widget_set_size_request(theApp->btnStudent, 80, 35); gtk_fixed_put(GTK_FIXED(theApp->appFrame), theApp->btnStudent, 50, 20); theApp->apply = gtk_button_new_with_label("Apply"); gtk_widget_set_size_request(theApp->apply, 80, 35); ///////////////////////////////////////////////////// //------Make the login button and add to frame---//// ///////////////////////////////////////////////////// theApp->login = gtk_button_new_with_label("Admin"); gtk_widget_set_size_request(theApp->login, 80, 35); gtk_fixed_put(GTK_FIXED(theApp->appFrame), theApp->login, 50, 80); ///////////////////////////////////////////////////// //------Make the Prompt Label and add to frame---//// ///////////////////////////////////////////////////// theApp->label = gtk_label_new("Choose a Menu Option"); gtk_fixed_put(GTK_FIXED(theApp->appFrame), theApp->label, 150, 58); ///////////////////////////////////////////////////// //----------Show all the widgets on the window---//// ///////////////////////////////////////////////////// theApp->moveOn = false; theApp->extra = false; gtk_widget_show_all(theApp->window); ///////////////////////////////////////////////////// //Connect signals with each button as well as close//// ///////////////////////////////////////////////////// g_signal_connect(theApp->window, "destroy", G_CALLBACK (Control::cancel), theApp); g_signal_connect(theApp->btnStudent, "clicked", G_CALLBACK(WindowApp::studentPage), theApp); g_signal_connect(theApp->login, "clicked", G_CALLBACK(WindowApp::adminPage), theApp); }
GtkWidget * dt_lib_gui_get_expander (dt_lib_module_t *module) { /* check if module is expandable */ if(!module->expandable()) { module->expander = NULL; return NULL; } int bs = 12; GtkWidget *expander = gtk_vbox_new(FALSE, 3); GtkWidget *header_evb = gtk_event_box_new(); GtkWidget *header = gtk_hbox_new(FALSE, 0); GtkWidget *pluginui_frame = gtk_frame_new(NULL); GtkWidget *pluginui = gtk_event_box_new(); /* steup the header box */ gtk_container_add(GTK_CONTAINER(header_evb), header); g_signal_connect(G_OBJECT(header_evb), "button-press-event", G_CALLBACK(_lib_plugin_header_button_press), module); /* setup plugin content frame */ gtk_frame_set_shadow_type(GTK_FRAME(pluginui_frame),GTK_SHADOW_IN); gtk_container_add(GTK_CONTAINER(pluginui_frame),pluginui); /* layout the main expander widget */ gtk_box_pack_start(GTK_BOX(expander), header_evb, TRUE, FALSE, 0); gtk_box_pack_start(GTK_BOX(expander), pluginui_frame, TRUE, FALSE,0); /* * initialize the header widgets */ int idx=0; GtkWidget *hw[5]= {NULL,NULL,NULL,NULL,NULL}; /* add the expand indicator icon */ hw[idx] = dtgtk_icon_new(dtgtk_cairo_paint_solid_arrow, CPF_DIRECTION_LEFT); gtk_widget_set_size_request(GTK_WIDGET(hw[idx++]),bs,bs); /* add module label */ char label[128]; g_snprintf(label,128,"<span size=\"larger\">%s</span>",module->name()); hw[idx] = gtk_label_new(""); gtk_widget_set_name(hw[idx], "panel_label"); gtk_label_set_markup(GTK_LABEL(hw[idx++]),label); /* add reset button if module has implementation */ if (module->gui_reset) { hw[idx] = dtgtk_button_new(dtgtk_cairo_paint_reset, CPF_STYLE_FLAT|CPF_DO_NOT_USE_BORDER); module->reset_button = GTK_WIDGET(hw[idx]); g_object_set(G_OBJECT(hw[idx]), "tooltip-text", _("reset parameters"), (char *)NULL); g_signal_connect (G_OBJECT (hw[idx]), "clicked", G_CALLBACK (dt_lib_gui_reset_callback), module); } else hw[idx] = gtk_fixed_new(); gtk_widget_set_size_request(GTK_WIDGET(hw[idx++]),bs,bs); /* add preset button if module has implementation */ if (module->get_params) { hw[idx] = dtgtk_button_new(dtgtk_cairo_paint_presets,CPF_STYLE_FLAT|CPF_DO_NOT_USE_BORDER); module->presets_button = GTK_WIDGET(hw[idx]); g_object_set(G_OBJECT(hw[idx]), "tooltip-text", _("presets"), (char *)NULL); g_signal_connect (G_OBJECT (hw[idx]), "clicked", G_CALLBACK (popup_callback), module); } else hw[idx] = gtk_fixed_new(); gtk_widget_set_size_request(GTK_WIDGET(hw[idx++]),bs,bs); /* add a spacer to align buttons with iop buttons (enabled button) */ hw[idx] = gtk_fixed_new(); gtk_widget_set_size_request(GTK_WIDGET(hw[idx++]),bs,bs); /* lets order header elements depending on left/right side panel placement */ int c = module->container(); if ( (c == DT_UI_CONTAINER_PANEL_LEFT_TOP) || (c == DT_UI_CONTAINER_PANEL_LEFT_CENTER) || (c == DT_UI_CONTAINER_PANEL_LEFT_BOTTOM) ) { for(int i=0; i<=4; i++) if (hw[i]) gtk_box_pack_start(GTK_BOX(header), hw[i],i==1?TRUE:FALSE,i==1?TRUE:FALSE,2); gtk_misc_set_alignment(GTK_MISC(hw[1]),0.0,0.5); dtgtk_icon_set_paint(hw[0], dtgtk_cairo_paint_solid_arrow, CPF_DIRECTION_RIGHT); } else { for(int i=4; i>=0; i--) if (hw[i]) gtk_box_pack_start(GTK_BOX(header), hw[i],i==1?TRUE:FALSE,i==1?TRUE:FALSE,2); gtk_misc_set_alignment(GTK_MISC(hw[1]),1.0,0.5); dtgtk_icon_set_paint(hw[0], dtgtk_cairo_paint_solid_arrow, CPF_DIRECTION_LEFT); } /* add module widget into an alignment */ GtkWidget *al = gtk_alignment_new(1.0, 1.0, 1.0, 1.0); gtk_alignment_set_padding(GTK_ALIGNMENT(al), 8, 8, 8, 8); gtk_container_add(GTK_CONTAINER(pluginui), al); gtk_container_add(GTK_CONTAINER(al), module->widget); gtk_widget_show_all(module->widget); module->expander = expander; return module->expander; }
int WindowApp::makeApplication(GtkWidget *widget, WindowApp *theApp) { theApp->gradApp = false; ///////////////////////////////////////////////// //--Creates new frame and adds it onto the window---// ///////////////////////////////////////////////// gtk_widget_destroy(theApp->student_window); gtk_widget_destroy(theApp->appFrame); theApp->appFrame = gtk_fixed_new(); gtk_window_resize(GTK_WINDOW(theApp->window), 400,600); theApp->combo = gtk_combo_box_text_new(); theApp->fName = gtk_entry_new(); theApp->lName = gtk_entry_new(); theApp->major = gtk_entry_new(); theApp->gpa = gtk_entry_new(); theApp->email = gtk_entry_new(); theApp->year = gtk_entry_new(); theApp->cgpa = gtk_entry_new(); theApp->stuNum = gtk_entry_new(); char text[800]; string courses[800]; ifstream inFile("courses.txt", ios::in); if (!inFile) { cout<<"Could not open file"<<endl; return 0; } while (!inFile.eof()) { inFile.getline(text, 800); gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(theApp->combo), text); } gtk_fixed_put(GTK_FIXED(theApp->appFrame), theApp->combo, 200, 200); ///////////////////////////////////////////////// //--Creates text Boxes and submit\cancel buttons---// ///////////////////////////////////////////////// //theApp->combo = combo; ///////////////////////////////////////////////// //--Puts text boxes onto the new frame---------// ///////////////////////////////////////////////// gtk_fixed_put(GTK_FIXED(theApp->appFrame), theApp->fName, 150, 280); gtk_fixed_put(GTK_FIXED(theApp->appFrame), theApp->lName, 150, 310); gtk_fixed_put(GTK_FIXED(theApp->appFrame), theApp->major, 150, 340); gtk_fixed_put(GTK_FIXED(theApp->appFrame), theApp->gpa, 150, 370); gtk_fixed_put(GTK_FIXED(theApp->appFrame), theApp->cgpa, 150, 400); gtk_fixed_put(GTK_FIXED(theApp->appFrame), theApp->email, 150, 430); gtk_fixed_put(GTK_FIXED(theApp->appFrame), theApp->year, 150, 460); gtk_fixed_put(GTK_FIXED(theApp->appFrame), theApp->stuNum, 150, 490); ///////////////////////////////////////////////// //--Puts labels onto the new frame---------// ///////////////////////////////////////////////// theApp->lblfName = gtk_label_new("First Name :"); gtk_fixed_put(GTK_FIXED(theApp->appFrame), theApp->lblfName, 30, 280); theApp->lbllName = gtk_label_new("Last Name :"); gtk_fixed_put(GTK_FIXED(theApp->appFrame), theApp->lbllName, 30, 310); theApp->lblMajor = gtk_label_new("Major :"); gtk_fixed_put(GTK_FIXED(theApp->appFrame), theApp->lblMajor, 30, 340); theApp->lblGpa = gtk_label_new("GPA :"); gtk_fixed_put(GTK_FIXED(theApp->appFrame), theApp->lblGpa, 30, 370); theApp->lblCgpa = gtk_label_new("CGPA :"); gtk_fixed_put(GTK_FIXED(theApp->appFrame), theApp->lblCgpa, 30, 400); theApp->lblEmail = gtk_label_new("Email Address :"); gtk_fixed_put(GTK_FIXED(theApp->appFrame), theApp->lblEmail, 30, 430); theApp->lblYear = gtk_label_new("Year :"); gtk_fixed_put(GTK_FIXED(theApp->appFrame), theApp->lblYear, 30, 460); theApp->lblstuNum = gtk_label_new("Student Number :"); gtk_fixed_put(GTK_FIXED(theApp->appFrame), theApp->lblstuNum, 30, 490); ///////////////////////////////////////////////// //--Puts buttons onto the new frame---------// ///////////////////////////////////////////////// theApp->submit = gtk_button_new_with_label("Submit"); theApp->cancel = gtk_button_new_with_label("Cancel"); gtk_widget_set_size_request(theApp->submit, 80, 35); gtk_fixed_put(GTK_FIXED(theApp->appFrame), theApp->submit, 50, 530); gtk_widget_set_size_request(theApp->cancel, 80, 35); gtk_fixed_put(GTK_FIXED(theApp->appFrame), theApp->cancel, 200, 530); theApp->info_label = gtk_label_new("Please Enter Info Below"); gtk_fixed_put(GTK_FIXED(theApp->appFrame), theApp->info_label, 150, 58); gtk_container_add(GTK_CONTAINER(theApp->window), theApp->appFrame); ///////////////////////////////////////////////// //--Show all widgets on new frame---------// ///////////////////////////////////////////////// gtk_widget_show_all(theApp->window); g_signal_connect(theApp->submit, "clicked", G_CALLBACK(Control::getInfo), theApp); g_signal_connect(theApp->cancel, "clicked", G_CALLBACK(Control::submitToMain), theApp); g_signal_connect(GTK_COMBO_BOX(theApp->combo), "changed", G_CALLBACK (WindowApp::relatedCourses1), theApp); return 0; }
static GtkWidget *create_window(void) { GtkWidget *startwin; GtkWidget *hlayout; GtkWidget *banner; GtkWidget *vlayout; GtkWidget *tabs; GtkWidget *configvlayout; GtkWidget *configlayout; GtkWidget *vmode3dlabel; GtkWidget *vmode3dcombo; GtkWidget *fullscreencheck; GtkWidget *alwaysshowcheck; GtkWidget *configtab; GtkWidget *messagesscroll; GtkWidget *messagestext; GtkWidget *messagestab; GtkWidget *buttons; GtkWidget *cancelbutton; GtkWidget *cancelbuttonalign; GtkWidget *cancelbuttonlayout; GtkWidget *cancelbuttonicon; GtkWidget *cancelbuttonlabel; GtkWidget *startbutton; GtkWidget *startbuttonalign; GtkWidget *startbuttonlayout; GtkWidget *startbuttonicon; GtkWidget *startbuttonlabel; GtkAccelGroup *accel_group; accel_group = gtk_accel_group_new(); // Basic window startwin = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_title(GTK_WINDOW(startwin), apptitle); // NOTE: use global app title gtk_window_set_position(GTK_WINDOW(startwin), GTK_WIN_POS_CENTER); gtk_window_set_resizable(GTK_WINDOW(startwin), FALSE); gtk_window_set_type_hint(GTK_WINDOW(startwin), GDK_WINDOW_TYPE_HINT_DIALOG); // Horizontal layout of banner and controls hlayout = gtk_hbox_new(FALSE, 0); gtk_widget_show(hlayout); gtk_container_add(GTK_CONTAINER(startwin), hlayout); // Banner { GdkPixbuf *pixbuf = load_banner(); banner = gtk_image_new_from_pixbuf(pixbuf); g_object_unref((gpointer)pixbuf); } gtk_widget_show(banner); gtk_box_pack_start(GTK_BOX(hlayout), banner, FALSE, FALSE, 0); gtk_misc_set_alignment(GTK_MISC(banner), 0.5, 0); // Vertical layout of tab control and start+cancel buttons vlayout = gtk_vbox_new(FALSE, 0); gtk_widget_show(vlayout); gtk_box_pack_start(GTK_BOX(hlayout), vlayout, TRUE, TRUE, 0); // Tab control tabs = gtk_notebook_new(); gtk_widget_show(tabs); gtk_box_pack_start(GTK_BOX(vlayout), tabs, TRUE, TRUE, 0); gtk_container_set_border_width(GTK_CONTAINER(tabs), 4); // Vertical layout of config page main body configvlayout = gtk_vbox_new(FALSE, 0); gtk_widget_show(configvlayout); gtk_container_add(GTK_CONTAINER(tabs), configvlayout); // Fixed-position layout of config page controls configlayout = gtk_fixed_new(); gtk_widget_show(configlayout); gtk_box_pack_start(GTK_BOX(configvlayout), configlayout, TRUE, TRUE, 0); gtk_container_set_border_width(GTK_CONTAINER(configlayout), 6); // 3D video mode label vmode3dlabel = gtk_label_new_with_mnemonic("_Video mode:"); gtk_widget_show(vmode3dlabel); gtk_fixed_put(GTK_FIXED(configlayout), vmode3dlabel, 0, 0); gtk_widget_set_size_request(vmode3dlabel, 88, 29); gtk_misc_set_alignment(GTK_MISC(vmode3dlabel), 0, 0.5); // 3D video mode combo { GtkListStore *list = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_INT); GtkCellRenderer *cell; vmode3dcombo = gtk_combo_box_new_with_model(GTK_TREE_MODEL(list)); g_object_unref(G_OBJECT(list)); cell = gtk_cell_renderer_text_new(); gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(vmode3dcombo), cell, FALSE); gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(vmode3dcombo), cell, "text", 0, NULL); } gtk_widget_show(vmode3dcombo); gtk_fixed_put(GTK_FIXED(configlayout), vmode3dcombo, 88, 0); gtk_widget_set_size_request(vmode3dcombo, 150, 29); gtk_widget_add_accelerator(vmode3dcombo, "grab_focus", accel_group, GDK_V, GDK_MOD1_MASK, GTK_ACCEL_VISIBLE); // Fullscreen checkbox fullscreencheck = gtk_check_button_new_with_mnemonic("_Fullscreen"); gtk_widget_show(fullscreencheck); gtk_fixed_put(GTK_FIXED(configlayout), fullscreencheck, 248, 0); gtk_widget_set_size_request(fullscreencheck, 85, 29); gtk_widget_add_accelerator(fullscreencheck, "grab_focus", accel_group, GDK_F, GDK_MOD1_MASK, GTK_ACCEL_VISIBLE); // Always show config checkbox alwaysshowcheck = gtk_check_button_new_with_mnemonic("_Always show configuration on start"); gtk_widget_show(alwaysshowcheck); gtk_box_pack_start(GTK_BOX(configvlayout), alwaysshowcheck, FALSE, FALSE, 0); gtk_widget_add_accelerator(alwaysshowcheck, "grab_focus", accel_group, GDK_A, GDK_MOD1_MASK, GTK_ACCEL_VISIBLE); // Configuration tab configtab = gtk_label_new("Configuration"); gtk_widget_show(configtab); gtk_notebook_set_tab_label(GTK_NOTEBOOK(tabs), gtk_notebook_get_nth_page(GTK_NOTEBOOK(tabs), 0), configtab); // Messages scrollable area messagesscroll = gtk_scrolled_window_new(NULL, NULL); gtk_widget_show(messagesscroll); gtk_container_add(GTK_CONTAINER(tabs), messagesscroll); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(messagesscroll), GTK_POLICY_NEVER, GTK_POLICY_ALWAYS); // Messages text area messagestext = gtk_text_view_new(); gtk_widget_show(messagestext); gtk_container_add(GTK_CONTAINER(messagesscroll), messagestext); gtk_text_view_set_editable(GTK_TEXT_VIEW(messagestext), FALSE); gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(messagestext), GTK_WRAP_WORD); gtk_text_view_set_cursor_visible(GTK_TEXT_VIEW(messagestext), FALSE); gtk_text_view_set_left_margin(GTK_TEXT_VIEW(messagestext), 2); gtk_text_view_set_right_margin(GTK_TEXT_VIEW(messagestext), 2); // Messages tab messagestab = gtk_label_new("Messages"); gtk_widget_show(messagestab); gtk_notebook_set_tab_label(GTK_NOTEBOOK(tabs), gtk_notebook_get_nth_page(GTK_NOTEBOOK(tabs), 1), messagestab); // Dialogue box buttons layout buttons = gtk_hbutton_box_new(); gtk_widget_show(buttons); gtk_box_pack_start(GTK_BOX(vlayout), buttons, FALSE, TRUE, 0); gtk_container_set_border_width(GTK_CONTAINER(buttons), 3); gtk_button_box_set_layout(GTK_BUTTON_BOX(buttons), GTK_BUTTONBOX_END); // Cancel button cancelbutton = gtk_button_new(); gtk_widget_show(cancelbutton); gtk_container_add(GTK_CONTAINER(buttons), cancelbutton); GTK_WIDGET_SET_FLAGS(cancelbutton, GTK_CAN_DEFAULT); gtk_widget_add_accelerator(cancelbutton, "grab_focus", accel_group, GDK_C, GDK_MOD1_MASK, GTK_ACCEL_VISIBLE); gtk_widget_add_accelerator(cancelbutton, "clicked", accel_group, GDK_Escape, 0, GTK_ACCEL_VISIBLE); cancelbuttonalign = gtk_alignment_new(0.5, 0.5, 0, 0); gtk_widget_show(cancelbuttonalign); gtk_container_add(GTK_CONTAINER(cancelbutton), cancelbuttonalign); cancelbuttonlayout = gtk_hbox_new(FALSE, 2); gtk_widget_show(cancelbuttonlayout); gtk_container_add(GTK_CONTAINER(cancelbuttonalign), cancelbuttonlayout); cancelbuttonicon = gtk_image_new_from_stock("gtk-cancel", GTK_ICON_SIZE_BUTTON); gtk_widget_show(cancelbuttonicon); gtk_box_pack_start(GTK_BOX(cancelbuttonlayout), cancelbuttonicon, FALSE, FALSE, 0); cancelbuttonlabel = gtk_label_new_with_mnemonic("_Cancel"); gtk_widget_show(cancelbuttonlabel); gtk_box_pack_start(GTK_BOX(cancelbuttonlayout), cancelbuttonlabel, FALSE, FALSE, 0); // Start button startbutton = gtk_button_new(); gtk_widget_show(startbutton); gtk_container_add(GTK_CONTAINER(buttons), startbutton); GTK_WIDGET_SET_FLAGS(startbutton, GTK_CAN_DEFAULT); gtk_widget_add_accelerator(startbutton, "grab_focus", accel_group, GDK_S, GDK_MOD1_MASK, GTK_ACCEL_VISIBLE); gtk_widget_add_accelerator(startbutton, "clicked", accel_group, GDK_Return, 0, GTK_ACCEL_VISIBLE); startbuttonalign = gtk_alignment_new(0.5, 0.5, 0, 0); gtk_widget_show(startbuttonalign); gtk_container_add(GTK_CONTAINER(startbutton), startbuttonalign); startbuttonlayout = gtk_hbox_new(FALSE, 2); gtk_widget_show(startbuttonlayout); gtk_container_add(GTK_CONTAINER(startbuttonalign), startbuttonlayout); startbuttonicon = gtk_image_new_from_stock("gtk-execute", GTK_ICON_SIZE_BUTTON); gtk_widget_show(startbuttonicon); gtk_box_pack_start(GTK_BOX(startbuttonlayout), startbuttonicon, FALSE, FALSE, 0); startbuttonlabel = gtk_label_new_with_mnemonic("_Start"); gtk_widget_show(startbuttonlabel); gtk_box_pack_start(GTK_BOX(startbuttonlayout), startbuttonlabel, FALSE, FALSE, 0); // Wire up the signals g_signal_connect((gpointer) startwin, "delete_event", G_CALLBACK(on_startwin_delete_event), NULL); g_signal_connect((gpointer) vmode3dcombo, "changed", G_CALLBACK(on_vmode3dcombo_changed), NULL); g_signal_connect((gpointer) fullscreencheck, "toggled", G_CALLBACK(on_fullscreencheck_toggled), NULL); g_signal_connect((gpointer) alwaysshowcheck, "toggled", G_CALLBACK(on_alwaysshowcheck_toggled), NULL); g_signal_connect((gpointer) cancelbutton, "clicked", G_CALLBACK(on_cancelbutton_clicked), NULL); g_signal_connect((gpointer) startbutton, "clicked", G_CALLBACK(on_startbutton_clicked), NULL); // Associate labels with their controls gtk_label_set_mnemonic_widget(GTK_LABEL(vmode3dlabel), vmode3dcombo); /* Store pointers to all widgets, for use by lookup_widget(). */ GLADE_HOOKUP_OBJECT_NO_REF(startwin, startwin, "startwin"); GLADE_HOOKUP_OBJECT(startwin, hlayout, "hlayout"); GLADE_HOOKUP_OBJECT(startwin, banner, "banner"); GLADE_HOOKUP_OBJECT(startwin, vlayout, "vlayout"); GLADE_HOOKUP_OBJECT(startwin, tabs, "tabs"); GLADE_HOOKUP_OBJECT(startwin, configvlayout, "configvlayout"); GLADE_HOOKUP_OBJECT(startwin, configlayout, "configlayout"); GLADE_HOOKUP_OBJECT(startwin, vmode3dlabel, "vmode3dlabel"); GLADE_HOOKUP_OBJECT(startwin, vmode3dcombo, "vmode3dcombo"); GLADE_HOOKUP_OBJECT(startwin, fullscreencheck, "fullscreencheck"); GLADE_HOOKUP_OBJECT(startwin, alwaysshowcheck, "alwaysshowcheck"); GLADE_HOOKUP_OBJECT(startwin, configtab, "configtab"); GLADE_HOOKUP_OBJECT(startwin, messagesscroll, "messagesscroll"); GLADE_HOOKUP_OBJECT(startwin, messagestext, "messagestext"); GLADE_HOOKUP_OBJECT(startwin, messagestab, "messagestab"); GLADE_HOOKUP_OBJECT(startwin, buttons, "buttons"); GLADE_HOOKUP_OBJECT(startwin, cancelbutton, "cancelbutton"); GLADE_HOOKUP_OBJECT(startwin, cancelbuttonalign, "cancelbuttonalign"); GLADE_HOOKUP_OBJECT(startwin, cancelbuttonlayout, "cancelbuttonlayout"); GLADE_HOOKUP_OBJECT(startwin, cancelbuttonicon, "cancelbuttonicon"); GLADE_HOOKUP_OBJECT(startwin, cancelbuttonlabel, "cancelbuttonlabel"); GLADE_HOOKUP_OBJECT(startwin, startbutton, "startbutton"); GLADE_HOOKUP_OBJECT(startwin, startbuttonalign, "startbuttonalign"); GLADE_HOOKUP_OBJECT(startwin, startbuttonlayout, "startbuttonlayout"); GLADE_HOOKUP_OBJECT(startwin, startbuttonicon, "startbuttonicon"); GLADE_HOOKUP_OBJECT(startwin, startbuttonlabel, "startbuttonlabel"); gtk_window_add_accel_group(GTK_WINDOW(startwin), accel_group); return startwin; }
int WindowApp::makeGradApplication(GtkWidget *widget, WindowApp *theApp) { theApp->gradApp = true; ///////////////////////////////////////////////// //--Creates new frame and adds it onto the window---// ///////////////////////////////////////////////// gtk_widget_destroy(theApp->student_window); gtk_widget_destroy(theApp->appFrame); theApp->appFrame = gtk_fixed_new(); gtk_window_resize(GTK_WINDOW(theApp->window), 400,600); //their general information, including student number, first and last names, email address, main research area //(selected from a preconfigured list), program (MCS or PhD), and supervisor name theApp->combo = gtk_combo_box_text_new(); theApp->grad_research_combo = gtk_combo_box_text_new(); theApp->grad_program_combo = gtk_combo_box_text_new(); theApp->fName = gtk_entry_new(); theApp->lName = gtk_entry_new(); theApp->email = gtk_entry_new(); theApp->grad_sup = gtk_entry_new(); theApp->stuNum = gtk_entry_new(); gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(theApp->grad_program_combo), "MCS"); gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(theApp->grad_program_combo), "PHD"); gtk_fixed_put(GTK_FIXED(theApp->appFrame), theApp->grad_program_combo, 200, 300); char text[800]; string courses[800]; ifstream inFile("courses.txt", ios::in); if (!inFile) { cout<<"Could not open courses file"<<endl; return 0; } while (!inFile.eof()) { inFile.getline(text, 800); gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(theApp->combo), text); } gtk_fixed_put(GTK_FIXED(theApp->appFrame), theApp->combo, 200, 200); char text2[800]; string areas[800]; ifstream inFile2("gradResearch.txt", ios::in); if (!inFile2) { cout<<"Could not open Grad Research file"<<endl; return 0; } while (!inFile2.eof()) { inFile2.getline(text2, 800); gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(theApp->grad_research_combo), text2); } gtk_fixed_put(GTK_FIXED(theApp->appFrame), theApp->grad_research_combo, 200, 250); ///////////////////////////////////////////////// //--Creates text Boxes and submit\cancel buttons---// ///////////////////////////////////////////////// //theApp->combo = combo; ///////////////////////////////////////////////// //--Puts text boxes onto the new frame---------// ///////////////////////////////////////////////// gtk_fixed_put(GTK_FIXED(theApp->appFrame), theApp->fName, 150, 340); gtk_fixed_put(GTK_FIXED(theApp->appFrame), theApp->lName, 150, 370); //gtk_fixed_put(GTK_FIXED(theApp->appFrame), theApp->major, 150, 340); //gtk_fixed_put(GTK_FIXED(theApp->appFrame), theApp->gpa, 150, 370); //gtk_fixed_put(GTK_FIXED(theApp->appFrame), theApp->cgpa, 150, 400); gtk_fixed_put(GTK_FIXED(theApp->appFrame), theApp->email, 150, 400); gtk_fixed_put(GTK_FIXED(theApp->appFrame), theApp->grad_sup, 150, 430); gtk_fixed_put(GTK_FIXED(theApp->appFrame), theApp->stuNum, 150, 460); ///////////////////////////////////////////////// //--Puts labels onto the new frame---------// ///////////////////////////////////////////////// theApp->lblpickCourse = gtk_label_new("Pick Course :"); gtk_fixed_put(GTK_FIXED(theApp->appFrame), theApp->lblpickCourse, 30, 200); theApp->lblpickArea = gtk_label_new("Study Area :"); gtk_fixed_put(GTK_FIXED(theApp->appFrame), theApp->lblpickArea, 30, 250); theApp->lblpickProgram = gtk_label_new("Grad Program:"); gtk_fixed_put(GTK_FIXED(theApp->appFrame), theApp->lblpickProgram, 30, 300); theApp->lblfName = gtk_label_new("First Name :"); gtk_fixed_put(GTK_FIXED(theApp->appFrame), theApp->lblfName, 30, 340); theApp->lbllName = gtk_label_new("Last Name :"); gtk_fixed_put(GTK_FIXED(theApp->appFrame), theApp->lbllName, 30, 370); theApp->lblEmail = gtk_label_new("Email Address:"); gtk_fixed_put(GTK_FIXED(theApp->appFrame), theApp->lblEmail, 30, 400); //theApp->lblGpa = gtk_label_new("GPA :"); //gtk_fixed_put(GTK_FIXED(theApp->appFrame), theApp->lblGpa, 30, 370); //theApp->lblCgpa = gtk_label_new("CGPA :"); //gtk_fixed_put(GTK_FIXED(theApp->appFrame), theApp->lblCgpa, 30, 400); theApp->lbl_grad_sup = gtk_label_new("Supervisor :"); gtk_fixed_put(GTK_FIXED(theApp->appFrame), theApp->lbl_grad_sup, 30, 430); //theApp->lblYear = gtk_label_new("Year :"); //gtk_fixed_put(GTK_FIXED(theApp->appFrame), theApp->lblYear, 30, 460); theApp->lblstuNum = gtk_label_new("Student Number :"); gtk_fixed_put(GTK_FIXED(theApp->appFrame), theApp->lblstuNum, 30, 460); ///////////////////////////////////////////////// //--Puts buttons onto the new frame---------// ///////////////////////////////////////////////// theApp->submit = gtk_button_new_with_label("Submit"); theApp->cancel = gtk_button_new_with_label("Cancel"); gtk_widget_set_size_request(theApp->submit, 80, 35); gtk_fixed_put(GTK_FIXED(theApp->appFrame), theApp->submit, 50, 530); gtk_widget_set_size_request(theApp->cancel, 80, 35); gtk_fixed_put(GTK_FIXED(theApp->appFrame), theApp->cancel, 200, 530); theApp->info_label = gtk_label_new("Please Enter Info Below"); gtk_fixed_put(GTK_FIXED(theApp->appFrame), theApp->info_label, 150, 58); gtk_container_add(GTK_CONTAINER(theApp->window), theApp->appFrame); ///////////////////////////////////////////////// //--Show all widgets on new frame---------// ///////////////////////////////////////////////// gtk_widget_show_all(theApp->window); g_signal_connect(theApp->submit, "clicked", G_CALLBACK(Control::getInfo), theApp); g_signal_connect(theApp->cancel, "clicked", G_CALLBACK(Control::submitToMain), theApp); g_signal_connect(GTK_COMBO_BOX(theApp->combo), "changed", G_CALLBACK (WindowApp::relatedCourses2), theApp); return 0; }
int main(int argc, char **argv) { char imgpath[50]; ///////////////////////////////////Get app Path/////////////////////////////////// char path_save[PATH_MAX]; char abs_exe_path[PATH_MAX]; char *p; if(!(p = strrchr(argv[0], '/'))) getcwd(abs_exe_path, sizeof(abs_exe_path)); else { *p = '\0'; getcwd(path_save, sizeof(path_save)); chdir(argv[0]); getcwd(abs_exe_path, sizeof(abs_exe_path)); chdir(path_save); } //////////////////////////////////////////////////////////////////////////////// printf("\n\n-*-*-*-*-* A piece of Gtk+ code by MAhezh -*-*-*-*-*-*\n\n"); gtk_init(&argc, &argv); GtkWidget *window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER); gtk_window_set_default_size(GTK_WINDOW(window), 10, 10); gtk_window_set_title(GTK_WINDOW(window), "Win orb"); g_signal_connect(G_OBJECT(window), "delete-event", gtk_main_quit, NULL); gtk_widget_set_app_paintable(window, TRUE); g_signal_connect(G_OBJECT(window), "draw", G_CALLBACK(draw), NULL); g_signal_connect(G_OBJECT(window), "screen-changed", G_CALLBACK(screen_changed), NULL); gtk_window_set_decorated(GTK_WINDOW(window), FALSE); gtk_widget_add_events(window, GDK_BUTTON_PRESS_MASK); g_signal_connect(G_OBJECT(window), "button-press-event", G_CALLBACK(on_button_press), NULL); //g_signal_connect(G_OBJECT(window), "button-press-event", G_CALLBACK(clicked), NULL); GtkWidget* fixed_container = gtk_fixed_new(); gtk_container_add(GTK_CONTAINER(window), fixed_container); sprintf(imgpath,"%s/img/metronew.png",abs_exe_path); GtkWidget *image = gtk_image_new_from_file(imgpath); gtk_container_add(GTK_CONTAINER(fixed_container), image); screen_changed(window, NULL, NULL); ////////////////////////////////////// Window 2 ////////////////////////////////////////////// GtkWidget *window2 = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_position(GTK_WINDOW(window2), GTK_WIN_POS_CENTER); gtk_window_set_default_size(GTK_WINDOW(window2), 10, 10); gtk_window_set_title(GTK_WINDOW(window2), "Win orb"); gtk_window_set_opacity(GTK_WINDOW(window2),0.0); g_signal_connect(G_OBJECT(window2), "delete-event", gtk_main_quit, NULL); gtk_widget_set_app_paintable(window2, TRUE); g_signal_connect(G_OBJECT(window2), "draw", G_CALLBACK(draw), NULL); g_signal_connect(G_OBJECT(window2), "screen-changed", G_CALLBACK(screen_changed), NULL); gtk_window_set_decorated(GTK_WINDOW(window2), FALSE); gtk_widget_add_events(window2, GDK_BUTTON_PRESS_MASK); // g_signal_connect(G_OBJECT(window2), "button-press-event", // G_CALLBACK(on_button_press), NULL); g_signal_connect_swapped(G_OBJECT(window2), "button-press-event", G_CALLBACK(on_button_press), window2); //g_signal_connect(G_OBJECT(window2), "button-press-event", G_CALLBACK(clicked), NULL); GtkWidget* fixed_container2 = gtk_fixed_new(); gtk_container_add(GTK_CONTAINER(window2), fixed_container2); sprintf(imgpath,"%s/img/metroglow.png",abs_exe_path); GtkWidget *image2 = gtk_image_new_from_file(imgpath); gtk_container_add(GTK_CONTAINER(fixed_container2), image2); screen_changed(window2, NULL, NULL); //////////////////////////////////////////////////////////////////////////////////////////////// gtk_widget_show_all(window); gtk_widget_show_all(window2); //window_2(); /////////////////////////////////////OPACITY/////////////////////////////////////////////////////// int timer; float vl = 0.0; int tnt; gboolean mouse_enter() { if(tnt==1) { timer = g_timeout_add ( 3, mouse_enter, NULL ); vl = vl + 0.008; gtk_window_set_opacity(GTK_WINDOW(window2), vl); if (vl >= 1.0) { g_source_remove (timer); return FALSE; printf("Still running\n"); //vl = 0; } } } gboolean mouse_leave() //function for timeouts must be a boolean { if(tnt==0) { timer = g_timeout_add ( 3, mouse_leave, NULL ); vl = vl - 0.008; gtk_window_set_opacity(GTK_WINDOW(window2), vl); if (vl <= 0.0) { g_source_remove (timer); return FALSE; //vl = 1.0; } } } int me() { //g_source_remove (timer); tnt=1; printf("Entered %d\n", tnt); mouse_enter(); }
/* ----------------------------------------------------------------------------*/ void buildMainUI() { GtkWidget* label; mainWindow = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_title((GtkWindow*)mainWindow,"gHermes"); gtk_widget_modify_bg(mainWindow,GTK_STATE_NORMAL,&background); g_signal_connect(G_OBJECT(mainWindow),"destroy",G_CALLBACK(quit),NULL); mainFixed=gtk_fixed_new(); gtk_widget_modify_bg(mainFixed,GTK_STATE_NORMAL,&background); buttonExit = gtk_button_new_with_label ("Quit"); gtk_widget_modify_bg(buttonExit, GTK_STATE_NORMAL, &buttonBackground); label=gtk_bin_get_child((GtkBin*)buttonExit); gtk_widget_modify_fg(label, GTK_STATE_NORMAL, &white); gtk_widget_set_size_request(GTK_WIDGET(buttonExit),LARGE_BUTTON_WIDTH,BUTTON_HEIGHT); g_signal_connect(G_OBJECT(buttonExit),"clicked",G_CALLBACK(exitCallback),NULL); gtk_widget_show(buttonExit); #ifdef NETBOOK gtk_fixed_put((GtkFixed*)mainFixed,buttonExit,2,0); #else gtk_fixed_put((GtkFixed*)mainFixed,buttonExit,5,0); #endif buttonSetup = gtk_button_new_with_label ("Setup"); gtk_widget_modify_bg(buttonSetup, GTK_STATE_NORMAL, &buttonBackground); label=gtk_bin_get_child((GtkBin*)buttonSetup); gtk_widget_modify_fg(label, GTK_STATE_NORMAL, &white); gtk_widget_set_size_request(GTK_WIDGET(buttonSetup),LARGE_BUTTON_WIDTH,BUTTON_HEIGHT); g_signal_connect(G_OBJECT(buttonSetup),"clicked",G_CALLBACK(setupCallback),NULL); gtk_widget_show(buttonSetup); #ifdef NETBOOK gtk_fixed_put((GtkFixed*)mainFixed,buttonSetup,82,0); #else gtk_fixed_put((GtkFixed*)mainFixed,buttonSetup,70,0); #endif #ifdef ALEX_TEST buttonTest = gtk_button_new_with_label ("Test"); gtk_widget_modify_bg(buttonTest, GTK_STATE_NORMAL, &buttonBackground); label=gtk_bin_get_child((GtkBin*)buttonTest); gtk_widget_modify_fg(label, GTK_STATE_NORMAL, &white); gtk_widget_set_size_request(GTK_WIDGET(buttonTest),LARGE_BUTTON_WIDTH,BUTTON_HEIGHT); g_signal_connect(G_OBJECT(buttonTest),"clicked",G_CALLBACK(testCallback),NULL); gtk_widget_show(buttonTest); #ifdef NETBOOK gtk_fixed_put((GtkFixed*)mainFixed,buttonTest,162,0); #else gtk_fixed_put((GtkFixed*)mainFixed,buttonTest,140,0); #endif #endif /* buttonTest = gtk_button_new_with_label ("DBTest"); gtk_widget_modify_bg(buttonTest, GTK_STATE_NORMAL, &buttonBackground); label=gtk_bin_get_child((GtkBin*)buttonTest); gtk_widget_modify_fg(label, GTK_STATE_NORMAL, &white); gtk_widget_set_size_request(GTK_WIDGET(buttonTest),LARGE_BUTTON_WIDTH,BUTTON_HEIGHT); g_signal_connect(G_OBJECT(buttonTest),"clicked",G_CALLBACK(dbTestCallback),NULL); gtk_widget_show(buttonTest); gtk_fixed_put((GtkFixed*)mainFixed,buttonTest,140,0); */ // add the vfo window gtk_widget_show(vfoWindow); #ifdef NETBOOK gtk_fixed_put((GtkFixed*)mainFixed,vfoWindow,164,0); #else gtk_fixed_put((GtkFixed*)mainFixed,vfoWindow,210,0); #endif // add the meter window gtk_widget_show(meterWindow); #ifdef NETBOOK gtk_fixed_put((GtkFixed*)mainFixed,meterWindow,878,0); #else gtk_fixed_put((GtkFixed*)mainFixed,meterWindow,1015,0); #endif // add the mic_meter window gtk_widget_show(mic_meterWindow); gtk_fixed_put((GtkFixed*)mainFixed,mic_meterWindow,1015,80); // add the band window gtk_widget_show(bandWindow); #ifdef NETBOOK gtk_fixed_put((GtkFixed*)mainFixed,bandWindow,1,23); #else gtk_fixed_put((GtkFixed*)mainFixed,bandWindow,5,25); #endif // add the mode window gtk_widget_show(modeWindow); #ifdef NETBOOK gtk_fixed_put((GtkFixed*)mainFixed,modeWindow,1,135); #else gtk_fixed_put((GtkFixed*)mainFixed,modeWindow,5,150); #endif // add the filter window gtk_widget_show(filterWindow); #ifdef NETBOOK gtk_fixed_put((GtkFixed*)mainFixed,filterWindow,1,225); #else gtk_fixed_put((GtkFixed*)mainFixed,filterWindow,5,250); #endif // add the audio window gtk_widget_show(audioWindow); #ifdef NETBOOK gtk_fixed_put((GtkFixed*)mainFixed,audioWindow,1,370); #else gtk_fixed_put((GtkFixed*)mainFixed,audioWindow,5,400); #endif // add the agc window gtk_widget_show(agcWindow); #ifdef NETBOOK gtk_fixed_put((GtkFixed*)mainFixed,agcWindow,1,437); #else gtk_fixed_put((GtkFixed*)mainFixed,agcWindow,5,475); #endif // add the preamp window gtk_widget_show(preampWindow); #ifdef NETBOOK gtk_fixed_put((GtkFixed*)mainFixed,preampWindow,1,483); #else gtk_fixed_put((GtkFixed*)mainFixed,preampWindow,5,525); #endif // add the zoom window gtk_widget_show(zoomWindow); gtk_fixed_put((GtkFixed*)mainFixed,zoomWindow,1020,525); // add the volume window gtk_widget_show(volumeWindow); #ifdef NETBOOK gtk_fixed_put((GtkFixed*)mainFixed,volumeWindow,164,483); #else gtk_fixed_put((GtkFixed*)mainFixed,volumeWindow,5,575); #endif // add the keyer window gtk_widget_show(keyerWindow); gtk_fixed_put((GtkFixed*)mainFixed,keyerWindow,210,525); // add the receiver window gtk_widget_show(receiverWindow); #ifdef NETBOOK gtk_fixed_put((GtkFixed*)mainFixed,receiverWindow,254,483); #else gtk_fixed_put((GtkFixed*)mainFixed,receiverWindow,5,635); #endif // add the display window gtk_widget_show(displayWindow); #ifdef NETBOOK gtk_fixed_put((GtkFixed*)mainFixed,displayWindow,164,40); #else gtk_fixed_put((GtkFixed*)mainFixed,displayWindow,210,120); #endif // add the bandscope display // add the transmit window gtk_widget_show(transmitWindow); #ifdef NETBOOK gtk_fixed_put((GtkFixed*)mainFixed,transmitWindow,344,483); #else gtk_fixed_put((GtkFixed*)mainFixed,transmitWindow,210,625); #endif // add the subrx window gtk_widget_show(subrxWindow); #ifdef NETBOOK gtk_fixed_put((GtkFixed*)mainFixed,subrxWindow,616,483); #else gtk_fixed_put((GtkFixed*)mainFixed,subrxWindow,710,575); #endif #ifdef NETBOOK gtk_widget_set_size_request(GTK_WIDGET(mainFixed),1024,576); #else gtk_widget_set_size_request(GTK_WIDGET(mainFixed),1180,700); #endif gtk_widget_show(mainFixed); gtk_container_add(GTK_CONTAINER(mainWindow), mainFixed); //gtk_window_set_position((GtkWindow*)mainWindow,GTK_WIN_POS_MOUSE); gtk_window_move((GtkWindow*)mainWindow,mainRootX,mainRootY); gtk_widget_show(mainWindow); // set the band if(displayHF) { setBand(band); } else { setBand(xvtr_band); } // get the display and meter running newSpectrumUpdate(); newMeterUpdate(); //newBandscopeUpdate(); }
static int gtkButtonMapMethod(Ihandle* ih) { int impress; char* value; value = iupAttribGet(ih, "IMAGE"); if (value) { ih->data->type = IUP_BUTTON_IMAGE; value = iupAttribGet(ih, "TITLE"); if (value && *value!=0) ih->data->type |= IUP_BUTTON_TEXT; } else ih->data->type = IUP_BUTTON_TEXT; if (ih->data->type == IUP_BUTTON_IMAGE && iupAttribGet(ih, "IMPRESS") && !iupAttribGetBoolean(ih, "IMPRESSBORDER")) { GtkWidget *img = gtk_image_new(); ih->handle = gtk_event_box_new(); gtk_container_add((GtkContainer*)ih->handle, img); gtk_widget_show(img); iupAttribSetStr(ih, "_IUPGTK_EVENTBOX", "1"); } else ih->handle = gtk_button_new(); if (!ih->handle) return IUP_ERROR; if (ih->data->type & IUP_BUTTON_IMAGE) { if (!iupAttribGet(ih, "_IUPGTK_EVENTBOX")) { gtk_button_set_image((GtkButton*)ih->handle, gtk_image_new()); if (ih->data->type & IUP_BUTTON_TEXT) { GtkSettings* settings = gtk_widget_get_settings(ih->handle); g_object_set(settings, "gtk-button-images", (int)TRUE, NULL); gtk_button_set_label((GtkButton*)ih->handle, iupgtkStrConvertToUTF8(iupAttribGet(ih, "TITLE"))); #if GTK_CHECK_VERSION(2, 10, 0) gtk_button_set_image_position((GtkButton*)ih->handle, ih->data->img_position); /* IUP and GTK have the same Ids */ #endif } } } else { char* title = iupAttribGet(ih, "TITLE"); if (!title) { if (iupAttribGet(ih, "BGCOLOR")) { int x=0, y=0; GtkWidget* frame = gtk_frame_new(NULL); #if GTK_CHECK_VERSION(2, 18, 0) GtkWidget* drawarea = gtk_drawing_area_new(); gtk_widget_set_has_window(drawarea, TRUE); #else GtkWidget* drawarea = gtk_fixed_new(); gtk_fixed_set_has_window(GTK_FIXED(drawarea), TRUE); #endif gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_IN); iupdrvButtonAddBorders(&x, &y); gtk_widget_set_size_request (frame, ih->currentwidth-x, ih->currentheight-y); gtk_container_add(GTK_CONTAINER(frame), drawarea); gtk_widget_show(drawarea); gtk_button_set_image((GtkButton*)ih->handle, frame); } else gtk_button_set_label((GtkButton*)ih->handle, ""); } else gtk_button_set_label((GtkButton*)ih->handle, iupgtkStrConvertToUTF8(title)); } /* add to the parent, all GTK controls must call this. */ iupgtkAddToParent(ih); if (!iupAttribGetBoolean(ih, "CANFOCUS")) iupgtkSetCanFocus(ih->handle, 0); value = iupAttribGet(ih, "IMPRESS"); impress = (ih->data->type & IUP_BUTTON_IMAGE && value)? 1: 0; if (!impress && iupAttribGetBoolean(ih, "FLAT")) { gtk_button_set_relief((GtkButton*)ih->handle, GTK_RELIEF_NONE); g_signal_connect(G_OBJECT(ih->handle), "enter-notify-event", G_CALLBACK(gtkButtonEnterLeaveEvent), ih); g_signal_connect(G_OBJECT(ih->handle), "leave-notify-event", G_CALLBACK(gtkButtonEnterLeaveEvent), ih); } else { if (!iupAttribGet(ih, "_IUPGTK_EVENTBOX")) { if (impress && !iupAttribGetStr(ih, "IMPRESSBORDER")) gtk_button_set_relief((GtkButton*)ih->handle, GTK_RELIEF_NONE); else gtk_button_set_relief((GtkButton*)ih->handle, GTK_RELIEF_NORMAL); } g_signal_connect(G_OBJECT(ih->handle), "enter-notify-event", G_CALLBACK(iupgtkEnterLeaveEvent), ih); g_signal_connect(G_OBJECT(ih->handle), "leave-notify-event", G_CALLBACK(iupgtkEnterLeaveEvent), ih); } g_signal_connect(G_OBJECT(ih->handle), "focus-in-event", G_CALLBACK(iupgtkFocusInOutEvent), ih); g_signal_connect(G_OBJECT(ih->handle), "focus-out-event", G_CALLBACK(iupgtkFocusInOutEvent), ih); g_signal_connect(G_OBJECT(ih->handle), "key-press-event", G_CALLBACK(iupgtkKeyPressEvent), ih); g_signal_connect(G_OBJECT(ih->handle), "show-help", G_CALLBACK(iupgtkShowHelp), ih); if (!iupAttribGet(ih, "_IUPGTK_EVENTBOX")) g_signal_connect(G_OBJECT(ih->handle), "clicked", G_CALLBACK(gtkButtonClicked), ih); g_signal_connect(G_OBJECT(ih->handle), "button-press-event", G_CALLBACK(gtkButtonEvent), ih); g_signal_connect(G_OBJECT(ih->handle), "button-release-event",G_CALLBACK(gtkButtonEvent), ih); gtk_widget_realize(ih->handle); /* update a mnemonic in a label if necessary */ iupgtkUpdateMnemonic(ih); return IUP_NOERROR; }
GtkWidget *dt_lib_gui_get_expander(dt_lib_module_t *module) { /* check if module is expandable */ if(!module->expandable(module)) { module->expander = NULL; return NULL; } int bs = DT_PIXEL_APPLY_DPI(12); GtkWidget *header = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); GtkWidget *expander = dtgtk_expander_new(header, module->widget); GtkWidget *header_evb = dtgtk_expander_get_header_event_box(DTGTK_EXPANDER(expander)); GtkWidget *pluginui_frame = dtgtk_expander_get_frame(DTGTK_EXPANDER(expander)); /* setup the header box */ g_signal_connect(G_OBJECT(header_evb), "button-press-event", G_CALLBACK(_lib_plugin_header_button_press), module); /* setup plugin content frame */ gtk_frame_set_shadow_type(GTK_FRAME(pluginui_frame), GTK_SHADOW_IN); /* * initialize the header widgets */ int idx = 0; GtkWidget *hw[5] = { NULL, NULL, NULL, NULL, NULL }; /* add the expand indicator icon */ hw[idx] = dtgtk_icon_new(dtgtk_cairo_paint_solid_arrow, CPF_DIRECTION_LEFT); gtk_widget_set_size_request(GTK_WIDGET(hw[idx++]), bs, bs); /* add module label */ char label[128]; g_snprintf(label, sizeof(label), "<span size=\"larger\">%s</span>", module->name(module)); hw[idx] = gtk_label_new(""); gtk_widget_set_name(hw[idx], "panel_label"); gtk_label_set_markup(GTK_LABEL(hw[idx]), label); gtk_widget_set_tooltip_text(hw[idx], module->name(module)); gtk_label_set_ellipsize(GTK_LABEL(hw[idx++]), PANGO_ELLIPSIZE_MIDDLE); /* add reset button if module has implementation */ if(module->gui_reset) { hw[idx] = dtgtk_button_new(dtgtk_cairo_paint_reset, CPF_STYLE_FLAT | CPF_DO_NOT_USE_BORDER); module->reset_button = GTK_WIDGET(hw[idx]); gtk_widget_set_tooltip_text(hw[idx], _("reset parameters")); g_signal_connect(G_OBJECT(hw[idx]), "clicked", G_CALLBACK(dt_lib_gui_reset_callback), module); } else hw[idx] = gtk_fixed_new(); gtk_widget_set_size_request(GTK_WIDGET(hw[idx++]), bs, bs); /* add preset button if module has implementation */ if(module->get_params) { hw[idx] = dtgtk_button_new(dtgtk_cairo_paint_presets, CPF_STYLE_FLAT | CPF_DO_NOT_USE_BORDER); module->presets_button = GTK_WIDGET(hw[idx]); gtk_widget_set_tooltip_text(hw[idx], _("presets")); g_signal_connect(G_OBJECT(hw[idx]), "clicked", G_CALLBACK(popup_callback), module); } else hw[idx] = gtk_fixed_new(); gtk_widget_set_size_request(GTK_WIDGET(hw[idx++]), bs, bs); /* add a spacer to align buttons with iop buttons (enabled button) */ hw[idx] = gtk_fixed_new(); gtk_widget_set_size_request(GTK_WIDGET(hw[idx++]), bs, bs); /* lets order header elements depending on left/right side panel placement */ int c = module->container(module); if((c == DT_UI_CONTAINER_PANEL_LEFT_TOP) || (c == DT_UI_CONTAINER_PANEL_LEFT_CENTER) || (c == DT_UI_CONTAINER_PANEL_LEFT_BOTTOM)) { for(int i = 0; i <= 4; i++) if(hw[i]) gtk_box_pack_start(GTK_BOX(header), hw[i], i == 1 ? TRUE : FALSE, i == 1 ? TRUE : FALSE, 2); gtk_widget_set_halign(hw[1], GTK_ALIGN_START); dtgtk_icon_set_paint(hw[0], dtgtk_cairo_paint_solid_arrow, CPF_DIRECTION_RIGHT); } else { for(int i = 4; i >= 0; i--) if(hw[i]) gtk_box_pack_start(GTK_BOX(header), hw[i], i == 1 ? TRUE : FALSE, i == 1 ? TRUE : FALSE, 2); gtk_widget_set_halign(hw[1], GTK_ALIGN_END); dtgtk_icon_set_paint(hw[0], dtgtk_cairo_paint_solid_arrow, CPF_DIRECTION_LEFT); } /* add empty space around widget */ gtk_widget_set_margin_start(module->widget, DT_PIXEL_APPLY_DPI(8)); gtk_widget_set_margin_end(module->widget, DT_PIXEL_APPLY_DPI(8)); gtk_widget_set_margin_top(module->widget, DT_PIXEL_APPLY_DPI(8)); gtk_widget_set_margin_bottom(module->widget, DT_PIXEL_APPLY_DPI(8)); gtk_widget_show_all(module->widget); gtk_widget_set_name(pluginui_frame, "lib-plugin-ui"); module->expander = expander; gtk_widget_set_hexpand(module->widget, FALSE); gtk_widget_set_vexpand(module->widget, FALSE); return module->expander; }