static void gtkutil_get_number_response (GtkDialog *dialog, gint arg1, gpointer spin) { void (*callback) (int cancel, int value, void *user_data); int num; void *user_data; num = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (spin)); callback = g_object_get_data (G_OBJECT (dialog), "cb"); user_data = g_object_get_data (G_OBJECT (dialog), "ud"); switch (arg1) { case GTK_RESPONSE_REJECT: callback (TRUE, num, user_data); gtk_widget_destroy (GTK_WIDGET (dialog)); break; case GTK_RESPONSE_ACCEPT: callback (FALSE, num, user_data); gtk_widget_destroy (GTK_WIDGET (dialog)); break; } }
//download either pace or cta bus info void on_btndownloadbus_clicked(GtkWidget *widget) { GtkSpinButton *busroute = GTK_SPIN_BUTTON(glade_xml_get_widget(xml, "busroute")); gint route = gtk_spin_button_get_value_as_int(busroute); /* buffer stores urls, dest stores where we put em */ gchar buffer[512]; gchar dest[512]; gchar buffer2[512]; gchar dest2[512]; if(route < 205) { g_snprintf(buffer,512,"http://transitchicago.com/maps/Bus/Bus/%d.pdf",route); g_snprintf(dest,512,"%s/ctabus/%d.pdf",getProgData(NULL),route); downOneFile(buffer,dest); } else { g_snprintf(buffer,512,"http://pacebus.com/pdf/schedules/%dsched.pdf",route); g_snprintf(dest,512,"%s/pacebus/%dsched.pdf",getProgData(NULL),route); g_snprintf(buffer2,512,"http://pacebus.com/pdf/maps/%dmap.pdf",route); g_snprintf(dest2,512,"%s/pacebus/%dmap.pdf",getProgData(NULL),route); downOneFile(buffer,dest); downOneFile(buffer2,dest2); } buses_load(); /* reload em */ }
static void update_workspaces_model(PagerData* pager) { int nr_ws, i; WnckWorkspace* workspace; GtkTreeIter iter; nr_ws = wnck_screen_get_workspace_count(pager->screen); if (pager->properties_dialog) { if (nr_ws != gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(pager->num_workspaces_spin))) gtk_spin_button_set_value(GTK_SPIN_BUTTON(pager->num_workspaces_spin), nr_ws); gtk_list_store_clear(pager->workspaces_store); for (i = 0; i < nr_ws; i++) { workspace = wnck_screen_get_workspace(pager->screen, i); gtk_list_store_append(pager->workspaces_store, &iter); gtk_list_store_set(pager->workspaces_store, &iter, 0, wnck_workspace_get_name(workspace), -1); } } }
static void cb_dialog_row_height_apply_clicked (G_GNUC_UNUSED GtkWidget *button, RowHeightState *state) { gint value = gtk_spin_button_get_value_as_int (state->spin); int size_pixels = (int)(value * state->sheet->last_zoom_factor_used + 0.5); gboolean use_default = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (state->default_check)); if (state->set_default_value) { double points = value * 72./gnm_app_display_dpi_get (TRUE); cmd_colrow_std_size (WORKBOOK_CONTROL (state->wbcg), state->sheet, FALSE, points); dialog_row_height_load_value (state); } else { if (use_default) size_pixels = 0; workbook_cmd_resize_selected_colrow (WORKBOOK_CONTROL (state->wbcg), state->sheet, FALSE, size_pixels); dialog_row_height_load_value (state); } }
/** @brief Get the settings from the autonumber text dialog * * Get the settings from the autonumber text dialog and store it in the * <B>AUTONUMBER_TEXT</B> structure. * * @param autotext Pointer to the state struct. */ void autonumber_get_state(AUTONUMBER_TEXT *autotext) { GtkWidget *widget; gchar *text; /* Scope */ /* Search text history */ widget = lookup_widget(autotext->dialog, "scope_text"); widget = gtk_bin_get_child(GTK_BIN(widget)); text = g_strdup(gtk_entry_get_text( GTK_ENTRY(widget))); autotext->scope_text=autonumber_history_add(autotext->scope_text, text); widget = lookup_widget(autotext->dialog, "scope_skip"); autotext->scope_skip = gtk_combo_box_get_active( GTK_COMBO_BOX(widget) ); widget = lookup_widget(autotext->dialog, "scope_number"); autotext->scope_number = gtk_combo_box_get_active(GTK_COMBO_BOX(widget) ); widget = lookup_widget(autotext->dialog, "scope_overwrite"); autotext->scope_overwrite = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); /* Sort order */ widget = lookup_widget(autotext->dialog, "sort_order"); autotext->order= gtk_combo_box_get_active(GTK_COMBO_BOX(widget)); /* Options */ widget = lookup_widget(autotext->dialog, "opt_startnum"); autotext->startnum=gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(widget)); widget = lookup_widget(autotext->dialog, "opt_removenum"); autotext->removenum = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); widget = lookup_widget(autotext->dialog, "opt_slotting"); autotext->slotting = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); }
void year_info_cb (GtkWidget *widget, gpointer user_data) { guint month, year, w_days; gchar tmpbuf[BUFFER_SIZE]; GUI *appGUI = (GUI *) user_data; year = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (appGUI->cal->fy_spinbutton)); w_days = 0; for (month = G_DATE_JANUARY; month <= G_DATE_DECEMBER; month++) { w_days += get_weekend_days (month, year); } g_snprintf (tmpbuf, BUFFER_SIZE, "%s: %d\n%s: %s\n\n%s: %s\n\n%s: %d\n%s: %d\n%s: %d (%.1f%%)", _("Year"), year, _("Leap year"), g_date_is_leap_year (year) ? _("Yes"):_("No"), _("Chinese year animal"), get_chinese_year_name (year), _("Number of days"), get_days_per_year (year), _("Number of weeks"), weeks_in_year (year), _("Number of weekend days"), w_days, (double) w_days / get_days_per_year (year) * 100.0); gui_create_dialog (GTK_MESSAGE_INFO, tmpbuf, GTK_WINDOW (appGUI->cal->fullyear_window)); }
static void modify_passes (GtkWidget * data, gpointer value) { grg_prefs_wipe_passes = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (data)); }
static void ui_to_setting (CEPageBond *self) { CEPageBondPrivate *priv = CE_PAGE_BOND_GET_PRIVATE (self); NMConnection *connection = CE_PAGE (self)->connection; const char *mode; const char *frequency; const char *updelay; const char *downdelay; const char *primary = NULL; char *targets; guint32 mtu; /* Mode */ switch (gtk_combo_box_get_active (priv->mode)) { case MODE_BALANCE_RR: mode = "balance-rr"; break; case MODE_ACTIVE_BACKUP: mode = "active-backup"; primary = gtk_entry_get_text (priv->primary); break; case MODE_BALANCE_XOR: mode = "balance-xor"; break; case MODE_BROADCAST: mode = "broadcast"; break; case MODE_802_3AD: mode = "802.3ad"; break; case MODE_BALANCE_TLB: mode = "balance-tlb"; break; case MODE_BALANCE_ALB: mode = "balance-alb"; break; default: g_assert_not_reached (); break; } /* Set bond mode and primary */ nm_setting_bond_add_option (priv->setting, NM_SETTING_BOND_OPTION_MODE, mode); if (primary && *primary) nm_setting_bond_add_option (priv->setting, NM_SETTING_BOND_OPTION_PRIMARY, primary); else nm_setting_bond_remove_option (priv->setting, NM_SETTING_BOND_OPTION_PRIMARY); /* Monitoring mode/frequency */ frequency = gtk_entry_get_text (GTK_ENTRY (priv->frequency)); updelay = gtk_entry_get_text (GTK_ENTRY (priv->updelay)); downdelay = gtk_entry_get_text (GTK_ENTRY (priv->downdelay)); targets = uglify_targets (gtk_entry_get_text (priv->arp_targets)); switch (gtk_combo_box_get_active (priv->monitoring)) { case MONITORING_MII: nm_setting_bond_add_option (priv->setting, NM_SETTING_BOND_OPTION_MIIMON, frequency); nm_setting_bond_add_option (priv->setting, NM_SETTING_BOND_OPTION_UPDELAY, updelay); nm_setting_bond_add_option (priv->setting, NM_SETTING_BOND_OPTION_DOWNDELAY, downdelay); nm_setting_bond_remove_option (priv->setting, NM_SETTING_BOND_OPTION_ARP_INTERVAL); nm_setting_bond_remove_option (priv->setting, NM_SETTING_BOND_OPTION_ARP_IP_TARGET); break; case MONITORING_ARP: nm_setting_bond_add_option (priv->setting, NM_SETTING_BOND_OPTION_ARP_INTERVAL, frequency); if (targets) nm_setting_bond_add_option (priv->setting, NM_SETTING_BOND_OPTION_ARP_IP_TARGET, targets); else nm_setting_bond_remove_option (priv->setting, NM_SETTING_BOND_OPTION_ARP_IP_TARGET); nm_setting_bond_remove_option (priv->setting, NM_SETTING_BOND_OPTION_MIIMON); nm_setting_bond_remove_option (priv->setting, NM_SETTING_BOND_OPTION_UPDELAY); nm_setting_bond_remove_option (priv->setting, NM_SETTING_BOND_OPTION_DOWNDELAY); break; default: g_assert_not_reached (); break; } g_free (targets); mtu = gtk_spin_button_get_value_as_int (priv->mtu); if (mtu && !priv->wired) { priv->wired = NM_SETTING_WIRED (nm_setting_wired_new ()); nm_connection_add_setting (connection, NM_SETTING (priv->wired)); } if (priv->wired) g_object_set (priv->wired, NM_SETTING_WIRED_MTU, mtu, NULL); }
extern void change_refresh_popup(GtkAction *action, gpointer user_data) { GtkWidget *table = gtk_table_new(1, 2, FALSE); GtkWidget *label = NULL; GtkObject *adjustment = gtk_adjustment_new( working_sview_config.refresh_delay, 1, 10000, 5, 60, 0); GtkWidget *spin_button = gtk_spin_button_new(GTK_ADJUSTMENT(adjustment), 1, 0); GtkWidget *popup = gtk_dialog_new_with_buttons( "Refresh Interval", GTK_WINDOW (user_data), GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, NULL); GError *error = NULL; int response = 0; char *temp = NULL; label = gtk_dialog_add_button(GTK_DIALOG(popup), GTK_STOCK_OK, GTK_RESPONSE_OK); gtk_window_set_default(GTK_WINDOW(popup), label); gtk_dialog_add_button(GTK_DIALOG(popup), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL); label = gtk_label_new("Interval in Seconds "); gtk_container_set_border_width(GTK_CONTAINER(table), 10); gtk_box_pack_start(GTK_BOX(GTK_DIALOG(popup)->vbox), table, FALSE, FALSE, 0); gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 0, 1); gtk_table_attach_defaults(GTK_TABLE(table), spin_button, 1, 2, 0, 1); gtk_widget_show_all(popup); response = gtk_dialog_run (GTK_DIALOG(popup)); if (response == GTK_RESPONSE_OK) { working_sview_config.refresh_delay = gtk_spin_button_get_value_as_int( GTK_SPIN_BUTTON(spin_button)); temp = g_strdup_printf("Refresh Interval set to %d seconds.", working_sview_config.refresh_delay); gtk_statusbar_pop(GTK_STATUSBAR(main_statusbar), STATUS_REFRESH); response = gtk_statusbar_push(GTK_STATUSBAR(main_statusbar), STATUS_REFRESH, temp); g_free(temp); if (!g_thread_create(_refresh_thr, GINT_TO_POINTER(response), FALSE, &error)) { g_printerr ("Failed to create refresh thread: %s\n", error->message); } } gtk_widget_destroy(popup); return; }
//updateRule is called by a SPIN_BUTTON which changes the // base 10 rule number void updateRule(GtkWidget *adjustor) { ca1->setRule(gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(adjustor))); }
/* Apply changes. Returns TRUE if things are ok, FALSE otherwise */ static gboolean apply_changes(radio_conf_t * conf) { /* name */ if (conf->name) g_free(conf->name); conf->name = g_strdup(gtk_entry_get_text(GTK_ENTRY(name))); /* host */ if (conf->host) g_free(conf->host); conf->host = g_strdup(gtk_entry_get_text(GTK_ENTRY(host))); /* port */ conf->port = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(port)); /* lo down freq */ conf->lo = 1000000.0 * gtk_spin_button_get_value(GTK_SPIN_BUTTON(lo)); /* lo up freq */ conf->loup = 1000000.0 * gtk_spin_button_get_value(GTK_SPIN_BUTTON(loup)); /* rig type */ conf->type = gtk_combo_box_get_active(GTK_COMBO_BOX(type)); /* ptt */ conf->ptt = gtk_combo_box_get_active(GTK_COMBO_BOX(ptt)); /* vfo up/down */ if (conf->type == RIG_TYPE_DUPLEX) { switch (gtk_combo_box_get_active(GTK_COMBO_BOX(vfo))) { case 1: conf->vfoUp = VFO_MAIN; conf->vfoDown = VFO_SUB; break; case 2: conf->vfoUp = VFO_SUB; conf->vfoDown = VFO_MAIN; break; case 3: conf->vfoUp = VFO_A; conf->vfoDown = VFO_B; break; case 4: conf->vfoUp = VFO_B; conf->vfoDown = VFO_A; break; default: conf->vfoUp = VFO_MAIN; conf->vfoDown = VFO_SUB; break; } } /* AOS / LOS signalling */ conf->signal_aos = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(sigaos)); conf->signal_los = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(siglos)); return TRUE; }
/* Verifies data for New & Properties dialogs. * Returns: FALSE if the user needs to change any data. */ static gboolean update_config(const PropertyDialogElements *e, gboolean new_project) { const gchar *name, *file_name, *base_path; gchar *locale_filename; gsize name_len; gint err_code = 0; GeanyProject *p; g_return_val_if_fail(e != NULL, TRUE); name = gtk_entry_get_text(GTK_ENTRY(e->name)); name_len = strlen(name); if (name_len == 0) { SHOW_ERR(_("The specified project name is too short.")); gtk_widget_grab_focus(e->name); return FALSE; } else if (name_len > MAX_NAME_LEN) { SHOW_ERR1(_("The specified project name is too long (max. %d characters)."), MAX_NAME_LEN); gtk_widget_grab_focus(e->name); return FALSE; } if (new_project) file_name = gtk_entry_get_text(GTK_ENTRY(e->file_name)); else file_name = gtk_label_get_text(GTK_LABEL(e->file_name)); if (G_UNLIKELY(! NZV(file_name))) { SHOW_ERR(_("You have specified an invalid project filename.")); gtk_widget_grab_focus(e->file_name); return FALSE; } locale_filename = utils_get_locale_from_utf8(file_name); base_path = gtk_entry_get_text(GTK_ENTRY(e->base_path)); if (NZV(base_path)) { /* check whether the given directory actually exists */ gchar *locale_path = utils_get_locale_from_utf8(base_path); if (! g_path_is_absolute(locale_path)) { /* relative base path, so add base dir of project file name */ gchar *dir = g_path_get_dirname(locale_filename); SETPTR(locale_path, g_strconcat(dir, G_DIR_SEPARATOR_S, locale_path, NULL)); g_free(dir); } if (! g_file_test(locale_path, G_FILE_TEST_IS_DIR)) { gboolean create_dir; create_dir = dialogs_show_question_full(NULL, GTK_STOCK_OK, GTK_STOCK_CANCEL, _("Create the project's base path directory?"), _("The path \"%s\" does not exist."), base_path); if (create_dir) err_code = utils_mkdir(locale_path, TRUE); if (! create_dir || err_code != 0) { if (err_code != 0) SHOW_ERR1(_("Project base directory could not be created (%s)."), g_strerror(err_code)); gtk_widget_grab_focus(e->base_path); utils_free_pointers(2, locale_path, locale_filename, NULL); return FALSE; } } g_free(locale_path); } /* finally test whether the given project file can be written */ if ((err_code = utils_is_file_writable(locale_filename)) != 0 || (err_code = g_file_test(locale_filename, G_FILE_TEST_IS_DIR) ? EISDIR : 0) != 0) { SHOW_ERR1(_("Project file could not be written (%s)."), g_strerror(err_code)); gtk_widget_grab_focus(e->file_name); g_free(locale_filename); return FALSE; } g_free(locale_filename); if (app->project == NULL) { create_project(); new_project = TRUE; } p = app->project; SETPTR(p->name, g_strdup(name)); SETPTR(p->file_name, g_strdup(file_name)); /* use "." if base_path is empty */ SETPTR(p->base_path, g_strdup(NZV(base_path) ? base_path : "./")); if (! new_project) /* save properties specific fields */ { GtkTextIter start, end; GtkTextBuffer *buffer; GeanyDocument *doc = document_get_current(); GeanyBuildCommand *oldvalue; GeanyFiletype *ft = doc ? doc->file_type : NULL; GtkWidget *widget; gchar *tmp; GString *str; GSList *node; /* get and set the project description */ buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(e->description)); gtk_text_buffer_get_start_iter(buffer, &start); gtk_text_buffer_get_end_iter(buffer, &end); SETPTR(p->description, g_strdup(gtk_text_buffer_get_text(buffer, &start, &end, FALSE))); foreach_slist(node, stash_groups) stash_group_update(node->data, e->dialog); /* read the project build menu */ oldvalue = ft ? ft->projfilecmds : NULL; build_read_project(ft, e->build_properties); if (ft != NULL && ft->projfilecmds != oldvalue && ft->project_list_entry < 0) { if (p->build_filetypes_list == NULL) p->build_filetypes_list = g_ptr_array_new(); ft->project_list_entry = p->build_filetypes_list->len; g_ptr_array_add(p->build_filetypes_list, ft); } build_menu_update(doc); widget = ui_lookup_widget(e->dialog, "radio_long_line_disabled_project"); if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))) p->long_line_behaviour = 0; else { widget = ui_lookup_widget(e->dialog, "radio_long_line_default_project"); if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))) p->long_line_behaviour = 1; else /* "Custom" radio button must be checked */ p->long_line_behaviour = 2; } widget = ui_lookup_widget(e->dialog, "spin_long_line_project"); p->long_line_column = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(widget)); apply_editor_prefs(); /* get and set the project file patterns */ tmp = g_strdup(gtk_entry_get_text(GTK_ENTRY(e->patterns))); g_strfreev(p->file_patterns); g_strstrip(tmp); str = g_string_new(tmp); do {} while (utils_string_replace_all(str, " ", " ")); p->file_patterns = g_strsplit(str->str, " ", -1); g_string_free(str, TRUE); g_free(tmp); } update_ui(); return TRUE; }
/******************************** * AL_Sprite_Add * @ sprite_rect: rectangle draw in editor @ parent: name of sheet. */ void AL_Sprite_Add( Spritesheet * spritesheet, GdkRectangle * sprite_rect ) { if ( !spritesheet || !mokoiBasePath ) { Meg_Error_Print( __func__, __LINE__, "AL_Sheet_AddSprite: Invalid parent" ); return; } GtkWidget * dialog, * text_name, * file_mask, *check_maskauto, * file_entity, * radio_align; GtkSpinButton * spin_mask, * spin_x, * spin_y, * spin_w, * spin_h, * spin_frames; /* UI */ GError * error = NULL; GtkBuilder * ui = gtk_builder_new(); if ( !gtk_builder_add_from_string( ui, mokoiUI_SpriteAdd, -1, &error ) ) { Meg_Error_Print( __func__, __LINE__, "UI creation error '%s'.", error->message ); return; } dialog = GET_WIDGET( ui, "mokoi_sheet_addchild"); text_name = GET_WIDGET( ui, "text_name"); spin_x = GET_SPIN_WIDGET( ui, "spin_x"); spin_y = GET_SPIN_WIDGET( ui, "spin_y"); spin_w = GET_SPIN_WIDGET( ui, "spin_w"); spin_h = GET_SPIN_WIDGET( ui, "spin_h"); spin_mask = GET_SPIN_WIDGET( ui, "spin_mask"); spin_frames = GET_SPIN_WIDGET( ui, "spin_frames"); check_maskauto = GET_WIDGET( ui, "check_maskauto"); file_mask = GET_WIDGET( ui, "file_mask"); file_entity = GET_WIDGET( ui, "file_entity"); radio_align = GET_WIDGET( ui, "radio_align"); /* Set Default Values */ gtk_file_chooser_set_current_folder( GTK_FILE_CHOOSER(file_mask), mokoiBasePath ); gtk_file_chooser_set_current_folder( GTK_FILE_CHOOSER(file_entity), mokoiBasePath ); gtk_spin_button_set_value( spin_x, (gdouble)sprite_rect->x ); gtk_spin_button_set_value( spin_y, (gdouble)sprite_rect->y ); gtk_spin_button_set_value( spin_w, (gdouble)sprite_rect->width ); gtk_spin_button_set_value( spin_h, (gdouble)sprite_rect->height ); /* Show Dialog */ gtk_widget_show_all( gtk_dialog_get_content_area( GTK_DIALOG(dialog) ) ); gtk_window_set_transient_for( GTK_WINDOW(dialog), Meg_Main_GetWindow()); if ( gtk_dialog_run( GTK_DIALOG(dialog) ) == GTK_RESPONSE_APPLY ) { gboolean bool_horizontal = FALSE; const gchar * sprite_name; gchar * mask_file, * entity_file; gint frame_count = 0; sprite_name = gtk_entry_get_text( GTK_ENTRY(text_name) ); mask_file = gtk_file_chooser_get_filename( GTK_FILE_CHOOSER(file_mask) ); entity_file = gtk_file_chooser_get_filename( GTK_FILE_CHOOSER(file_entity) ); frame_count = gtk_spin_button_get_value_as_int( GTK_SPIN_BUTTON(spin_frames) ); bool_horizontal = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(radio_align) ); if ( !g_utf8_strlen(sprite_name, -1) ) { Meg_Error_Print( __func__, __LINE__, "AL_Sheet_AddSprite: No name given" ); } else { SheetObject * sprite = NULL; SpriteData * sprite_data = g_new0(SpriteData, 1); sprite = SheetObject_New( (gpointer)sprite_data, &SpriteData_FreePointer ); sprite->parent_sheet = g_strdup( spritesheet->file ); sprite->display_name = g_strdup( sprite_name ); sprite->ident_string = g_strdup_printf( "%s:%s", sprite->parent_sheet, sprite->display_name ); if ( entity_file ) sprite_data->entity = g_path_get_basename( entity_file ); else sprite_data->entity = NULL; sprite->visible = TRUE; sprite_data->image_loaded = FALSE; sprite->position.x = gtk_spin_button_get_value_as_int( spin_x ); sprite->position.y = gtk_spin_button_get_value_as_int( spin_y ); sprite->position.width = gtk_spin_button_get_value_as_int( spin_w ); sprite->position.height = gtk_spin_button_get_value_as_int( spin_h ); if ( mask_file && g_utf8_strlen( mask_file, -1 ) ) sprite_data->mask.name = g_strdup(mask_file); else { sprite_data->mask.value = gtk_spin_button_get_value_as_int( spin_mask ); sprite_data->mask.autogen = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(check_maskauto) ); } GdkPixbuf * parent_image = AL_GetImage( sprite->parent_sheet, NULL ); if ( frame_count > 0 ) { /* Creating Animation */ gint frame_length = 0; if ( bool_horizontal ) { frame_length = sprite->position.width / frame_count; sprite->position.width = frame_length; } else { frame_length = sprite->position.height / frame_count; sprite->position.height = frame_length; } sprite_data->animation = g_new0(AnimationDetail, 1); gint q = 0; while ( q < frame_count ) { /* Create the sprite for the frame */ SheetObject * frame_sprite = NULL; SpriteData * frame_sprite_data = g_new0(SpriteData, 1); frame_sprite = SheetObject_New( (gpointer)frame_sprite_data, &SpriteData_FreePointer ); frame_sprite->display_name = g_strdup_printf("%s_%d", sprite->display_name, q); frame_sprite->parent_sheet = g_strdup( spritesheet->file ); frame_sprite->ident_string = g_strdup_printf( "%s:%s", frame_sprite->parent_sheet, frame_sprite->display_name ); frame_sprite->visible = FALSE; frame_sprite_data->mask = sprite_data->mask; frame_sprite_data->image_loaded = FALSE; if ( bool_horizontal ) { frame_sprite->position.x = sprite_rect->x + (q * frame_length); frame_sprite->position.y = sprite_rect->y; frame_sprite->position.width = frame_length; frame_sprite->position.height = sprite_rect->height; } else { frame_sprite->position.x = sprite_rect->x; frame_sprite->position.y = sprite_rect->y + (q * frame_length); frame_sprite->position.width = sprite_rect->width; frame_sprite->position.height = frame_length; } frame_sprite_data->image = gdk_pixbuf_new( GDK_COLORSPACE_RGB, TRUE, 8, frame_sprite->position.width, frame_sprite->position.height ); gdk_pixbuf_copy_area( parent_image, frame_sprite->position.x, frame_sprite->position.y, frame_sprite->position.width, frame_sprite->position.height, frame_sprite_data->image, 0, 0); frame_sprite_data->image_loaded = TRUE; spritesheet->children = g_slist_append( spritesheet->children, frame_sprite); /* Create the Frame and append to list */ AnimationFrame * frame = g_new0( AnimationFrame, 1 ); frame->sprite = g_strdup( frame_sprite->display_name ); frame->offset.x = 0; frame->offset.y = 0; frame->length_ms = 1000; frame->f = 0; sprite_data->animation->frames = g_slist_append( sprite_data->animation->frames, frame); q++; } } else { /* Create Sprite */ sprite_data->image = gdk_pixbuf_new( GDK_COLORSPACE_RGB, TRUE, 8, sprite->position.width, sprite->position.height ); gdk_pixbuf_copy_area( parent_image, sprite->position.x, sprite->position.y, sprite->position.width, sprite->position.height, sprite_data->image, 0, 0 ); sprite_data->image_loaded = TRUE; } g_object_unref( parent_image ); spritesheet->children = g_slist_append( spritesheet->children, sprite ); Sheet_SaveFile( spritesheet ); } } gtk_widget_destroy( dialog ); }
static VALUE rg_value_as_int(VALUE self) { return INT2NUM(gtk_spin_button_get_value_as_int(_SELF(self))); }
static void on_propdialog_response (GtkDialog *dialog, gint response_id, gpointer user_data) { SubscriptionPropDialog *spd = (SubscriptionPropDialog *)user_data; if(response_id == GTK_RESPONSE_OK) { gchar *newSource; const gchar *newFilter; gboolean needsUpdate = FALSE; subscriptionPtr subscription = spd->priv->subscription; nodePtr node = spd->priv->subscription->node; feedPtr feed = (feedPtr)node->data; if (SUBSCRIPTION_TYPE(subscription) == feed_get_subscription_type ()) { /* "General" */ node_set_title(node, gtk_entry_get_text(GTK_ENTRY(spd->priv->feedNameEntry))); /* Source */ newSource = ui_subscription_dialog_decode_source(spd->priv); /* Filter handling */ newFilter = gtk_entry_get_text(GTK_ENTRY(liferea_dialog_lookup(spd->priv->dialog, "filterEntry"))); if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(liferea_dialog_lookup(spd->priv->dialog, "filterCheckbox"))) && strcmp(newFilter,"")) { /* Maybe this should be a test to see if the file exists? */ if(subscription_get_filter(subscription) == NULL || strcmp(newFilter, subscription_get_filter(subscription))) { subscription_set_filter(subscription, newFilter); needsUpdate = TRUE; } } else { if(subscription_get_filter(subscription)) { subscription_set_filter(subscription, NULL); needsUpdate = TRUE; } } /* if URL has changed... */ if(strcmp(newSource, subscription_get_source(subscription))) { subscription_set_source(subscription, newSource); needsUpdate = TRUE; } g_free(newSource); /* Update interval handling */ if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (liferea_dialog_lookup (GTK_WIDGET (dialog), "updateIntervalNever")))) subscription_set_update_interval (subscription, -2); else if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (liferea_dialog_lookup (GTK_WIDGET (dialog), "updateIntervalDefault")))) subscription_set_update_interval (subscription, -1); else if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (liferea_dialog_lookup (GTK_WIDGET (dialog), "updateIntervalSpecific")))) { gint intervalUnit = gtk_combo_box_get_active (GTK_COMBO_BOX (spd->priv->refreshIntervalUnit)); gint updateInterval = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (spd->priv->refreshInterval)); if (intervalUnit == 1) updateInterval *= 60; /* hours */ if (intervalUnit == 2) updateInterval *= 1440; /* days */ subscription_set_update_interval (subscription, updateInterval); db_subscription_update (subscription); } } /* "Archive" handling */ if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(liferea_dialog_lookup(GTK_WIDGET(dialog), "feedCacheDefault")))) feed->cacheLimit = CACHE_DEFAULT; else if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(liferea_dialog_lookup(GTK_WIDGET(dialog), "feedCacheDisable")))) feed->cacheLimit = CACHE_DISABLE; else if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(liferea_dialog_lookup(GTK_WIDGET(dialog), "feedCacheUnlimited")))) feed->cacheLimit = CACHE_UNLIMITED; else if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(liferea_dialog_lookup(GTK_WIDGET(dialog), "feedCacheLimited")))) feed->cacheLimit = gtk_spin_button_get_value(GTK_SPIN_BUTTON(liferea_dialog_lookup(GTK_WIDGET(dialog), "cacheItemLimit"))); if (SUBSCRIPTION_TYPE(subscription) == feed_get_subscription_type ()) { /* "Download" Options */ subscription->updateOptions->dontUseProxy = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(liferea_dialog_lookup(GTK_WIDGET(dialog), "dontUseProxyCheck"))); } /* "Advanced" options */ feed->encAutoDownload = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (liferea_dialog_lookup (GTK_WIDGET (dialog), "enclosureDownloadCheck"))); node->loadItemLink = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (liferea_dialog_lookup (GTK_WIDGET (dialog), "loadItemLinkCheck"))); feed->ignoreComments = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (liferea_dialog_lookup (GTK_WIDGET (dialog), "ignoreCommentFeeds"))); feed->enforcePopup = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (liferea_dialog_lookup (GTK_WIDGET (dialog), "enforcePopupCheck"))); feed->preventPopup = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (liferea_dialog_lookup (GTK_WIDGET (dialog), "preventPopupCheck"))); feed->markAsRead = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (liferea_dialog_lookup (GTK_WIDGET (dialog), "markAsReadCheck"))); if (feed->enforcePopup && feed->preventPopup) feed->enforcePopup = FALSE; ui_node_update (node->id); feedlist_schedule_save (); db_subscription_update (subscription); if (needsUpdate) subscription_update (subscription, FEED_REQ_PRIORITY_HIGH); } g_object_unref(spd); }
static void on_ok_clicked (GtkButton *button, GtkamSave *save) { guint i, count, j = 1; int result = -1; GtkWidget *s, *dialog; unsigned int id = 0; GtkamSaveData *data; gchar *progname, *command; GError *error = NULL; if (count_items (save) == 0) { if (!save->priv->err_shown) { dialog = gtkam_error_new (result, NULL, GTK_WIDGET (save), _("There is nothing to be saved.")); gtk_widget_show (dialog); } return; } store_save_settings(save); gtk_widget_hide (GTK_WIDGET (save)); count = g_slist_length (save->priv->data); if (count == 1) s = gtkam_cancel_new (_("Downloading file")); else s = gtkam_cancel_new (_("Downloading %i files"), count); gtk_window_set_transient_for (GTK_WINDOW (s), save->priv->main_window); gtk_widget_show (s); if (count > 1) id = gp_context_progress_start ( GTKAM_CANCEL (s)->context->context, count, _("Downloading %i files..."), count); if (!save->priv->toggle_filename_camera->active) j = gtk_spin_button_get_value_as_int ( GTK_SPIN_BUTTON (save->priv->spin_entry)); for (i = 0; i < count; i++) { data = g_slist_nth_data (save->priv->data, i); /* Check for shutdown */ if (!GTKAM_IS_SAVE (save)) return; if (save->priv->toggle_normal && save->priv->toggle_normal->active) result = get_file (save, data->camera, data->folder, data->name, GP_FILE_TYPE_NORMAL, i + j, GTKAM_CANCEL (s)->context); if (save->priv->toggle_preview && save->priv->toggle_preview->active && (!result < 0)) result = get_file (save, data->camera, data->folder, data->name, GP_FILE_TYPE_PREVIEW, i + j, GTKAM_CANCEL (s)->context); if (save->priv->toggle_raw && save->priv->toggle_raw->active && (!result < 0)) result = get_file (save, data->camera, data->folder, data->name, GP_FILE_TYPE_RAW, i + j, GTKAM_CANCEL (s)->context); if (save->priv->toggle_audio && save->priv->toggle_audio->active && (!result < 0)) result = get_file (save, data->camera, data->folder, data->name, GP_FILE_TYPE_AUDIO, i + j, GTKAM_CANCEL (s)->context); if (save->priv->toggle_exif && save->priv->toggle_exif->active && (!result < 0)) result = get_file (save, data->camera, data->folder, data->name, GP_FILE_TYPE_EXIF, i + j, GTKAM_CANCEL (s)->context); if (result < 0) { if (count > 1) gp_context_progress_stop (GTKAM_CANCEL (s)->context->context, id); if (!save->priv->err_shown) { dialog = gtkam_error_new (result, GTKAM_CANCEL (s)->context, GTK_WIDGET (save), _("Problem getting '%s' " "from folder '%s'."), data->name, data->folder); gtk_widget_show (dialog); save->priv->err_shown = TRUE; } gtk_object_destroy (GTK_OBJECT (s)); gtk_object_destroy (GTK_OBJECT (save)); return; } if (count > 1) gp_context_progress_update ( GTKAM_CANCEL (s)->context->context, id, i + 1); gp_context_idle (GTKAM_CANCEL (s)->context->context); if (gp_context_cancel (GTKAM_CANCEL (s)->context->context) == GP_CONTEXT_FEEDBACK_CANCEL) break; } if (count > 1) gp_context_progress_stop ( GTKAM_CANCEL (s)->context->context, id); gtk_object_destroy (GTK_OBJECT (s)); /* If file(s) were saved and a program specified, load the program passing the filenames */ if (result >= 0) { progname = gtk_entry_get_text (save->priv->program); if (progname && progname[0] != '\0') { command = g_strdup_printf ("%s%s", progname, save->priv->filelist->str); /* FIXME Report any arising errors */ if (!g_spawn_command_line_async (command, &error)) { g_warning ("Error running command\n"); g_error_free (error); } g_free (command); g_string_free (save->priv->filelist, TRUE); } } gtk_object_destroy (GTK_OBJECT (save)); }
/** \brief User pressed OK. Any changes should be stored in config. */ void sat_pref_refresh_ok (GKeyFile *cfg) { if (dirty) { if (cfg != NULL) { g_key_file_set_integer (cfg, MOD_CFG_GLOBAL_SECTION, MOD_CFG_TIMEOUT_KEY, gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (dataspin))); g_key_file_set_integer (cfg, MOD_CFG_LIST_SECTION, MOD_CFG_LIST_REFRESH, gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (listspin))); g_key_file_set_integer (cfg, MOD_CFG_MAP_SECTION, MOD_CFG_MAP_REFRESH, gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (mapspin))); g_key_file_set_integer (cfg, MOD_CFG_POLAR_SECTION, MOD_CFG_POLAR_REFRESH, gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (polarspin))); g_key_file_set_integer (cfg, MOD_CFG_SINGLE_SAT_SECTION, MOD_CFG_SINGLE_SAT_REFRESH, gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (singlespin))); } else { sat_cfg_set_int (SAT_CFG_INT_MODULE_TIMEOUT, gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (dataspin))); sat_cfg_set_int (SAT_CFG_INT_LIST_REFRESH, gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (listspin))); sat_cfg_set_int (SAT_CFG_INT_MAP_REFRESH, gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (mapspin))); sat_cfg_set_int (SAT_CFG_INT_POLAR_REFRESH, gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (polarspin))); sat_cfg_set_int (SAT_CFG_INT_SINGLE_SAT_REFRESH, gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (singlespin))); } } else if (reset) { /* we have to reset the values to global or default settings */ if (cfg == NULL) { /* reset values in sat-cfg */ sat_cfg_reset_int (SAT_CFG_INT_MODULE_TIMEOUT); sat_cfg_reset_int (SAT_CFG_INT_LIST_REFRESH); sat_cfg_reset_int (SAT_CFG_INT_MAP_REFRESH); sat_cfg_reset_int (SAT_CFG_INT_POLAR_REFRESH); sat_cfg_reset_int (SAT_CFG_INT_SINGLE_SAT_REFRESH); } else { /* remove keys */ g_key_file_remove_key ((GKeyFile *)(cfg), MOD_CFG_GLOBAL_SECTION, MOD_CFG_TIMEOUT_KEY, NULL); g_key_file_remove_key ((GKeyFile *)(cfg), MOD_CFG_LIST_SECTION, MOD_CFG_LIST_REFRESH, NULL); g_key_file_remove_key ((GKeyFile *)(cfg), MOD_CFG_MAP_SECTION, MOD_CFG_MAP_REFRESH, NULL); g_key_file_remove_key ((GKeyFile *)(cfg), MOD_CFG_POLAR_SECTION, MOD_CFG_POLAR_REFRESH, NULL); g_key_file_remove_key ((GKeyFile *)(cfg), MOD_CFG_SINGLE_SAT_SECTION, MOD_CFG_SINGLE_SAT_REFRESH, NULL); } } dirty = FALSE; reset = FALSE; }
void onAddCameraToPlaylist(GtkButton *button, gpointer user_data) { intf_thread_t *p_intf = GtkGetIntf( button ); GtkSpinButton *entryV4LChannel = NULL; GtkSpinButton *entryV4LFrequency = NULL; GtkSpinButton *entryV4LSampleRate = NULL; GtkSpinButton *entryV4LQuality = NULL; GtkSpinButton *entryV4LTuner = NULL; gint i_v4l_channel; gint i_v4l_frequency; gint i_v4l_samplerate; gint i_v4l_quality; gint i_v4l_tuner; GtkEntry *entryV4LVideoDevice = NULL; GtkEntry *entryV4LAudioDevice = NULL; GtkEntry *entryV4LNorm = NULL; GtkEntry *entryV4LSize = NULL; GtkEntry *entryV4LSoundDirection = NULL; const gchar *p_v4l_video_device; const gchar *p_v4l_audio_device; const gchar *p_v4l_norm; const gchar *p_v4l_size; const gchar *p_v4l_sound_direction; /* MJPEG only */ GtkCheckButton *checkV4LMJPEG = NULL; GtkSpinButton *entryV4LDecimation = NULL; gboolean b_v4l_mjpeg; gint i_v4l_decimation; /* end MJPEG only */ GtkCheckButton *p_check_v4l_transcode = NULL; gboolean b_v4l_transcode; char **ppsz_options = NULL; /* list of options */ int i_options=0; char v4l_mrl[6]; int i_pos; int i; ppsz_options = (char **) malloc(11 *sizeof(char*)); if (ppsz_options == NULL) { msg_Err(p_intf, "No memory to allocate for v4l options."); return; } for (i=0; i<11; i++) { ppsz_options[i] = (char *) malloc(VLC_MAX_MRL * sizeof(char)); if (ppsz_options[i] == NULL) { msg_Err(p_intf, "No memory to allocate for v4l options string %i.", i); for (i-=1; i>=0; i--) free(ppsz_options[i]); free(ppsz_options); return; } } i_pos = snprintf( &v4l_mrl[0], 6, "v4l"); v4l_mrl[5]='\0'; entryV4LChannel = (GtkSpinButton*) lookup_widget( GTK_WIDGET(button), "entryV4LChannel" ); entryV4LFrequency = (GtkSpinButton*) lookup_widget( GTK_WIDGET(button), "entryV4LFrequency" ); entryV4LSampleRate = (GtkSpinButton*) lookup_widget( GTK_WIDGET(button), "entryV4LSampleRate" ); entryV4LQuality = (GtkSpinButton*) lookup_widget( GTK_WIDGET(button), "entryV4LQuality" ); entryV4LTuner = (GtkSpinButton*) lookup_widget( GTK_WIDGET(button), "entryV4LTuner" ); entryV4LVideoDevice = (GtkEntry*) lookup_widget( GTK_WIDGET(button), "entryV4LVideoDevice" ); entryV4LAudioDevice = (GtkEntry*) lookup_widget( GTK_WIDGET(button), "entryV4LAudioDevice" ); entryV4LNorm = (GtkEntry*) lookup_widget( GTK_WIDGET(button), "entryV4LNorm" ); entryV4LSize = (GtkEntry*) lookup_widget( GTK_WIDGET(button), "entryV4LSize" ); entryV4LSoundDirection = (GtkEntry*) lookup_widget( GTK_WIDGET(button), "entryV4LSoundDirection" ); i_v4l_channel = gtk_spin_button_get_value_as_int(entryV4LChannel); i_v4l_frequency = gtk_spin_button_get_value_as_int(entryV4LFrequency); i_v4l_samplerate = gtk_spin_button_get_value_as_int(entryV4LSampleRate); i_v4l_quality = gtk_spin_button_get_value_as_int(entryV4LQuality); i_v4l_tuner = gtk_spin_button_get_value_as_int(entryV4LTuner); p_v4l_video_device = gtk_entry_get_text(GTK_ENTRY(entryV4LVideoDevice)); p_v4l_audio_device = gtk_entry_get_text(GTK_ENTRY(entryV4LAudioDevice)); p_v4l_norm = gtk_entry_get_text(GTK_ENTRY(entryV4LNorm)); p_v4l_size = gtk_entry_get_text(GTK_ENTRY(entryV4LSize)); p_v4l_sound_direction = gtk_entry_get_text(GTK_ENTRY(entryV4LSoundDirection)); i_pos = snprintf( &ppsz_options[i_options++][0], VLC_MAX_MRL, "%s", (char*)p_v4l_video_device ); if (i_pos>=VLC_MAX_MRL) ppsz_options[i_options][VLC_MAX_MRL-1] = '\0'; i_pos = snprintf( &ppsz_options[i_options++][0], VLC_MAX_MRL, "adev=%s", (char*)p_v4l_audio_device ); if (i_pos>=VLC_MAX_MRL) ppsz_options[i_options][VLC_MAX_MRL-1] = '\0'; i_pos = snprintf( &ppsz_options[i_options++][0], VLC_MAX_MRL, "norm=%s", (char*)p_v4l_norm ); if (i_pos>=VLC_MAX_MRL) ppsz_options[i_options][VLC_MAX_MRL-1] = '\0'; i_pos = snprintf( &ppsz_options[i_options++][0], VLC_MAX_MRL, "size=%s", (char*)p_v4l_size ); if (i_pos>=VLC_MAX_MRL) ppsz_options[i_options][VLC_MAX_MRL-1] = '\0'; i_pos = snprintf( &ppsz_options[i_options++][0], VLC_MAX_MRL, "%s", (char*)p_v4l_sound_direction ); if (i_pos>=VLC_MAX_MRL) ppsz_options[i_options][VLC_MAX_MRL-1] = '\0'; i_pos = snprintf( &ppsz_options[i_options++][0], VLC_MAX_MRL, "channel=%d", (int)i_v4l_channel ); if (i_pos>=VLC_MAX_MRL) ppsz_options[i_options][VLC_MAX_MRL-1] = '\0'; i_pos = snprintf( &ppsz_options[i_options++][0], VLC_MAX_MRL, "frequency=%d", (int)i_v4l_frequency ); if (i_pos>=VLC_MAX_MRL) ppsz_options[i_options][VLC_MAX_MRL-1] = '\0'; i_pos = snprintf( &ppsz_options[i_options++][0], VLC_MAX_MRL, "samplerate=%d", (int)i_v4l_samplerate ); if (i_pos>=VLC_MAX_MRL) ppsz_options[i_options][VLC_MAX_MRL-1] = '\0'; i_pos = snprintf( &ppsz_options[i_options++][0], VLC_MAX_MRL, "quality=%d", (int)i_v4l_quality ); if (i_pos>=VLC_MAX_MRL) ppsz_options[i_options][VLC_MAX_MRL-1] = '\0'; i_pos = snprintf( &ppsz_options[i_options++][0], VLC_MAX_MRL, "tuner=%d", (int)i_v4l_tuner ); if (i_pos>=VLC_MAX_MRL) ppsz_options[i_options][VLC_MAX_MRL-1] = '\0'; /* MJPEG only */ checkV4LMJPEG = (GtkCheckButton*) lookup_widget( GTK_WIDGET(button), "checkV4LMJPEG" ); b_v4l_mjpeg = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(checkV4LMJPEG)); if (b_v4l_mjpeg) { entryV4LDecimation = (GtkSpinButton*) lookup_widget( GTK_WIDGET(button), "entryV4LDecimation" ); i_v4l_decimation = gtk_spin_button_get_value_as_int(entryV4LDecimation); i_pos = snprintf( &ppsz_options[i_options++][0], VLC_MAX_MRL, "mjpeg:%d", (int)i_v4l_decimation ); if (i_pos>=VLC_MAX_MRL) ppsz_options[i_options][VLC_MAX_MRL-1] = '\0'; } /* end MJPEG only */ p_check_v4l_transcode = (GtkCheckButton*) lookup_widget(GTK_WIDGET(button), "checkV4LTranscode" ); b_v4l_transcode = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(p_check_v4l_transcode)); if (b_v4l_transcode) { msg_Dbg( p_intf, "Camera transcode option selected." ); onAddTranscodeToPlaylist(GTK_WIDGET(button), (gchar *)v4l_mrl); } else { msg_Dbg( p_intf, "Camera reception option selected." ); PlaylistAddItem(GTK_WIDGET(button), (gchar*) &v4l_mrl, ppsz_options, i_options); } }
static void delay_spin_value_changed_cb (GtkSpinButton *button) { delay = gtk_spin_button_get_value_as_int (button); }
void onAddTranscodeToPlaylist(GtkButton *button, gpointer user_data) { intf_thread_t *p_intf = GtkGetIntf( button ); GtkEntry *p_entryVideoCodec = NULL; GtkSpinButton *p_entryVideoBitrate = NULL; GtkSpinButton *p_entryVideoBitrateTolerance = NULL; GtkSpinButton *p_entryVideoKeyFrameInterval = NULL; GtkCheckButton *p_checkVideoDeinterlace = NULL; GtkEntry *p_entryAudioCodec = NULL; GtkSpinButton *p_entryAudioBitrate = NULL; const gchar *p_video_codec; gint i_video_bitrate; gint i_video_bitrate_tolerance; gint i_video_keyframe_interval; gboolean b_video_deinterlace; const gchar *p_audio_codec; gint i_audio_bitrate; GtkEntry *p_entryStdAccess = NULL; GtkEntry *p_entryStdMuxer = NULL; GtkEntry *p_entryStdURL = NULL; GtkEntry *p_entryStdAnnounce = NULL; GtkSpinButton *p_entryStdTTL = NULL; GtkCheckButton *p_checkSAP = NULL; GtkCheckButton *p_checkSLP = NULL; const gchar *p_std_announce; const gchar *p_std_access; const gchar *p_std_muxer; const gchar *p_std_url; gboolean b_sap_announce; gboolean b_slp_announce; gint i_std_ttl; char **ppsz_options = NULL; /* list of options */ int i_options=0; int i; gchar mrl[7]; int i_pos; ppsz_options = (char **) malloc(3 *sizeof(char*)); if (ppsz_options == NULL) { msg_Err(p_intf, "No memory to allocate for v4l options."); return; } for (i=0; i<3; i++) { ppsz_options[i] = (char *) malloc(VLC_MAX_MRL * sizeof(char)); if (ppsz_options[i] == NULL) { msg_Err(p_intf, "No memory to allocate for v4l options string %i.", i); for (i-=1; i>=0; i--) free(ppsz_options[i]); free(ppsz_options); return; } } /* Update the playlist */ playlist_t *p_playlist = (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE ); if( p_playlist == NULL ) return; /* Get all the options. */ i_pos = snprintf( &mrl[0], VLC_MAX_MRL, "sout"); mrl[6] = '\0'; /* option 1 */ i_pos = snprintf( &ppsz_options[i_options][0], VLC_MAX_MRL, "sout='#transcode{"); if (i_pos>=VLC_MAX_MRL) ppsz_options[i_options][VLC_MAX_MRL-1] = '\0'; p_entryVideoCodec = (GtkEntry*) lookup_widget( GTK_WIDGET(button), "entryVideoCodec" ); p_entryVideoBitrate = (GtkSpinButton*) lookup_widget( GTK_WIDGET(button), "entryVideoBitrate" ); p_entryVideoBitrateTolerance = (GtkSpinButton*) lookup_widget( GTK_WIDGET(button), "entryVideoBitrateTolerance" ); p_entryVideoKeyFrameInterval = (GtkSpinButton*) lookup_widget( GTK_WIDGET(button), "entryVideoKeyFrameInterval" ); p_video_codec = gtk_entry_get_text(GTK_ENTRY(p_entryVideoCodec)); i_video_bitrate = gtk_spin_button_get_value_as_int(p_entryVideoBitrate); i_video_bitrate_tolerance = gtk_spin_button_get_value_as_int(p_entryVideoBitrateTolerance); i_video_keyframe_interval = gtk_spin_button_get_value_as_int(p_entryVideoKeyFrameInterval); i_pos += snprintf( &ppsz_options[i_options][i_pos], VLC_MAX_MRL - i_pos, "vcodec=%s,", (char*)p_video_codec ); if (i_pos>=VLC_MAX_MRL) ppsz_options[i_options][VLC_MAX_MRL-1] = '\0'; i_pos += snprintf( &ppsz_options[i_options][i_pos], VLC_MAX_MRL - i_pos, "vb=%d,", (int)i_video_bitrate ); if (i_pos>=VLC_MAX_MRL) ppsz_options[i_options][VLC_MAX_MRL-1] = '\0'; i_pos += snprintf( &ppsz_options[i_options][i_pos], VLC_MAX_MRL - i_pos, "vt=%d,", (int)i_video_bitrate_tolerance ); if (i_pos>=VLC_MAX_MRL) ppsz_options[i_options][VLC_MAX_MRL-1] = '\0'; i_pos += snprintf( &ppsz_options[i_options][i_pos], VLC_MAX_MRL - i_pos, "keyint=%d,", (int)i_video_keyframe_interval ); if (i_pos>=VLC_MAX_MRL) ppsz_options[i_options][VLC_MAX_MRL-1] = '\0'; p_checkVideoDeinterlace = (GtkCheckButton*) lookup_widget( GTK_WIDGET(button), "checkVideoDeinterlace" ); b_video_deinterlace = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(p_checkVideoDeinterlace)); if (b_video_deinterlace) { i_pos += snprintf( &ppsz_options[i_options][i_pos], VLC_MAX_MRL - i_pos, "deinterlace," ); if (i_pos>=VLC_MAX_MRL) ppsz_options[i_options][VLC_MAX_MRL-1] = '\0'; } p_entryAudioCodec = (GtkEntry*) lookup_widget( GTK_WIDGET(button), "entryAudioCodec" ); p_entryAudioBitrate = (GtkSpinButton*) lookup_widget( GTK_WIDGET(button), "entryAudioBitrate" ); p_audio_codec = gtk_entry_get_text(GTK_ENTRY(p_entryAudioCodec)); i_audio_bitrate = gtk_spin_button_get_value_as_int(p_entryAudioBitrate); i_pos += snprintf( &ppsz_options[i_options][i_pos], VLC_MAX_MRL - i_pos, "acodec=%s,", (char*)p_audio_codec ); if (i_pos>=VLC_MAX_MRL) ppsz_options[i_options][VLC_MAX_MRL-1] = '\0'; i_pos += snprintf( &ppsz_options[i_options][i_pos], VLC_MAX_MRL - i_pos, "ab=%d,", (int)i_audio_bitrate ); if (i_pos>=VLC_MAX_MRL) ppsz_options[i_options][VLC_MAX_MRL-1] = '\0'; i_pos += snprintf( &ppsz_options[i_options][i_pos], VLC_MAX_MRL - i_pos, "channels=1}"/*, (int)i_audio_channels*/ ); if (i_pos>=VLC_MAX_MRL) ppsz_options[i_options][VLC_MAX_MRL-1] = '\0'; /* option 2 */ i_pos = 0; i_pos = snprintf( &ppsz_options[i_options++][i_pos], VLC_MAX_MRL - i_pos, "#" ); if (i_pos>=VLC_MAX_MRL) ppsz_options[i_options][VLC_MAX_MRL-1] = '\0'; p_entryStdAccess = (GtkEntry*) lookup_widget( GTK_WIDGET(button), "entryStdAccess" ); p_entryStdMuxer = (GtkEntry*) lookup_widget( GTK_WIDGET(button), "entryStdMuxer" ); p_entryStdURL = (GtkEntry*) lookup_widget( GTK_WIDGET(button), "entryStdURL" ); p_entryStdAnnounce = (GtkEntry*) lookup_widget( GTK_WIDGET(button), "entryAnnounceChannel" ); p_entryStdTTL = (GtkSpinButton*) lookup_widget( GTK_WIDGET(button), "entryStdTTL" ); p_std_access = gtk_entry_get_text(GTK_ENTRY(p_entryStdAccess)); p_std_muxer = gtk_entry_get_text(GTK_ENTRY(p_entryStdMuxer)); p_std_url = gtk_entry_get_text(GTK_ENTRY(p_entryStdURL)); p_std_announce = gtk_entry_get_text(GTK_ENTRY(p_entryStdAnnounce)); b_sap_announce = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(p_checkSAP)); b_slp_announce = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(p_checkSLP)); i_pos += snprintf( &ppsz_options[i_options][i_pos], VLC_MAX_MRL - i_pos, "std{access=%s,", (char*)p_std_access); if (i_pos>=VLC_MAX_MRL) ppsz_options[i_options][VLC_MAX_MRL-1] = '\0'; i_pos += snprintf( &ppsz_options[i_options][i_pos], VLC_MAX_MRL - i_pos, "mux=%s,", (char*)p_std_muxer); if (i_pos>=VLC_MAX_MRL) ppsz_options[i_options][VLC_MAX_MRL-1] = '\0'; i_pos += snprintf( &ppsz_options[i_options][i_pos], VLC_MAX_MRL - i_pos, "dst=%s", (char*)p_std_url); if (i_pos>=VLC_MAX_MRL) ppsz_options[i_options][VLC_MAX_MRL-1] = '\0'; if (strncasecmp( (const char*)p_std_access, "udp", 3)==0) { if (b_sap_announce) { i_pos += snprintf( &ppsz_options[i_options][i_pos], VLC_MAX_MRL - i_pos, "sap=%s", (char*)p_std_announce); if (i_pos>=VLC_MAX_MRL) ppsz_options[i_options][VLC_MAX_MRL-1] = '\0'; } if (b_slp_announce) { i_pos += snprintf( &ppsz_options[i_options][i_pos], VLC_MAX_MRL - i_pos, "slp=%s", (char*)p_std_announce); if (i_pos>=VLC_MAX_MRL) ppsz_options[i_options][VLC_MAX_MRL-1] = '\0'; } } i_std_ttl = gtk_spin_button_get_value_as_int(p_entryStdTTL); i_pos += snprintf( &ppsz_options[i_options++][i_pos], VLC_MAX_MRL - i_pos, "ttl=%d}", (int)i_std_ttl); if (i_pos>=VLC_MAX_MRL) ppsz_options[i_options][VLC_MAX_MRL-1] = '\0'; if (user_data != NULL) { msg_Dbg(p_intf, "Adding transcoding options to playlist item." ); } else { msg_Dbg(p_intf, "Adding --sout to playlist." ); PlaylistAddItem(GTK_WIDGET(button), (gchar*) &mrl, ppsz_options, i_options); } }
/* fill_component handler for the alarm page */ static void dialog_to_alarm (Dialog *dialog) { ECalComponentAlarmTrigger trigger; ECalComponentAlarmAction action; /* Fill out the alarm */ memset (&trigger, 0, sizeof (ECalComponentAlarmTrigger)); trigger.type = e_dialog_combo_box_get (dialog->time_combo, time_map); if (e_dialog_combo_box_get (dialog->relative_combo, relative_map) == BEFORE) trigger.u.rel_duration.is_neg = 1; else trigger.u.rel_duration.is_neg = 0; switch (e_dialog_combo_box_get (dialog->value_units_combo, value_map)) { case MINUTES: trigger.u.rel_duration.minutes = gtk_spin_button_get_value_as_int ( GTK_SPIN_BUTTON (dialog->interval_value)); break; case HOURS: trigger.u.rel_duration.hours = gtk_spin_button_get_value_as_int ( GTK_SPIN_BUTTON (dialog->interval_value)); break; case DAYS: trigger.u.rel_duration.days = gtk_spin_button_get_value_as_int ( GTK_SPIN_BUTTON (dialog->interval_value)); break; default: g_return_if_reached (); } e_cal_component_alarm_set_trigger (dialog->alarm, trigger); action = e_dialog_combo_box_get (dialog->action_combo, action_map); e_cal_component_alarm_set_action (dialog->alarm, action); /* Repeat stuff */ repeat_widgets_to_alarm (dialog, dialog->alarm); /* Options */ switch (action) { case E_CAL_COMPONENT_ALARM_NONE: g_return_if_reached (); break; case E_CAL_COMPONENT_ALARM_AUDIO: aalarm_widgets_to_alarm (dialog, dialog->alarm); break; case E_CAL_COMPONENT_ALARM_DISPLAY: dalarm_widgets_to_alarm (dialog, dialog->alarm); break; case E_CAL_COMPONENT_ALARM_EMAIL: malarm_widgets_to_alarm (dialog, dialog->alarm); break; case E_CAL_COMPONENT_ALARM_PROCEDURE: palarm_widgets_to_alarm (dialog, dialog->alarm); break; case E_CAL_COMPONENT_ALARM_UNKNOWN: break; default: g_return_if_reached (); } }
void Tetris::lineFillProbChanged (GtkWidget *spin, gpointer data) { gint value = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (spin)); games_conf_set_integer (KEY_OPTIONS_GROUP, KEY_LINE_FILL_PROBABILITY, value); }
/* * snap_dialog * * Bring up the GTK dialog for setting snapshot * parameters. */ static gboolean snap_dialog (void) { GtkWidget *dialog; GtkWidget *vbox; GtkWidget *hbox; GtkWidget *label; GtkObject *adj; GSList *radio_group = NULL; gint radio_pressed[2]; gint decorations; gboolean run; /* Set defaults */ radio_pressed[0] = (winsnapvals.root == FALSE); radio_pressed[1] = (winsnapvals.root == TRUE); decorations = winsnapvals.decor; /* Init GTK */ gimp_ui_init (PLUG_IN_BINARY, FALSE); /* Main Dialog */ dialog = gimp_dialog_new (PLUG_IN_PRINT_NAME, PLUG_IN_ROLE, NULL, 0, gimp_standard_help_func, PLUG_IN_PROC, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, _("Grab"), GTK_RESPONSE_OK, NULL); gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog), GTK_RESPONSE_OK, GTK_RESPONSE_CANCEL, -1); vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12); gtk_container_set_border_width (GTK_CONTAINER (vbox), 12); gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), vbox, TRUE, TRUE, 0); gtk_widget_show (vbox); winsnapintf.single_button = gtk_radio_button_new_with_label (radio_group, _("Grab a single window")); gtk_box_pack_start (GTK_BOX (vbox), winsnapintf.single_button, FALSE, FALSE, 0); g_signal_connect (winsnapintf.single_button, "toggled", G_CALLBACK (snap_toggle_update), &radio_pressed[0]); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (winsnapintf.single_button), radio_pressed[0]); gtk_widget_show (winsnapintf.single_button); radio_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (winsnapintf.single_button)); winsnapintf.root_button = gtk_radio_button_new_with_label (radio_group, _("Grab the whole screen")); gtk_box_pack_start (GTK_BOX (vbox), winsnapintf.root_button, FALSE, FALSE, 0); g_signal_connect (winsnapintf.root_button, "toggled", G_CALLBACK (snap_toggle_update), &radio_pressed[1]); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (winsnapintf.root_button), radio_pressed[1]); gtk_widget_show (winsnapintf.root_button); radio_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (winsnapintf.root_button)); /* with delay */ hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6); gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); gtk_widget_show (hbox); label = gtk_label_new (_("after")); gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); gtk_widget_show (label); winsnapintf.delay_spinner = gimp_spin_button_new (&adj, winsnapvals.delay, 0.0, 100.0, 1.0, 5.0, 0.0, 0, 0); gtk_box_pack_start (GTK_BOX (hbox), winsnapintf.delay_spinner, FALSE, FALSE, 0); gtk_widget_show (winsnapintf.delay_spinner); label = gtk_label_new (_("Seconds delay")); gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); gtk_widget_show (label); #ifdef CAN_SET_DECOR /* With decorations */ winsnapintf.decor_button = gtk_check_button_new_with_label (_("Include decorations")); g_signal_connect (winsnapintf.decor_button, "toggled", G_CALLBACK (snap_toggle_update), &decorations); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (winsnapintf.decor_button), decorations); gtk_box_pack_end (GTK_BOX (vbox), winsnapintf.decor_button, FALSE, FALSE, 0); gtk_widget_set_sensitive (winsnapintf.decor_button, radio_pressed[0]); gtk_widget_show (winsnapintf.decor_button); #endif /* CAN_SET_DECOR */ gtk_widget_show (dialog); run = (gimp_dialog_run (GIMP_DIALOG (dialog)) == GTK_RESPONSE_OK); if (run) { winsnapvals.root = radio_pressed[1]; winsnapvals.decor = decorations; winsnapvals.delay = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (winsnapintf.delay_spinner)); } gtk_widget_destroy (dialog); return run; }
void Tetris::startingLevelChanged (GtkWidget *spin, gpointer data) { gint value = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (spin)); games_conf_set_integer (KEY_OPTIONS_GROUP, KEY_STARTING_LEVEL, value); }
extern void change_grid_popup(GtkAction *action, gpointer user_data) { GtkWidget *table = gtk_table_new(1, 2, FALSE); GtkWidget *label; GtkObject *adjustment; GtkWidget *width_sb, *hori_sb, *vert_sb; int width = working_sview_config.grid_x_width, hori = working_sview_config.grid_hori, vert = working_sview_config.grid_vert; GtkWidget *popup = gtk_dialog_new_with_buttons( "Grid Properties", GTK_WINDOW (user_data), GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, NULL); GError *error = NULL; int response = 0; char *temp = NULL; label = gtk_dialog_add_button(GTK_DIALOG(popup), GTK_STOCK_OK, GTK_RESPONSE_OK); gtk_window_set_default(GTK_WINDOW(popup), label); gtk_dialog_add_button(GTK_DIALOG(popup), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL); gtk_box_pack_start(GTK_BOX(GTK_DIALOG(popup)->vbox), table, FALSE, FALSE, 0); label = gtk_label_new("Nodes in row "); adjustment = gtk_adjustment_new(working_sview_config.grid_x_width, 1, 1000, 1, 60, 0); width_sb = gtk_spin_button_new(GTK_ADJUSTMENT(adjustment), 1, 0); gtk_container_set_border_width(GTK_CONTAINER(table), 10); gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 0, 1); gtk_table_attach_defaults(GTK_TABLE(table), width_sb, 1, 2, 0, 1); label = gtk_label_new("Nodes before horizontal break "); adjustment = gtk_adjustment_new(working_sview_config.grid_hori, 1, 1000, 1, 60, 0); hori_sb = gtk_spin_button_new(GTK_ADJUSTMENT(adjustment), 1, 0); gtk_container_set_border_width(GTK_CONTAINER(table), 10); gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 1, 2); gtk_table_attach_defaults(GTK_TABLE(table), hori_sb, 1, 2, 1, 2); label = gtk_label_new("Nodes before vertical break "); adjustment = gtk_adjustment_new(working_sview_config.grid_vert, 1, 1000, 1, 60, 0); vert_sb = gtk_spin_button_new(GTK_ADJUSTMENT(adjustment), 1, 0); gtk_container_set_border_width(GTK_CONTAINER(table), 10); gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 2, 3); gtk_table_attach_defaults(GTK_TABLE(table), vert_sb, 1, 2, 2, 3); /*TODO * do we care about this? label = gtk_label_new("Topology ordered "); adjustment = gtk_adjustment_new(working_sview_config.grid_topological, 1, 1000, 1, 60, 0); GtkWidget *gtbtton = gtk_check_button_new (); gtk_container_set_border_width(GTK_CONTAINER(table), 10); gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 3, 4); gtk_table_attach_defaults(GTK_TABLE(table), gtbtton, 1, 2, 3, 4); gtk_toggle_button_set_active (>btton, working_sview_config.grid_topological); */ gtk_widget_show_all(popup); response = gtk_dialog_run (GTK_DIALOG(popup)); if (response == GTK_RESPONSE_OK) { working_sview_config.grid_x_width = gtk_spin_button_get_value_as_int( GTK_SPIN_BUTTON(width_sb)); working_sview_config.grid_hori = gtk_spin_button_get_value_as_int( GTK_SPIN_BUTTON(hori_sb)); working_sview_config.grid_vert = gtk_spin_button_get_value_as_int( GTK_SPIN_BUTTON(vert_sb)); memcpy(&default_sview_config, &working_sview_config, sizeof(sview_config_t)); if ((width == working_sview_config.grid_x_width) && (hori == working_sview_config.grid_hori) && (vert == working_sview_config.grid_vert)) { temp = g_strdup_printf("Grid: Nothing changed."); } else if (working_sview_config.grid_topological) { temp = g_strdup_printf("Grid: Invalid mode .." " switch to non-topology " "order first."); } else { bool refresh = 0; temp = g_strdup_printf( "Grid set to %d nodes breaks " "at %d H and %d V.", working_sview_config.grid_x_width, working_sview_config.grid_hori, working_sview_config.grid_vert); /* If the old width was wider than the * current we need to remake the list so the * table gets set up correctly, so destroy it * here and it will be remade in get_system_stats(). */ if ((width > working_sview_config.grid_x_width) && grid_button_list) { list_destroy(grid_button_list); grid_button_list = NULL; refresh = 1; } get_system_stats(main_grid_table); if (refresh) refresh_main(NULL, NULL); } gtk_statusbar_pop(GTK_STATUSBAR(main_statusbar), STATUS_REFRESH); response = gtk_statusbar_push(GTK_STATUSBAR(main_statusbar), STATUS_REFRESH, temp); g_free(temp); if (!g_thread_create(_refresh_thr, GINT_TO_POINTER(response), FALSE, &error)) { g_printerr ("Failed to create refresh thread: %s\n", error->message); } } gtk_widget_destroy(popup); return; }
int pgin_read_int(char *name, char *label, int def, int min, int max, int inc){ GtkWidget *dialog; GtkWidget *vbox; GtkWidget *action; GtkWidget *lbl; GtkWidget *spin_button; GtkWidget *ok_button; GtkObject *adj; int i; /* Dialog */ dialog = gtk_dialog_new(); gtk_window_set_title(GTK_WINDOW(dialog), name); gtk_window_set_position(GTK_WINDOW(dialog), GTK_WIN_POS_CENTER); gtk_window_set_policy(GTK_WINDOW(dialog), TRUE, TRUE, FALSE); gtk_window_set_modal(GTK_WINDOW(dialog), TRUE); gtk_signal_connect(GTK_OBJECT(dialog), "delete_event", GTK_SIGNAL_FUNC(gtk_iface_grab_end_click), NULL); /* Vbox */ vbox = GTK_DIALOG(dialog)->vbox; gtk_container_set_border_width(GTK_CONTAINER(vbox), 4); gtk_widget_show(vbox); /* Label */ lbl = gtk_label_new(label); gtk_widget_show(lbl); gtk_container_add(GTK_CONTAINER(vbox), lbl); /* Spin button */ adj = gtk_adjustment_new(def, min, max, inc, inc, inc); spin_button = gtk_spin_button_new(GTK_ADJUSTMENT(adj), 0, 0); gtk_spin_button_set_numeric(GTK_SPIN_BUTTON(spin_button), TRUE); gtk_widget_show(spin_button); gtk_container_add(GTK_CONTAINER(vbox), spin_button); /* Action area */ action = GTK_DIALOG(dialog)->action_area; gtk_container_set_border_width(GTK_CONTAINER(vbox), 4); gtk_widget_show(action); /* OK button */ ok_button = gtk_button_new_with_label(" OK "); gtk_widget_show(ok_button); gtk_container_add(GTK_CONTAINER(action), ok_button); gtk_signal_connect(GTK_OBJECT(ok_button), "clicked", GTK_SIGNAL_FUNC(gtk_iface_grab_end_click), NULL); /* Get input */ gtk_widget_show(dialog); gtk_iface_grab_end = 0; while (!gtk_iface_grab_end){ while (gtk_events_pending()) gtk_main_iteration(); usleep(10000); } /* Get value */ i = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(spin_button)); /* Destroy */ gtk_widget_destroy(lbl); gtk_widget_destroy(spin_button); gtk_widget_destroy(ok_button); gtk_widget_destroy(vbox); gtk_widget_destroy(dialog); //gtk_object_destroy(adj); return i; }
static void change_size( GtkSpinButton * sb, CPUGraph *base) { set_size( base, gtk_spin_button_get_value_as_int( sb ) ); }
VikLayerParamData a_uibuilder_widget_get_value ( GtkWidget *widget, VikLayerParam *param ) { VikLayerParamData rv; switch ( param->widget_type ) { case VIK_LAYER_WIDGET_COLOR: gtk_color_button_get_color ( GTK_COLOR_BUTTON(widget), &(rv.c) ); break; case VIK_LAYER_WIDGET_CHECKBUTTON: rv.b = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); break; case VIK_LAYER_WIDGET_COMBOBOX: if ( param->type == VIK_LAYER_PARAM_UINT ) { rv.i = gtk_combo_box_get_active ( GTK_COMBO_BOX(widget) ); if ( rv.i == -1 ) rv.i = 0; rv.u = rv.i; if ( param->extra_widget_data ) rv.u = ((guint *)param->extra_widget_data)[rv.u]; } if ( param->type == VIK_LAYER_PARAM_STRING) { if ( param->extra_widget_data ) { /* Combobox displays labels and we want values from extra */ int pos = gtk_combo_box_get_active ( GTK_COMBO_BOX(widget) ); rv.s = ((const char **)param->extra_widget_data)[pos]; } else { /* Return raw value */ #if GTK_CHECK_VERSION (2, 24, 0) rv.s = gtk_entry_get_text (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (widget)))); #else rv.s = gtk_combo_box_get_active_text ( GTK_COMBO_BOX(widget) ); #endif } g_debug("%s: %s", __FUNCTION__, rv.s); } break; case VIK_LAYER_WIDGET_RADIOGROUP: case VIK_LAYER_WIDGET_RADIOGROUP_STATIC: rv.u = vik_radio_group_get_selected(VIK_RADIO_GROUP(widget)); if ( param->extra_widget_data ) rv.u = GPOINTER_TO_UINT ( g_list_nth_data(param->extra_widget_data, rv.u) ); break; case VIK_LAYER_WIDGET_SPINBUTTON: if ( param->type == VIK_LAYER_PARAM_UINT ) rv.u = gtk_spin_button_get_value_as_int ( GTK_SPIN_BUTTON(widget) ); else if ( param->type == VIK_LAYER_PARAM_INT ) rv.i = gtk_spin_button_get_value_as_int ( GTK_SPIN_BUTTON(widget) ); else rv.d = gtk_spin_button_get_value ( GTK_SPIN_BUTTON(widget) ); break; case VIK_LAYER_WIDGET_ENTRY: case VIK_LAYER_WIDGET_PASSWORD: rv.s = gtk_entry_get_text ( GTK_ENTRY(widget) ); break; case VIK_LAYER_WIDGET_FILEENTRY: case VIK_LAYER_WIDGET_FOLDERENTRY: rv.s = vik_file_entry_get_filename ( VIK_FILE_ENTRY(widget) ); break; case VIK_LAYER_WIDGET_FILELIST: rv.sl = vik_file_list_get_files ( VIK_FILE_LIST(widget) ); break; case VIK_LAYER_WIDGET_HSCALE: if ( param->type == VIK_LAYER_PARAM_UINT ) rv.u = (guint32) gtk_range_get_value ( GTK_RANGE(widget) ); else if ( param->type == VIK_LAYER_PARAM_INT ) rv.i = (gint32) gtk_range_get_value ( GTK_RANGE(widget) ); else rv.d = gtk_range_get_value ( GTK_RANGE(widget) ); break; } // Perform conversion if necessary if ( param->convert_to_internal ) rv = param->convert_to_internal ( rv ); return rv; }
void change_digits(GtkWidget *widget, GtkSpinButton *spin) { gtk_spin_button_set_digits(GTK_SPIN_BUTTON(spinner1), gtk_spin_button_get_value_as_int(spin)); }
void jsbeautify_dialog(Tbfwin * bfwin) { #if GTK_CHECK_VERSION(3,0,0) GtkWidget *dialog, *grid, *hbox, *inselection, *usetabs, *tabsize, *nopreservenewline, *jslinthappy, *unescape_encoded_chars; #else GtkWidget *dialog, *table, *inselection, *usetabs, *tabsize, *nopreservenewline, *jslinthappy, *unescape_encoded_chars; #endif gint result, begin, end; gchar *command; dialog = gtk_dialog_new_with_buttons(_("Javascript Beautify"), GTK_WINDOW(bfwin->main_window), GTK_DIALOG_DESTROY_WITH_PARENT, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, NULL); #if GTK_CHECK_VERSION(3,0,0) grid = gtk_grid_new(); gtk_grid_set_column_spacing(GTK_GRID(grid), 12); gtk_grid_set_row_spacing(GTK_GRID(grid), 6); gtk_container_set_border_width(GTK_CONTAINER(grid), 6); gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), grid, FALSE, FALSE, 0); hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); tabsize = dialog_spin_button_labeled(1, 99, 3, _("_Indent size:"), hbox, 12); gtk_container_add(GTK_CONTAINER(grid), hbox); usetabs = dialog_check_button_new(_("Use _tabs to indent, not spaces"), TRUE); gtk_grid_attach_next_to(GTK_GRID(grid), usetabs, hbox, GTK_POS_BOTTOM, 1, 1); nopreservenewline = dialog_check_button_new(_("Do not _preserve existing line breaks"), FALSE); gtk_grid_attach_next_to(GTK_GRID(grid), nopreservenewline, usetabs, GTK_POS_BOTTOM, 1, 1); jslinthappy = dialog_check_button_new(_("More _jslint-compatible output"), FALSE); gtk_grid_attach_next_to(GTK_GRID(grid), jslinthappy, nopreservenewline, GTK_POS_BOTTOM, 1, 1); unescape_encoded_chars = dialog_check_button_new(_("_Decode printable chars encoded in \\\\xNN notation"), FALSE); gtk_grid_attach_next_to(GTK_GRID(grid), unescape_encoded_chars, jslinthappy, GTK_POS_BOTTOM, 1, 1); /* TODO: Is this a bug? Altering the option doesn't change anything */ if (doc_get_selection(DOCUMENT(bfwin->current_document), &begin, &end)) { inselection = dialog_check_button_new(_("Beautify only in _selection"), TRUE); gtk_grid_attach_next_to(GTK_GRID(grid), inselection, unescape_encoded_chars, GTK_POS_BOTTOM, 1, 1); } else { begin = 0; end = -1; } #else table = dialog_table_in_vbox_defaults(3, 2, 6, gtk_dialog_get_content_area(GTK_DIALOG(dialog))); if (doc_get_selection(DOCUMENT(bfwin->current_document), &begin, &end)) { inselection = dialog_check_button_in_table(_("Beautify only in _selection"), TRUE, table, 0, 2, 0, 1); } else { begin = 0; end = -1; } usetabs = dialog_check_button_in_table(_("Use _tabs to indent, not spaces"), TRUE, table, 0, 2, 1, 2); gtk_table_attach_defaults(GTK_TABLE(table), gtk_label_new(_("_Indent size")), 0, 1, 2, 3); tabsize = dialog_spin_button_in_table(1, 99, 3, table, 1, 2, 2, 3); nopreservenewline = dialog_check_button_in_table(_("Do not _preserve existing line breaks"), FALSE, table, 0, 2, 3, 4); jslinthappy = dialog_check_button_in_table(_("More _jslint-compatible output"), FALSE, table, 0, 2, 4, 5); unescape_encoded_chars = dialog_check_button_in_table(_("_Decode printable chars encoded in \\\\xNN notation"), FALSE, table, 0, 2, 5, 6); #endif /* in selection or all text -s, --indent-size=NUMBER indentation size. (default 4). -c, --indent-char=CHAR character to indent with. (default space). -t, --indent-with-tabs Indent with tabs, overrides -s and -c -d, --disable-preserve-newlines do not preserve existing line breaks. -j, --jslint-happy more jslint-compatible output -b, --brace-style=collapse brace style (collapse, expand, end-expand) -k, --keep-array-indentation keep array indentation. -o, --outfile=FILE specify a file to output to (default stdout) -f, --keep-function-indentation Do not re-indent function bodies defined in var lines. -x, --unescape-strings Decode printable chars encoded in \\xNN notation. */ gtk_widget_show_all(dialog); result = gtk_dialog_run(GTK_DIALOG(dialog)); switch (result) { case GTK_RESPONSE_ACCEPT: #ifdef WIN32 command = g_strdup_printf("|python " PKGDATADIR "/jsbeautify %s -s %d %s %s %s -|", gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(usetabs)) ? "-t" : "", gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(tabsize)), gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(nopreservenewline)) ? "-d" : "", gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(jslinthappy)) ? "-j" : "", gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(unescape_encoded_chars)) ? "-x" : ""); #else command = g_strdup_printf("|" PKGDATADIR "/jsbeautify %s -s %d %s %s %s -|", gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(usetabs)) ? "-t" : "", gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(tabsize)), gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(nopreservenewline)) ? "-d" : "", gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(jslinthappy)) ? "-j" : "", gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(unescape_encoded_chars)) ? "-x" : ""); #endif filter_command(bfwin, command, begin, end); g_free(command); break; default: break; } gtk_widget_destroy(dialog); }