gboolean alarm_dialog_run (GtkWidget *parent, ECalClient *cal_client, ECalComponentAlarm *alarm) { Dialog dialog; GtkWidget *container; gint response_id; g_return_val_if_fail (alarm != NULL, FALSE); dialog.alarm = alarm; dialog.cal_client = cal_client; dialog.builder = gtk_builder_new (); e_load_ui_builder_definition (dialog.builder, "alarm-dialog.ui"); if (!get_widgets (&dialog)) { g_object_unref (dialog.builder); return FALSE; } if (!setup_select_names (&dialog)) { g_object_unref (dialog.builder); return FALSE; } init_widgets (&dialog); alarm_to_dialog (&dialog); gtk_widget_ensure_style (dialog.toplevel); container = gtk_dialog_get_action_area (GTK_DIALOG (dialog.toplevel)); gtk_container_set_border_width (GTK_CONTAINER (container), 12); container = gtk_dialog_get_content_area (GTK_DIALOG (dialog.toplevel)); gtk_container_set_border_width (GTK_CONTAINER (container), 0); gtk_window_set_icon_name ( GTK_WINDOW (dialog.toplevel), "x-office-calendar"); gtk_window_set_transient_for ( GTK_WINDOW (dialog.toplevel), GTK_WINDOW (parent)); response_id = gtk_dialog_run (GTK_DIALOG (dialog.toplevel)); if (response_id == GTK_RESPONSE_OK) dialog_to_alarm (&dialog); if (dialog.name_selector) { e_name_selector_cancel_loading (dialog.name_selector); g_object_unref (dialog.name_selector); } gtk_widget_destroy (dialog.toplevel); g_object_unref (dialog.builder); return response_id == GTK_RESPONSE_OK ? TRUE : FALSE; }
int main(int argc, char **argv) { GtkBuilder *builder; GError *error = NULL; struct widgets *widgets; gtk_init(&argc, &argv); builder = gtk_builder_new(); if (!gtk_builder_add_from_file(builder, "ping.glade", &error)) { g_warning("%s", error->message); exit(EXIT_FAILURE); } widgets = g_slice_new(struct widgets); get_widgets(widgets, builder); gtk_builder_connect_signals(builder, widgets); g_object_unref(G_OBJECT(builder)); g_signal_connect(G_OBJECT(widgets->start_button), "clicked", G_CALLBACK(start_ping), widgets); g_signal_connect(G_OBJECT(widgets->stop_button), "clicked", G_CALLBACK(stop_ping), widgets); gtk_widget_show(widgets->window); gtk_main(); g_slice_free(struct widgets, widgets); exit(EXIT_SUCCESS); }
int main(int argc, char *argv[]) { GtkBuilder *gb; gtk_init(&argc, &argv); gb = gtk_load_glade(UI_FILE); get_widgets(gb); gtk_widget_show(GTK_WIDGET(login_win)); //gtk_widget_show(GTK_WIDGET(main_win)); gtk_main(); return 0; }/*}}}*/
static void init (GnomePilotCapplet *gpcap) { GnomePilotCappletPrivate *priv; guint error; gchar *objects[] = {"timeout_adjustment", "device_speed_store", "pilot_charset_store", "CappletMain", NULL}; priv = g_new0 (GnomePilotCappletPrivate, 1); gpcap->priv = priv; /* State information */ loadPilotState (&priv->orig_state); priv->state = dupPilotState (priv->orig_state); /* Gui stuff */ priv->ui = gtk_builder_new (); error = gtk_builder_add_objects_from_file (priv->ui, "gpilotd-capplet.ui", objects, NULL); if (error == 0) { error = gtk_builder_add_objects_from_file (priv->ui, UIDATADIR "/gpilotd-capplet.ui", objects, NULL); if (error == 0) { g_message ("gnome-pilot-capplet init(): Could not load the GtkBuilder UI file!"); goto error; } } gpcap_create_pilots_treeview (priv); gpcap_create_devices_treeview (priv); gpcap_create_conduit_treeview (priv); if (!get_widgets (gpcap)) { g_message ("gnome-pilot-capplet init(): Could not find all widgets in the UI file!"); goto error; } fill_widgets (gpcap); init_widgets (gpcap); error: ; }
// Shows the JPEG configuration dialog. SharedPtr<FormatOptions> JpegFormat::onGetFormatOptions(FileOp* fop) { SharedPtr<JpegOptions> jpeg_options(new JpegOptions()); try { // Configuration parameters jpeg_options->quality = get_config_float("JPEG", "Quality", 1.0f); // Interactive mode if (!App::instance()->isGui()) return jpeg_options; // Load the window to ask to the user the JPEG options he wants. FramePtr window(load_widget("jpeg_options.xml", "jpeg_options")); Slider* slider_quality; Widget* ok; get_widgets(window, "quality", &slider_quality, "ok", &ok, NULL); slider_quality->setValue(jpeg_options->quality * 10.0f); window->open_window_fg(); if (window->get_killer() == ok) { jpeg_options->quality = slider_quality->getValue() / 10.0f; set_config_float("JPEG", "Quality", jpeg_options->quality); } else { jpeg_options.reset(NULL); } return jpeg_options; } catch (base::Exception& e) { Console::showException(e); return SharedPtr<JpegOptions>(0); } }
/* Creates a "goto date" dialog and runs it */ void goto_dialog (GnomeCalendar *gcal) { time_t start_time; struct icaltimetype tt; int b; char *gladefile; if (dlg) { return; } dlg = g_new0 (GoToDialog, 1); /* Load the content widgets */ gladefile = g_build_filename (EVOLUTION_GLADEDIR, "goto-dialog.glade", NULL); dlg->xml = glade_xml_new (gladefile, NULL, NULL); g_free (gladefile); if (!dlg->xml) { g_message ("goto_dialog(): Could not load the Glade XML file!"); g_free (dlg); return; } if (!get_widgets (dlg)) { g_message ("goto_dialog(): Could not find all widgets in the XML file!"); g_free (dlg); return; } dlg->gcal = gcal; gnome_calendar_get_selected_time_range (dlg->gcal, &start_time, NULL); tt = icaltime_from_timet_with_zone (start_time, FALSE, gnome_calendar_get_timezone (gcal)); dlg->year_val = tt.year; dlg->month_val = tt.month - 1; dlg->day_val = tt.day; gtk_option_menu_set_history (GTK_OPTION_MENU (dlg->month), dlg->month_val); gtk_spin_button_set_value (GTK_SPIN_BUTTON (dlg->year), dlg->year_val); create_ecal (dlg); goto_dialog_init_widgets (dlg); gtk_window_set_transient_for (GTK_WINDOW (dlg->dialog), GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (gcal)))); /* set initial selection to current day */ dlg->ecal->calitem->selection_set = TRUE; dlg->ecal->calitem->selection_start_month_offset = 0; dlg->ecal->calitem->selection_start_day = tt.day; dlg->ecal->calitem->selection_end_month_offset = 0; dlg->ecal->calitem->selection_end_day = tt.day; /* Set week_start_day. Convert it to 0 (Mon) to 6 (Sun), which is what we use. */ dlg->ecal->calitem->week_start_day = (calendar_config_get_week_start_day () + 6) % 7; gnome_canvas_item_grab_focus (GNOME_CANVAS_ITEM (dlg->ecal->calitem)); b = gtk_dialog_run (GTK_DIALOG (dlg->dialog)); gtk_widget_destroy (dlg->dialog); if (b == 0) goto_today (dlg); g_object_unref (dlg->xml); g_free (dlg); dlg = NULL; }
/** * Shows the "New Sprite" dialog. */ void NewFileCommand::onExecute(Context* context) { JWidget width, height, radio1, radio2, radio3, colors, ok, bg_box; int imgtype, w, h, bg, ncolors; char buf[1024]; Color bg_table[] = { Color::fromMask(), Color::fromRgb(0, 0, 0), Color::fromRgb(255, 255, 255), Color::fromRgb(255, 0, 255), app_get_colorbar()->getBgColor() }; // Load the window widget FramePtr window(load_widget("new_sprite.xml", "new_sprite")); get_widgets(window, "width", &width, "height", &height, "radio1", &radio1, "radio2", &radio2, "radio3", &radio3, "colors", &colors, "ok_button", &ok, "bg_box", &bg_box, NULL); // Default values: Indexed, 320x240, Background color imgtype = get_config_int("NewSprite", "Type", IMAGE_INDEXED); imgtype = MID(IMAGE_RGB, imgtype, IMAGE_INDEXED); w = get_config_int("NewSprite", "Width", 320); h = get_config_int("NewSprite", "Height", 240); bg = get_config_int("NewSprite", "Background", 4); // Default = Background color ncolors = get_config_int("NewSprite", "Colors", 256); width->setTextf("%d", MAX(1, w)); height->setTextf("%d", MAX(1, h)); colors->setTextf("%d", MID(2, ncolors, 256)); // Select image-type switch (imgtype) { case IMAGE_RGB: radio1->setSelected(true); break; case IMAGE_GRAYSCALE: radio2->setSelected(true); break; case IMAGE_INDEXED: radio3->setSelected(true); break; } // Select background color jlistbox_select_index(bg_box, bg); // Open the window window->open_window_fg(); if (window->get_killer() == ok) { bool ok = false; // Get the options if (radio1->isSelected()) imgtype = IMAGE_RGB; else if (radio2->isSelected()) imgtype = IMAGE_GRAYSCALE; else if (radio3->isSelected()) imgtype = IMAGE_INDEXED; w = width->getTextInt(); h = height->getTextInt(); ncolors = colors->getTextInt(); bg = jlistbox_get_selected_index(bg_box); w = MID(1, w, 9999); h = MID(1, h, 9999); ncolors = MID(2, ncolors, 256); // Select the color Color color = Color::fromMask(); if (bg >= 0 && bg <= 4) { color = bg_table[bg]; ok = true; } if (ok) { // Save the configuration set_config_int("NewSprite", "Type", imgtype); set_config_int("NewSprite", "Width", w); set_config_int("NewSprite", "Height", h); set_config_int("NewSprite", "Background", bg); // Create the new sprite ASSERT(imgtype == IMAGE_RGB || imgtype == IMAGE_GRAYSCALE || imgtype == IMAGE_INDEXED); ASSERT(w >= 1 && w <= 9999); ASSERT(h >= 1 && h <= 9999); UniquePtr<Document> document( Document::createBasicDocument(imgtype, w, h, (imgtype == IMAGE_INDEXED ? ncolors: 256))); Sprite* sprite(document->getSprite()); get_default_palette()->copyColorsTo(sprite->getCurrentPalette()); usprintf(buf, "Sprite-%04d", ++_sprite_counter); document->setFilename(buf); // If the background color isn't transparent, we have to // convert the `Layer 1' in a `Background' if (color.getType() != Color::MaskType) { Sprite* sprite = document->getSprite(); ASSERT(sprite->getCurrentLayer() && sprite->getCurrentLayer()->is_image()); static_cast<LayerImage*>(sprite->getCurrentLayer())->configureAsBackground(); image_clear(sprite->getCurrentImage(), color_utils::color_for_image(color, imgtype)); } // Show the sprite to the user context->addDocument(document); // Release the document as it is already owned by the context. // And put the document in a reliable editor. set_document_in_more_reliable_editor(document.release()); } } }
gboolean alarm_dialog_run (GtkWidget *parent, ECal *ecal, ECalComponentAlarm *alarm) { Dialog dialog; int response_id; GList *icon_list; char *gladefile; g_return_val_if_fail (alarm != NULL, FALSE); dialog.alarm = alarm; dialog.ecal = ecal; gladefile = g_build_filename (EVOLUTION_GLADEDIR, "alarm-dialog.glade", NULL); dialog.xml = glade_xml_new (gladefile, NULL, NULL); g_free (gladefile); if (!dialog.xml) { g_message (G_STRLOC ": Could not load the Glade XML file!"); return FALSE; } if (!get_widgets (&dialog)) { g_object_unref(dialog.xml); return FALSE; } if (!setup_select_names (&dialog)) { g_object_unref (dialog.xml); return FALSE; } init_widgets (&dialog); alarm_to_dialog (&dialog); gtk_widget_ensure_style (dialog.toplevel); gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (dialog.toplevel)->vbox), 0); gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (dialog.toplevel)->action_area), 12); icon_list = e_icon_factory_get_icon_list ("stock_calendar"); if (icon_list) { gtk_window_set_icon_list (GTK_WINDOW (dialog.toplevel), icon_list); g_list_foreach (icon_list, (GFunc) g_object_unref, NULL); g_list_free (icon_list); } gtk_window_set_transient_for (GTK_WINDOW (dialog.toplevel), GTK_WINDOW (parent)); response_id = gtk_dialog_run (GTK_DIALOG (dialog.toplevel)); if (response_id == GTK_RESPONSE_OK) dialog_to_alarm (&dialog); gtk_widget_destroy (dialog.toplevel); g_object_unref (dialog.xml); return response_id == GTK_RESPONSE_OK ? TRUE : FALSE; }